diff --git a/dist2/assets/index-B4PWk4UF.js b/dist2/assets/index-B4PWk4UF.js new file mode 100644 index 0000000..7d70e40 --- /dev/null +++ b/dist2/assets/index-B4PWk4UF.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],g=r[a+3];if(d!==g||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*g;m<0&&(h=-h,f=-f,p=-p,g=-g,m=-m);let _=1-o;if(m<.9995){const b=Math.acos(m),A=Math.sin(b);_=Math.sin(_*b)/A,o=Math.sin(o*b)/A,l=l*_+h*o,c=c*_+f*o,u=u*_+p*o,d=d*_+g*o}else{l=l*_+h*o,c=c*_+f*o,u=u*_+p*o,d=d*_+g*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],g=s[0],m=s[3],_=s[6],b=s[1],A=s[4],y=s[7],M=s[2],S=s[5],E=s[8];return r[0]=a*g+o*b+l*M,r[3]=a*m+o*A+l*S,r[6]=a*_+o*y+l*E,r[1]=c*g+u*b+d*M,r[4]=c*m+u*A+d*S,r[7]=c*_+u*y+d*E,r[2]=h*g+f*b+p*M,r[5]=h*m+f*A+p*S,r[8]=h*_+f*y+p*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/p;return e[0]=d*g,e[1]=(s*c-u*i)*g,e[2]=(o*i-s*a)*g,e[3]=h*g,e[4]=(u*t-s*l)*g,e[5]=(s*r-o*t)*g,e[6]=f*g,e[7]=(i*l-c*t)*g,e[8]=(a*t-i*r)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],g=l[2],m=l[6],_=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-g)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+g)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,y=(f+1)/2,M=(_+1)/2,S=(u+h)/4,E=(d+g)/4,v=(p+m)/4;return A>y&&A>M?A<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(A),s=S/i,r=E/i):y>M?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):M<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),i=E/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-g)*(d-g)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-g)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+_-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const g=f*c-l*p;if(g<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const _=1/(m+g+h);return a=g*_,o=h*_,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const g=1/u;d*=g,h*=g,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,g=h.length;pt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],g=r[9],m=r[10],_=r[11],b=r[12],A=r[13],y=r[14],M=r[15];if(s[0].setComponents(c-a,f-u,_-p,M-b).normalize(),s[1].setComponents(c+a,f+u,_+p,M+b).normalize(),s[2].setComponents(c+o,f+d,_+g,M+A).normalize(),s[3].setComponents(c-o,f-d,_-g,M-A).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,_-m,M-y).normalize();else if(s[4].setComponents(c-l,f-h,_-m,M-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,_+m,M+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/E),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),g=Math.max(o,l,c),m=Math.max(u,d,h),_=_c(f,p,e,t,i),b=_c(g,m,e,t,i);let A=n.prevZ,y=n.nextZ;for(;A&&A.z>=_&&y&&y.z<=b;){if(A.x>=f&&A.x<=g&&A.y>=p&&A.y<=m&&A!==s&&A!==a&&Sr(o,u,l,d,c,h,A.x,A.y)&&At(A.prev,A,A.next)>=0||(A=A.prevZ,y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;A&&A.z>=_;){if(A.x>=f&&A.x<=g&&A.y>=p&&A.y<=m&&A!==s&&A!==a&&Sr(o,u,l,d,c,h,A.x,A.y)&&At(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const g=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=g,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let A=b.isScene===!0?b.background:null;if(A&&A.isTexture){const y=b.backgroundBlurriness>0;A=e.get(A,y)}return A}function p(b){let A=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),A=!0);const M=n.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,r):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function g(b,A){const y=f(A);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,S,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(A.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,A){b.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,A,r)}function _(){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 a},setClearColor:function(b,A=1){a.set(b),o=A,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:g,dispose:_}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function g(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Pc;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),_=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),A=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),M=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:g,maxCubemapSize:m,maxAttributes:_,maxVertexUniforms:b,maxVaryings:A,maxFragmentUniforms:y,maxSamples:M,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,g=d.clipIntersection,m=d.clipShadows,_=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,A=b*4;let y=_.clippingState||null;l.value=y,y=u(p,h,A,f);for(let M=0;M!==A;++M)y[M]=t[M];_.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const g=d!==null?d.length:0;let m=null;if(g!==0){if(m=l.value,p!==!0||m===null){const _=f+g*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<_)&&(m=new Float32Array(_));for(let A=0,y=f;A!==g;++A,y+=4)a.copy(d[A]).applyMatrix4(b,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=g,e.numIntersection=0,m}}const Oi=4,sh=[.125,.215,.35,.446,.526,.582],Ji=20,Bx=256,mr=new Yc,rh=new Qe;let il=null,sl=0,rl=0,al=!1;const Hx=new B;class ah{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,r={}){const{size:a=256,position:o=Hx}=r;il=this._renderer.getRenderTarget(),sl=this._renderer.getActiveCubeFace(),rl=this._renderer.getActiveMipmapLevel(),al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?M:0,M,M),d.setRenderTarget(s),_&&d.render(g,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),_=4*(this._cubeSize-g);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,_,3*g,2*g),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,_,3*g,2*g),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),g=r/p,m=isFinite(r)?1+Math.floor(u*g):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const _=[];let b=0;for(let E=0;EA-Oi?s-A+Oi:0),S=4*(this._cubeSize-y);Us(t,M,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,g=3,m=2,_=1,b=new Float32Array(g*p*f),A=new Float32Array(m*p*f),y=new Float32Array(_*p*f);for(let S=0;S2?0:-1,T=[E,v,0,E+2/3,v,0,E+2/3,v+1,0,E,v,0,E+2/3,v+1,0,E,v+1,0];b.set(T,g*p*S),A.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,_*p*S)}const M=new Ct;M.setAttribute("position",new Un(b,g)),M.setAttribute("uv",new Un(A,m)),M.setAttribute("faceIndex",new Un(y,_)),i.push(new Vt(M,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const g=new Af(p.height);return g.fromEquirectangularTexture(n,h),e.set(h,g),h.addEventListener("dispose",c),o(g.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,g=f===ns||f===Ys;if(p||g){let m=t.get(h);const _=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==_)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||g&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let g=0;g=65535?sf:nf)(h,1);m.version=g;const _=r.get(d);_&&e.remove(_),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const E=new Float32Array(M*S*4*d),v=new Qd(E,M,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,g,m=null,_=[],b=!1;this.setSize=function(A,y){a.setSize(A,y),o.setSize(A,y);for(let M=0;M<_.length;M++){const S=_[M];S.setSize&&S.setSize(A,y)}},this.setEffects=function(A){_=A,b=_.length>0&&_[0].isRenderPass===!0;const y=a.width,M=a.height;for(let S=0;S<_.length;S++){const E=_[S];E.setSize&&E.setSize(y,M)}},this.begin=function(A,y){if(p||A.toneMapping===Jn&&_.length===0)return!1;if(m=y,y!==null){const M=y.width,S=y.height;(a.width!==M||a.height!==S)&&this.setSize(M,S)}return b===!1&&A.setRenderTarget(a),g=A.toneMapping,A.toneMapping=Jn,!0},this.hasRenderPass=function(){return b},this.end=function(A,y){A.toneMapping=g,p=!0;let M=a,S=o;for(let E=0;E<_.length;E++){const v=_[E];if(v.enabled!==!1&&(v.render(A,S,M,y),v.needsSwap!==!1)){const T=M;M=S,S=T}}if(h!==A.outputColorSpace||f!==A.toneMapping){h=A.outputColorSpace,f=A.toneMapping,c.defines={},it.getTransfer(h)===ft&&(c.defines.SRGB_TRANSFER="");const E=Jx[f];E&&(c.defines[E]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=M.texture,A.setRenderTarget(m),A.render(u,d),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Ef=new Jt,yc=new Ks(1,1),Tf=new Qd,Cf=new G0,wf=new cf,uh=[],hh=[],dh=new Float32Array(16),fh=new Float32Array(9),ph=new Float32Array(4);function ir(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),_.length>0&&(_+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),_=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,_=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#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(` +`)+` +`+_);const A=b+m+a,y=b+_+o,M=gh(s,s.VERTEX_SHADER,A),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(g,M),s.attachShader(g,S),t.index0AttributeName!==void 0?s.bindAttribLocation(g,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g);function E(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(g)||"",U=s.getShaderInfoLog(M)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(g,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,g,M,S);else{const ae=xh(s,M,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:_}})}s.deleteShader(M),s.deleteShader(S),v=new Va(s,g),T=Q1(s,g)}let v;this.getUniforms=function(){return v===void 0&&E(this),v};let T;this.getAttributes=function(){return T===void 0&&E(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(g,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=M,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function g(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===xo?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(_(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function _(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function A(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function M(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function E(){o.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:A,acquireProgram:y,releaseProgram:M,releaseShaderCache:S,programs:c,dispose:E}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,g,m,_){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:g,renderOrder:h.renderOrder,z:m,group:_},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=g,b.renderOrder=h.renderOrder,b.z=m,b.group=_),e++,b}function l(h,f,p,g,m,_){const b=o(h,f,p,g,m,_);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,g,m,_){const b=o(h,f,p,g,m,_);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,g=0,m=0,_=0,b=0,A=0,y=0,M=0,S=0,E=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==g||v.rectAreaLength!==m||v.hemiLength!==_||v.numDirectionalShadows!==b||v.numPointShadows!==A||v.numSpotShadows!==y||v.numSpotMaps!==M||v.numLightProbes!==E)&&(i.directional.length=f,i.spot.length=g,i.rectArea.length=m,i.point.length=p,i.hemi.length=_,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=y+M-S,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=E,v.directionalLength=f,v.pointLength=p,v.spotLength=g,v.rectAreaLength=m,v.hemiLength=_,v.numDirectionalShadows=b,v.numPointShadows=A,v.numSpotShadows=y,v.numSpotMaps=M,v.numLightProbes=E,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,g=0;const m=u.matrixWorldInverse;for(let _=0,b=c.length;_=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let _=this.type;this.render=function(S,E,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=_!==this.type;U&&E.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const w=I.uuid,U=E.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,E.addEventListener("dispose",M)),I=P}if(I.visible=E.visible,I.wireframe=E.wireframe,T===yr?I.side=E.shadowSide!==null?E.shadowSide:E.side:I.side=E.shadowSide!==null?E.shadowSide:d[E.side],I.alphaMap=E.alphaMap,I.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,I.map=E.map,I.clipShadows=E.clipShadows,I.clippingPlanes=E.clippingPlanes,I.clipIntersection=E.clipIntersection,I.displacementMap=E.displacementMap,I.displacementScale=E.displacementScale,I.displacementBias=E.displacementBias,I.wireframeLinewidth=E.wireframeLinewidth,I.linewidth=E.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,E,v,T,I){if(S.visible===!1)return;if(S.layers.test(E.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=g(fe,W));const F=x?g(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function _(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function A(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function M(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return _(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function E(R){const x=R.target;x.removeEventListener("dispose",E),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",E));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=M(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const g=typeof XRWebGLBinding<"u",m=new By,_={},b=t.getContextAttributes();let A=null,y=null;const M=[],S=[],E=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=M[z];return ne===void 0&&(ne=new Oo,M[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=M[z];return ne===void 0&&(ne=new Oo,M[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=M[z];return ne===void 0&&(ne=new Oo,M[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=M[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,M[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=M[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=_.alphaTest);const b=e.get(_),A=b.envMap,y=b.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=_.reflectivity,m.ior.value=_.ior,m.refractionRatio.value=_.refractionRatio),_.lightMap&&(m.lightMap.value=_.lightMap,m.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,m.lightMapTransform)),_.aoMap&&(m.aoMap.value=_.aoMap,m.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,m.aoMapTransform))}function a(m,_){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,_.map&&(m.map.value=_.map,t(_.map,m.mapTransform))}function o(m,_){m.dashSize.value=_.dashSize,m.totalSize.value=_.dashSize+_.gapSize,m.scale.value=_.scale}function l(m,_,b,A){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,m.size.value=_.size*b,m.scale.value=A*.5,_.map&&(m.map.value=_.map,t(_.map,m.uvTransform)),_.alphaMap&&(m.alphaMap.value=_.alphaMap,t(_.alphaMap,m.alphaMapTransform)),_.alphaTest>0&&(m.alphaTest.value=_.alphaTest)}function c(m,_){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,m.rotation.value=_.rotation,_.map&&(m.map.value=_.map,t(_.map,m.mapTransform)),_.alphaMap&&(m.alphaMap.value=_.alphaMap,t(_.alphaMap,m.alphaMapTransform)),_.alphaTest>0&&(m.alphaTest.value=_.alphaTest)}function u(m,_){m.specular.value.copy(_.specular),m.shininess.value=Math.max(_.shininess,1e-4)}function d(m,_){_.gradientMap&&(m.gradientMap.value=_.gradientMap)}function h(m,_){m.metalness.value=_.metalness,_.metalnessMap&&(m.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,m.metalnessMapTransform)),m.roughness.value=_.roughness,_.roughnessMap&&(m.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,m.roughnessMapTransform)),_.envMap&&(m.envMapIntensity.value=_.envMapIntensity)}function f(m,_,b){m.ior.value=_.ior,_.sheen>0&&(m.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),m.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(m.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,m.sheenColorMapTransform)),_.sheenRoughnessMap&&(m.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,m.sheenRoughnessMapTransform))),_.clearcoat>0&&(m.clearcoat.value=_.clearcoat,m.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(m.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,m.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(m.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===cn&&m.clearcoatNormalScale.value.negate())),_.dispersion>0&&(m.dispersion.value=_.dispersion),_.iridescence>0&&(m.iridescence.value=_.iridescence,m.iridescenceIOR.value=_.iridescenceIOR,m.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(m.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,m.iridescenceMapTransform)),_.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),_.transmission>0&&(m.transmission.value=_.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),_.transmissionMap&&(m.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,m.transmissionMapTransform)),m.thickness.value=_.thickness,_.thicknessMap&&(m.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=_.attenuationDistance,m.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(m.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(m.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=_.specularIntensity,m.specularColor.value.copy(_.specularColor),_.specularColorMap&&(m.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,m.specularColorMapTransform)),_.specularIntensityMap&&(m.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,_){_.matcap&&(m.matcap.value=_.matcap)}function g(m,_){const b=e.get(_).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,M){const S=M.program;i.uniformBlockBinding(y,S)}function c(y,M){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const E=M.program;i.updateUBOMapping(y,E);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const M=d();y.__bindingPointIndex=M;const S=n.createBuffer(),E=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,E,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,M,S),S}function d(){for(let y=0;y0&&(S+=E-v),y.__size=S,y.__cache={},this}function _(y){const M={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(M.boundary=4,M.storage=4):y.isVector2?(M.boundary=8,M.storage=8):y.isVector3||y.isColor?(M.boundary=16,M.storage=12):y.isVector4?(M.boundary=16,M.storage=16):y.isMatrix3?(M.boundary=48,M.storage=48):y.isMatrix4?(M.boundary=64,M.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(M.boundary=16,M.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),M}function b(y){const M=y.target;M.removeEventListener("dispose",b);const S=a.indexOf(M.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function A(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:A}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const g=f,m=new Set([Fc,kc,Nc]),_=new Set([vn,ei,wr,Rr,Uc,Oc]),b=new Uint32Array(4),A=new Int32Array(4),y=new B;let M=null,S=null;const E=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),W=new jm(V),Me=new Ox(V,W),F=new Yx(V,W,G,Me),Y=new $x(V,F,W,Me,G),k=new Zx(V,R,$),ge=new Fx(H),re=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),g!==vn&&(T=new jx(g,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(g===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),M=he.get(C,E.length),M.init(),E.push(M),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),M.finish(),I.sortObjects===!0&&M.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(M,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=M.opaque,Re=M.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(M,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,E.pop(),E.length>0?M=E[E.length-1]:M=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&M.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],g=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const A=-g/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1g.length).map(g=>{let m=parseFloat(g);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const g=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=g;else if(r.indexOf(g)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),g==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=g;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(g)>-1)a.type?(d.apply(this),a={type:g}):a.type=g;else{if(s.indexOf(g)>-1)throw new Error("Unsupported path command: "+g+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(g)>-1?o.push(""):g==="."?!a.type||m.indexOf(g)>-1?l=!0:o[o.length-1]+=g:l=!0}if(l)throw new Error("Unexpected character: "+g+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const g=this.commands[p];for(const m in g)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+g[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-g[m]:g[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,M;const S=()=>{let E=0;if(t==="gvar"){if(E=g.privatePoints.length||d.length,!E){const v=i.get(s);v.path,E=v.points.length,E+=4}}else t==="cvar"&&(E=i.length);this.offset=m,this.relativeOffset=_,y=this.parsePackedDeltas(E),t==="gvar"&&(M=this.parsePackedDeltas(E))};return{configurable:!0,get:function(){return y===void 0&&S(),A==="deltasY"?M:y},set:function(E){y===void 0&&S(),A==="deltasY"?M=E:y=E}}};Object.defineProperty(g,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(g,"deltasY",b.call(this,"deltasY")),h+=g.variationDataSize,delete g.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,g=0,m,_,b,A,y=0,M=[],S,E=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,A=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,_=P._subrsBias,i>1?(M=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,A=P._nominalWidthX)}else m=v.topDict._subrs,_=v.topDict._subrsBias;const T=rp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+A),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+A,h=!0),g+=u.pop(),L(p,g);break;case 5:for(;u.length>0;)p+=u.shift(),g+=u.shift(),c.lineTo(p,g);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,g),u.length!==0);)g+=u.shift(),c.lineTo(p,g);break;case 7:for(;u.length>0&&(g+=u.shift(),c.lineTo(p,g),u.length!==0);)p+=u.shift(),c.lineTo(p,g);break;case 8:for(;u.length>0;)r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 10:if(D=u.pop()+_,ae=m[D],ae){if(E>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}E++,U(ae),E--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),g=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 34:r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=g,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 36:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 37:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-g)?p=le+u.shift():g=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+A,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(M,y,s));var J=u.pop(),xe=S?S.length:M.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+A,h=!0),g+=u.pop(),p+=u.pop(),L(p,g);break;case 22:u.length>1&&!h&&(I=u.shift()+A,h=!0),p+=u.pop(),L(p,g);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);p+=u.shift(),g+=u.shift(),c.lineTo(p,g);break;case 25:for(;u.length>6;)p+=u.shift(),g+=u.shift(),c.lineTo(p,g);r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 27:for(u.length&1&&(g+=u.shift());u.length>0;)r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l,c.curveTo(r,a,o,l,p,g);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(E>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}E++,U(ae),E--}break;case 30:for(;u.length>0&&(r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g),u.length!==0);)r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),g=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),g=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g),u.length!==0);)r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),g=AS(n,e,p.objects);u._fdArray=g,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,g.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),g=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=g,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,g.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,g=Xn(n,p);t.subrs=g.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let g=0;n.weightClass>=600&&(g|=n.macStyleValues.BOLD),n.italicAngle<0&&(g|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:g,createdTimestamp:n.createdTimestamp}),_=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=dp.make(n.glyphs.length),A=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),M=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),E=n.getEnglishName("fontSubfamily"),v=S+" "+E;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+E);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),X=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:E,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,ae=[m,_,b,A,P,M,N,X,y];Z&&ae.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Ap(ae),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const g=new Image(f,p);return g.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:g}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let g=n;g<=e;g++){let m=s[g][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[g][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]Math.max(0,g[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(g[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,g=c.y,m=u.x,_=u.y,b=d.x,A=d.y,y=h.x,M=h.y,S=(p-m)*(A-M)-(g-_)*(b-y),E=p*_-g*m,v=b*M-A*y;f.x=(E*(b-y)-v*(p-m))/S,f.y=(E*(A-M)-v*(g-_))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const g=c[d];s.setRelative(g,g,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,g=Math.abs(g),n&&(_=r.cvt[o],i&&Math.abs(g-_)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const g=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),_=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=X;oe<=D;oe++)_[oe].push(U);const ae=Ia((Z-d)/g),ie=Ia((N-d)/g);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const A=w=>Math.ceil(w.length/4),y=_.reduce((w,U)=>w+A(U),0)+b.reduce((w,U)=>w+A(U),0),M=2+ln*2+y+a.length*2,S=this.alloc(M),E=this.data,v=(w,U,O,P,Z)=>{E[w*4]=U,E[w*4+1]=O,E[w*4+2]=P,E[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),g=Math.sin(s),m=(r>>16&255)/255,_=(r>>8&255)/255,b=(r&255)/255;for(let A=0;A=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,X=O+La,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=E+ie*u;this.pos.push(t.x+oe*p-_e*g,t.y+oe*g+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,_,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let g=0;g0){const g=e[0];g.startsWith('"')&&g.endsWith('"')?(s="text",o=g.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=g,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const A=_.substring(0,b).trim().toLowerCase(),y=_.substring(b+1).trim(),M=parseFloat(y);isNaN(M)||(A==="s"?c=M:A==="r"?u=M:A==="a"?(u=M,d=!0):A==="u"?(u=M,h=!0):A==="x"?f=M:A==="y"&&(p=M))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,A,y,M,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],g=d[5],m=((y=(A=this._controls)==null?void 0:A.target)==null?void 0:y.x)??s.position.x,_=((S=(M=this._controls)==null?void 0:M.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:_+a*c*f+o*u*g,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const g=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,_=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(_.has(R)||_.set(R,[]),_.get(R).push(se))}const b=[];let A=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),A++,!(A&7)&&b.length<1e5&&b.push(se,R))},M=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,E=Hs(e),v=E.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=E.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{M($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:_,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(g&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,M,u):M(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,M,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,M);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,M,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,M);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,M,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,M,y):(this._polylineSegs(x.points,F,x.elevation||0,H,M),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,M,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,M);break;case"POLYLINE_2D":{const W=(_.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,M,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,M,y):(this._polylineSegs(F,re,ce,H,M),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(M(W.x-1,W.y,W.x+1,W.y,W.z||0,H),M(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,M,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,M);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,M,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,M),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?M(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):M(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=_.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,M,u,{entsByOwner:_,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,M,y):(this._polylineSegs(re.points,!0,0,H,M),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=_.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)M(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,M);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?_.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,M,u,{entsByOwner:_,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,M),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,M,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,M),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(M(ce,ee,he,ee,k,H),M(he,ee,he,ge,k,H),M(he,ge,ce,ge,k,H),M(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const g=new Ct;g.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(g,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),g=f-(s.y||0),m=c*p-u*g,_=u*p+c*g;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(_-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(g,m)=>{let _=0;return gr.maxX&&(_|=2),mr.maxY&&(_|=8),_};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const g=f||p;let m=0,_=0;g&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),_=r.maxY):g&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),_=r.minY):g&2?(_=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(_=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),g===f?(e=m,t=_,f=h(e,t)):(i=m,s=_,p=h(i,s))}}_emitModelThroughViewport(e,t){var A,y,M,S,E,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,g=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},_=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(A=N.ownerHandle)==null?void 0:A.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((M=this._hiddenLayers)!=null&&M.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(g.size){const de=(E=N.layerHandle)==null?void 0:E.value;if(de!=null&&g.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>_(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,_):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>_(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>_(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,_):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>_(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),_(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const g=4*Math.atan(u),m=Math.abs(g)/2,_=p/2/Math.sin(m),b=_*Math.cos(m),A=(l.x+c.x)/2,y=(l.y+c.y)/2,M=-f/p,S=h/p,E=u>0?1:-1,v=A+E*M*b,T=y+E*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(g)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+g*w/L;r.push({x:v+_*Math.cos(U),y:T+_*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const g=r+u*p/d,m=o*Math.cos(g),_=l*Math.sin(g),b=i.x+m*Math.cos(c)-_*Math.sin(c),A=i.y+m*Math.sin(c)+_*Math.cos(c);h.push({x:b,y:A,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var _;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let b=0;b{let A=Math.max(0,Math.min(b,u));for(let S=0;S1e-9?A/E:0,T=l[S],I=l[S+1],L=T.x+(I.x-T.x)*v,w=T.y+(I.y-T.y)*v,U=(T.z||0)+((I.z||0)-(T.z||0))*v,O=Math.atan2(I.y-T.y,I.x-T.x);return{x:L,y:w,z:U,angle:O}}A-=E}const y=l[l.length-1],M=l[l.length-2];return{x:y.x,y:y.y,z:y.z||0,angle:Math.atan2(y.y-M.y,y.x-M.x)}},h=i.elements||[];if(i.patternLength*s<1e-6||!h.length)return;let p=0;for(const b of h){if(b.type==="shape")break;b.type==="dash"?p+=Math.max((b.val||.05)*s,.01*s):b.type==="gap"&&(p+=Math.abs(b.val||.1)*s)}let g=0,m=0;for(;gy){const S=d(y),E=d(M);a(S.x,S.y,E.x,E.y,S.z,r)}g+=A}else if(b.type==="gap"){const A=Math.abs(b.val||.1)*s;g+=A}else if(b.type==="shape"){const A=d(g);this._renderShapeSymbol(b,A,s,r,a)}else if(b.type==="text"){const A=d(g);if(b.text&&o){const y=(b.style||"STANDARD").toUpperCase(),M=((_=this._textStyleHeightMap)==null?void 0:_.get(y))||0,E=(M>0?M:b.scale||.2)*s;let v=A.angle+(b.rotation||0)*Math.PI/180;b.isAbsoluteAngle&&(v=(b.rotation||0)*Math.PI/180);let T=Math.atan2(Math.sin(v),Math.cos(v));T>Math.PI/2?T-=Math.PI:T<-Math.PI/2&&(T+=Math.PI),v=T;const I=Math.cos(v),L=Math.sin(v),w=(b.xOffset||0)*s,U=0;let O=0;const P=h[m%h.length];P&&P.type==="gap"&&(O=Math.abs(P.val||0)*s/2);const Z=O>1e-6?d(g+O):A,N=Z.x+(w*I-U*L),X=Z.y+(w*L+U*I);o.push({text:b.text,pos:{x:N,y:X,z:Z.z},height:Math.max(E,.01),rotation:v,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),g=t.z||0,m=Math.cos(l),_=Math.sin(l),b=(A,y)=>({x:f+(A*m-y*_)*o,y:p+(A*_+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let E=0;E<=12;E++){const v=E/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,g,s)}const y=b(.5,0),M=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,S.x,S.y,g,s),r(S.x,S.y,y.x,y.y,g,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let M=1;M<=12;M++){const S=M/12*Math.PI*2,E=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,E.x,E.y,g,s),y=E}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const A=b(-.3,-.3),y=b(.3,-.3),M=b(.3,.3),S=b(-.3,.3);r(A.x,A.y,y.x,y.y,g,s),r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,S.x,S.y,g,s),r(S.x,S.y,A.x,A.y,g,s)}else if(a.includes("TRACK1")){const A=b(0,-.4),y=b(0,.4);r(A.x,A.y,y.x,y.y,g,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const A=b(0,.4),y=b(.4,0),M=b(0,-.4),S=b(-.4,0);r(A.x,A.y,y.x,y.y,g,s),r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,S.x,S.y,g,s),r(S.x,S.y,A.x,A.y,g,s)}else{const A=b(.3,0),y=b(-.3,.2),M=b(-.3,-.2);r(A.x,A.y,y.x,y.y,g,s),r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,A.x,A.y,g,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let g=null;for(let m=0;m<=bl;m++){const _=o+p*m/bl,b=d*Math.cos(_),A=h*Math.sin(_),y=r.x+b*Math.cos(f)-A*Math.sin(f),M=r.y+b*Math.sin(f)+A*Math.cos(f);g&&i(g.x,g.y,y,M,r.z||0,t),g={x:y,y:M}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},g={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,g.x,g.y,0),e.push(f.x,f.y,0,g.x,g.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(_-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(g.x,g.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*A,I=M+v*E*A,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,g=0;for(const m of e)p+=m.x,g+=m.y;p/=e.length,g/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,g))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=_+M*A*m,E=b+M*y*m,v=Math.atan2(o.y-E,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&g>_*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,g=document.createElement("canvas");g.width=d,g.height=h;const m=g.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const _=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=_(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!M.length)return!1;const U=this._polyCentroid(w);for(const O of M)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(A.length){m.fillStyle="#ffffff",m.beginPath();for(const U of A)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const E=y.filter(w=>!S(w));if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const w of E)b(w);m.fill("evenodd")}const v=new _a(g);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,g=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),g=Math.max(g,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),_=Math.ceil(p+g+96*.35);d.width=f+m*2,d.height=_*e.length+m*2,h.font=u;const b=r>>16&255,A=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${A},${y})`,h.textBaseline="alphabetic";let M=m;a===1||a===4?(h.textAlign="center",M=d.width/2):a===2?(h.textAlign="right",M=d.width-m):(h.textAlign="left",M=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,g=h*p,m=f*p,_=e.alignH??1,b=e.alignV??2;let A=0,y=0;_===0||_===3||_===5?A=h/2:_===2&&(A=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const M=e.rotation||0,S=Math.cos(M),E=Math.sin(M),v=e.pos.x+A*S-y*E,T=e.pos.y+A*E+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(g,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=M,this._group.add(P)}if(a&&!r){const U=g/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*E,y:T+N*E+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,g=i*d.h/f,m=g*(d.w/d.h),_=g/d.h,b=d.h/2;let A=0;a===0||a===3||a===5?A=m/2:a===1||a===4?A=0:a===2&&(A=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*_:o===3&&(y=(p-b)*_));const M=new gc({map:h,transparent:!0,depthTest:!1});s&&(M.rotation=s);const S=new Nu(M);S.scale.set(m,g,1),S.position.set(t.x+A,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,g=t.xScale??1,m=t.yScale??1,_=t.rotation??0,b=Math.cos(_),A=Math.sin(_),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*g*b-ie*m*A,f.y+ae*g*A+ie*m*b]},M=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(g),Math.abs(m)),E=d+_;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=M(D.start.x,D.start.y),[de,le]=M(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=M(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+E:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+E:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=M(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+E;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=M(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=M(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=M(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=M(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:M,scale:S,rot:E,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+E;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+E)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=M(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,g=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",_=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,E)=>{!S||!E||(r(S.x,S.y,E.x,E.y,0,s),o(S.x,S.y),o(E.x,E.y))},A=(S,E,v,T,I)=>{this._arcSegs({x:S,y:E},v,T,I,0,s,r)},y=(S,E,v)=>this._arrowMesh(S,E,v,s),M=(S,E,v,T)=>{E&&S&&a.push({text:E,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,E,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,E=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(g))>.5,w=f/2;S=l.x-(L?0:w),E=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:E},{x:v,y:T}),b(c,{x:S,y:E}),b(u,{x:v,y:T}),y({x:S,y:E,z:0},Math.atan2(E-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-E,v-S),I),M(h??{x:(S+v)/2,y:(E+T)/2},m||_(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),M(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${_(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},E=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),E),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),E),M(h??l,m||`Ø${_(f)}`,Math.max(E*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,E=l.y,v=Math.hypot(c.x-S,c.y-E);if(v<1e-9)return;let T=Math.atan2(c.y-E,c.x-S),I=Math.atan2(u.y-E,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),A(S,E,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:E+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:E+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;M(h??{x:S+Math.cos(U)*v*1.2,y:E+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),M(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],g=e.clientY-this._downXY[1];if(Math.hypot(p,g)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,g=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const g=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),_=new ki(new B(d-g,f-m,0),new B(h+g,p+m,0));return _.min.max(t.min),_.max.min(t.max),_}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=_.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}_.name=g,_.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},_.methodFactory=m||h,_.getLevel=function(){return y??A??b},_.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(_)},_.setDefaultLevel=function(L){A=T(L),E()||_.setLevel(L,!1)},_.resetLevel=function(){y=null,v(),u.call(_)},_.enableAll=function(L){_.setLevel(_.levels.TRACE,L)},_.disableAll=function(L){_.setLevel(_.levels.SILENT,L)},_.rebuild=function(){if(a!==_&&(b=T(a.getLevel())),u.call(_),a===_)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=E();I!=null&&(y=T(I)),u.call(_)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var _=r[m];return _||(_=r[m]=new f(m,a.methodFactory)),_};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=A(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,E=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=E);break}else o.code===9?(S&&(v[S]=E),S=o.value):o.code===10?E={x:o.value}:o.code===20?E.y=o.value:o.code===30?E.z=o.value:E=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const E=d();nt.debug("}"),M(E),E.name?S[E.name]=E:nt.error('block with handle "'+E.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=A(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const E=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===E.dxfSymbolName?v[E.tableRecordsProperty]=E.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[E.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+E.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function g(){const S=[];let E={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:E.name=o.value,o=r.next();break;case 10:E.lowerLeftCorner=y(o),o=r.next();break;case 11:E.upperRightCorner=y(o),o=r.next();break;case 12:E.center=y(o),o=r.next();break;case 13:E.snapBasePoint=y(o),o=r.next();break;case 14:E.snapSpacing=y(o),o=r.next();break;case 15:E.gridSpacing=y(o),o=r.next();break;case 16:E.viewDirectionFromTarget=y(o),o=r.next();break;case 17:E.viewTarget=y(o),o=r.next();break;case 42:E.lensLength=o.value,o=r.next();break;case 43:E.frontClippingPlane=o.value,o=r.next();break;case 44:E.backClippingPlane=o.value,o=r.next();break;case 45:E.viewHeight=o.value,o=r.next();break;case 50:E.snapRotationAngle=o.value,o=r.next();break;case 51:E.viewTwistAngle=o.value,o=r.next();break;case 79:E.orthographicType=o.value,o=r.next();break;case 110:E.ucsOrigin=y(o),o=r.next();break;case 111:E.ucsXAxis=y(o),o=r.next();break;case 112:E.ucsYAxis=y(o),o=r.next();break;case 110:E.ucsOrigin=y(o),o=r.next();break;case 281:E.renderMode=o.value,o=r.next();break;case 281:E.defaultLightingType=o.value,o=r.next();break;case 292:E.defaultLightingOn=o.value,o=r.next();break;case 330:E.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:E.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(E),nt.debug("ViewPort {"),E={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(E),S}function m(){const S={};let E={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:E.name=o.value,T=o.value,o=r.next();break;case 3:E.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(E.pattern=[]),o=r.next();break;case 40:E.patternLength=o.value,o=r.next();break;case 49:E.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==E.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=E,E={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=E,S}function _(){const S={};let E={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:E.name=o.value,v=o.value,o=r.next();break;case 62:E.visible=o.value>=0,E.colorIndex=Math.abs(o.value),E.color=iE(E.colorIndex),o=r.next();break;case 70:E.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=E,nt.debug("Layer {"),E={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=E,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:g},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:_}};function A(S){const E=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),M(I),E.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),E}function y(S){const E={};let v=S.code;if(E.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return E.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),E):(E.z=S.value,E)}function M(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,g=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const _=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=_;b++){const A=u+m*b/_,y=f*Math.cos(A),M=p*Math.sin(A);t.points.push({x:r+y*Math.cos(g)-M*Math.sin(g),y:a+y*Math.sin(g)+M*Math.cos(g)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const g=wd(p,i);g.ownerHandle={value:f},a.push(g)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-BVQWKQJi.js b/dist2/assets/index-BVQWKQJi.js new file mode 100644 index 0000000..74d61f0 --- /dev/null +++ b/dist2/assets/index-BVQWKQJi.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),E=Math.sin(b);g=Math.sin(g*b)/E,o=Math.sin(o*b)/E,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],E=s[4],y=s[7],A=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*A,r[3]=a*m+o*E+l*S,r[6]=a*g+o*y+l*M,r[1]=c*_+u*b+d*A,r[4]=c*m+u*E+d*S,r[7]=c*g+u*y+d*M,r[2]=h*_+f*b+p*A,r[5]=h*m+f*E+p*S,r[8]=h*g+f*y+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,y=(f+1)/2,A=(g+1)/2,S=(u+h)/4,M=(d+_)/4,v=(p+m)/4;return E>y&&E>A?E<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(E),s=S/i,r=M/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=M/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=b,A=E;yt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],E=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,g-p,A-b).normalize(),s[1].setComponents(c+a,f+u,g+p,A+b).normalize(),s[2].setComponents(c+o,f+d,g+_,A+E).normalize(),s[3].setComponents(c-o,f-d,g-_,A-E).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,g-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,g-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,g+m,A+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/M),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=_c(f,p,e,t,i),b=_c(_,m,e,t,i);let E=n.prevZ,y=n.nextZ;for(;E&&E.z>=g&&y&&y.z<=b;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0||(E=E.prevZ,y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;E&&E.z>=g;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const y=b.backgroundBlurriness>0;E=e.get(E,y)}return E}function p(b){let E=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),E=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,E){const y=f(E);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(E.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,E,r)}function g(){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 a},setClearColor:function(b,E=1){a.set(b),o=E,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function _(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Pc;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,E=b*4;let y=g.clippingState||null;l.value=y,y=u(p,h,E,f);for(let A=0;A!==E;++A)y[A]=t[A];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const g=[];let b=0;for(let M=0;ME-Oi?s-E+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),E=new Float32Array(m*p*f),y=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,v,0,M+2/3,v,0,M+2/3,v+1,0,M,v,0,M+2/3,v+1,0,M,v+1,0];b.set(T,_*p*S),E.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,g*p*S)}const A=new Ct;A.setAttribute("position",new Un(b,_)),A.setAttribute("uv",new Un(E,m)),A.setAttribute("faceIndex",new Un(y,g)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Af(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,_=f===ns||f===Ys;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?sf:nf)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const M=new Float32Array(A*S*4*d),v=new Qd(M,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(E,y){a.setSize(E,y),o.setSize(E,y);for(let A=0;A0&&g[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),g.length>0&&(g+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),g=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);const E=b+m+a,y=b+g+o,A=gh(s,s.VERTEX_SHADER,E),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(_,A),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,A,S);else{const ae=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:g}})}s.deleteShader(A),s.deleteShader(S),v=new Va(s,_),T=Q1(s,_)}let v;this.getUniforms=function(){return v===void 0&&M(this),v};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=A,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===xo?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(g(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function g(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function E(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:M}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,E=0,y=0,A=0,S=0,M=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==_||v.rectAreaLength!==m||v.hemiLength!==g||v.numDirectionalShadows!==b||v.numPointShadows!==E||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,v.directionalLength=f,v.pointLength=p,v.spotLength=_,v.rectAreaLength=m,v.hemiLength=g,v.numDirectionalShadows=b,v.numPointShadows=E,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=M,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let g=this.type;this.render=function(S,M,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=g!==this.type;U&&M.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,U=M.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,M.addEventListener("dispose",A)),I=P}if(I.visible=M.visible,I.wireframe=M.wireframe,T===yr?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,M,v,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=_(fe,W));const F=x?_(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function E(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function M(R){const x=R.target;x.removeEventListener("dispose",M),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",M));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new By,g={},b=t.getContextAttributes();let E=null,y=null;const A=[],S=[],M=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),E=b.envMap,y=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,E){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=E*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const M=A.program;i.updateUBOMapping(y,M);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),M=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=M-v),y.__size=S,y.__cache={},this}function g(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function b(y){const A=y.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function E(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:E}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([Fc,kc,Nc]),g=new Set([vn,ei,wr,Rr,Uc,Oc]),b=new Uint32Array(4),E=new Int32Array(4),y=new B;let A=null,S=null;const M=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),W=new jm(V),Me=new Ox(V,W),F=new Yx(V,W,G,Me),Y=new $x(V,F,W,Me,G),k=new Zx(V,R,$),ge=new Fx(H),re=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),_!==vn&&(T=new jx(_,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,M.length),A.init(),M.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(A,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?A=M[M.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const E=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const v=i.get(s);v.path,M=v.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,y=this.parsePackedDeltas(M),t==="gvar"&&(A=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return y===void 0&&S(),E==="deltasY"?A:y},set:function(M){y===void 0&&S(),E==="deltasY"?A=M:y=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,E,y=0,A=[],S,M=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,E=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,g=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,E=P._nominalWidthX)}else m=v.topDict._subrs,g=v.topDict._subrsBias;const T=rp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+E),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(D=u.pop()+g,ae=m[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,U(ae),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=_,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-_)?p=le+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+E,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+E,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,U(ae),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),_=AS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),_=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Xn(n,p);t.subrs=_.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=dp.make(n.glyphs.length),E=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),A=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),v=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),X=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,ae=[m,g,b,E,P,A,N,X,y];Z&&ae.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Ap(ae),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,E=d.y,y=h.x,A=h.y,S=(p-m)*(E-A)-(_-g)*(b-y),M=p*g-_*m,v=b*A-E*y;f.x=(M*(b-y)-v*(p-m))/S,f.y=(M*(E-A)-v*(_-g))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=X;oe<=D;oe++)g[oe].push(U);const ae=Ia((Z-d)/_),ie=Ia((N-d)/_);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const E=w=>Math.ceil(w.length/4),y=g.reduce((w,U)=>w+E(U),0)+b.reduce((w,U)=>w+E(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),M=this.data,v=(w,U,O,P,Z)=>{M[w*4]=U,M[w*4+1]=O,M[w*4+2]=P,M[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let E=0;E=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,X=O+La,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=M+ie*u;this.pos.push(t.x+oe*p-_e*_,t.y+oe*_+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const E=g.substring(0,b).trim().toLowerCase(),y=g.substring(b+1).trim(),A=parseFloat(y);isNaN(A)||(E==="s"?c=A:E==="r"?u=A:E==="a"?(u=A,d=!0):E==="u"?(u=A,h=!0):E==="x"?f=A:E==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,E,y,A,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((y=(E=this._controls)==null?void 0:E.target)==null?void 0:y.x)??s.position.x,g=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const _=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,g=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(g.has(R)||g.set(R,[]),g.get(R).push(se))}const b=[];let E=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),E++,!(E&7)&&b.length<1e5&&b.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,M=Hs(e),v=M.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=M.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{A($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(_&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,A,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const W=(g.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,A,y):(this._polylineSegs(F,re,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(A(W.x-1,W.y,W.x+1,W.y,W.z||0,H),A(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?A(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):A(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=g.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:g,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,A,y):(this._polylineSegs(re.points,!0,0,H,A),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=g.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?g.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,A),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(_,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var E,y,A,S,M,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},g=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(E=N.ownerHandle)==null?void 0:E.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(_.size){const de=(M=N.layerHandle)==null?void 0:M.value;if(de!=null&&_.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>g(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,g):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>g(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>g(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,g):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),g(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),E=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,M=u>0?1:-1,v=E+M*A*b,T=y+M*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+_*w/L;r.push({x:v+g*Math.cos(U),y:T+g*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),E=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:E,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var m;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let g=0;g{let b=Math.max(0,Math.min(g,u));for(let A=0;A1e-9?b/S:0,v=l[A],T=l[A+1],I=v.x+(T.x-v.x)*M,L=v.y+(T.y-v.y)*M,w=(v.z||0)+((T.z||0)-(v.z||0))*M,U=Math.atan2(T.y-v.y,T.x-v.x);return{x:I,y:L,z:w,angle:U}}b-=S}const E=l[l.length-1],y=l[l.length-2];return{x:E.x,y:E.y,z:E.z||0,angle:Math.atan2(E.y-y.y,E.x-y.x)}};if(i.patternLength*s<1e-6)return;let f=0,p=0;const _=i.elements;for(;fE){const A=d(E),S=d(y);a(A.x,A.y,S.x,S.y,A.z,r)}f+=b}else if(g.type==="gap"){const b=Math.abs(g.val||.1)*s;f+=b}else if(g.type==="shape"){const b=d(f);this._renderShapeSymbol(g,b,s,r,a)}else if(g.type==="text"){const b=d(f);if(g.text&&o){const E=(g.style||"STANDARD").toUpperCase(),y=((m=this._textStyleHeightMap)==null?void 0:m.get(E))||0,S=(y>0?y:g.scale||.2)*s;let M=b.angle+(g.rotation||0)*Math.PI/180;g.isAbsoluteAngle&&(M=(g.rotation||0)*Math.PI/180);let v=Math.atan2(Math.sin(M),Math.cos(M));v>Math.PI/2?v-=Math.PI:v<-Math.PI/2&&(v+=Math.PI),M=v;const T=Math.cos(M),I=Math.sin(M),L=(g.xOffset||0)*s,w=0;let U=0;const O=_[p%_.length];O&&O.type==="gap"&&(U=Math.abs(O.val||0)*s/2);const P=U>1e-6?d(f+U):b,Z=P.x+(L*T-w*I),N=P.y+(L*I+w*T);o.push({text:g.text,pos:{x:Z,y:N,z:P.z},height:Math.max(S,.01),rotation:M,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(E,y)=>({x:f+(E*m-y*g)*o,y:p+(E*g+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const v=M/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const y=b(.5,0),A=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,y.x,y.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,M.x,M.y,_,s),y=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const E=b(-.3,-.3),y=b(.3,-.3),A=b(.3,.3),S=b(-.3,.3);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else if(a.includes("TRACK1")){const E=b(0,-.4),y=b(0,.4);r(E.x,E.y,y.x,y.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const E=b(0,.4),y=b(.4,0),A=b(0,-.4),S=b(-.4,0);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else{const E=b(.3,0),y=b(-.3,.2),A=b(-.3,-.2);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,E.x,E.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=bl;m++){const g=o+p*m/bl,b=d*Math.cos(g),E=h*Math.sin(g),y=r.x+b*Math.cos(f)-E*Math.sin(f),A=r.y+b*Math.sin(f)+E*Math.cos(f);_&&i(_.x,_.y,y,A,r.z||0,t),_={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(g-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*E,I=A+v*M*E,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+A*E*m,M=b+A*y*m,v=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=g(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const U of E)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=y.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const v=new _a(_);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),_=Math.max(_,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,E=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${E},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let E=0,y=0;g===0||g===3||g===5?E=h/2:g===2&&(E=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),M=Math.sin(A),v=e.pos.x+E*S-y*M,T=e.pos.y+E*M+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(_,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=_/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*M,y:T+N*M+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let E=0;a===0||a===3||a===5?E=m/2:a===1||a===4?E=0:a===2&&(E=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*g:o===3&&(y=(p-b)*g));const A=new gc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,_,1),S.position.set(t.x+E,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),E=Math.sin(g),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*_*b-ie*m*E,f.y+ae*_*E+ie*m*b]},A=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+M:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+M;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:M,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+M;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+M)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},E=(S,M,v,T,I)=>{this._arcSegs({x:S,y:M},v,T,I,0,s,r)},y=(S,M,v)=>this._arrowMesh(S,M,v,s),A=(S,M,v,T)=>{M&&S&&a.push({text:M,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,M=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:v,y:T}),b(c,{x:S,y:M}),b(u,{x:v,y:T}),y({x:S,y:M,z:0},Math.atan2(M-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-M,v-S),I),A(h??{x:(S+v)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),A(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,v=Math.hypot(c.x-S,c.y-M);if(v<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),E(S,M,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:M+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:M+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:M+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new ki(new B(d-_,f-m,0),new B(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return y??E??b},g.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(g)},g.setDefaultLevel=function(L){E=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){y=null,v(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(y=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=E(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=M);break}else o.code===9?(S&&(v[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),A(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=E(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?v[M.tableRecordsProperty]=M.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=y(o),o=r.next();break;case 11:M.upperRightCorner=y(o),o=r.next();break;case 12:M.center=y(o),o=r.next();break;case 13:M.snapBasePoint=y(o),o=r.next();break;case 14:M.snapSpacing=y(o),o=r.next();break;case 15:M.gridSpacing=y(o),o=r.next();break;case 16:M.viewDirectionFromTarget=y(o),o=r.next();break;case 17:M.viewTarget=y(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 111:M.ucsXAxis=y(o),o=r.next();break;case 112:M.ucsYAxis=y(o),o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,v=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=iE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=M,nt.debug("Layer {"),M={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function E(S){const M=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),M}function y(S){const M={};let v=S.code;if(M.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return M.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),M):(M.z=S.value,M)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const E=u+m*b/g,y=f*Math.cos(E),A=p*Math.sin(E);t.points.push({x:r+y*Math.cos(_)-A*Math.sin(_),y:a+y*Math.sin(_)+A*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=wd(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-C-ZCL9XD.js b/dist2/assets/index-C-ZCL9XD.js new file mode 100644 index 0000000..a145e12 --- /dev/null +++ b/dist2/assets/index-C-ZCL9XD.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),E=Math.sin(b);g=Math.sin(g*b)/E,o=Math.sin(o*b)/E,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],E=s[4],y=s[7],A=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*A,r[3]=a*m+o*E+l*S,r[6]=a*g+o*y+l*M,r[1]=c*_+u*b+d*A,r[4]=c*m+u*E+d*S,r[7]=c*g+u*y+d*M,r[2]=h*_+f*b+p*A,r[5]=h*m+f*E+p*S,r[8]=h*g+f*y+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,y=(f+1)/2,A=(g+1)/2,S=(u+h)/4,M=(d+_)/4,v=(p+m)/4;return E>y&&E>A?E<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(E),s=S/i,r=M/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=M/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=b,A=E;yt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],E=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,g-p,A-b).normalize(),s[1].setComponents(c+a,f+u,g+p,A+b).normalize(),s[2].setComponents(c+o,f+d,g+_,A+E).normalize(),s[3].setComponents(c-o,f-d,g-_,A-E).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,g-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,g-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,g+m,A+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/M),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=_c(f,p,e,t,i),b=_c(_,m,e,t,i);let E=n.prevZ,y=n.nextZ;for(;E&&E.z>=g&&y&&y.z<=b;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0||(E=E.prevZ,y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;E&&E.z>=g;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const y=b.backgroundBlurriness>0;E=e.get(E,y)}return E}function p(b){let E=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),E=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,E){const y=f(E);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(E.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,E,r)}function g(){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 a},setClearColor:function(b,E=1){a.set(b),o=E,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function _(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Pc;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,E=b*4;let y=g.clippingState||null;l.value=y,y=u(p,h,E,f);for(let A=0;A!==E;++A)y[A]=t[A];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const g=[];let b=0;for(let M=0;ME-Oi?s-E+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),E=new Float32Array(m*p*f),y=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,v,0,M+2/3,v,0,M+2/3,v+1,0,M,v,0,M+2/3,v+1,0,M,v+1,0];b.set(T,_*p*S),E.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,g*p*S)}const A=new Ct;A.setAttribute("position",new Un(b,_)),A.setAttribute("uv",new Un(E,m)),A.setAttribute("faceIndex",new Un(y,g)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Af(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,_=f===ns||f===Ys;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?sf:nf)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const M=new Float32Array(A*S*4*d),v=new Qd(M,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(E,y){a.setSize(E,y),o.setSize(E,y);for(let A=0;A0&&g[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),g.length>0&&(g+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),g=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);const E=b+m+a,y=b+g+o,A=gh(s,s.VERTEX_SHADER,E),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(_,A),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,A,S);else{const ae=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:g}})}s.deleteShader(A),s.deleteShader(S),v=new Va(s,_),T=Q1(s,_)}let v;this.getUniforms=function(){return v===void 0&&M(this),v};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=A,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===xo?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(g(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function g(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function E(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:M}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,E=0,y=0,A=0,S=0,M=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==_||v.rectAreaLength!==m||v.hemiLength!==g||v.numDirectionalShadows!==b||v.numPointShadows!==E||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,v.directionalLength=f,v.pointLength=p,v.spotLength=_,v.rectAreaLength=m,v.hemiLength=g,v.numDirectionalShadows=b,v.numPointShadows=E,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=M,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let g=this.type;this.render=function(S,M,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=g!==this.type;U&&M.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,U=M.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,M.addEventListener("dispose",A)),I=P}if(I.visible=M.visible,I.wireframe=M.wireframe,T===yr?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,M,v,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=_(fe,W));const F=x?_(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function E(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function M(R){const x=R.target;x.removeEventListener("dispose",M),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",M));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new By,g={},b=t.getContextAttributes();let E=null,y=null;const A=[],S=[],M=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),E=b.envMap,y=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,E){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=E*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const M=A.program;i.updateUBOMapping(y,M);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),M=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=M-v),y.__size=S,y.__cache={},this}function g(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function b(y){const A=y.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function E(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:E}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([Fc,kc,Nc]),g=new Set([vn,ei,wr,Rr,Uc,Oc]),b=new Uint32Array(4),E=new Int32Array(4),y=new B;let A=null,S=null;const M=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),W=new jm(V),Me=new Ox(V,W),F=new Yx(V,W,G,Me),Y=new $x(V,F,W,Me,G),k=new Zx(V,R,$),ge=new Fx(H),re=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),_!==vn&&(T=new jx(_,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,M.length),A.init(),M.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(A,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?A=M[M.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const E=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const v=i.get(s);v.path,M=v.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,y=this.parsePackedDeltas(M),t==="gvar"&&(A=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return y===void 0&&S(),E==="deltasY"?A:y},set:function(M){y===void 0&&S(),E==="deltasY"?A=M:y=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,E,y=0,A=[],S,M=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,E=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,g=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,E=P._nominalWidthX)}else m=v.topDict._subrs,g=v.topDict._subrsBias;const T=rp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+E),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(D=u.pop()+g,ae=m[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,U(ae),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=_,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-_)?p=le+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+E,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+E,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,U(ae),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),_=AS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),_=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Xn(n,p);t.subrs=_.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=dp.make(n.glyphs.length),E=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),A=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),v=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),X=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,ae=[m,g,b,E,P,A,N,X,y];Z&&ae.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Ap(ae),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,E=d.y,y=h.x,A=h.y,S=(p-m)*(E-A)-(_-g)*(b-y),M=p*g-_*m,v=b*A-E*y;f.x=(M*(b-y)-v*(p-m))/S,f.y=(M*(E-A)-v*(_-g))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=X;oe<=D;oe++)g[oe].push(U);const ae=Ia((Z-d)/_),ie=Ia((N-d)/_);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const E=w=>Math.ceil(w.length/4),y=g.reduce((w,U)=>w+E(U),0)+b.reduce((w,U)=>w+E(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),M=this.data,v=(w,U,O,P,Z)=>{M[w*4]=U,M[w*4+1]=O,M[w*4+2]=P,M[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i/l.capHeightEm,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let E=0;E=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,X=O+La,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=M+ie*u;this.pos.push(t.x+oe*p-_e*_,t.y+oe*_+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const E=g.substring(0,b).trim().toLowerCase(),y=g.substring(b+1).trim(),A=parseFloat(y);isNaN(A)||(E==="s"?c=A:E==="r"?u=A:E==="a"?(u=A,d=!0):E==="u"?(u=A,h=!0):E==="x"?f=A:E==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,E,y,A,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((y=(E=this._controls)==null?void 0:E.target)==null?void 0:y.x)??s.position.x,g=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const _=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,g=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(g.has(R)||g.set(R,[]),g.get(R).push(se))}const b=[];let E=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),E++,!(E&7)&&b.length<1e5&&b.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,M=Hs(e),v=M.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=M.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{A($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(_&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,A,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const W=(g.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,A,y):(this._polylineSegs(F,re,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(A(W.x-1,W.y,W.x+1,W.y,W.z||0,H),A(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?A(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):A(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=g.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:g,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,A,y):(this._polylineSegs(re.points,!0,0,H,A),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=g.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?g.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,A),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(_,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var E,y,A,S,M,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},g=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(E=N.ownerHandle)==null?void 0:E.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(_.size){const de=(M=N.layerHandle)==null?void 0:M.value;if(de!=null&&_.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>g(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,g):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>g(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>g(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,g):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),g(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),E=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,M=u>0?1:-1,v=E+M*A*b,T=y+M*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+_*w/L;r.push({x:v+g*Math.cos(U),y:T+g*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),E=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:E,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var m;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let g=0;g{let b=Math.max(0,Math.min(g,u));for(let A=0;A1e-9?b/S:0,v=l[A],T=l[A+1],I=v.x+(T.x-v.x)*M,L=v.y+(T.y-v.y)*M,w=(v.z||0)+((T.z||0)-(v.z||0))*M,U=Math.atan2(T.y-v.y,T.x-v.x);return{x:I,y:L,z:w,angle:U}}b-=S}const E=l[l.length-1],y=l[l.length-2];return{x:E.x,y:E.y,z:E.z||0,angle:Math.atan2(E.y-y.y,E.x-y.x)}};if(i.patternLength*s<1e-6)return;let f=0,p=0;const _=i.elements;for(;fE){const A=d(E),S=d(y);a(A.x,A.y,S.x,S.y,A.z,r)}f+=b}else if(g.type==="gap"){const b=Math.abs(g.val||.1)*s;f+=b}else if(g.type==="shape"){const b=d(f);this._renderShapeSymbol(g,b,s,r,a)}else if(g.type==="text"){const b=d(f);if(g.text&&o){const E=(g.style||"STANDARD").toUpperCase(),y=((m=this._textStyleHeightMap)==null?void 0:m.get(E))||0,S=(y>0?y:g.scale||.2)*s;let M=b.angle+(g.rotation||0)*Math.PI/180;g.isAbsoluteAngle&&(M=(g.rotation||0)*Math.PI/180);let v=Math.atan2(Math.sin(M),Math.cos(M));v>Math.PI/2?v-=Math.PI:v<-Math.PI/2&&(v+=Math.PI),M=v;const T=Math.cos(M),I=Math.sin(M),L=(g.xOffset||0)*s,w=(g.yOffset||0)*s;let U=0;const O=_[p%_.length];O&&O.type==="gap"&&(U=Math.abs(O.val||0)*s/2);const P=U>1e-6?d(f+U):b,Z=P.x+(L*T-w*I),N=P.y+(L*I+w*T);o.push({text:g.text,pos:{x:Z,y:N,z:P.z},height:Math.max(S,.01),rotation:M,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(E,y)=>({x:f+(E*m-y*g)*o,y:p+(E*g+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const v=M/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const y=b(.5,0),A=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,y.x,y.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,M.x,M.y,_,s),y=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const E=b(-.3,-.3),y=b(.3,-.3),A=b(.3,.3),S=b(-.3,.3);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else if(a.includes("TRACK1")){const E=b(0,-.4),y=b(0,.4);r(E.x,E.y,y.x,y.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const E=b(0,.4),y=b(.4,0),A=b(0,-.4),S=b(-.4,0);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else{const E=b(.3,0),y=b(-.3,.2),A=b(-.3,-.2);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,E.x,E.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=bl;m++){const g=o+p*m/bl,b=d*Math.cos(g),E=h*Math.sin(g),y=r.x+b*Math.cos(f)-E*Math.sin(f),A=r.y+b*Math.sin(f)+E*Math.cos(f);_&&i(_.x,_.y,y,A,r.z||0,t),_={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(g-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*E,I=A+v*M*E,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+A*E*m,M=b+A*y*m,v=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=g(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const U of E)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=y.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const v=new _a(_);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),_=Math.max(_,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,E=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${E},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let E=0,y=0;g===0||g===3||g===5?E=h/2:g===2&&(E=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),M=Math.sin(A),v=e.pos.x+E*S-y*M,T=e.pos.y+E*M+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(_,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=_/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*M,y:T+N*M+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let E=0;a===0||a===3||a===5?E=m/2:a===1||a===4?E=0:a===2&&(E=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*g:o===3&&(y=(p-b)*g));const A=new gc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,_,1),S.position.set(t.x+E,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),E=Math.sin(g),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*_*b-ie*m*E,f.y+ae*_*E+ie*m*b]},A=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+M:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+M;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:M,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+M;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+M)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},E=(S,M,v,T,I)=>{this._arcSegs({x:S,y:M},v,T,I,0,s,r)},y=(S,M,v)=>this._arrowMesh(S,M,v,s),A=(S,M,v,T)=>{M&&S&&a.push({text:M,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,M=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:v,y:T}),b(c,{x:S,y:M}),b(u,{x:v,y:T}),y({x:S,y:M,z:0},Math.atan2(M-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-M,v-S),I),A(h??{x:(S+v)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),A(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,v=Math.hypot(c.x-S,c.y-M);if(v<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),E(S,M,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:M+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:M+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:M+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new ki(new B(d-_,f-m,0),new B(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return y??E??b},g.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(g)},g.setDefaultLevel=function(L){E=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){y=null,v(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(y=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=E(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=M);break}else o.code===9?(S&&(v[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),A(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=E(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?v[M.tableRecordsProperty]=M.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=y(o),o=r.next();break;case 11:M.upperRightCorner=y(o),o=r.next();break;case 12:M.center=y(o),o=r.next();break;case 13:M.snapBasePoint=y(o),o=r.next();break;case 14:M.snapSpacing=y(o),o=r.next();break;case 15:M.gridSpacing=y(o),o=r.next();break;case 16:M.viewDirectionFromTarget=y(o),o=r.next();break;case 17:M.viewTarget=y(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 111:M.ucsXAxis=y(o),o=r.next();break;case 112:M.ucsYAxis=y(o),o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,v=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=iE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=M,nt.debug("Layer {"),M={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function E(S){const M=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),M}function y(S){const M={};let v=S.code;if(M.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return M.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),M):(M.z=S.value,M)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const E=u+m*b/g,y=f*Math.cos(E),A=p*Math.sin(E);t.points.push({x:r+y*Math.cos(_)-A*Math.sin(_),y:a+y*Math.sin(_)+A*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=wd(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-C1AQ5P3M.js b/dist2/assets/index-C1AQ5P3M.js new file mode 100644 index 0000000..79232f4 --- /dev/null +++ b/dist2/assets/index-C1AQ5P3M.js @@ -0,0 +1,5531 @@ +var $p=Object.defineProperty;var Jp=(n,e,t)=>e in n?$p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Jp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Lc="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jp=0,gu=1,Qp=2,Oa=1,e0=2,xr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,t0=5,$i=100,n0=101,i0=102,s0=103,r0=104,a0=200,o0=201,l0=202,c0=203,El=204,Tl=205,u0=206,h0=207,d0=208,f0=209,p0=210,m0=211,g0=212,_0=213,x0=214,Cl=0,wl=1,Rl=2,Xs=3,Dl=4,Ll=5,Il=6,Pl=7,Od=0,y0=1,v0=2,Jn=0,Nd=1,kd=2,Fd=3,Bd=4,Hd=5,zd=6,Vd=7,Gd=300,ns=301,Ys=302,Eo=303,To=304,_o=306,Ul=1e3,ui=1001,Ol=1002,Nt=1003,S0=1004,Yr=1005,Xt=1006,Co=1007,Ui=1008,vn=1009,Wd=1010,Xd=1011,Cr=1012,Ic=1013,ei=1014,Pn=1015,_i=1016,Pc=1017,Uc=1018,wr=1020,Yd=35902,Kd=35899,qd=1021,Zd=1022,bn=1023,xi=1026,es=1027,$d=1028,Oc=1029,is=1030,Nc=1031,kc=1033,Na=33776,ka=33777,Fa=33778,Ba=33779,Nl=35840,kl=35841,Fl=35842,Bl=35843,Hl=36196,zl=37492,Vl=37496,Gl=37488,Wl=37489,Ya=37490,Xl=37491,Yl=37808,Kl=37809,ql=37810,Zl=37811,$l=37812,Jl=37813,jl=37814,Ql=37815,ec=37816,tc=37817,nc=37818,ic=37819,sc=37820,rc=37821,ac=36492,oc=36494,lc=36495,cc=36283,uc=36284,Ka=36285,hc=36286,b0=3200,vu=0,M0=1,ci="",pn="srgb",qa="srgb-linear",Za="linear",ft="srgb",_s=7680,Su=519,A0=512,E0=513,T0=514,Fc=515,C0=516,w0=517,Bc=518,R0=519,dc=35044,fc="300 es",Zn=2e3,$a=2001;function D0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function L0(){const n=Ja("canvas");return n.style.display="block",n}const bu={};function ja(...n){const e="THREE."+n.shift();console.log(e,...n)}function Jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=Jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=Jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function I0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const P0={[Cl]:wl,[Rl]:Il,[Dl]:Pl,[Xs]:Ll,[wl]:Cl,[Il]:Rl,[Pl]:Dl,[Ll]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function U0(n,e){return(n%e+e)%e}function wo(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const O0={DEG2RAD:Ha},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),E=Math.sin(b);g=Math.sin(g*b)/E,o=Math.sin(o*b)/E,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Ro.copy(this).projectOnVector(e),this.sub(Ro)}reflect(e){return this.sub(Ro.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Ro=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],E=s[4],y=s[7],A=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*A,r[3]=a*m+o*E+l*S,r[6]=a*g+o*y+l*M,r[1]=c*_+u*b+d*A,r[4]=c*m+u*E+d*S,r[7]=c*g+u*y+d*M,r[2]=h*_+f*b+p*A,r[5]=h*m+f*E+p*S,r[8]=h*g+f*y+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Do.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Do.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Do.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Do=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function N0(){const n={enabled:!0,workingColorSpace:qa,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?Za:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[qa]:{primaries:e,whitePoint:i,transfer:Za,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=N0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class k0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=Ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Io).x}get height(){return this.source.getSize(Io).y}get depth(){return this.source.getSize(Io).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ul:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Ol:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ul:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Ol:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Gd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,y=(f+1)/2,A=(g+1)/2,S=(u+h)/4,M=(d+_)/4,v=(p+m)/4;return E>y&&E>A?E<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(E),s=S/i,r=M/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=M/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class H0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(q0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new yr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const ef={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},Ai={h:0,s:0,l:0},Zr={h:0,s:0,l:0};function Oo(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=U0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=Oo(a,r,e+1/3),this.g=Oo(a,r,e),this.b=Oo(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=ef[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,No=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,ko=new B,Fo=new B,Bo=new B,Ho=new wt,zo=new wt,Vo=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),No.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(No),c=ri.dot(ri),u=ri.dot(No),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return Ho.setScalar(0),zo.setScalar(0),Vo.setScalar(0),Ho.fromBufferAttribute(e,t),zo.fromBufferAttribute(e,i),Vo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Ho,r.x),a.addScaledVector(zo,r.y),a.addScaledVector(Vo,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),ko.subVectors(e,i);const l=bs.dot(ko),c=Ms.dot(ko);if(l<=0&&c<=0)return t.copy(i);Fo.subVectors(e,s);const u=bs.dot(Fo),d=Ms.dot(Fo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Bo.subVectors(e,r);const f=bs.dot(Bo),p=Ms.dot(Bo);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(or),Jr.subVectors(this.max,or),As.subVectors(e.a,or),Es.subVectors(e.b,or),Ts.subVectors(e.c,or),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Go(t,As,Es,Ts,Jr)||(t=[1,0,0,0,1,0,0,0,1],!Go(t,As,Es,Ts,Jr))?!1:(jr.crossVectors(Ei,Ti),t=[jr.x,jr.y,jr.z],Go(t,As,Es,Ts,Jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,$r=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,or=new B,Jr=new B,jr=new B,Xi=new B;function Go(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,Qr=new Ee;let $0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=dc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;lr.subVectors(e,this.center);const t=lr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(lr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Wo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(lr.copy(e.center).add(Wo)),this.expandByPoint(lr.copy(e.center).sub(Wo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let j0=0;const yn=new Et,Xo=new sn,Cs=new B,fn=new ki,cr=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:j0++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(D0(e)?nf:tf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Xo.lookAt(e),Xo.updateMatrix(),this.applyMatrix4(Xo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==El&&(i.blendSrc=this.blendSrc),this.blendDst!==Tl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class mc extends tr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const ur=new B,Rs=new B,Ds=new B,Ls=new Ee,hr=new Ee,sf=new Et,ea=new B,dr=new B,ta=new B,Uu=new Ee,Yo=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new mc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Q0(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new Qa(i,3,0,!1)),ws.setAttribute("uv",new Qa(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),sf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;na(ea.set(-.5,-.5,0),Ds,a,Rs,s,r),na(dr.set(.5,-.5,0),Ds,a,Rs,s,r),na(ta.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Yo.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ea,dr,ta,!1,ur);if(o===null&&(na(dr.set(-.5,.5,0),Ds,a,Rs,s,r),Yo.set(0,1),o=e.ray.intersectTriangle(ea,ta,dr,!1,ur),o===null))return;const l=e.ray.origin.distanceTo(ur);le.far||t.push({distance:l,point:ur.clone(),uv:Sn.getInterpolation(ur,ea,dr,ta,Uu,Yo,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function na(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(hr.x=r*Ls.x-s*Ls.y,hr.y=s*Ls.x+r*Ls.y):hr.copy(Ls),n.copy(e),n.x+=hr.x,n.y+=hr.y,n.applyMatrix4(sf)}const li=new B,Ko=new B,ia=new B,Ci=new B,qo=new B,sa=new B,Zo=new B;class zc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){Ko.copy(e).add(t).multiplyScalar(.5),ia.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(Ko);const r=e.distanceTo(t)*.5,a=-this.direction.dot(ia),o=Ci.dot(this.direction),l=-Ci.dot(ia),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Ko).addScaledVector(ia,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){qo.subVectors(t,e),sa.subVectors(i,e),Zo.crossVectors(qo,sa);let a=this.direction.dot(Zo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(sa.crossVectors(Ci,sa));if(l<0)return null;const c=o*this.direction.dot(qo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot(Zo);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends tr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Od,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new zc,ra=new xo,Fu=new B,aa=new B,oa=new B,la=new B,$o=new B,ca=new B,Bu=new B,ua=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=b,A=E;yt.far?null:{distance:c,point:ua.clone(),object:n}}function ha(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,aa),n.getVertexPosition(l,oa),n.getVertexPosition(c,la);const u=tm(n,e,t,i,aa,oa,la,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,aa,oa,la,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(aa,oa,la,h.normal),u.face=h,u.barycoord=d}return u}class rf extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Jo=new B,nm=new B,im=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=Jo.subVectors(i,t).cross(nm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(Jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||im.getNormalMatrix(e),s=this.coplanarPoint(Jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new xo,sm=new Ee(.5,.5),da=new B;class af{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],E=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,g-p,A-b).normalize(),s[1].setComponents(c+a,f+u,g+p,A+b).normalize(),s[2].setComponents(c+o,f+d,g+_,A+E).normalize(),s[3].setComponents(c-o,f-d,g-_,A-E).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,g-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,g-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,g+m,A+y).normalize();else if(t===$a)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=sm.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,da.y=s.normal.y>0?e.max.y:e.min.y,da.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(da)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends tr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const eo=new B,to=new B,Hu=new Et,fr=new zc,fa=new xo,jo=new B,zu=new B;let of=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;jo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(jo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ma extends of{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/M),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Vc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class pf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Rr(r,a,t,o,l,c,0),a}function mf(n,e,t,i,s){let r;if(s===Om(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Lr(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Lr(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Rr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Rm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Sm(n,i,s,r):vm(n)){e.push(l.i,n.i,c.i),Lr(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=bm(rs(n),e),Rr(n,e,t,i,s,r,2)):a===2&&Mm(n,e,t,i,s,r):Rr(rs(n),e,t,i,s,r,1);break}}}function vm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&vr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Sm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=gc(f,p,e,t,i),b=gc(_,m,e,t,i);let E=n.prevZ,y=n.nextZ;for(;E&&E.z>=g&&y&&y.z<=b;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&vr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0||(E=E.prevZ,y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&vr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;E&&E.z>=g;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&vr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&vr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function bm(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&_f(i,t,t.next,s)&&Dr(i,s)&&Dr(s,i)&&(e.push(i.i,t.i,s.i),Lr(t),Lr(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Mm(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Im(a,o)){let l=xf(a,o);a=rs(a,a.next),l=rs(l,l.next),Rr(a,e,t,i,s,r,0),Rr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Am(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&gf(sa.x||t.x===a.x&&wm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function wm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Rm(n,e,t,i){let s=n;do s.z===0&&(s.z=gc(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Dm(s)}function Dm(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function gc(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Lm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function vr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&gf(n,e,t,i,s,r,a,o)}function Im(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Pm(n,e)&&(Dr(n,e)&&Dr(e,n)&&Um(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function _f(n,e,t,i){const s=xa(At(n,e,t)),r=xa(At(n,e,i)),a=xa(At(t,i,n)),o=xa(At(t,i,e));return!!(s!==r&&a!==o||s===0&&_a(n,t,e)||r===0&&_a(n,i,e)||a===0&&_a(t,n,i)||o===0&&_a(t,e,i))}function _a(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function xa(n){return n>0?1:n<0?-1:0}function Pm(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&_f(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Dr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Um(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function xf(n,e){const t=_c(n.i,n.x,n.y),i=_c(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=_c(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Lr(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function _c(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Om(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Vm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Gm extends tr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=b0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Wm extends tr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Xm extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const ya=new B,va=new Hi,Hn=new B;class vf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ya,va,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ya,va,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(ya,va,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ya,va,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends vf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=pc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ha*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return pc*2*Math.atan(Math.tan(Ha*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ha*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Xc extends vf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class Ym extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===$a)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Km extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class qm extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Zm(i);switch(t){case qd:return n*e;case $d:return n*e/s.components*s.byteLength;case Oc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case Nc:return n*e*2/s.components*s.byteLength;case Zd:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case kc:return n*e*4/s.components*s.byteLength;case Na:case ka:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Fa:case Ba:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case kl:case Bl:return Math.max(n,16)*Math.max(e,8)/4;case Nl:case Fl:return Math.max(n,8)*Math.max(e,8)/2;case Hl:case zl:case Gl:case Wl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Vl:case Ya:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Zl:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case ec:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case sc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case ac:case oc:case lc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case cc:case uc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ka:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Zm(n){switch(n){case vn:case Wd:return{byteLength:1,components:1};case Cr:case Xd:case _i:return{byteLength:2,components:1};case Pc:case Uc:return{byteLength:2,components:4};case ei:case Ic:case Pn:return{byteLength:4,components:1};case Yd:case Kd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Lc}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Lc);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function Sf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function $m(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,fg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,pg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,_g=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,yg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,vg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Sg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,bg=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Mg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Ag=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Eg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Tg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Cg="gl_FragColor = linearToOutputTexel( gl_FragColor );",wg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Rg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Dg=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Lg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ug=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Og=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Ng=`#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`,kg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Fg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,Bg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Hg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,zg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Vg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Gg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Wg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Xg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Yg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Kg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qg=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Zg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,$g=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Jg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,jg=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,Qg=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,e_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,t_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,n_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,i_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,s_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,r_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,a_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,o_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,l_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,c_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,u_=`#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`,h_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,d_=`#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`,f_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,p_=`#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`,m_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,g_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,__=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,x_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,y_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,v_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,S_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,b_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,M_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,A_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,E_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,T_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,C_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,w_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,R_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,D_=`#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`,L_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,I_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,P_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,U_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,O_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,N_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,k_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,F_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,B_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,H_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,z_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,V_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,G_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,W_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,X_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Y_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,q_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,$_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const J_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,j_=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Q_=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,ex=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,ix=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,sx=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,rx=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,ax=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,ox=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,lx=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,cx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,ux=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,hx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,fx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,px=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,gx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,_x=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,xx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,yx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,vx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Sx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,bx=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Mx=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Ax=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Ex=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Tx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Cx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,wx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Rx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Dx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Jm,alphahash_pars_fragment:jm,alphamap_fragment:Qm,alphamap_pars_fragment:eg,alphatest_fragment:tg,alphatest_pars_fragment:ng,aomap_fragment:ig,aomap_pars_fragment:sg,batching_pars_vertex:rg,batching_vertex:ag,begin_vertex:og,beginnormal_vertex:lg,bsdfs:cg,iridescence_fragment:ug,bumpmap_pars_fragment:hg,clipping_planes_fragment:dg,clipping_planes_pars_fragment:fg,clipping_planes_pars_vertex:pg,clipping_planes_vertex:mg,color_fragment:gg,color_pars_fragment:_g,color_pars_vertex:xg,color_vertex:yg,common:vg,cube_uv_reflection_fragment:Sg,defaultnormal_vertex:bg,displacementmap_pars_vertex:Mg,displacementmap_vertex:Ag,emissivemap_fragment:Eg,emissivemap_pars_fragment:Tg,colorspace_fragment:Cg,colorspace_pars_fragment:wg,envmap_fragment:Rg,envmap_common_pars_fragment:Dg,envmap_pars_fragment:Lg,envmap_pars_vertex:Ig,envmap_physical_pars_fragment:Gg,envmap_vertex:Pg,fog_vertex:Ug,fog_pars_vertex:Og,fog_fragment:Ng,fog_pars_fragment:kg,gradientmap_pars_fragment:Fg,lightmap_pars_fragment:Bg,lights_lambert_fragment:Hg,lights_lambert_pars_fragment:zg,lights_pars_begin:Vg,lights_toon_fragment:Wg,lights_toon_pars_fragment:Xg,lights_phong_fragment:Yg,lights_phong_pars_fragment:Kg,lights_physical_fragment:qg,lights_physical_pars_fragment:Zg,lights_fragment_begin:$g,lights_fragment_maps:Jg,lights_fragment_end:jg,lightprobes_pars_fragment:Qg,logdepthbuf_fragment:e_,logdepthbuf_pars_fragment:t_,logdepthbuf_pars_vertex:n_,logdepthbuf_vertex:i_,map_fragment:s_,map_pars_fragment:r_,map_particle_fragment:a_,map_particle_pars_fragment:o_,metalnessmap_fragment:l_,metalnessmap_pars_fragment:c_,morphinstance_vertex:u_,morphcolor_vertex:h_,morphnormal_vertex:d_,morphtarget_pars_vertex:f_,morphtarget_vertex:p_,normal_fragment_begin:m_,normal_fragment_maps:g_,normal_pars_fragment:__,normal_pars_vertex:x_,normal_vertex:y_,normalmap_pars_fragment:v_,clearcoat_normal_fragment_begin:S_,clearcoat_normal_fragment_maps:b_,clearcoat_pars_fragment:M_,iridescence_pars_fragment:A_,opaque_fragment:E_,packing:T_,premultiplied_alpha_fragment:C_,project_vertex:w_,dithering_fragment:R_,dithering_pars_fragment:D_,roughnessmap_fragment:L_,roughnessmap_pars_fragment:I_,shadowmap_pars_fragment:P_,shadowmap_pars_vertex:U_,shadowmap_vertex:O_,shadowmask_pars_fragment:N_,skinbase_vertex:k_,skinning_pars_vertex:F_,skinning_vertex:B_,skinnormal_vertex:H_,specularmap_fragment:z_,specularmap_pars_fragment:V_,tonemapping_fragment:G_,tonemapping_pars_fragment:W_,transmission_fragment:X_,transmission_pars_fragment:Y_,uv_pars_fragment:K_,uv_pars_vertex:q_,uv_vertex:Z_,worldpos_vertex:$_,background_vert:J_,background_frag:j_,backgroundCube_vert:Q_,backgroundCube_frag:ex,cube_vert:tx,cube_frag:nx,depth_vert:ix,depth_frag:sx,distance_vert:rx,distance_frag:ax,equirect_vert:ox,equirect_frag:lx,linedashed_vert:cx,linedashed_frag:ux,meshbasic_vert:hx,meshbasic_frag:dx,meshlambert_vert:fx,meshlambert_frag:px,meshmatcap_vert:mx,meshmatcap_frag:gx,meshnormal_vert:_x,meshnormal_frag:xx,meshphong_vert:yx,meshphong_frag:vx,meshphysical_vert:Sx,meshphysical_frag:bx,meshtoon_vert:Mx,meshtoon_frag:Ax,points_vert:Ex,points_frag:Tx,shadow_vert:Cx,shadow_frag:wx,sprite_vert:Rx,sprite_frag:Dx},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const Sa={r:0,b:0,g:0},Lx=new Et,bf=new qe;bf.set(-1,0,0,0,1,0,0,0,1);function Ix(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const y=b.backgroundBlurriness>0;E=e.get(E,y)}return E}function p(b){let E=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),E=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,E){const y=f(E);y&&(y.isCubeTexture||y.mapping===_o)?(c===void 0&&(c=new Vt(new Nr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Lx.makeRotationFromEuler(E.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(bf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(Sa,yf(n)),t.buffers.color.setClear(Sa.r,Sa.g,Sa.b,E,r)}function g(){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 a},setClearColor:function(b,E=1){a.set(b),o=E,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Px(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function _(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Ic;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Nx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,E=b*4;let y=g.clippingState||null;l.value=y,y=u(p,h,E,f);for(let A=0;A!==E;++A)y[A]=t[A];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,pr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,pr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,pr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const g=[];let b=0;for(let M=0;ME-Oi?s-E+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,pr)}}function Bx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),E=new Float32Array(m*p*f),y=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,v,0,M+2/3,v,0,M+2/3,v+1,0,M,v,0,M+2/3,v+1,0,M,v+1,0];b.set(T,_*p*S),E.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,g*p*S)}const A=new Ct;A.setAttribute("position",new Un(b,_)),A.setAttribute("uv",new Un(E,m)),A.setAttribute("faceIndex",new Un(y,g)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=_o,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Hx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:kx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:yo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function zx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:yo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function yo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Mf extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new lf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Nr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new Ym(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Vx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===Eo||f===To)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Mf(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===Eo||f===To,_=f===ns||f===Ys;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===Eo?h.mapping=ns:f===To&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?nf:tf)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const M=new Float32Array(A*S*4*d),v=new jd(M,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Xc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(E,y){a.setSize(E,y),o.setSize(E,y);for(let A=0;A0&&g[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const z1=37297;let V1=0;function G1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function W1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case Za:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+G1(n.getShaderSource(e),o)}else return r}function X1(n,e){const t=W1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const Y1={[Nd]:"Linear",[kd]:"Reinhard",[Fd]:"Cineon",[Bd]:"ACESFilmic",[zd]:"AgX",[Vd]:"Neutral",[Hd]:"Custom"};function K1(n,e){const t=Y1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ba=new B;function q1(){it.getLuminanceCoefficients(ba);const n=ba.x.toFixed(4),e=ba.y.toFixed(4),t=ba.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Z1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(Sr).join(` +`)}function $1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function J1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function yc(n){return n.replace(j1,ey)}const Q1=new Map;function ey(n,e){let t=$e[e];if(t===void 0){const i=Q1.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return yc(t)}const ty=/#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 Sh(n){return n.replace(ty,ny)}function ny(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(Sr).join(` +`),g.length>0&&(g+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(Sr).join(` +`),g=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?K1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,X1("linearToOutputTexel",t.outputColorSpace),q1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(Sr).join(` +`)),a=yc(a),a=yh(a,t),a=vh(a,t),o=yc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===fc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===fc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);const E=b+m+a,y=b+g+o,A=gh(s,s.VERTEX_SHADER,E),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(_,A),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,A,S);else{const ae=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:g}})}s.deleteShader(A),s.deleteShader(S),v=new za(s,_),T=J1(s,_)}let v;this.getUniforms=function(){return v===void 0&&M(this),v};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,z1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=V1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=A,this.fragmentShader=S,this}let fy=0;class py{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new my(e),t.set(e,i)),i}}class my{constructor(e){this.id=fy++,this.code=e,this.usedTimes=0}}function gy(n){return n===is||n===Ya||n===Ka}function _y(n,e,t,i,s,r){const a=new Qd,o=new py,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===_o?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===M0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&gy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(g(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function g(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function E(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=Bm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new dy(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:M}}function xy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function yy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||yy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function Sy(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function by(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let My=0;function Ay(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Ey(n){const e=new Sy,t=by(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,E=0,y=0,A=0,S=0,M=0;c.sort(Ay);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==_||v.rectAreaLength!==m||v.hemiLength!==g||v.numDirectionalShadows!==b||v.numPointShadows!==E||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,v.directionalLength=f,v.pointLength=p,v.spotLength=_,v.rectAreaLength=m,v.hemiLength=g,v.numDirectionalShadows=b,v.numPointShadows=E,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=M,i.version=My++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Cy=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,wy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ry=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Dy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,mr=new B,ol=new B;function Ly(n,e,t){let i=new af;const s=new Ee,r=new Ee,a=new wt,o=new Gm,l=new Wm,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Cy,fragmentShader:wy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oa;let g=this.type;this.render=function(S,M,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===e0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Oa);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=g!==this.type;U&&M.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===xr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Mf(s.x),N.map.depthTexture=new rm(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Oa?(N.map.depthTexture.compareFunction=D?Bc:Fc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,U=M.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,M.addEventListener("dispose",A)),I=P}if(I.visible=M.visible,I.wireframe=M.wireframe,T===xr?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,M,v,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===xr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,x){return p?new OffscreenCanvas(R,x):Ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=_(fe,W));const F=x?_(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function E(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?Za:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===wr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===Cr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===wr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===Cr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function M(R){const x=R.target;x.removeEventListener("dispose",M),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ul]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Ol]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[S0]:n.NEAREST_MIPMAP_NEAREST,[Yr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[Co]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[A0]:n.NEVER,[R0]:n.ALWAYS,[E0]:n.LESS,[Fc]:n.LEQUAL,[T0]:n.EQUAL,[Bc]:n.GEQUAL,[C0]:n.GREATER,[w0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===Co||x.magFilter===Yr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===Co||x.minFilter===Yr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Yr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",M));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==qa&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Uy(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Pc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Uc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Yd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Kd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Wd)return n.BYTE;if(i===Xd)return n.SHORT;if(i===Cr)return n.UNSIGNED_SHORT;if(i===Ic)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===qd)return n.ALPHA;if(i===Zd)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===$d)return n.RED;if(i===Oc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===Nc)return n.RG_INTEGER;if(i===kc)return n.RGBA_INTEGER;if(i===Na||i===ka||i===Fa||i===Ba)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Na)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ka)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Na)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ka)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Nl||i===kl||i===Fl||i===Bl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Nl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===kl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Hl||i===zl||i===Vl||i===Gl||i===Wl||i===Ya||i===Xl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Hl||i===zl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Vl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Gl)return r.COMPRESSED_R11_EAC;if(i===Wl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ya)return r.COMPRESSED_RG11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Yl||i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Yl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ac||i===oc||i===lc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===ac)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===oc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===cc||i===uc||i===Ka||i===hc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===cc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===uc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ka)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===wr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Oy=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Ny=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class ky{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new cf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:Oy,fragmentShader:Ny,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new ky,g={},b=t.getContextAttributes();let E=null,y=null;const A=[],S=[],M=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Km;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Uo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Uo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Uo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),E=b.envMap,y=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(By.makeRotationFromEuler(y)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(wf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,E){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=E*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function zy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const M=A.program;i.updateUBOMapping(y,M);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),M=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=M-v),y.__size=S,y.__cache={},this}function g(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function b(y){const A=y.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function E(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:E}}const Vy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Gy(){return zn===null&&(zn=new rf(Vy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Wy{constructor(e={}){const{canvas:t=L0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([kc,Nc,Oc]),g=new Set([vn,ei,Cr,wr,Pc,Uc]),b=new Uint32Array(4),E=new Int32Array(4),y=new B;let A=null,S=null;const M=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new af;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Lc}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Gx(V),se.init(),ve=new Uy(V,se),R=new Ox(V,se,e,ve),x=new Iy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new Yx(V),H=new xy,$=new Py(V,se,x,H,R,ve,G),fe=new Vx(I),W=new $m(V),Me=new Px(V,W),F=new Wx(V,W,G,Me),Y=new qx(V,F,W,Me,G),k=new Kx(V,R,$),ge=new Nx(H),re=new _y(I,fe,se,R,Me,ge),ce=new Hy(I,H),he=new vy,ee=new Ty(se),Ge=new Ix(I,fe,x,Y,p,l),we=new Ly(I,Y,R),pe=new zy(V,G,R,x),ye=new Ux(V,se,G),ue=new Xx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),_!==vn&&(T=new $x(_,t.width,t.height,o,s,r));const Ne=new Fy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Xr(C){hs&&hs(C)}function ni(){_n.stop()}function sr(){_n.start()}const _n=new Sf;_n.setAnimationLoop(Xr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",sr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,M.length),A.init(),M.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),rr(A,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?A=M[M.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=za.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Gy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}za.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(za.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await I0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ma.origin.copy(this.object.position),Ma.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ma.direction))ll||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ll||this._lastTargetPosition.distanceToSquared(this.target)>ll?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=ov[e%10];return rv(Math.floor(e/10)*15,t,i)}return 13226457}function Kc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Df(n){return Kc(n.ownerHandle)}function lv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function cv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Df(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=lv(o.name??"");if(!l)continue;const c=Kc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:cv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function uv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function cl(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function vc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function mv(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return Lf;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,qc}function kf(n,e){var t=new hv(n,e),i,s,r;do{switch(i=pv(t),s=Yn(t,2,0),s){case 0:r=gv(t);break;case 1:r=Lh(t,If,Pf);break;case 2:mv(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=Lf}if(r!==qc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const E=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Bf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=Hf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Ff){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Ff;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=Hf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>vv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var no={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=no[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function Sc(n){return n>=-128&&n<=127}function bv(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Mv(n,e,t):e=Av(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const v=i.get(s);v.path,M=v.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,y=this.parsePackedDeltas(M),t==="gvar"&&(A=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return y===void 0&&S(),E==="deltasY"?A:y},set:function(M){y===void 0&&S(),E==="deltasY"?A=M:y=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Hv(t,u,a,o);else if(t.format===12||t.format===13)zv(t,u,t.format);else if(t.format===4)Vv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Gv(t,i),t}function Xv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Yv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Kv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function jf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function eu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=jf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function rS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=aS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=jf(n)}else typeof n!="object"&&(n=ho(n,"bgra"));let t=["hsl","hsla"].includes(e)?rS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return Qf(n);default:throw new Error("Unknown color format: "+e)}}var ep={parse:iS,make:sS,getPaletteColor:eu,parseColor:ho,formatColor:er};function oS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",oS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function So(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});So.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function fS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function pS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return fS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function mS(n){const e={};for(let t=0;t1&&l===23){ES(a);continue}r.push([l,a]),a=[]}else a.push(pS(s,l))}return mS(r)}function Er(n,e){return e<=390?e=Va[e]:n?e=n[e-391]:e=void 0,e}function nu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var np=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],_S=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],ip=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],xS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],yS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function vS(n,e,t,i){const s=tu(n,e,n.byteLength,i);return nu(s,i>1?_S:np,t)}function iu(n,e,t,i,s){const r=tu(n,e,t,s);return nu(r,s>1?xS:ip,i)}function SS(n,e,t){const i=tu(n,e,void 0,t);return nu(i,yS)}function bS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function sp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Ec(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,E,y=0,A=[],S,M=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,E=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Ec(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,g=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,E=P._nominalWidthX)}else m=v.topDict._subrs,g=v.topDict._subrsBias;const T=sp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+E),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(D=u.pop()+g,ae=m[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,U(ae),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=_,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-_)?p=le+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ac[u.pop()],Xe=Ac[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+E,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+E,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,U(ae),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=fo(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=hl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=hl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),_=bS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),_=hl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=iu(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Xn(n,p);t.subrs=_.objects,t.subrsBias=fo(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=hS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Zv:u.charset===1?h=$v:u.charset===2?h=Jv:h=MS(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ac:u.encoding===1?f=jv:f=AS(n,e+u.encoding),t.cffEncoding=new Jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=dS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Ec,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Va.length:(t=Va.length+e.length,e.push(n)),t}function CS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function wS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function $S(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var wc={parse:ZS,make:$S,unicodeRanges:Cc,getUnicodeRange:qS};function JS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var mp={parse:ib,make:sb};function rb(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function ab(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=uo(t,r),i}function ob(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Rb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Rb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=op.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=lp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=hp.make(n.glyphs.length),E=wc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=cp.make(n.glyphs),A=qf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),v=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=Kf.make(I,O),Z=O.length>0?up.make(O):void 0,N=dp.make(n),X=Tc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?pp.make(n.metas):void 0,ae=[m,g,b,E,P,A,N,X,y];Z&&ae.push(Z);const ie={gsub:fp,cpal:ep,colr:mp,stat:_p,avar:xp,cvar:yp,fvar:gp,gvar:vp,gasp:Sp,svg:bp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Mp(ae),de=_e.encode(),le=su(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ap(n,e){this.font=n,this.tableName=e}Ap.prototype={searchTag:dl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=dl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function Ob(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Nb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Ep(n){return n[0]===31&&n[1]===139&&n[2]===8}function kb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return kf(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Fb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){bo.call(this,n,"gsub")}function ru(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=ru(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=ru(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dho(e,"raw")):ho(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return eu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=Ob(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Nb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Vb(n){return{template:Wb(n).then(Kb),images:new Map}}function Gb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=qb(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Wb=typeof DecompressionStream=="function"?Yb:Xb;function Xb(n){try{return Promise.resolve(new TextDecoder().decode(Ep(n)?kb(n):n))}catch(e){return Promise.reject(e)}}function Yb(n){if(Ep(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Kb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function qb(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var fl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function Cp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Ga([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Ga(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return au(e.points)}function $b(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Ga(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,po=64,mo=1e4,Dp,as,Lp,Rc;function Ip(n){this.font=n,this.getCommands=function(e){return Rp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function t2(n){return n}function Pp(n){return Math.sign(n)*Math.round(Math.abs(n))}function n2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function i2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function s2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function r2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Up=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Hr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Hr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Hr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Hr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Hr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function zr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Hr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Ur=Object.freeze(new gi(0,0)),a2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Pp}}Ip.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=a2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Lp(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Lp=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Rc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Dp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Mo(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=zr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=zr(o,l)}function o2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=zr(i,t)}function l2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=zr(i,t)}function c2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function u2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function h2(n){n.fv=n.pv}function d2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,E=d.y,y=h.x,A=h.y,S=(p-m)*(E-A)-(_-g)*(b-y),M=p*g-_*m,v=b*A-E*y;f.x=(M*(b-y)-v*(p-m))/S,f.y=(M*(E-A)-v*(_-g))/S}function f2(n){n.rp0=n.stack.pop()}function p2(n){n.rp1=n.stack.pop()}function m2(n){n.rp2=n.stack.pop()}function g2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Mo(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function _2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Mo(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function x2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Mo(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Mo(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){n.loop=n.stack.pop(),n.loop>mo&&(n.loop=mo)}function S2(n){n.round=Pp}function b2(n){n.round=i2}function M2(n){const e=n.stack.pop();n.minDis=e/64}function A2(n){Op(n,!1)}function E2(n){const e=n.stack.pop();n.ip+=e-1}function T2(n){const e=n.stack.pop();n.cvCutIn=e/64}function C2(n){const e=n.stack;e.push(e[e.length-1])}function pl(n){n.stack.pop()}function w2(n){n.stack.length=0}function R2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function D2(n){const e=n.stack;e.push(e.length)}function L2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>mo&&(i=mo),++n.callDepth>po)throw new Error("Hinting call depth exceeded maximum of "+po);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;apo)throw new Error("Hinting call depth exceeded maximum of "+po);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function P2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function U2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function O2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Ur);n&&(a=e.round(a)),s.setRelative(i,Ur,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function J2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function j2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function eM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function tM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function nM(n){n.stack.pop()||Op(n,!0)}function iM(n){}function sM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function rM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function aM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function ml(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function oM(n){const t=n.stack.pop();n.deltaBase=t}function lM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function cM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function uM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function fM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function pM(n){const e=n.stack;let t=e.pop();e.push(-t)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function gM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Ra(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function _M(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function gl(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function xM(n){let e=n.stack.pop();n.round=Up;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function yM(n){let e=n.stack.pop();n.round=Up;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function vM(n){n.round=t2}function SM(n){n.round=s2}function bM(n){n.round=r2}function MM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=zr(o,l)}function AM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function EM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function TM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function CM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function wM(n){n.stack.pop()}function RM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof ir);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof ir){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof ir)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Ao.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Ao.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof ou)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Ao)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function OM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function NM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function _l(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>OM.apply(this,[i,e]);case"12":return i=>NM.apply(this,[i,e]);case"63":return i=>kM.apply(this,[i,e]);case"41":return i=>FM.apply(this,[i,e]);case"21":return i=>zM.apply(this,[i,e]);case"51":return i=>BM.apply(this,[i,e]);case"53":return i=>HM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var VM=gn;function GM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function WM(n){const e=n.get(1);return e===null||!Fi(e)}var XM={startCheck:GM,endCheck:WM};function YM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function KM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=UM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var qM={startCheck:YM,endCheck:KM};function ZM(n,e,t){e[t].setState(n.tag,n.substitution)}function $M(n,e,t){e[t].setState(n.tag,n.substitution)}function xl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=Np(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function e3(n){if(Np(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function i3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function a3(n){return n.index===n.context.length-1}var o3={startCheck:r3,endCheck:a3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function l3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function f3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function x3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function A3(n){const e=n.current,t=n.get(1);return t===null&&Dc(e)||Dc(t)}function E3(n){const e=n.get(1);return e===null||!Dc(e)}var T3={startCheck:A3,endCheck:E3};function C3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var w3=C3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new PM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:o3,latinWordCheck:d3,arabicWordCheck:XM,arabicSentenceCheck:qM,thaiWordCheck:_3,unicodeVariationSequenceCheck:T3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function R3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function D3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new VM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=yl(n),this.names.macintosh=yl(n),this.names.windows=yl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new Zf(this),this.position=new Ib(this),this.substitution=new Bb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new e2(this)),!0)}),this.palettes=new Tp(this),this.layers=new Hb(this),this.svgImages=new zb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new DM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new k3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Lb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(Y3)),s}var q3={parse:K3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Z3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var $3=new Array(10);function J3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,$3)}])}var j3={parse:Z3,make:J3};function Q3(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Tr(aA(t))})(),this._shared.catch(()=>{Tr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=La((O-h)/m),D=La((P-h)/m);for(let oe=X;oe<=D;oe++)g[oe].push(U);const ae=La((Z-d)/_),ie=La((N-d)/_);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const E=w=>Math.ceil(w.length/4),y=g.reduce((w,U)=>w+E(U),0)+b.reduce((w,U)=>w+E(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),M=this.data,v=(w,U,O,P,Z)=>{M[w*4]=U,M[w*4+1]=O,M[w*4+2]=P,M[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class uA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i/l.capHeightEm,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let E=0;E=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-Da,Z=w-Da,N=U+Da,X=O+Da,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=M+ie*u;this.pos.push(t.x+oe*p-_e*_,t.y+oe*_+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:fc,vertexShader:lA,fragmentShader:cA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const hA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,dA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function fA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const E=g.substring(0,b).trim().toLowerCase(),y=g.substring(b+1).trim(),A=parseFloat(y);isNaN(A)||(E==="s"?c=A:E==="r"?u=A:E==="a"?(u=A,d=!0):E==="u"?(u=A,h=!0):E==="x"?f=A:E==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function pA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=pA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=fA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Fp=new Map;function Bp(n){const e=mA(n);for(const[t,i]of e.entries())Fp.set(t,i)}Bp(hA);Bp(dA);const gA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},_A=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function xA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Fp.get(e);if(!t)return;let i=t.elements;_A.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=gA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const vl=13226457,Sd=64,Sl=72,yA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class vA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Or.shared().catch(()=>{}),this._scene=new Z0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Xc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Wy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new Yy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new yr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,E,y,A,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((y=(E=this._controls)==null?void 0:E.target)==null?void 0:y.x)??s.position.x,g=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const _=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?cl(i,this._activeSpaceHex):null,g=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(g.has(R)||g.set(R,[]),g.get(R).push(se))}const b=[];let E=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),E++,!(E&7)&&b.length<1e5&&b.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,M=Hs(e),v=M.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=M.find(R=>R.kind==="model");if(se){const R=cl(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{A($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(_&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,A,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const W=(g.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,A,y):(this._polylineSegs(F,re,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(A(W.x-1,W.y,W.x+1,W.y,W.z||0,H),A(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?A(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):A(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=g.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:g,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,A,y):(this._polylineSegs(re.points,!0,0,H,A),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=g.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?g.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,A),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),rr=ds.createImageData(An,ni),En=rr.data;if(Xr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ma(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ma(R,new Xm({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ma(_,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var E,y,A,S,M,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},g=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(E=N.ownerHandle)==null?void 0:E.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(_.size){const de=(M=N.layerHandle)==null?void 0:M.value;if(de!=null&&_.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>g(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,g):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>g(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>g(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,g):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),g(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?cl(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Aa(h)??vl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=xA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),E=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,M=u>0?1:-1,v=E+M*A*b,T=y+M*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+_*w/L;r.push({x:v+g*Math.cos(U),y:T+g*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=Sl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),E=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:E,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var m;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let g=0;g{let b=Math.max(0,Math.min(g,u));for(let A=0;A1e-9?b/S:0,v=l[A],T=l[A+1],I=v.x+(T.x-v.x)*M,L=v.y+(T.y-v.y)*M,w=(v.z||0)+((T.z||0)-(v.z||0))*M,U=Math.atan2(T.y-v.y,T.x-v.x);return{x:I,y:L,z:w,angle:U}}b-=S}const E=l[l.length-1],y=l[l.length-2];return{x:E.x,y:E.y,z:E.z||0,angle:Math.atan2(E.y-y.y,E.x-y.x)}};if(i.patternLength*s<1e-6)return;let f=0,p=0;const _=i.elements;for(;fE){const A=d(E),S=d(y);a(A.x,A.y,S.x,S.y,A.z,r)}f+=b}else if(g.type==="gap"){const b=Math.abs(g.val||.1)*s;f+=b}else if(g.type==="shape"){const b=d(f);this._renderShapeSymbol(g,b,s,r,a)}else if(g.type==="text"){const b=d(f);if(g.text&&o){const E=(g.style||"STANDARD").toUpperCase(),y=((m=this._textStyleHeightMap)==null?void 0:m.get(E))||0,S=(y>0?y:g.scale||.2)*s;let M=b.angle+(g.rotation||0)*Math.PI/180;g.isAbsoluteAngle&&(M=(g.rotation||0)*Math.PI/180);let v=Math.atan2(Math.sin(M),Math.cos(M));v>Math.PI/2?v-=Math.PI:v<-Math.PI/2&&(v+=Math.PI),M=v;const T=Math.cos(M),I=Math.sin(M),L=(g.xOffset||0)*s,w=(g.yOffset||0)*s;let U=0;const O=_[p%_.length];O&&O.type==="gap"&&(U=Math.abs(O.val||0)*s/2);const P=U>1e-6?d(f+U):b,Z=P.x+(L*T-w*I),N=P.y+(L*I+w*T);o.push({text:g.text,pos:{x:Z,y:N,z:P.z},height:Math.max(S,.01),rotation:M,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(E,y)=>({x:f+(E*m-y*g)*o,y:p+(E*g+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const v=M/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const y=b(.5,0),A=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,y.x,y.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,M.x,M.y,_,s),y=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const E=b(-.3,-.3),y=b(.3,-.3),A=b(.3,.3),S=b(-.3,.3);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else if(a.includes("TRACK1")){const E=b(0,-.4),y=b(0,.4);r(E.x,E.y,y.x,y.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const E=b(0,.4),y=b(.4,0),A=b(0,-.4),S=b(-.4,0);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else{const E=b(.3,0),y=b(-.3,.2),A=b(-.3,-.2);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,E.x,E.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Aa(a)??vl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Aa(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return vl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=Sl;m++){const g=o+p*m/Sl,b=d*Math.cos(g),E=h*Math.sin(g),y=r.x+b*Math.cos(f)-E*Math.sin(f),A=r.y+b*Math.sin(f)+E*Math.cos(f);_&&i(_.x,_.y,y,A,r.z||0,t),_={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(g-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*E,I=A+v*M*E,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+A*E*m,M=b+A*y*m,v=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new pf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=g(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const U of E)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=y.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const v=new ga(_);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),_=Math.max(_,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,E=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${E},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let E=0,y=0;g===0||g===3||g===5?E=h/2:g===2&&(E=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),M=Math.sin(A),v=e.pos.x+E*S-y*M,T=e.pos.y+E*M+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Aa(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(_,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=_/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*M,y:T+N*M+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Or.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new uA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new ga(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let E=0;a===0||a===3||a===5?E=m/2:a===1||a===4?E=0:a===2&&(E=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*g:o===3&&(y=(p-b)*g));const A=new mc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,_,1),S.position.set(t.x+E,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),E=Math.sin(g),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*_*b-ie*m*E,f.y+ae*_*E+ie*m*b]},A=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+M:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+M;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:M,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+M;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+M)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},E=(S,M,v,T,I)=>{this._arcSegs({x:S,y:M},v,T,I,0,s,r)},y=(S,M,v)=>this._arrowMesh(S,M,v,s),A=(S,M,v,T)=>{M&&S&&a.push({text:M,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,M=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:v,y:T}),b(c,{x:S,y:M}),b(u,{x:v,y:T}),y({x:S,y:M,z:0},Math.atan2(M-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-M,v-S),I),A(h??{x:(S+v)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),A(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,v=Math.hypot(c.x-S,c.y-M);if(v<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),E(S,M,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:M+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:M+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:M+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=yA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ma(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new of(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new ki(new B(d-_,f-m,0),new B(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const SA="modulepreload",bA=function(n){return"/"+n},bd={},MA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=bA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":SA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,AA=["cp949","windows-949","euc-kr"];let _r;function EA(){if(_r!==void 0)return _r;for(const n of AA)try{return _r=new TextDecoder(n),_r}catch{}return _r=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=EA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function TA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),TA(t(n))}class CA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?wA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function wA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const Hp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function RA(n){return Hp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=RA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class DA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=LA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function LA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class IA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class PA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class UA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return y??E??b},g.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(g)},g.setDefaultLevel=function(L){E=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){y=null,v(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(y=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(zp);var jA=zp.exports;const nt=JA(jA);nt.setLevel("error");function QA(n){n.registerEntityHandler(DA),n.registerEntityHandler(IA),n.registerEntityHandler(PA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(zA),n.registerEntityHandler(VA),n.registerEntityHandler(WA),n.registerEntityHandler(KA),n.registerEntityHandler(qA),n.registerEntityHandler(ZA)}class eE{constructor(){this._entityHandlers={},QA(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new CA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Vp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=E(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=M);break}else o.code===9?(S&&(v[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),A(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=E(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?v[M.tableRecordsProperty]=M.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=y(o),o=r.next();break;case 11:M.upperRightCorner=y(o),o=r.next();break;case 12:M.center=y(o),o=r.next();break;case 13:M.snapBasePoint=y(o),o=r.next();break;case 14:M.snapSpacing=y(o),o=r.next();break;case 15:M.gridSpacing=y(o),o=r.next();break;case 16:M.viewDirectionFromTarget=y(o),o=r.next();break;case 17:M.viewTarget=y(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 111:M.ucsXAxis=y(o),o=r.next();break;case 112:M.ucsYAxis=y(o),o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,v=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=tE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=M,nt.debug("Layer {"),M={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function E(S){const M=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),M}function y(S){const M={};let v=S.code;if(M.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return M.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),M):(M.z=S.value,M)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Vp(n))}function Vp(n){return n.code+":"+n.value}function tE(n){return Hp[n]}const Ia=Math.PI/180,nE=48;function iE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*nE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class sE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Ia,s=e.next()),s.code===51&&(c=s.value*Ia,s=e.next()),s.code===73&&(u=s.value,s=e.next()),iE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Ia,s=e.next()),s.code===51&&(d=s.value*Ia,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const E=u+m*b/g,y=f*Math.cos(E),A=p*Math.sin(E);t.points.push({x:r+y*Math.cos(_)-A*Math.sin(_),y:a+y*Math.sin(_)+A*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Pa,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Pa),y:Math.sin(n.rotation*Pa)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Pa;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function rE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=wd(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function aE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return oE(aE(n))}function oE(n){const e=new eE;e.registerEntityHandler(sE);const t=e.parseSync(n);return rE(t)}const Gp=/\.dwg$/i,Wp=/\.dxf$/i;function lE(n){return Gp.test(n)}function cE(n){return Wp.test(n)}function uE(n){return Gp.test(n)||Wp.test(n)}oA("/fonts/NanumGothic-Regular.ttf");const hE=document.getElementById("app"),Dd=document.getElementById("status"),bl=document.getElementById("layerList"),Ld=document.getElementById("layers"),Ua=document.getElementById("spaces");function os(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new vA(hE);nn.onSelect(n=>{var t;if(!n){os("deselected");return}const e=n;os(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Xp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Ua.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Ua.style.display="none";return}Ua.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Xp(),qp(),nn.fit(),os(`space ${i.label} · ${i.entityCount} entities`))}),Ua.append(s)}}async function dE(n,e){return cE(e)?Rd(n):lE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Yp(n,e){const t=await dE(n,e),i=Hs(t),s=uv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function lu(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Yp(await i.arrayBuffer(),t)}async function Kp(n){if(!uE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Yp(await n.arrayBuffer(),n.name)}function qp(){bl.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;bl.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),bl.append(e)}}async function fE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";os(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Xp(),qp(),nn.fit()}async function Gr(n,e){os(`loading ${n}…`);try{await fE(n,await e())}catch(t){os(`${n}: ${t.message}`,!0),console.error(t)}}document.getElementById("sample").addEventListener("click",()=>{Gr("BasicSample.dwg",()=>lu("/samples/BasicSample.dwg","BasicSample.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{Gr("simple.dxf",()=>lu("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(Gr(e.name,()=>Kp(e)),n.target.value="")});let Ml=!0;document.getElementById("theme").addEventListener("click",()=>{Ml=!Ml,nn.setTheme(Ml)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&Gr(e.name,()=>Kp(e))});const Al=new URLSearchParams(location.search).get("model");Al?Gr(Al,()=>lu(Al)):os("ready · Sample DWG / DXF 또는 파일 드롭");window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-Csdc1y5g.js b/dist2/assets/index-Csdc1y5g.js new file mode 100644 index 0000000..3ab751b --- /dev/null +++ b/dist2/assets/index-Csdc1y5g.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),E=Math.sin(b);g=Math.sin(g*b)/E,o=Math.sin(o*b)/E,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],E=s[4],y=s[7],A=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*A,r[3]=a*m+o*E+l*S,r[6]=a*g+o*y+l*M,r[1]=c*_+u*b+d*A,r[4]=c*m+u*E+d*S,r[7]=c*g+u*y+d*M,r[2]=h*_+f*b+p*A,r[5]=h*m+f*E+p*S,r[8]=h*g+f*y+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,y=(f+1)/2,A=(g+1)/2,S=(u+h)/4,M=(d+_)/4,v=(p+m)/4;return E>y&&E>A?E<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(E),s=S/i,r=M/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=M/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=b,A=E;yt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],E=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,g-p,A-b).normalize(),s[1].setComponents(c+a,f+u,g+p,A+b).normalize(),s[2].setComponents(c+o,f+d,g+_,A+E).normalize(),s[3].setComponents(c-o,f-d,g-_,A-E).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,g-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,g-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,g+m,A+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/M),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=_c(f,p,e,t,i),b=_c(_,m,e,t,i);let E=n.prevZ,y=n.nextZ;for(;E&&E.z>=g&&y&&y.z<=b;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0||(E=E.prevZ,y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;E&&E.z>=g;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const y=b.backgroundBlurriness>0;E=e.get(E,y)}return E}function p(b){let E=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),E=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,E){const y=f(E);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(E.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,E,r)}function g(){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 a},setClearColor:function(b,E=1){a.set(b),o=E,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function _(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Pc;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,E=b*4;let y=g.clippingState||null;l.value=y,y=u(p,h,E,f);for(let A=0;A!==E;++A)y[A]=t[A];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const g=[];let b=0;for(let M=0;ME-Oi?s-E+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),E=new Float32Array(m*p*f),y=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,v,0,M+2/3,v,0,M+2/3,v+1,0,M,v,0,M+2/3,v+1,0,M,v+1,0];b.set(T,_*p*S),E.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,g*p*S)}const A=new Ct;A.setAttribute("position",new Un(b,_)),A.setAttribute("uv",new Un(E,m)),A.setAttribute("faceIndex",new Un(y,g)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Af(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,_=f===ns||f===Ys;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?sf:nf)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const M=new Float32Array(A*S*4*d),v=new Qd(M,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(E,y){a.setSize(E,y),o.setSize(E,y);for(let A=0;A0&&g[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),g.length>0&&(g+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),g=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);const E=b+m+a,y=b+g+o,A=gh(s,s.VERTEX_SHADER,E),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(_,A),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,A,S);else{const ae=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:g}})}s.deleteShader(A),s.deleteShader(S),v=new Va(s,_),T=Q1(s,_)}let v;this.getUniforms=function(){return v===void 0&&M(this),v};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=A,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===xo?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(g(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function g(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function E(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:M}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,E=0,y=0,A=0,S=0,M=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==_||v.rectAreaLength!==m||v.hemiLength!==g||v.numDirectionalShadows!==b||v.numPointShadows!==E||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,v.directionalLength=f,v.pointLength=p,v.spotLength=_,v.rectAreaLength=m,v.hemiLength=g,v.numDirectionalShadows=b,v.numPointShadows=E,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=M,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let g=this.type;this.render=function(S,M,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=g!==this.type;U&&M.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,U=M.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,M.addEventListener("dispose",A)),I=P}if(I.visible=M.visible,I.wireframe=M.wireframe,T===yr?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,M,v,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=_(fe,W));const F=x?_(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function E(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function M(R){const x=R.target;x.removeEventListener("dispose",M),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",M));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new By,g={},b=t.getContextAttributes();let E=null,y=null;const A=[],S=[],M=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),E=b.envMap,y=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,E){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=E*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const M=A.program;i.updateUBOMapping(y,M);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),M=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=M-v),y.__size=S,y.__cache={},this}function g(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function b(y){const A=y.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function E(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:E}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([Fc,kc,Nc]),g=new Set([vn,ei,wr,Rr,Uc,Oc]),b=new Uint32Array(4),E=new Int32Array(4),y=new B;let A=null,S=null;const M=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),W=new jm(V),Me=new Ox(V,W),F=new Yx(V,W,G,Me),Y=new $x(V,F,W,Me,G),k=new Zx(V,R,$),ge=new Fx(H),re=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),_!==vn&&(T=new jx(_,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,M.length),A.init(),M.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(A,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?A=M[M.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const E=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const v=i.get(s);v.path,M=v.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,y=this.parsePackedDeltas(M),t==="gvar"&&(A=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return y===void 0&&S(),E==="deltasY"?A:y},set:function(M){y===void 0&&S(),E==="deltasY"?A=M:y=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,E,y=0,A=[],S,M=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,E=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,g=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,E=P._nominalWidthX)}else m=v.topDict._subrs,g=v.topDict._subrsBias;const T=rp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+E),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(D=u.pop()+g,ae=m[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,U(ae),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=_,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-_)?p=le+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+E,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+E,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,U(ae),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),_=AS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),_=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Xn(n,p);t.subrs=_.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=dp.make(n.glyphs.length),E=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),A=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),v=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),X=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,ae=[m,g,b,E,P,A,N,X,y];Z&&ae.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Ap(ae),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,E=d.y,y=h.x,A=h.y,S=(p-m)*(E-A)-(_-g)*(b-y),M=p*g-_*m,v=b*A-E*y;f.x=(M*(b-y)-v*(p-m))/S,f.y=(M*(E-A)-v*(_-g))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=X;oe<=D;oe++)g[oe].push(U);const ae=Ia((Z-d)/_),ie=Ia((N-d)/_);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const E=w=>Math.ceil(w.length/4),y=g.reduce((w,U)=>w+E(U),0)+b.reduce((w,U)=>w+E(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),M=this.data,v=(w,U,O,P,Z)=>{M[w*4]=U,M[w*4+1]=O,M[w*4+2]=P,M[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let E=0;E=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,X=O+La,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=M+ie*u;this.pos.push(t.x+oe*p-_e*_,t.y+oe*_+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const E=g.substring(0,b).trim().toLowerCase(),y=g.substring(b+1).trim(),A=parseFloat(y);isNaN(A)||(E==="s"?c=A:E==="r"?u=A:E==="a"?(u=A,d=!0):E==="u"?(u=A,h=!0):E==="x"?f=A:E==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,E,y,A,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((y=(E=this._controls)==null?void 0:E.target)==null?void 0:y.x)??s.position.x,g=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const _=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,g=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(g.has(R)||g.set(R,[]),g.get(R).push(se))}const b=[];let E=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),E++,!(E&7)&&b.length<1e5&&b.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,M=Hs(e),v=M.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=M.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{A($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(_&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,A,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const W=(g.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,A,y):(this._polylineSegs(F,re,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(A(W.x-1,W.y,W.x+1,W.y,W.z||0,H),A(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?A(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):A(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=g.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:g,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,A,y):(this._polylineSegs(re.points,!0,0,H,A),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=g.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?g.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,A),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(_,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var E,y,A,S,M,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},g=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(E=N.ownerHandle)==null?void 0:E.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(_.size){const de=(M=N.layerHandle)==null?void 0:M.value;if(de!=null&&_.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>g(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,g):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>g(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>g(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,g):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),g(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),E=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,M=u>0?1:-1,v=E+M*A*b,T=y+M*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+_*w/L;r.push({x:v+g*Math.cos(U),y:T+g*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),E=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:E,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var m;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let g=0;g{let b=Math.max(0,Math.min(g,u));for(let A=0;A1e-9?b/S:0,v=l[A],T=l[A+1],I=v.x+(T.x-v.x)*M,L=v.y+(T.y-v.y)*M,w=(v.z||0)+((T.z||0)-(v.z||0))*M,U=Math.atan2(T.y-v.y,T.x-v.x);return{x:I,y:L,z:w,angle:U}}b-=S}const E=l[l.length-1],y=l[l.length-2];return{x:E.x,y:E.y,z:E.z||0,angle:Math.atan2(E.y-y.y,E.x-y.x)}};if(i.patternLength*s<1e-6)return;let f=0;for(const g of elements){if(g.type==="shape")break;g.type==="dash"?f+=Math.max((g.val||.05)*s,.01*s):g.type==="gap"&&(f+=Math.abs(g.val||.1)*s)}let p=0,_=0;for(;pE){const A=d(E),S=d(y);a(A.x,A.y,S.x,S.y,A.z,r)}p+=b}else if(g.type==="gap"){const b=Math.abs(g.val||.1)*s;p+=b}else if(g.type==="shape"){const b=d(p);this._renderShapeSymbol(g,b,s,r,a)}else if(g.type==="text"){const b=d(p);if(g.text&&o){const E=(g.style||"STANDARD").toUpperCase(),y=((m=this._textStyleHeightMap)==null?void 0:m.get(E))||0,S=(y>0?y:g.scale||.2)*s;let M=b.angle+(g.rotation||0)*Math.PI/180;g.isAbsoluteAngle&&(M=(g.rotation||0)*Math.PI/180);let v=Math.atan2(Math.sin(M),Math.cos(M));v>Math.PI/2?v-=Math.PI:v<-Math.PI/2&&(v+=Math.PI),M=v;const T=Math.cos(M),I=Math.sin(M),L=(g.xOffset||0)*s,w=0;let U=0;const O=elements[_%elements.length];O&&O.type==="gap"&&(U=Math.abs(O.val||0)*s/2);const P=U>1e-6?d(p+U):b,Z=P.x+(L*T-w*I),N=P.y+(L*I+w*T);o.push({text:g.text,pos:{x:Z,y:N,z:P.z},height:Math.max(S,.01),rotation:M,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(E,y)=>({x:f+(E*m-y*g)*o,y:p+(E*g+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const v=M/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const y=b(.5,0),A=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,y.x,y.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,M.x,M.y,_,s),y=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const E=b(-.3,-.3),y=b(.3,-.3),A=b(.3,.3),S=b(-.3,.3);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else if(a.includes("TRACK1")){const E=b(0,-.4),y=b(0,.4);r(E.x,E.y,y.x,y.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const E=b(0,.4),y=b(.4,0),A=b(0,-.4),S=b(-.4,0);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else{const E=b(.3,0),y=b(-.3,.2),A=b(-.3,-.2);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,E.x,E.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=bl;m++){const g=o+p*m/bl,b=d*Math.cos(g),E=h*Math.sin(g),y=r.x+b*Math.cos(f)-E*Math.sin(f),A=r.y+b*Math.sin(f)+E*Math.cos(f);_&&i(_.x,_.y,y,A,r.z||0,t),_={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(g-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*E,I=A+v*M*E,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+A*E*m,M=b+A*y*m,v=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=g(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const U of E)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=y.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const v=new _a(_);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),_=Math.max(_,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,E=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${E},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let E=0,y=0;g===0||g===3||g===5?E=h/2:g===2&&(E=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),M=Math.sin(A),v=e.pos.x+E*S-y*M,T=e.pos.y+E*M+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(_,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=_/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*M,y:T+N*M+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let E=0;a===0||a===3||a===5?E=m/2:a===1||a===4?E=0:a===2&&(E=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*g:o===3&&(y=(p-b)*g));const A=new gc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,_,1),S.position.set(t.x+E,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),E=Math.sin(g),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*_*b-ie*m*E,f.y+ae*_*E+ie*m*b]},A=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+M:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+M;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:M,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+M;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+M)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},E=(S,M,v,T,I)=>{this._arcSegs({x:S,y:M},v,T,I,0,s,r)},y=(S,M,v)=>this._arrowMesh(S,M,v,s),A=(S,M,v,T)=>{M&&S&&a.push({text:M,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,M=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:v,y:T}),b(c,{x:S,y:M}),b(u,{x:v,y:T}),y({x:S,y:M,z:0},Math.atan2(M-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-M,v-S),I),A(h??{x:(S+v)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),A(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,v=Math.hypot(c.x-S,c.y-M);if(v<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),E(S,M,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:M+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:M+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:M+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new ki(new B(d-_,f-m,0),new B(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return y??E??b},g.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(g)},g.setDefaultLevel=function(L){E=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){y=null,v(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(y=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=E(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=M);break}else o.code===9?(S&&(v[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),A(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=E(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?v[M.tableRecordsProperty]=M.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=y(o),o=r.next();break;case 11:M.upperRightCorner=y(o),o=r.next();break;case 12:M.center=y(o),o=r.next();break;case 13:M.snapBasePoint=y(o),o=r.next();break;case 14:M.snapSpacing=y(o),o=r.next();break;case 15:M.gridSpacing=y(o),o=r.next();break;case 16:M.viewDirectionFromTarget=y(o),o=r.next();break;case 17:M.viewTarget=y(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 111:M.ucsXAxis=y(o),o=r.next();break;case 112:M.ucsYAxis=y(o),o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,v=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=iE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=M,nt.debug("Layer {"),M={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function E(S){const M=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),M}function y(S){const M={};let v=S.code;if(M.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return M.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),M):(M.z=S.value,M)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const E=u+m*b/g,y=f*Math.cos(E),A=p*Math.sin(E);t.points.push({x:r+y*Math.cos(_)-A*Math.sin(_),y:a+y*Math.sin(_)+A*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=wd(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-D5xeJTBF.js b/dist2/assets/index-D5xeJTBF.js new file mode 100644 index 0000000..662f917 --- /dev/null +++ b/dist2/assets/index-D5xeJTBF.js @@ -0,0 +1,5531 @@ +var $p=Object.defineProperty;var Jp=(n,e,t)=>e in n?$p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Vt=(n,e,t)=>Jp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Dc="185",di={ROTATE:0,DOLLY:1,PAN:2},Ui={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jp=0,pu=1,Qp=2,Ua=1,e0=2,gr=3,Hi=0,on=1,Ht=2,fi=0,Bs=1,mu=2,gu=3,_u=4,t0=5,ji=100,n0=101,i0=102,s0=103,r0=104,a0=200,o0=201,l0=202,c0=203,Al=204,El=205,u0=206,h0=207,d0=208,f0=209,p0=210,m0=211,g0=212,_0=213,x0=214,Tl=0,Cl=1,wl=2,Gs=3,Rl=4,Dl=5,Ll=6,Il=7,Pd=0,y0=1,v0=2,Qn=0,Ud=1,Od=2,Nd=3,kd=4,Fd=5,Bd=6,Hd=7,zd=300,ss=301,Ws=302,Ao=303,Eo=304,go=306,Pl=1e3,ui=1001,Ul=1002,Ot=1003,S0=1004,Xr=1005,Wt=1006,To=1007,Oi=1008,yn=1009,Vd=1010,Gd=1011,Tr=1012,Lc=1013,ni=1014,Ln=1015,_i=1016,Ic=1017,Pc=1018,Cr=1020,Wd=35902,Xd=35899,Yd=1021,Kd=1022,Sn=1023,xi=1026,ns=1027,qd=1028,Uc=1029,rs=1030,Oc=1031,Nc=1033,Oa=33776,Na=33777,ka=33778,Fa=33779,Ol=35840,Nl=35841,kl=35842,Fl=35843,Bl=36196,Hl=37492,zl=37496,Vl=37488,Gl=37489,Xa=37490,Wl=37491,Xl=37808,Yl=37809,Kl=37810,ql=37811,Zl=37812,$l=37813,Jl=37814,jl=37815,Ql=37816,ec=37817,tc=37818,nc=37819,ic=37820,sc=37821,rc=36492,ac=36494,oc=36495,lc=36283,cc=36284,Ya=36285,uc=36286,b0=3200,xu=0,M0=1,ci="",dn="srgb",Ka="srgb-linear",qa="linear",pt="srgb",gs=7680,yu=519,A0=512,E0=513,T0=514,kc=515,C0=516,w0=517,Fc=518,R0=519,hc=35044,dc="300 es",Jn=2e3,Za=2001;function D0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function $a(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function L0(){const n=$a("canvas");return n.style.display="block",n}const vu={};function Ja(...n){const e="THREE."+n.shift();console.log(e,...n)}function Zd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ke(...n){n=Zd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=Zd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Hs(...n){const e=n.join(" ");e in vu||(vu[e]=!0,Ke(...n))}function I0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const P0={[Tl]:Cl,[wl]:Ll,[Rl]:Il,[Gs]:Dl,[Cl]:Tl,[Ll]:wl,[Il]:Rl,[Dl]:Gs};class Wi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+Kt[n>>16&255]+Kt[n>>24&255]+"-"+Kt[e&255]+Kt[e>>8&255]+"-"+Kt[e>>16&15|64]+Kt[e>>24&255]+"-"+Kt[t&63|128]+Kt[t>>8&255]+"-"+Kt[t>>16&255]+Kt[t>>24&255]+Kt[i&255]+Kt[i>>8&255]+Kt[i>>16&255]+Kt[i>>24&255]).toLowerCase()}function Qe(n,e,t){return Math.max(e,Math.min(t,n))}function U0(n,e){return(n%e+e)%e}function Co(n,e,t){return(1-t)*n+t*e}function $n(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function xt(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const O0={DEG2RAD:Ba},lu=class lu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=Qe(this.x,e.x,t.x),this.y=Qe(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=Qe(this.x,e,t),this.y=Qe(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Qe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};lu.prototype.isVector2=!0;let Me=lu;class zi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),A=Math.sin(b);g=Math.sin(g*b)/A,o=Math.sin(o*b)/A,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ke("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(Qe(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const cu=class cu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Su.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Su.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=Qe(this.x,e.x,t.x),this.y=Qe(this.y,e.y,t.y),this.z=Qe(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=Qe(this.x,e,t),this.y=Qe(this.y,e,t),this.z=Qe(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return wo.copy(this).projectOnVector(e),this.sub(wo)}reflect(e){return this.sub(wo.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(Qe(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};cu.prototype.isVector3=!0;let H=cu;const wo=new H,Su=new zi,uu=class uu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],A=s[4],x=s[7],E=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*E,r[3]=a*m+o*A+l*S,r[6]=a*g+o*x+l*M,r[1]=c*_+u*b+d*E,r[4]=c*m+u*A+d*S,r[7]=c*g+u*x+d*M,r[2]=h*_+f*b+p*E,r[5]=h*m+f*A+p*S,r[8]=h*g+f*x+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Hs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Ro.makeScale(e,t)),this}rotate(e){return Hs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Ro.makeRotation(-e)),this}translate(e,t){return Hs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Ro.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};uu.prototype.isMatrix3=!0;let Ze=uu;const Ro=new Ze,bu=new Ze().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Mu=new Ze().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function N0(){const n={enabled:!0,workingColorSpace:Ka,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===pt&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===pt&&(s.r=zs(s.r),s.g=zs(s.g),s.b=zs(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===ci?qa:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Hs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Hs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Ka]:{primaries:e,whitePoint:i,transfer:qa,toXYZ:bu,fromXYZ:Mu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:dn},outputColorSpaceConfig:{drawingBufferColorSpace:dn}},[dn]:{primaries:e,whitePoint:i,transfer:pt,toXYZ:bu,fromXYZ:Mu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:dn}}}),n}const it=N0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function zs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let _s;class k0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{_s===void 0&&(_s=$a("canvas")),_s.width=e.width,_s.height=e.height;const s=_s.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=_s}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=$a("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Lo).x}get height(){return this.source.getSize(Lo).y}get depth(){return this.source.getSize(Lo).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ke(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ke(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==zd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Pl:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Ul:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Pl:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Ul:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=zd;Jt.DEFAULT_ANISOTROPY=1;const hu=class hu{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,x=(f+1)/2,E=(g+1)/2,S=(u+h)/4,M=(d+_)/4,y=(p+m)/4;return A>x&&A>E?A<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(A),s=S/i,r=M/i):x>E?x<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(x),i=S/s,r=y/s):E<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(E),i=M/r,s=y/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=Qe(this.x,e.x,t.x),this.y=Qe(this.y,e.y,t.y),this.z=Qe(this.z,e.z,t.z),this.w=Qe(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=Qe(this.x,e,t),this.y=Qe(this.y,e,t),this.z=Qe(this.z,e,t),this.w=Qe(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(Qe(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};hu.prototype.isVector4=!0;let wt=hu;class H0 extends Wi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Wt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(q0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new _r;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const jd={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},Ei={h:0,s:0,l:0},qr={h:0,s:0,l:0};function Uo(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class et{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=dn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=U0(e,1),t=Qe(t,0,1),i=Qe(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=Uo(a,r,e+1/3),this.g=Uo(a,r,e),this.b=Uo(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=dn){function i(r){r!==void 0&&parseFloat(r)<1&&Ke("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ke("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ke("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=dn){const i=jd[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ke("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=zs(e.r),this.g=zs(e.g),this.b=zs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=dn){return it.workingToColorSpace(qt.copy(this),e),Math.round(Qe(qt.r*255,0,255))*65536+Math.round(Qe(qt.g*255,0,255))*256+Math.round(Qe(qt.b*255,0,255))}getHexString(e=dn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(qt.copy(this),t);const i=qt.r,s=qt.g,r=qt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Cn=new H,ri=new H,Oo=new H,ai=new H,Ss=new H,bs=new H,Lu=new H,No=new H,ko=new H,Fo=new H,Bo=new wt,Ho=new wt,zo=new wt;class vn{constructor(e=new H,t=new H,i=new H){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Cn.subVectors(e,t),s.cross(Cn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Cn.subVectors(s,t),ri.subVectors(i,t),Oo.subVectors(e,t);const a=Cn.dot(Cn),o=Cn.dot(ri),l=Cn.dot(Oo),c=ri.dot(ri),u=ri.dot(Oo),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return Bo.setScalar(0),Ho.setScalar(0),zo.setScalar(0),Bo.fromBufferAttribute(e,t),Ho.fromBufferAttribute(e,i),zo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Bo,r.x),a.addScaledVector(Ho,r.y),a.addScaledVector(zo,r.z),a}static isFrontFacing(e,t,i,s){return Cn.subVectors(i,t),ri.subVectors(e,t),Cn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Cn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Cn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return vn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return vn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return vn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return vn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return vn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;Ss.subVectors(s,i),bs.subVectors(r,i),No.subVectors(e,i);const l=Ss.dot(No),c=bs.dot(No);if(l<=0&&c<=0)return t.copy(i);ko.subVectors(e,s);const u=Ss.dot(ko),d=bs.dot(ko);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(Ss,a);Fo.subVectors(e,r);const f=Ss.dot(Fo),p=bs.dot(Fo);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(bs,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Lu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Lu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(Ss,a).addScaledVector(bs,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class Fi{constructor(e=new H(1/0,1/0,1/0),t=new H(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,wn),wn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(rr),$r.subVectors(this.max,rr),Ms.subVectors(e.a,rr),As.subVectors(e.b,rr),Es.subVectors(e.c,rr),Ti.subVectors(As,Ms),Ci.subVectors(Es,As),Yi.subVectors(Ms,Es);let t=[0,-Ti.z,Ti.y,0,-Ci.z,Ci.y,0,-Yi.z,Yi.y,Ti.z,0,-Ti.x,Ci.z,0,-Ci.x,Yi.z,0,-Yi.x,-Ti.y,Ti.x,0,-Ci.y,Ci.x,0,-Yi.y,Yi.x,0];return!Vo(t,Ms,As,Es,$r)||(t=[1,0,0,0,1,0,0,0,1],!Vo(t,Ms,As,Es,$r))?!1:(Jr.crossVectors(Ti,Ci),t=[Jr.x,Jr.y,Jr.z],Vo(t,Ms,As,Es,$r))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,wn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(wn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new H,new H,new H,new H,new H,new H,new H,new H],wn=new H,Zr=new Fi,Ms=new H,As=new H,Es=new H,Ti=new H,Ci=new H,Yi=new H,rr=new H,$r=new H,Jr=new H,Ki=new H;function Vo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Ki.fromArray(n,r);const o=s.x*Math.abs(Ki.x)+s.y*Math.abs(Ki.y)+s.z*Math.abs(Ki.z),l=e.dot(Ki),c=t.dot(Ki),u=i.dot(Ki);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Pt=new H,jr=new Me;let $0=0;class In extends Wi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=hc,this.updateRanges=[],this.gpuType=Ln,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;ar.subVectors(e,this.center);const t=ar.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(ar,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Go.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(ar.copy(e.center).add(Go)),this.expandByPoint(ar.copy(e.center).sub(Go))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let j0=0;const xn=new Et,Wo=new tn,Ts=new H,hn=new Fi,or=new Fi,Bt=new H;class Ct extends Wi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:j0++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(D0(e)?ef:Qd)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new Ze().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return xn.makeRotationFromQuaternion(e),this.applyMatrix4(xn),this}rotateX(e){return xn.makeRotationX(e),this.applyMatrix4(xn),this}rotateY(e){return xn.makeRotationY(e),this.applyMatrix4(xn),this}rotateZ(e){return xn.makeRotationZ(e),this.applyMatrix4(xn),this}translate(e,t,i){return xn.makeTranslation(e,t,i),this.applyMatrix4(xn),this}scale(e,t,i){return xn.makeScale(e,t,i),this.applyMatrix4(xn),this}lookAt(e){return Wo.lookAt(e),Wo.updateMatrix(),this.applyMatrix4(Wo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Ts).negate(),this.translate(Ts.x,Ts.y,Ts.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ke("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new Fi);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new H(-1/0,-1/0,-1/0),new H(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ke(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ke(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Bs&&(i.blending=this.blending),this.side!==Hi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Al&&(i.blendSrc=this.blendSrc),this.blendDst!==El&&(i.blendDst=this.blendDst),this.blendEquation!==ji&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Gs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==yu&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==gs&&(i.stencilFail=this.stencilFail),this.stencilZFail!==gs&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==gs&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new et().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Me().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Me().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class pc extends Qs{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new et(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let Cs;const lr=new H,ws=new H,Rs=new H,Ds=new Me,cr=new Me,tf=new Et,Qr=new H,ur=new H,ea=new H,Iu=new Me,Xo=new Me,Pu=new Me;class Uu extends tn{constructor(e=new pc){if(super(),this.isSprite=!0,this.type="Sprite",Cs===void 0){Cs=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Q0(t,5);Cs.setIndex([0,1,2,0,2,3]),Cs.setAttribute("position",new ja(i,3,0,!1)),Cs.setAttribute("uv",new ja(i,2,3,!1))}this.geometry=Cs,this.material=e,this.center=new Me(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),ws.setFromMatrixScale(this.matrixWorld),tf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Rs.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&ws.multiplyScalar(-Rs.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ta(Qr.set(-.5,-.5,0),Rs,a,ws,s,r),ta(ur.set(.5,-.5,0),Rs,a,ws,s,r),ta(ea.set(.5,.5,0),Rs,a,ws,s,r),Iu.set(0,0),Xo.set(1,0),Pu.set(1,1);let o=e.ray.intersectTriangle(Qr,ur,ea,!1,lr);if(o===null&&(ta(ur.set(-.5,.5,0),Rs,a,ws,s,r),Xo.set(0,1),o=e.ray.intersectTriangle(Qr,ea,ur,!1,lr),o===null))return;const l=e.ray.origin.distanceTo(lr);le.far||t.push({distance:l,point:lr.clone(),uv:vn.getInterpolation(lr,Qr,ur,ea,Iu,Xo,Pu,new Me),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ta(n,e,t,i,s,r){Ds.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(cr.x=r*Ds.x-s*Ds.y,cr.y=s*Ds.x+r*Ds.y):cr.copy(Ds),n.copy(e),n.x+=cr.x,n.y+=cr.y,n.applyMatrix4(tf)}const li=new H,Yo=new H,na=new H,wi=new H,Ko=new H,ia=new H,qo=new H;class Hc{constructor(e=new H,t=new H(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){Yo.copy(e).add(t).multiplyScalar(.5),na.copy(t).sub(e).normalize(),wi.copy(this.origin).sub(Yo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(na),o=wi.dot(this.direction),l=-wi.dot(na),c=wi.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Yo).addScaledVector(na,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Ko.subVectors(t,e),ia.subVectors(i,e),qo.crossVectors(Ko,ia);let a=this.direction.dot(qo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;wi.subVectors(this.origin,e);const l=o*this.direction.dot(ia.crossVectors(wi,ia));if(l<0)return null;const c=o*this.direction.dot(Ko.cross(wi));if(c<0||l+c>a)return null;const u=-o*wi.dot(qo);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Yn extends Qs{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new et(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 as,this.combine=Pd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const Ou=new Et,qi=new Hc,sa=new _o,Nu=new H,ra=new H,aa=new H,oa=new H,Zo=new H,la=new H,ku=new H,ca=new H;class zt extends tn{constructor(e=new Ct,t=new Yn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(Ou.copy(r).invert(),qi.copy(e.ray).applyMatrix4(Ou),!(i.boundingBox!==null&&qi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,qi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),A=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let x=b,E=A;xt.far?null:{distance:c,point:ca.clone(),object:n}}function ua(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,ra),n.getVertexPosition(l,aa),n.getVertexPosition(c,oa);const u=tm(n,e,t,i,ra,aa,oa,ku);if(u){const d=new H;vn.getBarycoord(ku,ra,aa,oa,d),s&&(u.uv=vn.getInterpolatedAttribute(s,o,l,c,d,new Me)),r&&(u.uv1=vn.getInterpolatedAttribute(r,o,l,c,d,new Me)),a&&(u.normal=vn.getInterpolatedAttribute(a,o,l,c,d,new H),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new H,materialIndex:0};vn.getNormal(ra,aa,oa,h.normal),u.face=h,u.barycoord=d}return u}class nf extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Ot,u=Ot,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const $o=new H,nm=new H,im=new Ze;class Ii{constructor(e=new H(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=$o.subVectors(i,t).cross(nm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta($o),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||im.getNormalMatrix(e),s=this.coplanarPoint($o).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Zi=new _o,sm=new Me(.5,.5),ha=new H;class sf{constructor(e=new Ii,t=new Ii,i=new Ii,s=new Ii,r=new Ii,a=new Ii){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Jn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],A=r[13],x=r[14],E=r[15];if(s[0].setComponents(c-a,f-u,g-p,E-b).normalize(),s[1].setComponents(c+a,f+u,g+p,E+b).normalize(),s[2].setComponents(c+o,f+d,g+_,E+A).normalize(),s[3].setComponents(c-o,f-d,g-_,E-A).normalize(),i)s[4].setComponents(l,h,m,x).normalize(),s[5].setComponents(c-l,f-h,g-m,E-x).normalize();else if(s[4].setComponents(c-l,f-h,g-m,E-x).normalize(),t===Jn)s[5].setComponents(c+l,f+h,g+m,E+x).normalize();else if(t===Za)s[5].setComponents(l,h,m,x).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Zi.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Zi.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Zi)}intersectsSprite(e){Zi.center.set(0,0,0);const t=sm.distanceTo(e.center);return Zi.radius=.7071067811865476+t,Zi.applyMatrix4(e.matrixWorld),this.intersectsSphere(Zi)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,ha.y=s.normal.y>0?e.max.y:e.min.y,ha.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(ha)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Fs extends Qs{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new et(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const Qa=new H,eo=new H,Fu=new Et,hr=new Hc,da=new _o,Jo=new H,Bu=new H;let rf=class extends tn{constructor(e=new Ct,t=new Fs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Jo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Jo);if(!(ce.far))return{distance:c,point:Bu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Hu=new H,zu=new H;class pa extends rf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(R.x,R.y,R.z),d.push(ae/M),d.push(1-re/y),F+=1}}for(let re=0;re0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Me:new H);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new H,s=[],r=[],a=[],o=new H,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new H)}r[0]=new H,a[0]=new H;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(Qe(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(Qe(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class zc extends ii{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Me){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Gu.subVectors(s[0],s[1]).add(s[0]),c=Gu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Wu(o,l.x,c.x,u.x,d.x),Wu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class df extends Yu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return wr(r,a,t,o,l,c,0),a}function ff(n,e,t,i,s){let r;if(s===Om(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Ku(a/i|0,n[a],n[a+1],r);return r&&Ys(r,r.next)&&(Dr(r),r=r.next),r}function os(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Ys(t,t.next)||At(t.prev,t,t.next)===0)){if(Dr(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function wr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Rm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Sm(n,i,s,r):vm(n)){e.push(l.i,n.i,c.i),Dr(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=bm(os(n),e),wr(n,e,t,i,s,r,2)):a===2&&Mm(n,e,t,i,s,r):wr(os(n),e,t,i,s,r,1);break}}}function vm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&xr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Sm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=mc(f,p,e,t,i),b=mc(_,m,e,t,i);let A=n.prevZ,x=n.nextZ;for(;A&&A.z>=g&&x&&x.z<=b;){if(A.x>=f&&A.x<=_&&A.y>=p&&A.y<=m&&A!==s&&A!==a&&xr(o,u,l,d,c,h,A.x,A.y)&&At(A.prev,A,A.next)>=0||(A=A.prevZ,x.x>=f&&x.x<=_&&x.y>=p&&x.y<=m&&x!==s&&x!==a&&xr(o,u,l,d,c,h,x.x,x.y)&&At(x.prev,x,x.next)>=0))return!1;x=x.nextZ}for(;A&&A.z>=g;){if(A.x>=f&&A.x<=_&&A.y>=p&&A.y<=m&&A!==s&&A!==a&&xr(o,u,l,d,c,h,A.x,A.y)&&At(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;x&&x.z<=b;){if(x.x>=f&&x.x<=_&&x.y>=p&&x.y<=m&&x!==s&&x!==a&&xr(o,u,l,d,c,h,x.x,x.y)&&At(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function bm(n,e){let t=n;do{const i=t.prev,s=t.next.next;!Ys(i,s)&&mf(i,t,t.next,s)&&Rr(i,s)&&Rr(s,i)&&(e.push(i.i,t.i,s.i),Dr(t),Dr(t.next),t=n=s),t=t.next}while(t!==n);return os(t)}function Mm(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Im(a,o)){let l=gf(a,o);a=os(a,a.next),l=os(l,l.next),wr(a,e,t,i,s,r,0),wr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Am(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&pf(sa.x||t.x===a.x&&wm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function wm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Rm(n,e,t,i){let s=n;do s.z===0&&(s.z=mc(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Dm(s)}function Dm(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function mc(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Lm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function xr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&pf(n,e,t,i,s,r,a,o)}function Im(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Pm(n,e)&&(Rr(n,e)&&Rr(e,n)&&Um(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||Ys(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Ys(n,e){return n.x===e.x&&n.y===e.y}function mf(n,e,t,i){const s=_a(At(n,e,t)),r=_a(At(n,e,i)),a=_a(At(t,i,n)),o=_a(At(t,i,e));return!!(s!==r&&a!==o||s===0&&ga(n,t,e)||r===0&&ga(n,i,e)||a===0&&ga(t,n,i)||o===0&&ga(t,e,i))}function ga(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function _a(n){return n>0?1:n<0?-1:0}function Pm(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&mf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Rr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Um(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function gf(n,e){const t=gc(n.i,n.x,n.y),i=gc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Ku(n,e,t,i){const s=gc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Dr(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function gc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Om(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Zu(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new et().setHex(s.value);break;case"v2":this.uniforms[i].value=new Me().fromArray(s.value);break;case"v3":this.uniforms[i].value=new H().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new Ze().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Vm extends Pn{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Gm extends Qs{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=b0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Wm extends Qs{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Xm extends Fs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const xa=new H,ya=new zi,Vn=new H;class xf extends tn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Jn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(xa,ya,Vn),Vn.x===1&&Vn.y===1&&Vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xa,ya,Vn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(xa,ya,Vn),Vn.x===1&&Vn.y===1&&Vn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(xa,ya,Vn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const Ri=new H,Ju=new Me,ju=new Me;class Dn extends xf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=fc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ba*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return fc*2*Math.atan(Math.tan(Ba*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){Ri.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(Ri.x,Ri.y).multiplyScalar(-e/Ri.z),Ri.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(Ri.x,Ri.y).multiplyScalar(-e/Ri.z)}getViewSize(e,t){return this.getViewBounds(e,Ju,ju),t.subVectors(ju,Ju)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ba*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Wc extends xf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Ls=-90,Is=1;class Ym extends tn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new Dn(Ls,Is,e,t);s.layers=this.layers,this.add(s);const r=new Dn(Ls,Is,e,t);r.layers=this.layers,this.add(r);const a=new Dn(Ls,Is,e,t);a.layers=this.layers,this.add(a);const o=new Dn(Ls,Is,e,t);o.layers=this.layers,this.add(o);const l=new Dn(Ls,Is,e,t);l.layers=this.layers,this.add(l);const c=new Dn(Ls,Is,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Jn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Za)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Km extends Dn{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class Qu{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=Qe(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(Qe(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const du=class du{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};du.prototype.isMatrix2=!0;let eh=du;class qm extends Wi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ke("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function th(n,e,t,i){const s=Zm(i);switch(t){case Yd:return n*e;case qd:return n*e/s.components*s.byteLength;case Uc:return n*e/s.components*s.byteLength;case rs:return n*e*2/s.components*s.byteLength;case Oc:return n*e*2/s.components*s.byteLength;case Kd:return n*e*3/s.components*s.byteLength;case Sn:return n*e*4/s.components*s.byteLength;case Nc:return n*e*4/s.components*s.byteLength;case Oa:case Na:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Nl:case Fl:return Math.max(n,16)*Math.max(e,8)/4;case Ol:case kl:return Math.max(n,8)*Math.max(e,8)/2;case Bl:case Hl:case Vl:case Gl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case zl:case Xa:case Wl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yl:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case ql:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Zl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case $l:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case Ql:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case ec:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case ic:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case sc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case rc:case ac:case oc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ya:case uc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Zm(n){switch(n){case yn:case Vd:return{byteLength:1,components:1};case Tr:case Gd:case _i:return{byteLength:2,components:1};case Ic:case Pc:return{byteLength:2,components:4};case ni:case Lc:case Ln:return{byteLength:4,components:1};case Wd:case Xd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Dc}}));typeof window<"u"&&(window.__THREE__?Ke("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Dc);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function yf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function $m(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,fg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,pg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,_g=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,yg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,vg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Sg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,bg=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Mg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Ag=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Eg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Tg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Cg="gl_FragColor = linearToOutputTexel( gl_FragColor );",wg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Rg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Dg=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Lg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ug=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Og=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Ng=`#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`,kg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Fg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,Bg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Hg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,zg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Vg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Gg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Wg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Xg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Yg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Kg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qg=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Zg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,$g=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Jg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,jg=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,Qg=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,e_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,t_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,n_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,i_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,s_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,r_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,a_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,o_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,l_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,c_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,u_=`#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`,h_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,d_=`#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`,f_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,p_=`#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`,m_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,g_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,__=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,x_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,y_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,v_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,S_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,b_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,M_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,A_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,E_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,T_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,C_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,w_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,R_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,D_=`#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`,L_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,I_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,P_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,U_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,O_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,N_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,k_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,F_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,B_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,H_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,z_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,V_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,G_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,W_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,X_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Y_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,q_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,$_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const J_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,j_=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Q_=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,ex=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,ix=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,sx=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,rx=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,ax=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,ox=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,lx=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,cx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,ux=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,hx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,fx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,px=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,gx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,_x=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,xx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,yx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,vx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Sx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,bx=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Mx=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Ax=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Ex=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Tx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Cx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,wx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Rx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Dx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,Je={alphahash_fragment:Jm,alphahash_pars_fragment:jm,alphamap_fragment:Qm,alphamap_pars_fragment:eg,alphatest_fragment:tg,alphatest_pars_fragment:ng,aomap_fragment:ig,aomap_pars_fragment:sg,batching_pars_vertex:rg,batching_vertex:ag,begin_vertex:og,beginnormal_vertex:lg,bsdfs:cg,iridescence_fragment:ug,bumpmap_pars_fragment:hg,clipping_planes_fragment:dg,clipping_planes_pars_fragment:fg,clipping_planes_pars_vertex:pg,clipping_planes_vertex:mg,color_fragment:gg,color_pars_fragment:_g,color_pars_vertex:xg,color_vertex:yg,common:vg,cube_uv_reflection_fragment:Sg,defaultnormal_vertex:bg,displacementmap_pars_vertex:Mg,displacementmap_vertex:Ag,emissivemap_fragment:Eg,emissivemap_pars_fragment:Tg,colorspace_fragment:Cg,colorspace_pars_fragment:wg,envmap_fragment:Rg,envmap_common_pars_fragment:Dg,envmap_pars_fragment:Lg,envmap_pars_vertex:Ig,envmap_physical_pars_fragment:Gg,envmap_vertex:Pg,fog_vertex:Ug,fog_pars_vertex:Og,fog_fragment:Ng,fog_pars_fragment:kg,gradientmap_pars_fragment:Fg,lightmap_pars_fragment:Bg,lights_lambert_fragment:Hg,lights_lambert_pars_fragment:zg,lights_pars_begin:Vg,lights_toon_fragment:Wg,lights_toon_pars_fragment:Xg,lights_phong_fragment:Yg,lights_phong_pars_fragment:Kg,lights_physical_fragment:qg,lights_physical_pars_fragment:Zg,lights_fragment_begin:$g,lights_fragment_maps:Jg,lights_fragment_end:jg,lightprobes_pars_fragment:Qg,logdepthbuf_fragment:e_,logdepthbuf_pars_fragment:t_,logdepthbuf_pars_vertex:n_,logdepthbuf_vertex:i_,map_fragment:s_,map_pars_fragment:r_,map_particle_fragment:a_,map_particle_pars_fragment:o_,metalnessmap_fragment:l_,metalnessmap_pars_fragment:c_,morphinstance_vertex:u_,morphcolor_vertex:h_,morphnormal_vertex:d_,morphtarget_pars_vertex:f_,morphtarget_vertex:p_,normal_fragment_begin:m_,normal_fragment_maps:g_,normal_pars_fragment:__,normal_pars_vertex:x_,normal_vertex:y_,normalmap_pars_fragment:v_,clearcoat_normal_fragment_begin:S_,clearcoat_normal_fragment_maps:b_,clearcoat_pars_fragment:M_,iridescence_pars_fragment:A_,opaque_fragment:E_,packing:T_,premultiplied_alpha_fragment:C_,project_vertex:w_,dithering_fragment:R_,dithering_pars_fragment:D_,roughnessmap_fragment:L_,roughnessmap_pars_fragment:I_,shadowmap_pars_fragment:P_,shadowmap_pars_vertex:U_,shadowmap_vertex:O_,shadowmask_pars_fragment:N_,skinbase_vertex:k_,skinning_pars_vertex:F_,skinning_vertex:B_,skinnormal_vertex:H_,specularmap_fragment:z_,specularmap_pars_fragment:V_,tonemapping_fragment:G_,tonemapping_pars_fragment:W_,transmission_fragment:X_,transmission_pars_fragment:Y_,uv_pars_fragment:K_,uv_pars_vertex:q_,uv_vertex:Z_,worldpos_vertex:$_,background_vert:J_,background_frag:j_,backgroundCube_vert:Q_,backgroundCube_frag:ex,cube_vert:tx,cube_frag:nx,depth_vert:ix,depth_frag:sx,distance_vert:rx,distance_frag:ax,equirect_vert:ox,equirect_frag:lx,linedashed_vert:cx,linedashed_frag:ux,meshbasic_vert:hx,meshbasic_frag:dx,meshlambert_vert:fx,meshlambert_frag:px,meshmatcap_vert:mx,meshmatcap_frag:gx,meshnormal_vert:_x,meshnormal_frag:xx,meshphong_vert:yx,meshphong_frag:vx,meshphysical_vert:Sx,meshphysical_frag:bx,meshtoon_vert:Mx,meshtoon_frag:Ax,points_vert:Ex,points_frag:Tx,shadow_vert:Cx,shadow_frag:wx,sprite_vert:Rx,sprite_frag:Dx},Ce={common:{diffuse:{value:new et(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new Ze},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new Ze}},envmap:{envMap:{value:null},envMapRotation:{value:new Ze},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new Ze}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new Ze}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new Ze},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new Ze},normalScale:{value:new Me(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new Ze},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new Ze}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new Ze}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new Ze}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new et(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new H},probesMax:{value:new H},probesResolution:{value:new H}},points:{diffuse:{value:new et(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0},uvTransform:{value:new Ze}},sprite:{diffuse:{value:new et(16777215)},opacity:{value:1},center:{value:new Me(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new Ze},alphaMap:{value:null},alphaMapTransform:{value:new Ze},alphaTest:{value:0}}},Zn={basic:{uniforms:en([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:Je.meshbasic_vert,fragmentShader:Je.meshbasic_frag},lambert:{uniforms:en([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new et(0)},envMapIntensity:{value:1}}]),vertexShader:Je.meshlambert_vert,fragmentShader:Je.meshlambert_frag},phong:{uniforms:en([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new et(0)},specular:{value:new et(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:Je.meshphong_vert,fragmentShader:Je.meshphong_frag},standard:{uniforms:en([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new et(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:Je.meshphysical_vert,fragmentShader:Je.meshphysical_frag},toon:{uniforms:en([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new et(0)}}]),vertexShader:Je.meshtoon_vert,fragmentShader:Je.meshtoon_frag},matcap:{uniforms:en([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:Je.meshmatcap_vert,fragmentShader:Je.meshmatcap_frag},points:{uniforms:en([Ce.points,Ce.fog]),vertexShader:Je.points_vert,fragmentShader:Je.points_frag},dashed:{uniforms:en([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:Je.linedashed_vert,fragmentShader:Je.linedashed_frag},depth:{uniforms:en([Ce.common,Ce.displacementmap]),vertexShader:Je.depth_vert,fragmentShader:Je.depth_frag},normal:{uniforms:en([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:Je.meshnormal_vert,fragmentShader:Je.meshnormal_frag},sprite:{uniforms:en([Ce.sprite,Ce.fog]),vertexShader:Je.sprite_vert,fragmentShader:Je.sprite_frag},background:{uniforms:{uvTransform:{value:new Ze},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:Je.background_vert,fragmentShader:Je.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new Ze}},vertexShader:Je.backgroundCube_vert,fragmentShader:Je.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:Je.cube_vert,fragmentShader:Je.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:Je.equirect_vert,fragmentShader:Je.equirect_frag},distance:{uniforms:en([Ce.common,Ce.displacementmap,{referencePosition:{value:new H},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:Je.distance_vert,fragmentShader:Je.distance_frag},shadow:{uniforms:en([Ce.lights,Ce.fog,{color:{value:new et(0)},opacity:{value:1}}]),vertexShader:Je.shadow_vert,fragmentShader:Je.shadow_frag}};Zn.physical={uniforms:en([Zn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new Ze},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new Ze},clearcoatNormalScale:{value:new Me(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new Ze},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new Ze},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new Ze},sheen:{value:0},sheenColor:{value:new et(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new Ze},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new Ze},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new Ze},transmissionSamplerSize:{value:new Me},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new Ze},attenuationDistance:{value:0},attenuationColor:{value:new et(0)},specularColor:{value:new et(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new Ze},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new Ze},anisotropyVector:{value:new Me},anisotropyMap:{value:null},anisotropyMapTransform:{value:new Ze}}]),vertexShader:Je.meshphysical_vert,fragmentShader:Je.meshphysical_frag};const va={r:0,b:0,g:0},Lx=new Et,vf=new Ze;vf.set(-1,0,0,0,1,0,0,0,1);function Ix(n,e,t,i,s,r){const a=new et(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let A=b.isScene===!0?b.background:null;if(A&&A.isTexture){const x=b.backgroundBlurriness>0;A=e.get(A,x)}return A}function p(b){let A=!1;const x=f(b);x===null?m(a,o):x&&x.isColor&&(m(x,1),A=!0);const E=n.xr.getEnvironmentBlendMode();E==="additive"?t.buffers.color.setClear(0,0,0,1,r):E==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,A){const x=f(A);x&&(x.isCubeTexture||x.mapping===go)?(c===void 0&&(c=new zt(new Or(1,1,1),new Pn({name:"BackgroundCubeMaterial",uniforms:Ks(Zn.backgroundCube.uniforms),vertexShader:Zn.backgroundCube.vertexShader,fragmentShader:Zn.backgroundCube.fragmentShader,side:on,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(E,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=x,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Lx.makeRotationFromEuler(A.backgroundRotation)).transpose(),x.isCubeTexture&&x.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(vf),c.material.toneMapped=it.getTransfer(x.colorSpace)!==pt,(u!==x||d!==x.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=x,d=x.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):x&&x.isTexture&&(l===void 0&&(l=new zt(new is(2,2),new Pn({name:"BackgroundMaterial",uniforms:Ks(Zn.background.uniforms),vertexShader:Zn.background.vertexShader,fragmentShader:Zn.background.fragmentShader,side:Hi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=x,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=it.getTransfer(x.colorSpace)!==pt,x.matrixAutoUpdate===!0&&x.updateMatrix(),l.material.uniforms.uvTransform.value.copy(x.matrix),(u!==x||d!==x.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=x,d=x.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,A){b.getRGB(va,_f(n)),t.buffers.color.setClear(va.r,va.g,va.b,A,r)}function g(){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 a},setClearColor:function(b,A=1){a.set(b),o=A,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Px(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,O,k,U){let $=!1;const F=d(L,k,O,w);r!==F&&(r=F,c(r.object)),$=f(L,k,O,U),$&&p(L,k,O,U),U!==null&&e.update(U,n.ELEMENT_ARRAY_BUFFER),($||a)&&(a=!1,x(L,w,O,k),U!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(U).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,O,k){const U=k.wireframe===!0;let $=i[w.id];$===void 0&&($={},i[w.id]=$);const F=L.isInstancedMesh===!0?L.id:0;let Z=$[F];Z===void 0&&(Z={},$[F]=Z);let R=Z[O.id];R===void 0&&(R={},Z[O.id]=R);let re=R[U];return re===void 0&&(re=h(l()),R[U]=re),re}function h(L){const w=[],O=[],k=[];for(let U=0;U=0){const se=U[R];let ae=$[R];if(ae===void 0&&(R==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),R==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),se===void 0||se.attribute!==ae||ae&&se.data!==ae.data)return!0;F++}return r.attributesNum!==F||r.index!==k}function p(L,w,O,k){const U={},$=w.attributes;let F=0;const Z=O.getAttributes();for(const R in Z)if(Z[R].location>=0){let se=$[R];se===void 0&&(R==="instanceMatrix"&&L.instanceMatrix&&(se=L.instanceMatrix),R==="instanceColor"&&L.instanceColor&&(se=L.instanceColor));const ae={};ae.attribute=se,se&&se.data&&(ae.data=se.data),U[R]=ae,F++}r.attributes=U,r.attributesNum=F,r.index=k}function _(){const L=r.newAttributes;for(let w=0,O=L.length;w=0){let re=U[Z];if(re===void 0&&(Z==="instanceMatrix"&&L.instanceMatrix&&(re=L.instanceMatrix),Z==="instanceColor"&&L.instanceColor&&(re=L.instanceColor)),re!==void 0){const se=re.normalized,ae=re.itemSize,ge=e.get(re);if(ge===void 0)continue;const he=ge.buffer,oe=ge.type,G=ge.bytesPerElement,ne=oe===n.INT||oe===n.UNSIGNED_INT||re.gpuType===Lc;if(re.isInterleavedBufferAttribute){const j=re.data,xe=j.stride,be=re.offset;if(j.isInstancedInterleavedBuffer){for(let ve=0;ve0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ke("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ke("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),A=n.getParameter(n.MAX_VARYING_VECTORS),x=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),E=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:A,maxFragmentUniforms:x,maxSamples:E,samples:S}}function Nx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Ii,o=new Ze,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,A=b*4;let x=g.clippingState||null;l.value=x,x=u(p,h,A,f);for(let E=0;E!==A;++E)x[E]=t[E];g.clippingState=x,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=oh(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=ah(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?E:0,E,E),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ss||e.mapping===Ws;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=oh()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=ah());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Ps(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,dr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Ni?i-p+Ni:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Ps(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,dr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Ps(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,dr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Qi-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Qi;m>Qi&&Ke(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Qi}`);const g=[];let b=0;for(let M=0;MA-Ni?s-A+Ni:0),S=4*(this._cubeSize-x);Ps(t,E,S,3*x,2*x),l.setRenderTarget(t),l.render(d,dr)}}function Bx(n){const e=[],t=[],i=[];let s=n;const r=n-Ni+1+nh.length;for(let a=0;an-Ni?l=nh[a-n+Ni-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),A=new Float32Array(m*p*f),x=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,y,0,M+2/3,y,0,M+2/3,y+1,0,M,y,0,M+2/3,y+1,0,M,y+1,0];b.set(T,_*p*S),A.set(h,m*p*S);const I=[S,S,S,S,S,S];x.set(I,g*p*S)}const E=new Ct;E.setAttribute("position",new In(b,_)),E.setAttribute("uv",new In(A,m)),E.setAttribute("faceIndex",new In(x,g)),i.push(new zt(E,null)),s>Ni&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function rh(n,e,t){const i=new ei(n,e,t);return i.texture.mapping=go,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Ps(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Hx(n,e,t){return new Pn({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:kx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:xo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function zx(n,e,t){const i=new Float32Array(Qi),s=new H(0,1,0);return new Pn({name:"SphericalGaussianBlur",defines:{n:Qi,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:xo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ah(){return new Pn({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:xo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function oh(){return new Pn({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:xo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function xo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Sf extends ei{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new af(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Or(5,5,5),r=new Pn({name:"CubemapFromEquirect",uniforms:Ks(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:on,blending:fi});r.uniforms.tEquirect.value=t;const a=new zt(s,r),o=t.minFilter;return t.minFilter===Oi&&(t.minFilter=Wt),new Ym(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Vx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===Ao||f===Eo)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Sf(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===Ao||f===Eo,_=f===ss||f===Ws;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new sh(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new sh(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===Ao?h.mapping=ss:f===Eo&&(h.mapping=Ws),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?ef:Qd)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(E/e.maxTextureSize),E=e.maxTextureSize);const M=new Float32Array(E*S*4*d),y=new $d(M,E,S,d);y.type=Ln,y.needsUpdate=!0;const T=x*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new zt(l,c),d=new Wc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(A,x){a.setSize(A,x),o.setSize(A,x);for(let E=0;E0&&g[0].isRenderPass===!0;const x=a.width,E=a.height;for(let S=0;S0)return n;const s=e*t;let r=lh[s];if(r===void 0&&(r=new Float32Array(s),lh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function Nt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function ph(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const z1=37297;let V1=0;function G1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const mh=new Ze;function W1(n){it._getMatrix(mh,it.workingColorSpace,n);const e=`mat3( ${mh.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case qa:return[e,"LinearTransferOETF"];case pt:return[e,"sRGBTransferOETF"];default:return Ke("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function gh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+G1(n.getShaderSource(e),o)}else return r}function X1(n,e){const t=W1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const Y1={[Ud]:"Linear",[Od]:"Reinhard",[Nd]:"Cineon",[kd]:"ACESFilmic",[Bd]:"AgX",[Hd]:"Neutral",[Fd]:"Custom"};function K1(n,e){const t=Y1[e];return t===void 0?(Ke("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Sa=new H;function q1(){it.getLuminanceCoefficients(Sa);const n=Sa.x.toFixed(4),e=Sa.y.toFixed(4),t=Sa.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Z1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(yr).join(` +`)}function $1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function J1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function xc(n){return n.replace(j1,ey)}const Q1=new Map;function ey(n,e){let t=Je[e];if(t===void 0){const i=Q1.get(e);if(i!==void 0)t=Je[i],Ke('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return xc(t)}const ty=/#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 yh(n){return n.replace(ty,ny)}function ny(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(yr).join(` +`),g.length>0&&(g+=` +`)):(m=[vh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(yr).join(` +`),g=[vh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Qn?"#define TONE_MAPPING":"",t.toneMapping!==Qn?Je.tonemapping_pars_fragment:"",t.toneMapping!==Qn?K1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",Je.colorspace_pars_fragment,X1("linearToOutputTexel",t.outputColorSpace),q1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(yr).join(` +`)),a=xc(a),a=_h(a,t),a=xh(a,t),o=xc(o),o=_h(o,t),o=xh(o,t),a=yh(a),o=yh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===dc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.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(` +`)+` +`+g);const A=b+m+a,x=b+g+o,E=ph(s,s.VERTEX_SHADER,A),S=ph(s,s.FRAGMENT_SHADER,x);s.attachShader(_,E),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",O=s.getShaderInfoLog(E)||"",k=s.getShaderInfoLog(S)||"",U=w.trim(),$=O.trim(),F=k.trim();let Z=!0,R=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(Z=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,E,S);else{const re=gh(s,E,"vertex"),se=gh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+U+` +`+re+` +`+se)}else U!==""?Ke("WebGLProgram: Program Info Log:",U):($===""||F==="")&&(R=!1);R&&(L.diagnostics={runnable:Z,programLog:U,vertexShader:{log:$,prefix:m},fragmentShader:{log:F,prefix:g}})}s.deleteShader(E),s.deleteShader(S),y=new Ha(s,_),T=J1(s,_)}let y;this.getUniforms=function(){return y===void 0&&M(this),y};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,z1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=V1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=E,this.fragmentShader=S,this}let fy=0;class py{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new my(e),t.set(e,i)),i}}class my{constructor(e){this.id=fy++,this.code=e,this.usedTimes=0}}function gy(n){return n===rs||n===Xa||n===Ya}function _y(n,e,t,i,s,r){const a=new Jd,o=new py,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(y){return l.add(y),y===0?"uv":`uv${y}`}function _(y,T,I,L,w,O){const k=L.fog,U=w.geometry,$=y.isMeshStandardMaterial||y.isMeshLambertMaterial||y.isMeshPhongMaterial?L.environment:null,F=y.isMeshStandardMaterial||y.isMeshLambertMaterial&&!y.envMap||y.isMeshPhongMaterial&&!y.envMap,Z=e.get(y.envMap||$,F),R=Z&&Z.mapping===go?Z.image.height:null,re=f[y.type];y.precision!==null&&(h=i.getMaxPrecision(y.precision),h!==y.precision&&Ke("WebGLProgram.getParameters:",y.precision,"not supported, using",h,"instead."));const se=U.morphAttributes.position||U.morphAttributes.normal||U.morphAttributes.color,ae=se!==void 0?se.length:0;let ge=0;U.morphAttributes.position!==void 0&&(ge=1),U.morphAttributes.normal!==void 0&&(ge=2),U.morphAttributes.color!==void 0&&(ge=3);let he,oe,G,ne;if(re){const Ue=Zn[re];he=Ue.vertexShader,oe=Ue.fragmentShader}else{he=y.vertexShader,oe=y.fragmentShader;const Ue=o.getVertexShaderStage(y),ot=o.getFragmentShaderStage(y);o.update(y,Ue,ot),G=Ue.id,ne=ot.id}const j=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),be=w.isInstancedMesh===!0,ve=w.isBatchedMesh===!0,Be=!!y.map,Ve=!!y.matcap,Ne=!!Z,ke=!!y.aoMap,Xe=!!y.lightMap,tt=!!y.bumpMap&&y.wireframe===!1,rt=!!y.normalMap,gt=!!y.displacementMap,vt=!!y.emissiveMap,ht=!!y.metalnessMap,dt=!!y.roughnessMap,D=y.anisotropy>0,Ee=y.clearcoat>0,z=y.dispersion>0,P=y.iridescence>0,v=y.sheen>0,B=y.transmission>0,Y=D&&!!y.anisotropyMap,N=Ee&&!!y.clearcoatMap,J=Ee&&!!y.clearcoatNormalMap,ie=Ee&&!!y.clearcoatRoughnessMap,X=P&&!!y.iridescenceMap,W=P&&!!y.iridescenceThicknessMap,ce=v&&!!y.sheenColorMap,le=v&&!!y.sheenRoughnessMap,de=!!y.specularMap,pe=!!y.specularColorMap,Le=!!y.specularIntensityMap,we=B&&!!y.transmissionMap,Ye=B&&!!y.thicknessMap,V=!!y.gradientMap,_e=!!y.alphaMap,ue=y.alphaTest>0,ye=!!y.alphaHash,Te=!!y.extensions;let fe=Qn;y.toneMapped&&(j===null||j.isXRRenderTarget===!0)&&(fe=n.toneMapping);const He={shaderID:re,shaderType:y.type,shaderName:y.name,vertexShader:he,fragmentShader:oe,defines:y.defines,customVertexShaderID:G,customFragmentShaderID:ne,isRawShaderMaterial:y.isRawShaderMaterial===!0,glslVersion:y.glslVersion,precision:h,batching:ve,batchingColor:ve&&w._colorsTexture!==null,instancing:be,instancingColor:be&&w.instanceColor!==null,instancingMorph:be&&w.morphTexture!==null,outputColorSpace:j===null?n.outputColorSpace:j.isXRRenderTarget===!0?j.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!y.alphaToCoverage,map:Be,matcap:Ve,envMap:Ne,envMapMode:Ne&&Z.mapping,envMapCubeUVHeight:R,aoMap:ke,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:gt,emissiveMap:vt,normalMapObjectSpace:rt&&y.normalMapType===M0,normalMapTangentSpace:rt&&y.normalMapType===xu,packedNormalMap:rt&&y.normalMapType===xu&&gy(y.normalMap.format),metalnessMap:ht,roughnessMap:dt,anisotropy:D,anisotropyMap:Y,clearcoat:Ee,clearcoatMap:N,clearcoatNormalMap:J,clearcoatRoughnessMap:ie,dispersion:z,iridescence:P,iridescenceMap:X,iridescenceThicknessMap:W,sheen:v,sheenColorMap:ce,sheenRoughnessMap:le,specularMap:de,specularColorMap:pe,specularIntensityMap:Le,transmission:B,transmissionMap:we,thicknessMap:Ye,gradientMap:V,opaque:y.transparent===!1&&y.blending===Bs&&y.alphaToCoverage===!1,alphaMap:_e,alphaTest:ue,alphaHash:ye,combine:y.combine,mapUv:Be&&p(y.map.channel),aoMapUv:ke&&p(y.aoMap.channel),lightMapUv:Xe&&p(y.lightMap.channel),bumpMapUv:tt&&p(y.bumpMap.channel),normalMapUv:rt&&p(y.normalMap.channel),displacementMapUv:gt&&p(y.displacementMap.channel),emissiveMapUv:vt&&p(y.emissiveMap.channel),metalnessMapUv:ht&&p(y.metalnessMap.channel),roughnessMapUv:dt&&p(y.roughnessMap.channel),anisotropyMapUv:Y&&p(y.anisotropyMap.channel),clearcoatMapUv:N&&p(y.clearcoatMap.channel),clearcoatNormalMapUv:J&&p(y.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:ie&&p(y.clearcoatRoughnessMap.channel),iridescenceMapUv:X&&p(y.iridescenceMap.channel),iridescenceThicknessMapUv:W&&p(y.iridescenceThicknessMap.channel),sheenColorMapUv:ce&&p(y.sheenColorMap.channel),sheenRoughnessMapUv:le&&p(y.sheenRoughnessMap.channel),specularMapUv:de&&p(y.specularMap.channel),specularColorMapUv:pe&&p(y.specularColorMap.channel),specularIntensityMapUv:Le&&p(y.specularIntensityMap.channel),transmissionMapUv:we&&p(y.transmissionMap.channel),thicknessMapUv:Ye&&p(y.thicknessMap.channel),alphaMapUv:_e&&p(y.alphaMap.channel),vertexTangents:!!U.attributes.tangent&&(rt||D),vertexNormals:!!U.attributes.normal,vertexColors:y.vertexColors,vertexAlphas:y.vertexColors===!0&&!!U.attributes.color&&U.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!U.attributes.uv&&(Be||_e),fog:!!k,useFog:y.fog===!0,fogExp2:!!k&&k.isFogExp2,flatShading:y.wireframe===!1&&(y.flatShading===!0||U.attributes.normal===void 0&&rt===!1&&(y.isMeshLambertMaterial||y.isMeshPhongMaterial||y.isMeshStandardMaterial||y.isMeshPhysicalMaterial)),sizeAttenuation:y.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:U.attributes.position!==void 0,morphTargets:U.morphAttributes.position!==void 0,morphNormals:U.morphAttributes.normal!==void 0,morphColors:U.morphAttributes.color!==void 0,morphTargetsCount:ae,morphTextureStride:ge,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.length,numDirLightShadows:T.directionalShadowMap.length,numPointLightShadows:T.pointShadowMap.length,numSpotLightShadows:T.spotShadowMap.length,numSpotLightShadowsWithMaps:T.numSpotLightShadowsWithMaps,numLightProbes:T.numLightProbes,numLightProbeGrids:O.length,numClippingPlanes:r.numPlanes,numClipIntersection:r.numIntersection,dithering:y.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:fe,decodeVideoTexture:Be&&y.map.isVideoTexture===!0&&it.getTransfer(y.map.colorSpace)===pt,decodeVideoTextureEmissive:vt&&y.emissiveMap.isVideoTexture===!0&&it.getTransfer(y.emissiveMap.colorSpace)===pt,premultipliedAlpha:y.premultipliedAlpha,doubleSided:y.side===Ht,flipSided:y.side===on,useDepthPacking:y.depthPacking>=0,depthPacking:y.depthPacking||0,index0AttributeName:y.index0AttributeName,extensionClipCullDistance:Te&&y.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Te&&y.extensions.multiDraw===!0||ve)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:y.customProgramCacheKey()};return He.vertexUv1s=l.has(1),He.vertexUv2s=l.has(2),He.vertexUv3s=l.has(3),l.clear(),He}function m(y){const T=[];if(y.shaderID?T.push(y.shaderID):(T.push(y.customVertexShaderID),T.push(y.customFragmentShaderID)),y.defines!==void 0)for(const I in y.defines)T.push(I),T.push(y.defines[I]);return y.isRawShaderMaterial===!1&&(g(T,y),b(T,y),T.push(n.outputColorSpace)),T.push(y.customProgramCacheKey),T.join()}function g(y,T){y.push(T.precision),y.push(T.outputColorSpace),y.push(T.envMapMode),y.push(T.envMapCubeUVHeight),y.push(T.mapUv),y.push(T.alphaMapUv),y.push(T.lightMapUv),y.push(T.aoMapUv),y.push(T.bumpMapUv),y.push(T.normalMapUv),y.push(T.displacementMapUv),y.push(T.emissiveMapUv),y.push(T.metalnessMapUv),y.push(T.roughnessMapUv),y.push(T.anisotropyMapUv),y.push(T.clearcoatMapUv),y.push(T.clearcoatNormalMapUv),y.push(T.clearcoatRoughnessMapUv),y.push(T.iridescenceMapUv),y.push(T.iridescenceThicknessMapUv),y.push(T.sheenColorMapUv),y.push(T.sheenRoughnessMapUv),y.push(T.specularMapUv),y.push(T.specularColorMapUv),y.push(T.specularIntensityMapUv),y.push(T.transmissionMapUv),y.push(T.thicknessMapUv),y.push(T.combine),y.push(T.fogExp2),y.push(T.sizeAttenuation),y.push(T.morphTargetsCount),y.push(T.morphAttributeCount),y.push(T.numDirLights),y.push(T.numPointLights),y.push(T.numSpotLights),y.push(T.numSpotLightMaps),y.push(T.numHemiLights),y.push(T.numRectAreaLights),y.push(T.numDirLightShadows),y.push(T.numPointLightShadows),y.push(T.numSpotLightShadows),y.push(T.numSpotLightShadowsWithMaps),y.push(T.numLightProbes),y.push(T.shadowMapType),y.push(T.toneMapping),y.push(T.numClippingPlanes),y.push(T.numClipIntersection),y.push(T.depthPacking)}function b(y,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),y.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),y.push(a.mask)}function A(y){const T=f[y.type];let I;if(T){const L=Zn[T];I=Bm.clone(L.uniforms)}else I=y.uniforms;return I}function x(y,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new dy(n,T,y,s),c.push(I),u.set(T,I)),I}function E(y){if(--y.usedTimes===0){const T=c.indexOf(y);c[T]=c[c.length-1],c.pop(),u.delete(y.cacheKey),y.destroy()}}function S(y){o.remove(y)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:A,acquireProgram:x,releaseProgram:E,releaseShaderCache:S,programs:c,dispose:M}}function xy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function yy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Sh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function bh(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||yy),i.length>1&&i.sort(f||Sh),s.length>1&&s.sort(f||Sh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new bh,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function Sy(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new H,color:new et};break;case"SpotLight":t={position:new H,direction:new H,color:new et,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new H,color:new et,distance:0,decay:0};break;case"HemisphereLight":t={direction:new H,skyColor:new et,groundColor:new et};break;case"RectAreaLight":t={color:new et,position:new H,halfWidth:new H,halfHeight:new H};break}return n[e.id]=t,t}}}function by(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Me,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let My=0;function Ay(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Ey(n){const e=new Sy,t=by(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new H);const s=new H,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,A=0,x=0,E=0,S=0,M=0;c.sort(Ay);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const y=i.hash;(y.directionalLength!==f||y.pointLength!==p||y.spotLength!==_||y.rectAreaLength!==m||y.hemiLength!==g||y.numDirectionalShadows!==b||y.numPointShadows!==A||y.numSpotShadows!==x||y.numSpotMaps!==E||y.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=x,i.spotShadowMap.length=x,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=x+E-S,i.spotLightMap.length=E,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,y.directionalLength=f,y.pointLength=p,y.spotLength=_,y.rectAreaLength=m,y.hemiLength=g,y.numDirectionalShadows=b,y.numPointShadows=A,y.numSpotShadows=x,y.numSpotMaps=E,y.numLightProbes=M,i.version=My++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Mh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Cy=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,wy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ry=[new H(1,0,0),new H(-1,0,0),new H(0,1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1)],Dy=[new H(0,-1,0),new H(0,-1,0),new H(0,0,1),new H(0,0,-1),new H(0,-1,0),new H(0,-1,0)],Ah=new Et,fr=new H,al=new H;function Ly(n,e,t){let i=new sf;const s=new Me,r=new Me,a=new wt,o=new Gm,l=new Wm,c={},u=t.maxTextureSize,d={[Hi]:on,[on]:Hi,[Ht]:Ht},h=new Pn({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Me},radius:{value:4}},vertexShader:Cy,fragmentShader:wy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new In(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new zt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Ua;let g=this.type;this.render=function(S,M,y){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===e0&&(Ke("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Ua);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const O=g!==this.type;O&&M.traverse(function(k){k.material&&(Array.isArray(k.material)?k.material.forEach(U=>U.needsUpdate=!0):k.material.needsUpdate=!0)});for(let k=0,U=S.length;ku||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/Z.x),s.x=r.x*Z.x,F.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/Z.y),s.y=r.y*Z.y,F.mapSize.y=r.y));const R=n.state.buffers.depth.getReversed();if(F.camera._reversedDepth=R,F.map===null||O===!0){if(F.map!==null&&(F.map.depthTexture!==null&&(F.map.depthTexture.dispose(),F.map.depthTexture=null),F.map.dispose()),this.type===gr){if($.isPointLight){Ke("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}F.map=new ei(s.x,s.y,{format:rs,type:_i,minFilter:Wt,magFilter:Wt,generateMipmaps:!1}),F.map.texture.name=$.name+".shadowMap",F.map.depthTexture=new Xs(s.x,s.y,Ln),F.map.depthTexture.name=$.name+".shadowMapDepth",F.map.depthTexture.format=xi,F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Ot,F.map.depthTexture.magFilter=Ot}else $.isPointLight?(F.map=new Sf(s.x),F.map.depthTexture=new rm(s.x,ni)):(F.map=new ei(s.x,s.y),F.map.depthTexture=new Xs(s.x,s.y,ni)),F.map.depthTexture.name=$.name+".shadowMap",F.map.depthTexture.format=xi,this.type===Ua?(F.map.depthTexture.compareFunction=R?Fc:kc,F.map.depthTexture.minFilter=Wt,F.map.depthTexture.magFilter=Wt):(F.map.depthTexture.compareFunction=null,F.map.depthTexture.minFilter=Ot,F.map.depthTexture.magFilter=Ot);F.camera.updateProjectionMatrix()}const re=F.map.isWebGLCubeRenderTarget?6:1;for(let se=0;se0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,O=M.uuid;let k=c[w];k===void 0&&(k={},c[w]=k);let U=k[O];U===void 0&&(U=I.clone(),k[O]=U,M.addEventListener("dispose",E)),I=U}if(I.visible=M.visible,I.wireframe=M.wireframe,T===gr?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,y.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=y}return I}function x(S,M,y,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===gr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(y.matrixWorldInverse,S.matrixWorld);const O=e.update(S),k=S.material;if(Array.isArray(k)){const U=O.groups;for(let $=0,F=U.length;$=1):R.indexOf("OpenGL ES")!==-1&&(Z=parseFloat(/^OpenGL ES (\d)/.exec(R)[1]),F=Z>=2);let re=null,se={};const ae=n.getParameter(n.SCISSOR_BOX),ge=n.getParameter(n.VIEWPORT),he=new wt().fromArray(ae),oe=new wt().fromArray(ge);function G(V,_e,ue,ye){const Te=new Uint8Array(4),fe=n.createTexture();n.bindTexture(V,fe),n.texParameteri(V,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(V,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let He=0;He"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Me,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(P,v){return p?new OffscreenCanvas(P,v):$a("canvas")}function m(P,v,B){let Y=1;const N=z(P);if((N.width>B||N.height>B)&&(Y=B/Math.max(N.width,N.height)),Y<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){const J=Math.floor(Y*N.width),ie=Math.floor(Y*N.height);h===void 0&&(h=_(J,ie));const X=v?_(J,ie):h;return X.width=J,X.height=ie,X.getContext("2d").drawImage(P,0,0,J,ie),Ke("WebGLRenderer: Texture has been resized from ("+N.width+"x"+N.height+") to ("+J+"x"+ie+")."),X}else return"data"in P&&Ke("WebGLRenderer: Image in DataTexture is too big ("+N.width+"x"+N.height+")."),P;return P}function g(P){return P.generateMipmaps}function b(P){n.generateMipmap(P)}function A(P){return P.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:P.isWebGL3DRenderTarget?n.TEXTURE_3D:P.isWebGLArrayRenderTarget||P.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function x(P,v,B,Y,N,J=!1){if(P!==null){if(n[P]!==void 0)return n[P];Ke("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+P+"'")}let ie;Y&&(ie=e.get("EXT_texture_norm16"),ie||Ke("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let X=v;if(v===n.RED&&(B===n.FLOAT&&(X=n.R32F),B===n.HALF_FLOAT&&(X=n.R16F),B===n.UNSIGNED_BYTE&&(X=n.R8),B===n.UNSIGNED_SHORT&&ie&&(X=ie.R16_EXT),B===n.SHORT&&ie&&(X=ie.R16_SNORM_EXT)),v===n.RED_INTEGER&&(B===n.UNSIGNED_BYTE&&(X=n.R8UI),B===n.UNSIGNED_SHORT&&(X=n.R16UI),B===n.UNSIGNED_INT&&(X=n.R32UI),B===n.BYTE&&(X=n.R8I),B===n.SHORT&&(X=n.R16I),B===n.INT&&(X=n.R32I)),v===n.RG&&(B===n.FLOAT&&(X=n.RG32F),B===n.HALF_FLOAT&&(X=n.RG16F),B===n.UNSIGNED_BYTE&&(X=n.RG8),B===n.UNSIGNED_SHORT&&ie&&(X=ie.RG16_EXT),B===n.SHORT&&ie&&(X=ie.RG16_SNORM_EXT)),v===n.RG_INTEGER&&(B===n.UNSIGNED_BYTE&&(X=n.RG8UI),B===n.UNSIGNED_SHORT&&(X=n.RG16UI),B===n.UNSIGNED_INT&&(X=n.RG32UI),B===n.BYTE&&(X=n.RG8I),B===n.SHORT&&(X=n.RG16I),B===n.INT&&(X=n.RG32I)),v===n.RGB_INTEGER&&(B===n.UNSIGNED_BYTE&&(X=n.RGB8UI),B===n.UNSIGNED_SHORT&&(X=n.RGB16UI),B===n.UNSIGNED_INT&&(X=n.RGB32UI),B===n.BYTE&&(X=n.RGB8I),B===n.SHORT&&(X=n.RGB16I),B===n.INT&&(X=n.RGB32I)),v===n.RGBA_INTEGER&&(B===n.UNSIGNED_BYTE&&(X=n.RGBA8UI),B===n.UNSIGNED_SHORT&&(X=n.RGBA16UI),B===n.UNSIGNED_INT&&(X=n.RGBA32UI),B===n.BYTE&&(X=n.RGBA8I),B===n.SHORT&&(X=n.RGBA16I),B===n.INT&&(X=n.RGBA32I)),v===n.RGB&&(B===n.UNSIGNED_SHORT&&ie&&(X=ie.RGB16_EXT),B===n.SHORT&&ie&&(X=ie.RGB16_SNORM_EXT),B===n.UNSIGNED_INT_5_9_9_9_REV&&(X=n.RGB9_E5),B===n.UNSIGNED_INT_10F_11F_11F_REV&&(X=n.R11F_G11F_B10F)),v===n.RGBA){const W=J?qa:it.getTransfer(N);B===n.FLOAT&&(X=n.RGBA32F),B===n.HALF_FLOAT&&(X=n.RGBA16F),B===n.UNSIGNED_BYTE&&(X=W===pt?n.SRGB8_ALPHA8:n.RGBA8),B===n.UNSIGNED_SHORT&&ie&&(X=ie.RGBA16_EXT),B===n.SHORT&&ie&&(X=ie.RGBA16_SNORM_EXT),B===n.UNSIGNED_SHORT_4_4_4_4&&(X=n.RGBA4),B===n.UNSIGNED_SHORT_5_5_5_1&&(X=n.RGB5_A1)}return(X===n.R16F||X===n.R32F||X===n.RG16F||X===n.RG32F||X===n.RGBA16F||X===n.RGBA32F)&&e.get("EXT_color_buffer_float"),X}function E(P,v){let B;return P?v===null||v===ni||v===Cr?B=n.DEPTH24_STENCIL8:v===Ln?B=n.DEPTH32F_STENCIL8:v===Tr&&(B=n.DEPTH24_STENCIL8,Ke("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):v===null||v===ni||v===Cr?B=n.DEPTH_COMPONENT24:v===Ln?B=n.DEPTH_COMPONENT32F:v===Tr&&(B=n.DEPTH_COMPONENT16),B}function S(P,v){return g(P)===!0||P.isFramebufferTexture&&P.minFilter!==Ot&&P.minFilter!==Wt?Math.log2(Math.max(v.width,v.height))+1:P.mipmaps!==void 0&&P.mipmaps.length>0?P.mipmaps.length:P.isCompressedTexture&&Array.isArray(P.image)?v.mipmaps.length:1}function M(P){const v=P.target;v.removeEventListener("dispose",M),T(v),v.isVideoTexture&&u.delete(v),v.isHTMLTexture&&d.delete(v)}function y(P){const v=P.target;v.removeEventListener("dispose",y),L(v)}function T(P){const v=i.get(P);if(v.__webglInit===void 0)return;const B=P.source,Y=f.get(B);if(Y){const N=Y[v.__cacheKey];N.usedTimes--,N.usedTimes===0&&I(P),Object.keys(Y).length===0&&f.delete(B)}i.remove(P)}function I(P){const v=i.get(P);n.deleteTexture(v.__webglTexture);const B=P.source,Y=f.get(B);delete Y[v.__cacheKey],a.memory.textures--}function L(P){const v=i.get(P);if(P.depthTexture&&(P.depthTexture.dispose(),i.remove(P.depthTexture)),P.isWebGLCubeRenderTarget)for(let Y=0;Y<6;Y++){if(Array.isArray(v.__webglFramebuffer[Y]))for(let N=0;N=s.maxTextures&&Ke("WebGLTextures: Trying to use "+P+" texture units while this GPU supports only "+s.maxTextures),w+=1,P}function F(P){const v=[];return v.push(P.wrapS),v.push(P.wrapT),v.push(P.wrapR||0),v.push(P.magFilter),v.push(P.minFilter),v.push(P.anisotropy),v.push(P.internalFormat),v.push(P.format),v.push(P.type),v.push(P.generateMipmaps),v.push(P.premultiplyAlpha),v.push(P.flipY),v.push(P.unpackAlignment),v.push(P.colorSpace),v.join()}function Z(P,v){const B=i.get(P);if(P.isVideoTexture&&D(P),P.isRenderTargetTexture===!1&&P.isExternalTexture!==!0&&P.version>0&&B.__version!==P.version){const Y=P.image;if(Y===null)Ke("WebGLRenderer: Texture marked for update but no image data found.");else if(Y.complete===!1)Ke("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(B,P,v);return}}else P.isExternalTexture&&(B.__webglTexture=P.sourceTexture?P.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,B.__webglTexture,n.TEXTURE0+v)}function R(P,v){const B=i.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&B.__version!==P.version){xe(B,P,v);return}else P.isExternalTexture&&(B.__webglTexture=P.sourceTexture?P.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,B.__webglTexture,n.TEXTURE0+v)}function re(P,v){const B=i.get(P);if(P.isRenderTargetTexture===!1&&P.version>0&&B.__version!==P.version){xe(B,P,v);return}t.bindTexture(n.TEXTURE_3D,B.__webglTexture,n.TEXTURE0+v)}function se(P,v){const B=i.get(P);if(P.isCubeDepthTexture!==!0&&P.version>0&&B.__version!==P.version){be(B,P,v);return}t.bindTexture(n.TEXTURE_CUBE_MAP,B.__webglTexture,n.TEXTURE0+v)}const ae={[Pl]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Ul]:n.MIRRORED_REPEAT},ge={[Ot]:n.NEAREST,[S0]:n.NEAREST_MIPMAP_NEAREST,[Xr]:n.NEAREST_MIPMAP_LINEAR,[Wt]:n.LINEAR,[To]:n.LINEAR_MIPMAP_NEAREST,[Oi]:n.LINEAR_MIPMAP_LINEAR},he={[A0]:n.NEVER,[R0]:n.ALWAYS,[E0]:n.LESS,[kc]:n.LEQUAL,[T0]:n.EQUAL,[Fc]:n.GEQUAL,[C0]:n.GREATER,[w0]:n.NOTEQUAL};function oe(P,v){if(v.type===Ln&&e.has("OES_texture_float_linear")===!1&&(v.magFilter===Wt||v.magFilter===To||v.magFilter===Xr||v.magFilter===Oi||v.minFilter===Wt||v.minFilter===To||v.minFilter===Xr||v.minFilter===Oi)&&Ke("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(P,n.TEXTURE_WRAP_S,ae[v.wrapS]),n.texParameteri(P,n.TEXTURE_WRAP_T,ae[v.wrapT]),(P===n.TEXTURE_3D||P===n.TEXTURE_2D_ARRAY)&&n.texParameteri(P,n.TEXTURE_WRAP_R,ae[v.wrapR]),n.texParameteri(P,n.TEXTURE_MAG_FILTER,ge[v.magFilter]),n.texParameteri(P,n.TEXTURE_MIN_FILTER,ge[v.minFilter]),v.compareFunction&&(n.texParameteri(P,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(P,n.TEXTURE_COMPARE_FUNC,he[v.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(v.magFilter===Ot||v.minFilter!==Xr&&v.minFilter!==Oi||v.type===Ln&&e.has("OES_texture_float_linear")===!1)return;if(v.anisotropy>1||i.get(v).__currentAnisotropy){const B=e.get("EXT_texture_filter_anisotropic");n.texParameterf(P,B.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(v.anisotropy,s.getMaxAnisotropy())),i.get(v).__currentAnisotropy=v.anisotropy}}}function G(P,v){let B=!1;P.__webglInit===void 0&&(P.__webglInit=!0,v.addEventListener("dispose",M));const Y=v.source;let N=f.get(Y);N===void 0&&(N={},f.set(Y,N));const J=F(v);if(J!==P.__cacheKey){N[J]===void 0&&(N[J]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,B=!0),N[J].usedTimes++;const ie=N[P.__cacheKey];ie!==void 0&&(N[P.__cacheKey].usedTimes--,ie.usedTimes===0&&I(v)),P.__cacheKey=J,P.__webglTexture=N[J].texture}return B}function ne(P,v,B){return Math.floor(Math.floor(P/B)/v)}function j(P,v,B,Y){const J=P.updateRanges;if(J.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,v.width,v.height,B,Y,v.data);else{J.sort((le,de)=>le.start-de.start);let ie=0;for(let le=1;le0){we&&Ye&&t.texStorage2D(n.TEXTURE_2D,_e,de,Le[0].width,Le[0].height);for(let ue=0,ye=Le.length;ue0){const Te=th(pe.width,pe.height,v.format,v.type);for(const fe of v.layerUpdates){const He=pe.data.subarray(fe*Te/pe.data.BYTES_PER_ELEMENT,(fe+1)*Te/pe.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,fe,pe.width,pe.height,1,ce,He)}v.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,pe.width,pe.height,W.depth,ce,pe.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,de,pe.width,pe.height,W.depth,0,pe.data,0,0);else Ke("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?V&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,pe.width,pe.height,W.depth,ce,le,pe.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,de,pe.width,pe.height,W.depth,0,ce,le,pe.data)}else{we&&Ye&&t.texStorage2D(n.TEXTURE_2D,_e,de,Le[0].width,Le[0].height);for(let ue=0,ye=Le.length;ue0){const ue=th(W.width,W.height,v.format,v.type);for(const ye of v.layerUpdates){const Te=W.data.subarray(ye*ue/W.data.BYTES_PER_ELEMENT,(ye+1)*ue/W.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ye,W.width,W.height,1,ce,le,Te)}v.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,W.width,W.height,W.depth,ce,le,W.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,de,W.width,W.height,W.depth,0,ce,le,W.data);else if(v.isData3DTexture)we?(Ye&&t.texStorage3D(n.TEXTURE_3D,_e,de,W.width,W.height,W.depth),V&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,W.width,W.height,W.depth,ce,le,W.data)):t.texImage3D(n.TEXTURE_3D,0,de,W.width,W.height,W.depth,0,ce,le,W.data);else if(v.isFramebufferTexture){if(Ye)if(we)t.texStorage2D(n.TEXTURE_2D,_e,de,W.width,W.height);else{let ue=W.width,ye=W.height;for(let Te=0;Te<_e;Te++)t.texImage2D(n.TEXTURE_2D,Te,de,ue,ye,0,ce,le,null),ue>>=1,ye>>=1}}else if(v.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),W.parentNode!==ue){ue.appendChild(W),d.add(v),ue.onpaint=ye=>{const Te=ye.changedElements;for(const fe of d)Te.includes(fe.image)&&(fe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,W);else{const Te=n.RGBA,fe=n.RGBA,He=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Te,fe,He,W)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(Le.length>0){if(we&&Ye){const ue=z(Le[0]);t.texStorage2D(n.TEXTURE_2D,_e,de,ue.width,ue.height)}for(let ue=0,ye=Le.length;ue0&&ye++;const fe=z(de[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ye,Ye,fe.width,fe.height)}for(let fe=0;fe<6;fe++)if(le){V?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,0,0,de[fe].width,de[fe].height,Le,we,de[fe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+fe,0,Ye,de[fe].width,de[fe].height,0,Le,we,de[fe].data);for(let He=0;He>J),pe=Math.max(1,v.height>>J);N===n.TEXTURE_3D||N===n.TEXTURE_2D_ARRAY?t.texImage3D(N,J,W,de,pe,v.depth,0,ie,X,null):t.texImage2D(N,J,W,de,pe,0,ie,X,null)}t.bindFramebuffer(n.FRAMEBUFFER,P),dt(v)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,Y,N,le.__webglTexture,0,ht(v)):(N===n.TEXTURE_2D||N>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&N<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,Y,N,le.__webglTexture,J),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(P,v,B){if(n.bindRenderbuffer(n.RENDERBUFFER,P),v.depthBuffer){const Y=v.depthTexture,N=Y&&Y.isDepthTexture?Y.type:null,J=E(v.stencilBuffer,N),ie=v.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;dt(v)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ht(v),J,v.width,v.height):B?n.renderbufferStorageMultisample(n.RENDERBUFFER,ht(v),J,v.width,v.height):n.renderbufferStorage(n.RENDERBUFFER,J,v.width,v.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,ie,n.RENDERBUFFER,P)}else{const Y=v.textures;for(let N=0;N{delete v.__boundDepthTexture,delete v.__depthDisposeCallback,Y.removeEventListener("dispose",N)};Y.addEventListener("dispose",N),v.__depthDisposeCallback=N}v.__boundDepthTexture=Y}if(P.depthTexture&&!v.__autoAllocateDepthBuffer)if(B)for(let Y=0;Y<6;Y++)Ve(v.__webglFramebuffer[Y],P,Y);else{const Y=P.texture.mipmaps;Y&&Y.length>0?Ve(v.__webglFramebuffer[0],P,0):Ve(v.__webglFramebuffer,P,0)}else if(B){v.__webglDepthbuffer=[];for(let Y=0;Y<6;Y++)if(t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[Y]),v.__webglDepthbuffer[Y]===void 0)v.__webglDepthbuffer[Y]=n.createRenderbuffer(),Be(v.__webglDepthbuffer[Y],P,!1);else{const N=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,J=v.__webglDepthbuffer[Y];n.bindRenderbuffer(n.RENDERBUFFER,J),n.framebufferRenderbuffer(n.FRAMEBUFFER,N,n.RENDERBUFFER,J)}}else{const Y=P.texture.mipmaps;if(Y&&Y.length>0?t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,v.__webglFramebuffer),v.__webglDepthbuffer===void 0)v.__webglDepthbuffer=n.createRenderbuffer(),Be(v.__webglDepthbuffer,P,!1);else{const N=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,J=v.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,J),n.framebufferRenderbuffer(n.FRAMEBUFFER,N,n.RENDERBUFFER,J)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function ke(P,v,B){const Y=i.get(P);v!==void 0&&ve(Y.__webglFramebuffer,P,P.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),B!==void 0&&Ne(P)}function Xe(P){const v=P.texture,B=i.get(P),Y=i.get(v);P.addEventListener("dispose",y);const N=P.textures,J=P.isWebGLCubeRenderTarget===!0,ie=N.length>1;if(ie||(Y.__webglTexture===void 0&&(Y.__webglTexture=n.createTexture()),Y.__version=v.version,a.memory.textures++),J){B.__webglFramebuffer=[];for(let X=0;X<6;X++)if(v.mipmaps&&v.mipmaps.length>0){B.__webglFramebuffer[X]=[];for(let W=0;W0){B.__webglFramebuffer=[];for(let X=0;X0&&dt(P)===!1){B.__webglMultisampledFramebuffer=n.createFramebuffer(),B.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,B.__webglMultisampledFramebuffer);for(let X=0;X0)for(let W=0;W0)for(let W=0;W0){if(dt(P)===!1){const v=P.textures,B=P.width,Y=P.height;let N=n.COLOR_BUFFER_BIT;const J=P.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,ie=i.get(P),X=v.length>1;if(X)for(let ce=0;ce0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ie.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,ie.__webglFramebuffer);for(let ce=0;ce0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&v.__useRenderToTexture!==!1}function D(P){const v=a.render.frame;u.get(P)!==v&&(u.set(P,v),P.update())}function Ee(P,v){const B=P.colorSpace,Y=P.format,N=P.type;return P.isCompressedTexture===!0||P.isVideoTexture===!0||B!==Ka&&B!==ci&&(it.getTransfer(B)===pt?(Y!==Sn||N!==yn)&&Ke("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",B)),v}function z(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=$,this.resetTextureUnits=O,this.getTextureUnits=k,this.setTextureUnits=U,this.setTexture2D=Z,this.setTexture2DArray=R,this.setTexture3D=re,this.setTextureCube=se,this.rebindTextures=ke,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=vt,this.setupDepthRenderbuffer=Ne,this.setupFrameBufferTexture=ve,this.useMultisampledRTT=dt,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Uy(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===yn)return n.UNSIGNED_BYTE;if(i===Ic)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Pc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Wd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Xd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Vd)return n.BYTE;if(i===Gd)return n.SHORT;if(i===Tr)return n.UNSIGNED_SHORT;if(i===Lc)return n.INT;if(i===ni)return n.UNSIGNED_INT;if(i===Ln)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Yd)return n.ALPHA;if(i===Kd)return n.RGB;if(i===Sn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===ns)return n.DEPTH_STENCIL;if(i===qd)return n.RED;if(i===Uc)return n.RED_INTEGER;if(i===rs)return n.RG;if(i===Oc)return n.RG_INTEGER;if(i===Nc)return n.RGBA_INTEGER;if(i===Oa||i===Na||i===ka||i===Fa)if(a===pt)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Oa)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Na)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===ka)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Oa)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Na)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===ka)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Ol||i===Nl||i===kl||i===Fl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Ol)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Nl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===kl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Bl||i===Hl||i===zl||i===Vl||i===Gl||i===Xa||i===Wl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Bl||i===Hl)return a===pt?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===zl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Vl)return r.COMPRESSED_R11_EAC;if(i===Gl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Xa)return r.COMPRESSED_RG11_EAC;if(i===Wl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Xl||i===Yl||i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Xl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Yl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Kl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===ql)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Zl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===$l)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Jl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===jl)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===Ql)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===ec)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===tc)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===nc)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===ic)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===sc)return a===pt?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===rc||i===ac||i===oc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===rc)return a===pt?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===ac)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===oc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===lc||i===cc||i===Ya||i===uc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===lc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===cc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ya)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===uc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Cr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Oy=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Ny=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class ky{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new of(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new Pn({vertexShader:Oy,fragmentShader:Ny,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new zt(new is(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fy extends Wi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new ky,g={},b=t.getContextAttributes();let A=null,x=null;const E=[],S=[],M=new Me;let y=null;const T=new Dn;T.viewport=new wt;const I=new Dn;I.viewport=new wt;const L=[T,I],w=new Km;let O=null,k=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(G){let ne=E[G];return ne===void 0&&(ne=new Po,E[G]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(G){let ne=E[G];return ne===void 0&&(ne=new Po,E[G]=ne),ne.getGripSpace()},this.getHand=function(G){let ne=E[G];return ne===void 0&&(ne=new Po,E[G]=ne),ne.getHandSpace()};function U(G){const ne=S.indexOf(G.inputSource);if(ne===-1)return;const j=E[ne];j!==void 0&&(j.update(G.inputSource,G.frame,c||a),j.dispatchEvent({type:G.type,data:G.inputSource}))}function $(){s.removeEventListener("select",U),s.removeEventListener("selectstart",U),s.removeEventListener("selectend",U),s.removeEventListener("squeeze",U),s.removeEventListener("squeezestart",U),s.removeEventListener("squeezeend",U),s.removeEventListener("end",$),s.removeEventListener("inputsourceschange",F);for(let G=0;G=0&&(S[xe]=null,E[xe].disconnect(j))}for(let ne=0;ne=S.length){S.push(j),xe=ve;break}else if(S[ve]===null){S[ve]=j,xe=ve;break}if(xe===-1)break}const be=E[xe];be&&be.connect(j)}}const Z=new H,R=new H;function re(G,ne,j){Z.setFromMatrixPosition(ne.matrixWorld),R.setFromMatrixPosition(j.matrixWorld);const xe=Z.distanceTo(R),be=ne.projectionMatrix.elements,ve=j.projectionMatrix.elements,Be=be[14]/(be[10]-1),Ve=be[14]/(be[10]+1),Ne=(be[9]+1)/be[5],ke=(be[9]-1)/be[5],Xe=(be[8]-1)/be[0],tt=(ve[8]+1)/ve[0],rt=Be*Xe,gt=Be*tt,vt=xe/(-Xe+tt),ht=vt*-Xe;if(ne.matrixWorld.decompose(G.position,G.quaternion,G.scale),G.translateX(ht),G.translateZ(vt),G.matrixWorld.compose(G.position,G.quaternion,G.scale),G.matrixWorldInverse.copy(G.matrixWorld).invert(),be[10]===-1)G.projectionMatrix.copy(ne.projectionMatrix),G.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const dt=Be+vt,D=Ve+vt,Ee=rt-ht,z=gt+(xe-ht),P=Ne*Ve/D*dt,v=ke*Ve/D*dt;G.projectionMatrix.makePerspective(Ee,z,P,v,dt,D),G.projectionMatrixInverse.copy(G.projectionMatrix).invert()}}function se(G,ne){ne===null?G.matrixWorld.copy(G.matrix):G.matrixWorld.multiplyMatrices(ne.matrixWorld,G.matrix),G.matrixWorldInverse.copy(G.matrixWorld).invert()}this.updateCamera=function(G){if(s===null)return;let ne=G.near,j=G.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(j=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=j,(O!==w.near||k!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),O=w.near,k=w.far),w.layers.mask=G.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=G.parent,be=w.cameras;se(w,xe);for(let ve=0;ve0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),A=b.envMap,x=b.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(By.makeRotationFromEuler(x)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Tf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,A){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=A*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===on&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function zy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(x,E){const S=E.program;i.uniformBlockBinding(x,S)}function c(x,E){let S=s[x.id];S===void 0&&(m(x),S=u(x),s[x.id]=S,x.addEventListener("dispose",b));const M=E.program;i.updateUBOMapping(x,M);const y=e.render.frame;r[x.id]!==y&&(h(x),r[x.id]=y)}function u(x){const E=d();x.__bindingPointIndex=E;const S=n.createBuffer(),M=x.__size,y=x.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,y),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,E,S),S}function d(){for(let x=0;x0&&(S+=M-y),x.__size=S,x.__cache={},this}function g(x){const E={boundary:0,storage:0};return typeof x=="number"||typeof x=="boolean"?(E.boundary=4,E.storage=4):x.isVector2?(E.boundary=8,E.storage=8):x.isVector3||x.isColor?(E.boundary=16,E.storage=12):x.isVector4?(E.boundary=16,E.storage=16):x.isMatrix3?(E.boundary=48,E.storage=48):x.isMatrix4?(E.boundary=64,E.storage=64):x.isTexture?Ke("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(x)?(E.boundary=16,E.storage=x.byteLength):Ke("WebGLRenderer: Unsupported uniform value type.",x),E}function b(x){const E=x.target;E.removeEventListener("dispose",b);const S=a.indexOf(E.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[E.id]),delete s[E.id],delete r[E.id]}function A(){for(const x in s)n.deleteBuffer(s[x]);a=[],s={},r={}}return{bind:l,update:c,dispose:A}}const Vy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let Gn=null;function Gy(){return Gn===null&&(Gn=new nf(Vy,16,16,rs,_i),Gn.name="DFG_LUT",Gn.minFilter=Wt,Gn.magFilter=Wt,Gn.wrapS=ui,Gn.wrapT=ui,Gn.generateMipmaps=!1,Gn.needsUpdate=!0),Gn}class Wy{constructor(e={}){const{canvas:t=L0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=yn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([Nc,Oc,Uc]),g=new Set([yn,ni,Tr,Cr,Ic,Pc]),b=new Uint32Array(4),A=new Int32Array(4),x=new H;let E=null,S=null;const M=[],y=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Qn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,O=null,k=null,U=null;this._outputColorSpace=dn;let $=0,F=0,Z=null,R=-1,re=null;const se=new wt,ae=new wt;let ge=null;const he=new et(0);let oe=0,G=t.width,ne=t.height,j=1,xe=null,be=null;const ve=new wt(0,0,G,ne),Be=new wt(0,0,G,ne);let Ve=!1;const Ne=new sf;let ke=!1,Xe=!1;const tt=new Et,rt=new H,gt=new wt,vt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ht=!1;function dt(){return Z===null?j:1}let D=i;function Ee(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Dc}`),t.addEventListener("webglcontextlost",ot,!1),t.addEventListener("webglcontextrestored",ct,!1),t.addEventListener("webglcontextcreationerror",Mn,!1),D===null){const K="webgl2";if(D=Ee(K,C),D===null)throw Ee(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let z,P,v,B,Y,N,J,ie,X,W,ce,le,de,pe,Le,we,Ye,V,_e,ue,ye,Te,fe;function He(){z=new Gx(D),z.init(),ye=new Uy(D,z),P=new Ox(D,z,e,ye),v=new Iy(D,z),P.reversedDepthBuffer&&h&&v.buffers.depth.setReversed(!0),O=D.createFramebuffer(),k=D.createFramebuffer(),U=D.createFramebuffer(),B=new Yx(D),Y=new xy,N=new Py(D,z,v,Y,P,ye,B),J=new Vx(I),ie=new $m(D),Te=new Px(D,ie),X=new Wx(D,ie,B,Te),W=new qx(D,X,ie,Te,B),V=new Kx(D,P,N),Le=new Nx(Y),ce=new _y(I,J,z,P,Te,Le),le=new Hy(I,Y),de=new vy,pe=new Ty(z),Ye=new Ix(I,J,v,W,p,l),we=new Ly(I,W,P),fe=new zy(D,B,P,v),_e=new Ux(D,z,B),ue=new Xx(D,z,B),B.programs=ce.programs,I.capabilities=P,I.extensions=z,I.properties=Y,I.renderLists=de,I.shadowMap=we,I.state=v,I.info=B}He(),_!==yn&&(T=new $x(_,t.width,t.height,o,s,r));const Ue=new Fy(I,D);this.xr=Ue,this.getContext=function(){return D},this.getContextAttributes=function(){return D.getContextAttributes()},this.forceContextLoss=function(){const C=z.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=z.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return j},this.setPixelRatio=function(C){C!==void 0&&(j=C,this.setSize(G,ne,!1))},this.getSize=function(C){return C.set(G,ne)},this.setSize=function(C,K,te=!0){if(Ue.isPresenting){Ke("WebGLRenderer: Can't change size while VR device is presenting.");return}G=C,ne=K,t.width=Math.floor(C*j),t.height=Math.floor(K*j),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(G*j,ne*j).floor()},this.setDrawingBufferSize=function(C,K,te){G=C,ne=K,j=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===yn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(Q.forEach(function(Pe){Y.get(Pe).currentProgram.isReady()&&Q.delete(Pe)}),Q.size===0){ee(C);return}setTimeout(De,10)}z.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let Fn=null;function Wr(C){Fn&&Fn(C)}function Xi(){Bn.stop()}function ir(){Bn.start()}const Bn=new yf;Bn.setAnimationLoop(Wr),typeof self<"u"&&Bn.setContext(self),this.setAnimationLoop=function(C){Fn=C,Ue.setAnimationLoop(C),C===null?Bn.stop():Bn.start()},Ue.addEventListener("sessionstart",Xi),Ue.addEventListener("sessionend",ir),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ue.enabled===!0&&Ue.isPresenting===!0,Q=T!==null&&(Z===null||te)&&T.begin(I,Z);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ue.enabled===!0&&Ue.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ue.cameraAutoUpdate===!0&&Ue.updateCamera(K),K=Ue.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,Z),S=pe.get(C,y.length),S.init(K),S.state.textureUnits=N.getTextureUnits(),y.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ne.setFromProjectionMatrix(tt,Jn,K.reversedDepth),Xe=this.localClippingEnabled,ke=Le.init(this.clippingPlanes,Xe),E=de.get(C,M.length),E.init(),M.push(E),Ue.enabled===!0&&Ue.isPresenting===!0){const Pe=I.xr.getDepthSensingMesh();Pe!==null&&mn(Pe,K,-1/0,I.sortObjects)}mn(C,K,0,I.sortObjects),E.finish(),I.sortObjects===!0&&E.sort(xe,be,K.reversedDepth),ht=Ue.enabled===!1||Ue.isPresenting===!1||Ue.hasDepthSensing()===!1,ht&&Ye.addToRenderList(E,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),ke===!0&&Le.beginShadows();const ee=S.state.shadowsArray;if(we.render(ee,C,K),ke===!0&&Le.endShadows(),(Q&&T.hasRenderPass())===!1){const Pe=E.opaque,Re=E.transmissive;if(S.setupLights(),K.isArrayCamera){const ze=K.cameras;if(Re.length>0)for(let Ge=0,$e=ze.length;Ge<$e;Ge++){const je=ze[Ge];sn(Pe,Re,C,je)}ht&&Ye.render(C);for(let Ge=0,$e=ze.length;Ge<$e;Ge++){const je=ze[Ge];An(E,C,je,je.viewport)}}else Re.length>0&&sn(Pe,Re,C,K),ht&&Ye.render(C),An(E,C,K)}Z!==null&&F===0&&(N.updateMultisampleRenderTarget(Z),N.updateRenderTargetMipmap(Z)),Q&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Te.resetDefaultState(),R=-1,re=null,y.pop(),y.length>0?(S=y[y.length-1],N.setTextureUnits(S.state.textureUnits),ke===!0&&Le.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?E=M[M.length-1]:E=null,w!==null&&w.renderEnd()};function mn(C,K,te,Q){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ne.intersectsSprite(C)){Q&>.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Pe=W.update(C),Re=C.material;Re.visible&&E.push(C,Pe,Re,te,gt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ne.intersectsObject(C))){const Pe=W.update(C),Re=C.material;if(Q&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),gt.copy(C.boundingSphere.center)):(Pe.boundingSphere===null&&Pe.computeBoundingSphere(),gt.copy(Pe.boundingSphere.center)),gt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const ze=Pe.groups;for(let Ge=0,$e=ze.length;Ge<$e;Ge++){const je=ze[Ge],We=Re[je.materialIndex];We&&We.visible&&E.push(C,Pe,We,te,gt.z,je)}}else Re.visible&&E.push(C,Pe,Re,te,gt.z,null)}}const De=C.children;for(let Pe=0,Re=De.length;Pe0&&yi(ee,K,te),De.length>0&&yi(De,K,te),Pe.length>0&&yi(Pe,K,te),v.buffers.depth.setTest(!0),v.buffers.depth.setMask(!0),v.buffers.color.setMask(!0),v.setPolygonOffset(!1)}function sn(C,K,te,Q){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[Q.id]===void 0){const We=z.has("EXT_color_buffer_half_float")||z.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[Q.id]=new ei(1,1,{generateMipmaps:!0,type:We?_i:yn,minFilter:Oi,samples:Math.max(4,P.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[Q.id],Pe=Q.viewport||se;De.setSize(Pe.z*I.transmissionResolutionScale,Pe.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),ze=I.getActiveCubeFace(),Ge=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(he),oe=I.getClearAlpha(),oe<1&&I.setClearColor(16777215,.5),I.clear(),ht&&Ye.render(te);const $e=I.toneMapping;I.toneMapping=Qn;const je=Q.viewport;if(Q.viewport!==void 0&&(Q.viewport=void 0),S.setupLightsView(Q),ke===!0&&Le.setGlobalState(I.clippingPlanes,Q),yi(C,te,Q),N.updateMultisampleRenderTarget(De),N.updateRenderTargetMipmap(De),z.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let _t=0,Dt=K.length;_t0,Q.currentProgram=je,Q.uniformsList=null,je}function gn(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Ha.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function Hn(C,K){const te=Y.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function En(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;x.setFromMatrixPosition(K.matrixWorld);for(let te=0,Q=C.length;te0),We=!!te.morphAttributes.position,_t=!!te.morphAttributes.normal,Dt=!!te.morphAttributes.color;let Tt=Qn;Q.toneMapped&&(Z===null||Z.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const St=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Yt=St!==void 0?St.length:0,Ie=Y.get(Q),cn=S.state.lights;if(ke===!0&&(Xe===!0||C!==re)){const Mt=C===re&&Q.id===R;Le.setState(Q,C,Mt)}let lt=!1;Q.version===Ie.__version?(Ie.needsLights&&Ie.lightsStateVersion!==cn.state.version||Ie.outputColorSpace!==Re||ee.isBatchedMesh&&Ie.batching===!1||!ee.isBatchedMesh&&Ie.batching===!0||ee.isBatchedMesh&&Ie.batchingColor===!0&&ee.colorTexture===null||ee.isBatchedMesh&&Ie.batchingColor===!1&&ee.colorTexture!==null||ee.isInstancedMesh&&Ie.instancing===!1||!ee.isInstancedMesh&&Ie.instancing===!0||ee.isSkinnedMesh&&Ie.skinning===!1||!ee.isSkinnedMesh&&Ie.skinning===!0||ee.isInstancedMesh&&Ie.instancingColor===!0&&ee.instanceColor===null||ee.isInstancedMesh&&Ie.instancingColor===!1&&ee.instanceColor!==null||ee.isInstancedMesh&&Ie.instancingMorph===!0&&ee.morphTexture===null||ee.isInstancedMesh&&Ie.instancingMorph===!1&&ee.morphTexture!==null||Ie.envMap!==Ge||Q.fog===!0&&Ie.fog!==De||Ie.numClippingPlanes!==void 0&&(Ie.numClippingPlanes!==Le.numPlanes||Ie.numIntersection!==Le.numIntersection)||Ie.vertexAlphas!==$e||Ie.vertexTangents!==je||Ie.morphTargets!==We||Ie.morphNormals!==_t||Ie.morphColors!==Dt||Ie.toneMapping!==Tt||Ie.morphTargetsCount!==Yt||!!Ie.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(lt=!0):(lt=!0,Ie.__version=Q.version);let _n=Ie.currentProgram;lt===!0&&(_n=vi(Q,K,ee),w&&Q.isNodeMaterial&&w.onUpdateProgram(Q,_n,Ie));let zn=!1,Si=!1,ps=!1;const bt=_n.getUniforms(),Lt=Ie.uniforms;if(v.useProgram(_n.program)&&(zn=!0,Si=!0,ps=!0),Q.id!==R&&(R=Q.id,Si=!0),Ie.needsLights){const Mt=En(S.state.lightProbeGridArray,ee);Ie.lightProbeGrid!==Mt&&(Ie.lightProbeGrid=Mt,Si=!0)}if(zn||re!==C){v.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),bt.setValue(D,"projectionMatrix",C.projectionMatrix),bt.setValue(D,"viewMatrix",C.matrixWorldInverse);const Mi=bt.map.cameraPosition;Mi!==void 0&&Mi.setValue(D,rt.setFromMatrixPosition(C.matrixWorld)),P.logarithmicDepthBuffer&&bt.setValue(D,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(Q.isMeshPhongMaterial||Q.isMeshToonMaterial||Q.isMeshLambertMaterial||Q.isMeshBasicMaterial||Q.isMeshStandardMaterial||Q.isShaderMaterial)&&bt.setValue(D,"isOrthographic",C.isOrthographicCamera===!0),re!==C&&(re=C,Si=!0,ps=!0)}if(Ie.needsLights&&(cn.state.directionalShadowMap.length>0&&bt.setValue(D,"directionalShadowMap",cn.state.directionalShadowMap,N),cn.state.spotShadowMap.length>0&&bt.setValue(D,"spotShadowMap",cn.state.spotShadowMap,N),cn.state.pointShadowMap.length>0&&bt.setValue(D,"pointShadowMap",cn.state.pointShadowMap,N)),ee.isSkinnedMesh){bt.setOptional(D,ee,"bindMatrix"),bt.setOptional(D,ee,"bindMatrixInverse");const Mt=ee.skeleton;Mt&&(Mt.boneTexture===null&&Mt.computeBoneTexture(),bt.setValue(D,"boneTexture",Mt.boneTexture,N))}ee.isBatchedMesh&&(bt.setOptional(D,ee,"batchingTexture"),bt.setValue(D,"batchingTexture",ee._matricesTexture,N),bt.setOptional(D,ee,"batchingIdTexture"),bt.setValue(D,"batchingIdTexture",ee._indirectTexture,N),bt.setOptional(D,ee,"batchingColorTexture"),ee._colorsTexture!==null&&bt.setValue(D,"batchingColorTexture",ee._colorsTexture,N));const bi=te.morphAttributes;if((bi.position!==void 0||bi.normal!==void 0||bi.color!==void 0)&&V.update(ee,te,_n),(Si||Ie.receiveShadow!==ee.receiveShadow)&&(Ie.receiveShadow=ee.receiveShadow,bt.setValue(D,"receiveShadow",ee.receiveShadow)),(Q.isMeshStandardMaterial||Q.isMeshLambertMaterial||Q.isMeshPhongMaterial)&&Q.envMap===null&&K.environment!==null&&(Lt.envMapIntensity.value=K.environmentIntensity),Lt.dfgLUT!==void 0&&(Lt.dfgLUT.value=Gy()),Si){if(bt.setValue(D,"toneMappingExposure",I.toneMappingExposure),Ie.needsLights&&qp(Lt,ps),De&&Q.fog===!0&&le.refreshFogUniforms(Lt,De),le.refreshMaterialUniforms(Lt,Q,j,ne,S.state.transmissionRenderTarget[C.id]),Ie.needsLights&&Ie.lightProbeGrid){const Mt=Ie.lightProbeGrid;Lt.probesSH.value=Mt.texture,Lt.probesMin.value.copy(Mt.boundingBox.min),Lt.probesMax.value.copy(Mt.boundingBox.max),Lt.probesResolution.value.copy(Mt.resolution)}Ha.upload(D,gn(Ie),Lt,N)}if(Q.isShaderMaterial&&Q.uniformsNeedUpdate===!0&&(Ha.upload(D,gn(Ie),Lt,N),Q.uniformsNeedUpdate=!1),Q.isSpriteMaterial&&bt.setValue(D,"center",ee.center),bt.setValue(D,"modelViewMatrix",ee.modelViewMatrix),bt.setValue(D,"normalMatrix",ee.normalMatrix),bt.setValue(D,"modelMatrix",ee.matrixWorld),Q.uniformsGroups!==void 0){const Mt=Q.uniformsGroups;for(let Mi=0,ms=Mt.length;Mi0&&N.useMultisampledRTT(C)===!1?Q=Y.get(C).__webglMultisampledFramebuffer:Array.isArray(Ge)?Q=Ge[te]:Q=Ge,se.copy(C.viewport),ae.copy(C.scissor),ge=C.scissorTest}else se.copy(ve).multiplyScalar(j).floor(),ae.copy(Be).multiplyScalar(j).floor(),ge=Ve;if(te!==0&&(Q=O),v.bindFramebuffer(D.FRAMEBUFFER,Q)&&v.drawBuffers(C,Q),v.viewport(se),v.scissor(ae),v.setScissorTest(ge),ee){const Re=Y.get(C.texture);D.framebufferTexture2D(D.FRAMEBUFFER,D.COLOR_ATTACHMENT0,D.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let ze=0;ze1&&D.readBuffer(D.COLOR_ATTACHMENT0+Re),!P.textureFormatReadable($e)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!P.textureTypeReadable(je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-Q&&te>=0&&te<=C.height-ee&&D.readPixels(K,te,Q,ee,ye.convert($e),ye.convert(je),De)}finally{const Ge=Z!==null?Y.get(Z).__webglFramebuffer:null;v.bindFramebuffer(D.FRAMEBUFFER,Ge)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,Q,ee,De,Pe,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let ze=Y.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Pe!==void 0&&(ze=ze[Pe]),ze)if(K>=0&&K<=C.width-Q&&te>=0&&te<=C.height-ee){v.bindFramebuffer(D.FRAMEBUFFER,ze);const Ge=C.textures[Re],$e=Ge.format,je=Ge.type;if(C.textures.length>1&&D.readBuffer(D.COLOR_ATTACHMENT0+Re),!P.textureFormatReadable($e))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!P.textureTypeReadable(je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=D.createBuffer();D.bindBuffer(D.PIXEL_PACK_BUFFER,We),D.bufferData(D.PIXEL_PACK_BUFFER,De.byteLength,D.STREAM_READ),D.readPixels(K,te,Q,ee,ye.convert($e),ye.convert(je),0);const _t=Z!==null?Y.get(Z).__webglFramebuffer:null;v.bindFramebuffer(D.FRAMEBUFFER,_t);const Dt=D.fenceSync(D.SYNC_GPU_COMMANDS_COMPLETE,0);return D.flush(),await I0(D,Dt,4),D.bindBuffer(D.PIXEL_PACK_BUFFER,We),D.getBufferSubData(D.PIXEL_PACK_BUFFER,0,De),D.deleteBuffer(We),D.deleteSync(Dt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const Q=Math.pow(2,-te),ee=Math.floor(C.image.width*Q),De=Math.floor(C.image.height*Q),Pe=K!==null?K.x:0,Re=K!==null?K.y:0;N.setTexture2D(C,0),D.copyTexSubImage2D(D.TEXTURE_2D,te,0,0,Pe,Re,ee,De),v.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,Q=null,ee=0,De=0){let Pe,Re,ze,Ge,$e,je,We,_t,Dt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Pe=te.max.x-te.min.x,Re=te.max.y-te.min.y,ze=te.isBox3?te.max.z-te.min.z:1,Ge=te.min.x,$e=te.min.y,je=te.isBox3?te.min.z:0;else{const Lt=Math.pow(2,-ee);Pe=Math.floor(Tt.width*Lt),Re=Math.floor(Tt.height*Lt),C.isDataArrayTexture?ze=Tt.depth:C.isData3DTexture?ze=Math.floor(Tt.depth*Lt):ze=1,Ge=0,$e=0,je=0}Q!==null?(We=Q.x,_t=Q.y,Dt=Q.z):(We=0,_t=0,Dt=0);const St=ye.convert(K.format),Yt=ye.convert(K.type);let Ie;K.isData3DTexture?(N.setTexture3D(K,0),Ie=D.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?(N.setTexture2DArray(K,0),Ie=D.TEXTURE_2D_ARRAY):(N.setTexture2D(K,0),Ie=D.TEXTURE_2D),v.activeTexture(D.TEXTURE0),v.pixelStorei(D.UNPACK_FLIP_Y_WEBGL,K.flipY),v.pixelStorei(D.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),v.pixelStorei(D.UNPACK_ALIGNMENT,K.unpackAlignment);const cn=v.getParameter(D.UNPACK_ROW_LENGTH),lt=v.getParameter(D.UNPACK_IMAGE_HEIGHT),_n=v.getParameter(D.UNPACK_SKIP_PIXELS),zn=v.getParameter(D.UNPACK_SKIP_ROWS),Si=v.getParameter(D.UNPACK_SKIP_IMAGES);v.pixelStorei(D.UNPACK_ROW_LENGTH,Tt.width),v.pixelStorei(D.UNPACK_IMAGE_HEIGHT,Tt.height),v.pixelStorei(D.UNPACK_SKIP_PIXELS,Ge),v.pixelStorei(D.UNPACK_SKIP_ROWS,$e),v.pixelStorei(D.UNPACK_SKIP_IMAGES,je);const ps=C.isDataArrayTexture||C.isData3DTexture,bt=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const Lt=Y.get(C),bi=Y.get(K),Mt=Y.get(Lt.__renderTarget),Mi=Y.get(bi.__renderTarget);v.bindFramebuffer(D.READ_FRAMEBUFFER,Mt.__webglFramebuffer),v.bindFramebuffer(D.DRAW_FRAMEBUFFER,Mi.__webglFramebuffer);for(let ms=0;msMath.PI&&(i-=rn),s<-Math.PI?s+=rn:s>Math.PI&&(s-=rn),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ut.setFromSpherical(this._spherical),Ut.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ut),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ut.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new H(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new H(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ut.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(ba.origin.copy(this.object.position),ba.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(ba.direction))ol||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ol||this._lastTargetPosition.distanceToSquared(this.target)>ol?(this.dispatchEvent(Eh),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?rn/60*this.autoRotateSpeed*e:rn/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ut.setFromMatrixColumn(t,0),Ut.multiplyScalar(-e),this._panOffset.add(Ut)}_panUp(e,t){this.screenSpacePanning===!0?Ut.setFromMatrixColumn(t,1):(Ut.setFromMatrixColumn(t,0),Ut.crossVectors(this.object.up,Ut)),Ut.multiplyScalar(e),this._panOffset.add(Ut)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ut.copy(s).sub(this.target);let r=Ut.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(rn*this._rotateDelta.x/t.clientHeight),this._rotateUp(rn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(rn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-rn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(rn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-rn*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(rn*this._rotateDelta.x/t.clientHeight),this._rotateUp(rn*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=ov[e%10];return rv(Math.floor(e/10)*15,t,i)}return 13226457}function Yc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function wf(n){return Yc(n.ownerHandle)}function lv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function cv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Mr(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=wf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=lv(o.name??"");if(!l)continue;const c=Yc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:cv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function uv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ll(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function qn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function yc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function mv(n,e,t){var i,s,r,a,o,l;for(i=qn(n,5,257),s=qn(n,5,1),r=qn(n,4,4),a=0;a<19;++a)Wn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return Rf;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Kc}function Of(n,e){var t=new hv(n,e),i,s,r;do{switch(i=pv(t),s=qn(t,2,0),s){case 0:r=gv(t);break;case 1:r=Rh(t,Df,Lf);break;case 2:mv(t,t.ltree,t.dtree),r=Rh(t,t.ltree,t.dtree);break;default:r=Rf}if(r!==Kc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};us.prototype.addX=function(n){this.addPoint(n,null)};us.prototype.addY=function(n){this.addPoint(null,n)};us.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const A=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=kf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=Ff(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Ft.fromSVG=function(n,e){return new Ft().fromSVG(n,e)};Ft.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Ft.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Ft.prototype.curveTo=Ft.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Ft.prototype.quadTo=Ft.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Ft.prototype.close=Ft.prototype.closePath=function(){this.commands.push({type:"Z"})};Ft.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Nf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Ft.prototype.getBoundingBox=function(){const n=new Nf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=Ff(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Ft;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};qe.BYTE=Nn(1);Se.CHAR=function(n){return[n.charCodeAt(0)]};qe.CHAR=Nn(1);Se.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};Se.USHORT=function(n){return[n>>8&255,n&255]};qe.USHORT=Nn(2);Se.SHORT=function(n){return n>=Lh&&(n=-(2*Lh-n)),[n>>8&255,n&255]};qe.SHORT=Nn(2);Se.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};qe.UINT24=Nn(3);Se.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};qe.ULONG=Nn(4);Se.LONG=function(n){return n>=Ih&&(n=-(2*Ih-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};qe.LONG=Nn(4);Se.FLOAT=function(n){if(n>vv||n>24&255,n>>16&255,n>>8&255,n&255]};qe.LONGDATETIME=Nn(8);Se.TAG=function(n){return Fe.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};qe.TAG=Nn(4);Se.Card8=Se.BYTE;qe.Card8=qe.BYTE;Se.Card16=Se.USHORT;qe.Card16=qe.USHORT;Se.OffSize=Se.BYTE;qe.OffSize=qe.BYTE;Se.SID=Se.USHORT;qe.SID=qe.USHORT;Se.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?Se.NUMBER16(n):Se.NUMBER32(n)};qe.NUMBER=function(n){return Se.NUMBER(n).length};Se.NUMBER16=function(n){return[28,n>>8&255,n&255]};qe.NUMBER16=Nn(3);Se.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};qe.NUMBER32=Nn(5);Se.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};qe.UTF16=function(n){return n.length*2};var to={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Zs.MACSTRING=function(n,e,t,i){const s=to[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};qe.MACSTRING=function(n,e){const t=Se.MACSTRING(n,e);return t!==void 0?t.length:0};function vc(n){return n>=-128&&n<=127}function bv(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}Se.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Mv(n,e,t):e=Av(n,e,t)}return t};Se.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let x,E;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const y=i.get(s);y.path,M=y.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,x=this.parsePackedDeltas(M),t==="gvar"&&(E=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return x===void 0&&S(),A==="deltasY"?E:x},set:function(M){x===void 0&&S(),A==="deltasY"?E=M:x=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Ae.Parser(t,i+s+14),o=new Ae.Parser(t,i+s+16+r*2),l=new Ae.Parser(t,i+s+16+r*4),c=new Ae.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Ae.getUShort(n,e+4+d*8),o=Ae.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Ae.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Ae.getULong(n,e+4+d*8+4),i=new Ae.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Ae.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Hv(t,u,a,o);else if(t.format===12||t.format===13)zv(t,u,t.format);else if(t.format===4)Vv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Gv(t,i),t}function Xv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Yv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Kv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&Fe.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function $f(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function Qc(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=$f(s.colorRecords[r]);return i==="bgra"?a:js(a,i)}function Rn(n){return("0"+parseInt(n).toString(16)).slice(-2)}function rS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=aS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return js(n,e)}function js(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=$f(n)}else typeof n!="object"&&(n=uo(n,"bgra"));let t=["hsl","hsla"].includes(e)?rS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Rn(n.r)}${Rn(n.g)}${Rn(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Rn(n.r)}${Rn(n.g)}${Rn(n.b)}${Rn(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return Jf(n);default:throw new Error("Unknown color format: "+e)}}var jf={parse:iS,make:sS,getPaletteColor:Qc,parseColor:uo,formatColor:js};function oS(n,e){let t=e||new qs;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",oS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new qs;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new qs;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function vo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});vo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Ae.getULong(n,e):Ae.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Ae.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Ae.getULong(n,e):Ae.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Ae.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Ae.getULong(t,i):Ae.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Ae.getByte(t,i+o);l=i+(a+1)*u+o}return Ae.getBytes(t,l+e[n],l+e[n+1])}function fS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function pS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return fS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function mS(n){const e={};for(let t=0;t1&&l===23){ES(a);continue}r.push([l,a]),a=[]}else a.push(pS(s,l))}return mS(r)}function Ar(n,e){return e<=390?e=za[e]:n?e=n[e-391]:e=void 0,e}function tu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Ae.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Ae.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Ae.getCard16(n,e+3),t.endOffset=e+8),t}var ep=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],_S=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],tp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],xS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],yS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function vS(n,e,t,i){const s=eu(n,e,n.byteLength,i);return tu(s,i>1?_S:ep,t)}function nu(n,e,t,i,s){const r=eu(n,e,t,s);return tu(r,s>1?xS:tp,i)}function SS(n,e,t){const i=eu(n,e,void 0,t);return tu(i,yS)}function bS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function np(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Ac(n,e,t,i,s){let r,a,o,l;const c=new qs,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,A,x=0,E=[],S,M=0;const y=n.tables.cff2||n.tables.cff;if(b=y.topDict._defaultWidthX,A=y.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(k){return Ac(n,e,t,i,k)}),n.isCIDFont||i>1){const k=y.topDict._fdSelect?y.topDict._fdSelect[e.index]:0,U=y.topDict._fdArray[k];m=U._subrs,g=U._subrsBias,i>1?(E=y.topDict._vstore.itemVariationStore,x=U._privateDict.vsindex):(b=U._defaultWidthX,A=U._nominalWidthX)}else m=y.topDict._subrs,g=y.topDict._subrsBias;const T=np(n,c);let I=b;function L(k,U){f&&T!==2&&c.closePath(),c.moveTo(k,U),f=!0}function w(){let k;k=(u.length&1)!==0,k&&!h&&(I=u.shift()+A),d+=u.length>>1,u.length=0,h=!0}function O(k){let U,$,F,Z,R,re,se,ae,ge,he,oe,G,ne=0;for(;ne1&&!h&&(I=u.shift()+A,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(R=u.pop()+g,re=m[R],re){if(M>=kh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,O(re),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ne=k[ne],ne+=1,Ne){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),se=o+u.shift(),ae=l+u.shift(),ge=se+u.shift(),he=ae+u.shift(),oe=ge+u.shift(),G=he+u.shift(),p=oe+u.shift(),_=G+u.shift(),u.shift(),c.curveTo(r,a,o,l,se,ae),c.curveTo(ge,he,oe,G,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),se=o+u.shift(),ae=l,ge=se+u.shift(),he=l,oe=ge+u.shift(),G=_,p=oe+u.shift(),c.curveTo(r,a,o,l,se,ae),c.curveTo(ge,he,oe,G,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),se=o+u.shift(),ae=l,ge=se+u.shift(),he=l,oe=ge+u.shift(),G=he+u.shift(),p=oe+u.shift(),c.curveTo(r,a,o,l,se,ae),c.curveTo(ge,he,oe,G,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),se=o+u.shift(),ae=l+u.shift(),ge=se+u.shift(),he=ae+u.shift(),oe=ge+u.shift(),G=he+u.shift(),Math.abs(oe-p)>Math.abs(G-_)?p=oe+u.shift():_=G+u.shift(),c.curveTo(r,a,o,l,se,ae),c.curveTo(ge,he,oe,G,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ne),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const ke=Mc[u.pop()],Xe=Mc[u.pop()],tt=u.pop(),rt=u.pop();if(ke&&Xe){e.isComposite=!0,e.components=[];const gt=n.cffEncoding.charset.indexOf(ke),vt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:vt,dx:0,dy:0}),e.components.push({glyphIndex:gt,dx:rt,dy:tt}),c.extend(n.glyphs.get(vt).path);const ht=n.glyphs.get(gt),dt=JSON.parse(JSON.stringify(ht.path.commands));for(let D=0;D0&&!h&&(I=u.shift()+A,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}x=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(E,x,s));var j=u.pop(),xe=S?S.length:E.itemVariationSubtables[x].regionIndexes.length,be=j*xe,ve=u.length-be,Be=ve-j;if(S)for(let ke=0;ke>3;break;case 21:u.length>2&&!h&&(I=u.shift()+A,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+A,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:U=k[ne],$=k[ne+1],u.push((U<<24|$<<16)>>16),ne+=2;break;case 29:if(R=u.pop()+n.gsubrsBias,re=n.gsubrs[R],re){if(M>=kh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,O(re),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ne<32?console.log("Glyph "+e.index+": unknown operator "+Ne):Ne<247?u.push(Ne-139):Ne<251?(U=k[ne],ne+=1,u.push((Ne-247)*256+U+108)):Ne<255?(U=k[ne],ne+=1,u.push(-(Ne-251)*256-U-108)):(U=k[ne],$=k[ne+1],F=k[ne+2],Z=k[ne+3],ne+=4,u.push((U<<24|$<<16|F<<8|Z)/65536))}}}return O(t),n.variation&&s&&(c.commands=c.commands.map(k=>{const U=Object.keys(k);for(let $=0;$=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Kn(n,r.endOffset,Ae.bytesToString),o=r.formatMajor>1?null:Kn(n,a.endOffset),l=r.formatMajor>1?null:Kn(n,o.endOffset,Ae.bytesToString),c=Kn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=ho(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Ae.getBytes(n,h,h+r.topDictLength);u=ul(n,0,[f],void 0,r.formatMajor)[0]}else{const h=ul(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Kn(n,e+h,null,r.formatMajor),_=bS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Fh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Kn(n,h),_=ul(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Fh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=nu(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Kn(n,p);t.subrs=_.objects,t.subrsBias=ho(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=hS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Kn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Zv:u.charset===1?h=$v:u.charset===2?h=Jv:h=MS(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Mc:u.encoding===1?f=jv:f=AS(n,e+u.encoding),t.cffEncoding=new Zf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new ti.GlyphSet(t),i.lowMemory)t._push=function(h){const f=dS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,ti.cffGlyphLoader(t,h,Ac,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+za.length:(t=za.length+e.length,e.push(n)),t}function CS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function wS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function $S(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Cc={parse:ZS,make:$S,unicodeRanges:Tc,getUnicodeRange:qS};function JS(n,e){const t={},i=new Ae.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=es.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=es.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var fp={parse:ib,make:sb};function rb(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function ab(n,e,t){const i={},s=new Ae.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=co(t,r),i}function ob(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&Fe.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&Fe.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Gh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Rb(n){let e=0;for(let t=0;tbe||l===void 0)&&be>0&&(l=be),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Rb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=rp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=ap.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=cp.make(n.glyphs.length),A=Cc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Gh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Gh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),x=op.make(n.glyphs),E=Yf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),y=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let j in n.names)I[j]=n.names[j];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},O=n.names.windows||{};for(const j in I){if(I[j]=I[j]||{},!I[j].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[j].uniqueID={en:`${xe}: ${y}`}}I[j].postScriptName||(I[j].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||O.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||O.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=O.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||O.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||O.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=O.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const k=[],U=Xf.make(I,k),$=k.length>0?lp.make(k):void 0,F=up.make(n),Z=Ec.make(n.glyphs,{version:n.getEnglishName("version"),fullName:y,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),R=n.metas&&Object.keys(n.metas).length>0?dp.make(n.metas):void 0,re=[m,g,b,A,U,E,F,Z,x];$&&re.push($);const se={gsub:hp,cpal:jf,colr:fp,stat:mp,avar:gp,cvar:_p,fvar:pp,gvar:xp,gasp:yp,svg:vp},ae={avar:[n.tables.fvar],fvar:[n.names]};for(let j in se){const xe=n.tables[j];if(xe){const be=se[j].make.call(n,xe,...ae[j]||[]);be&&re.push(be)}}R&&re.push(R);const ge=Sp(re),he=ge.encode(),oe=iu(he),G=ge.fields;let ne=!1;for(let j=0;j>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function bp(n,e){this.font=n,this.tableName=e}bp.prototype={searchTag:hl,binSearch:Wh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=hl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Xh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function Ob(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Nb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Mp(n){return n[0]===31&&n[1]===139&&n[2]===8}function kb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Of(n.subarray(t,i),new Uint8Array(r))}function Yh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Fb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function fn(n){So.call(this,n,"gsub")}function su(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=su(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});Fe.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};fn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=su(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});Fe.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};fn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),Fe.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;duo(e,"raw")):uo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return Qc(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=Ob(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Nb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Vb(n){return{template:Wb(n).then(Kb),images:new Map}}function Gb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=qb(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Wb=typeof DecompressionStream=="function"?Yb:Xb;function Xb(n){try{return Promise.resolve(new TextDecoder().decode(Mp(n)?kb(n):n))}catch(e){return Promise.reject(e)}}function Yb(n){if(Mp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Kb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function qb(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var dl=new WeakMap;function Kh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function Ep(n,e,t){const i=new Ae.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Va([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Va(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ru(e.points)}function $b(n,e,t,i){const s=new ti.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Va(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(Yh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},qh=1e6,fo=64,po=1e4,wp,ls,Rp,wc;function Dp(n){this.font=n,this.getCommands=function(e){return Cp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function t2(n){return n}function Lp(n){return Math.sign(n)*Math.round(Math.abs(n))}function n2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function i2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function s2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function r2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Ip=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},jn={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){jn.setRelative(n,n,(l+c)/2,i,!0);return}jn.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze(jn);Object.freeze(hi);function Br(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Br.prototype.distance=function(n,e,t,i){return this.x*jn.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Br.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Br.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Br.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Hr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?jn:n===0&&e===1?hi:new Br(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Pr=Object.freeze(new gi(0,0)),a2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function ki(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=jn,this.round=Lp}}Dp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){ki.prototype=a2,s=this._fpgmState=new ki("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{ls(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}ki.prototype=s,i=this._prepState=new ki("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Rp(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Rp=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(ki.prototype=e,!s)o=new ki("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,wc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;cqh)throw new Error("Hinting instructions exceeded maximum of "+qh);if(i=wp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function bo(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Zh(n,e){e.fv=e.pv=e.dpv=n}function $h(n,e){e.pv=e.dpv=n}function Jh(n,e){e.fv=n}function jh(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Hr(o,l)}function Qh(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Hr(o,l)}function o2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Hr(i,t)}function l2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Hr(i,t)}function c2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function u2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function h2(n){n.fv=n.pv}function d2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,A=d.y,x=h.x,E=h.y,S=(p-m)*(A-E)-(_-g)*(b-x),M=p*g-_*m,y=b*E-A*x;f.x=(M*(b-x)-y*(p-m))/S,f.y=(M*(A-E)-y*(_-g))/S}function f2(n){n.rp0=n.stack.pop()}function p2(n){n.rp1=n.stack.pop()}function m2(n){n.rp2=n.stack.pop()}function g2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||bo(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function _2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||bo(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function x2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||bo(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||bo(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){n.loop=n.stack.pop(),n.loop>po&&(n.loop=po)}function S2(n){n.round=Lp}function b2(n){n.round=i2}function M2(n){const e=n.stack.pop();n.minDis=e/64}function A2(n){Pp(n,!1)}function E2(n){const e=n.stack.pop();n.ip+=e-1}function T2(n){const e=n.stack.pop();n.cvCutIn=e/64}function C2(n){const e=n.stack;e.push(e[e.length-1])}function fl(n){n.stack.pop()}function w2(n){n.stack.length=0}function R2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function D2(n){const e=n.stack;e.push(e.length)}function L2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>po&&(i=po),++n.callDepth>fo)throw new Error("Hinting call depth exceeded maximum of "+fo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;afo)throw new Error("Hinting call depth exceeded maximum of "+fo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],ls(n),n.ip=t,n.prog=i,n.callDepth--}function P2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function U2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function O2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function ed(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Pr);n&&(a=e.round(a)),s.setRelative(i,Pr,a,r),s.touch(i),e.rp0=e.rp1=t}function td(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function J2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function j2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function eM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function tM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function nM(n){n.stack.pop()||Pp(n,!0)}function iM(n){}function sM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function rM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function aM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function pl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function oM(n){const t=n.stack.pop();n.deltaBase=t}function lM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function cM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function uM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function fM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function pM(n){const e=n.stack;let t=e.pop();e.push(-t)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function gM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function wa(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function _M(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function ml(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function xM(n){let e=n.stack.pop();n.round=Ip;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function yM(n){let e=n.stack.pop();n.round=Ip;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function vM(n){n.round=t2}function SM(n){n.round=s2}function bM(n){n.round=r2}function MM(n){n.stack.pop()}function cd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Hr(o,l)}function AM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function EM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function TM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function CM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function wM(n){n.stack.pop()}function RM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Di(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof tr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof tr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof tr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Mo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Mo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};nn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};nn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof au)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Mo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function OM(n,e){return Gi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function NM(n,e){let t=Gi(n,e.coverage);return t===-1?null:e.substitute[t]}function gl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Gi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};pn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};pn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>OM.apply(this,[i,e]);case"12":return i=>NM.apply(this,[i,e]);case"63":return i=>kM.apply(this,[i,e]);case"41":return i=>FM.apply(this,[i,e]);case"21":return i=>zM.apply(this,[i,e]);case"51":return i=>BM.apply(this,[i,e]);case"53":return i=>HM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};pn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};pn.prototype.getLookupSubtables=function(n){return n.subtables||null};pn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};pn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};pn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var VM=pn;function GM(n){const e=n.current,t=n.get(-1);return t===null&&Bi(e)||!Bi(t)&&Bi(e)}function WM(n){const e=n.get(1);return e===null||!Bi(e)}var XM={startCheck:GM,endCheck:WM};function YM(n){const e=n.current,t=n.get(-1);return(Bi(e)||Vi(e))&&!Bi(t)}function KM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Bi(e)&&!Vi(e)):{const t=UM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Bi(s)||Vi(s)),!i)return!0}break}default:return!1}}var qM={startCheck:YM,endCheck:KM};function ZM(n,e,t){e[t].setState(n.tag,n.substitution)}function $M(n,e,t){e[t].setState(n.tag,n.substitution)}function _l(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=Up(i),r=Vi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function e3(n){if(Up(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new nn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new nn(t,0)}function i3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=hd(t);for(let s=0;s1}function a3(n){return n.index===n.context.length-1}var o3={startCheck:r3,endCheck:a3};function dd(n,e){const t=n.map(i=>i.activeState.value);return new nn(t,0)}function l3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=dd(i);for(let r=0;ri.activeState.value);return new nn(t,0)}function f3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;si.activeState.value);return new nn(t,e||0)}function x3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=pd(t,0);for(let s=0;si.activeState.value);return new nn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=md(t,0);for(let s=0;si.activeState.value);return new nn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function A3(n){const e=n.current,t=n.get(1);return t===null&&Rc(e)||Rc(t)}function E3(n){const e=n.get(1);return e===null||!Rc(e)}var T3={startCheck:A3,endCheck:E3};function C3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var w3=C3;function bn(n){this.baseDir=n||"ltr",this.tokenizer=new PM,this.featuresTags={}}bn.prototype.setText=function(n){this.text=n};bn.prototype.contextChecks={ccmpReplacementCheck:o3,latinWordCheck:d3,arabicWordCheck:XM,arabicSentenceCheck:qM,thaiWordCheck:_3,unicodeVariationSequenceCheck:T3};function Ns(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function R3(){return Ns.call(this,"ccmpReplacement"),Ns.call(this,"latinWord"),Ns.call(this,"arabicWord"),Ns.call(this,"arabicSentence"),Ns.call(this,"thaiWord"),Ns.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function D3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};bn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new VM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=xl(n),this.names.macintosh=xl(n),this.names.windows=xl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new ti.GlyphSet(this,n.glyphs||[]),this.encoding=new Kf(this),this.position=new Ib(this),this.substitution=new Bb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new e2(this)),!0)}),this.palettes=new Ap(this),this.layers=new Hb(this),this.svgImages=new zb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new DM(this):null}})}mt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};mt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};mt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};mt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};mt.prototype.stringToGlyphIndexes=function(n,e){const t=new k3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};mt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};mt.prototype.toTables=function(){return Lb.fontToTable(this)};mt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};mt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(Y3)),s}var q3={parse:K3},On=new Array(10);On[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};Fe.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};On[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();Fe.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};On[3]=function(){return{error:"GPOS Lookup 3 not supported"}};On[4]=function(){return{error:"GPOS Lookup 4 not supported"}};On[5]=function(){return{error:"GPOS Lookup 5 not supported"}};On[6]=function(){return{error:"GPOS Lookup 6 not supported"}};On[7]=function(){return{error:"GPOS Lookup 7 not supported"}};On[8]=function(){return{error:"GPOS Lookup 8 not supported"}};On[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Z3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return Fe.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(On)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(On),variations:t.parseFeatureVariationsList()}}var $3=new Array(10);function J3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,$3)}])}var j3={parse:Z3,make:J3};function Q3(n){const e={};n.skip("uShort");const t=n.parseUShort();Fe.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Er(aA(t))})(),this._shared.catch(()=>{Er._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(xd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const O=(w.x1+w.x2)/2,k=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:O,cy:k,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(xd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:an},()=>[]),b=Array.from({length:an},()=>[]);a.forEach((w,O)=>{const k=Math.min(w.y0,w.cy,w.y1),U=Math.max(w.y0,w.cy,w.y1),$=Math.min(w.x0,w.cx,w.x1),F=Math.max(w.x0,w.cx,w.x1),Z=Da((k-h)/m),R=Da((U-h)/m);for(let ae=Z;ae<=R;ae++)g[ae].push(O);const re=Da(($-d)/_),se=Da((F-d)/_);for(let ae=re;ae<=se;ae++)b[ae].push(O)});const A=w=>Math.ceil(w.length/4),x=g.reduce((w,O)=>w+A(O),0)+b.reduce((w,O)=>w+A(O),0),E=2+an*2+x+a.length*2,S=this.alloc(E),M=this.data,y=(w,O,k,U,$)=>{M[w*4]=O,M[w*4+1]=k,M[w*4+2]=U,M[w*4+3]=$},T=S+2+an*2+x;y(S,d,h,f,p),y(S+1,S+2,S+2+an,0,0);let I=S+2+an*2;const L=(w,O)=>{for(let k=0;k{y(T+O*2,w.x0,w.y0,w.cx,w.cy),y(T+O*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${an})), 0, ${an-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${an})), 0, ${an-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class uA{constructor(e){Vt(this,"pos",[]);Vt(this,"emuv",[]);Vt(this,"gbase",[]);Vt(this,"color",[]);Vt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i/l.capHeightEm,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let A=0;A=0){const[L,w,O,k]=this.engine.bboxOf(I),U=L-Ra,$=w-Ra,F=O+Ra,Z=k+Ra,R=this.pos.length/3;for(const[re,se]of[[U,$],[F,$],[F,Z],[U,Z]]){const ae=S+(y+re)*u,ge=M+se*u;this.pos.push(t.x+ae*p-ge*_,t.y+ae*_+ge*p,1),this.emuv.push(re,se),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(R,R+1,R+2,R,R+2,R+3)}y+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new ft(this.pos,3)),e.setAttribute("emuv",new ft(this.emuv,2)),e.setAttribute("gbase",new ft(this.gbase,1)),e.setAttribute("tcolor",new ft(this.color,3)),e.setIndex(this.index);const t=new Pn({glslVersion:dc,vertexShader:lA,fragmentShader:cA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:Ht}),i=new zt(e,t);return i.frustumCulled=!0,i}}const hA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,dA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function fA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const A=g.substring(0,b).trim().toLowerCase(),x=g.substring(b+1).trim(),E=parseFloat(x);isNaN(E)||(A==="s"?c=E:A==="r"?u=E:A==="a"?(u=E,d=!0):A==="u"?(u=E,h=!0):A==="x"?f=E:A==="y"&&(p=E))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function pA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=pA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=fA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Np=new Map;function kp(n){const e=mA(n);for(const[t,i]of e.entries())Np.set(t,i)}kp(hA);kp(dA);const gA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},_A=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function xA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Np.get(e);if(!t)return;let i=t.elements;_A.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=gA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const yl=13226457,yd=64,vl=72,yA=14;function ks(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>ks(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class vA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Ur.shared().catch(()=>{}),this._scene=new Z0,this._scene.background=new et(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Wc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Wy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new Yy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Ui.PAN,TWO:Ui.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new _r,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new H,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,A,x,E,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((x=(A=this._controls)==null?void 0:A.target)==null?void 0:x.x)??s.position.x,g=((S=(E=this._controls)==null?void 0:E.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Mr(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new Fi,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+10;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ll(i,this._activeSpaceHex):null,g=new Map;for(const D of i){const Ee=($=(U=D.ownerHandle)==null?void 0:U.value)==null?void 0:$.toString(16);Ee!=null&&(g.has(Ee)||g.set(Ee,[]),g.get(Ee).push(D))}const b=[];let A=0;const x=(D,Ee,z=0)=>{!Number.isFinite(D)||!Number.isFinite(Ee)||(l.expandByPoint(c.set(D,Ee,z)),A++,!(A&7)&&b.length<1e5&&b.push(D,Ee))},E=(D,Ee,z,P,v,B)=>{const Y=(B>>16&255)/255,N=(B>>8&255)/255,J=(B&255)/255;if(o){let ie=a.get(o.key);ie||(ie={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,ie)),ie.verts.push(D,Ee,v,z,P,v),ie.colors.push(Y,N,J,Y,N,J)}else s.push(D,Ee,v,z,P,v),r.push(Y,N,J,Y,N,J);this._pickCurIdx>=0&&(this._pickSegs.push(D,Ee,z,P),this._pickSegMeta.push(this._pickCurIdx)),x(D,Ee,v),x(z,P,v)},S=-1,M=Mr(e),y=M.find(D=>D.handleHex===this._activeSpaceHex);if((y==null?void 0:y.kind)==="paper"){const D=M.find(Ee=>Ee.kind==="model");if(D){const Ee=ll(i,D.handleHex),z=i.filter(B=>{var N,J;return(B.type||B.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((J=(N=B.ownerHandle)==null?void 0:N.value)==null?void 0:J.toString(16))===this._activeSpaceHex&&this._isModelViewport(B)}),P=(B,Y,N,J,ie,X)=>{E(B,Y,N,J,S,X)},v=(B,Y,N=0)=>x(B,Y,S);for(const B of z)this._emitModelThroughViewport(B,{entities:i,modelAllowed:Ee,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:P,expand:v,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const D of i){const Ee=(Z=(F=D.ownerHandle)==null?void 0:F.value)==null?void 0:Z.toString(16);if(_&&Ee&&d.has(Ee)||m&&Ee&&!m.has(Ee))continue;if((R=this._hiddenLayers)!=null&&R.size){const N=((re=D.layerHandle)==null?void 0:re.value)??D.layerHandle,J=(N!=null&&this._layerNameByHandle.get(String(N)))??D.layer??D.layerName;if(J&&this._hiddenLayers.has(J))continue}const z=D.data||D,P=(D.type||D.typeName||"").toUpperCase(),v=this._entityColor(D),B=this._resolveComplexLinetype(D);B?o=null:o=this._resolveDash(D);const Y={entity:D,type:P,bounds:null,colStart:r.length};this._entityMeta.push(Y),this._pickCurIdx=this._entityMeta.length-1;try{switch(P){case"LINE":z.start&&z.end&&(B?this._drawComplexPath([z.start,z.end],!1,B.pattern,B.ltscale,v,E,u):E(z.start.x,z.start.y,z.end.x,z.end.y,z.start.z||0,v),Y.bounds={type:"line",x1:z.start.x,y1:z.start.y,x2:z.end.x,y2:z.end.y});break;case"CIRCLE":if(z.center&&z.radius!=null){if(B){const N=this._sampleArcPoints(z.center,z.radius,0,Math.PI*2,z.center.z||0);this._drawComplexPath(N,!0,B.pattern,B.ltscale,v,E,u)}else this._arcSegs(z.center,z.radius,0,Math.PI*2,z.center.z||0,v,E);Y.bounds={type:"circle",cx:z.center.x,cy:z.center.y,r:z.radius}}break;case"ARC":if(z.center&&z.radius!=null){if(B){const N=this._sampleArcPoints(z.center,z.radius,z.startAngle??0,z.endAngle??Math.PI*2,z.center.z||0);this._drawComplexPath(N,!1,B.pattern,B.ltscale,v,E,u)}else this._arcSegs(z.center,z.radius,z.startAngle??0,z.endAngle??Math.PI*2,z.center.z||0,v,E);Y.bounds={type:"circle",cx:z.center.x,cy:z.center.y,r:z.radius}}break;case"LWPOLYLINE":if((se=z.points)!=null&&se.length){const N=(ae=z.bulges)==null?void 0:ae.some(X=>Math.abs(X)>=1e-6),J=!!(z.closed||z.flags&1),ie=J?z.points.length:z.points.length-1;if(this._polyHasWidth(D,ie,1))this._widePolyMesh(z.points,z.bulges,J,D,v,1,x);else if(B){const X=this._samplePolylinePoints(z.points,z.bulges,J,z.elevation||0);this._drawComplexPath(X,J,B.pattern,B.ltscale,v,E,u),X.forEach(W=>x(W.x,W.y,W.z))}else N?this._bulgePolySegs(z.points,z.bulges,J,v,E,x):(this._polylineSegs(z.points,J,z.elevation||0,v,E),z.points.forEach(X=>x(X.x,X.y,z.elevation||0)));Y.bounds={type:"point",cx:z.points[0].x,cy:z.points[0].y}}break;case"POLYLINE":if(B&&(z.vertices||z.points)){const N=!!(z.closed||z.flags&1),J=z.vertices||z.points;this._drawComplexPath(J,N,B.pattern,B.ltscale,v,E,u),J.forEach(ie=>x(ie.x,ie.y,ie.z||0))}else this._polylineSegs(z.vertices||z.points,z.closed||z.flags&1,0,v,E);break;case"POLYLINE_2D":{const N=(g.get((he=(ge=D.handle)==null?void 0:ge.value)==null?void 0:he.toString(16))??[]).filter(J=>(J.type||"").toUpperCase().startsWith("VERTEX")&&J.point);if(N.length>=2){const J=N.map(ce=>ce.point),ie=N.map(ce=>ce.bulge||0),X=(z.flags&1)===1,W=z.elevation||0;if(B){const ce=this._samplePolylinePoints(J,ie,X,W);this._drawComplexPath(ce,X,B.pattern,B.ltscale,v,E,u),ce.forEach(le=>x(le.x,le.y,le.z))}else ie.some(ce=>Math.abs(ce)>=1e-6)?this._bulgePolySegs(J,ie,X,v,E,x):(this._polylineSegs(J,X,W,v,E),J.forEach(ce=>x(ce.x,ce.y,W)));Y.bounds={type:"point",cx:J[0].x,cy:J[0].y}}break}case"POINT":{const N=z.position||z;typeof N.x=="number"&&(E(N.x-1,N.y,N.x+1,N.y,N.z||0,v),E(N.x,N.y-1,N.x,N.y+1,N.z||0,v),Y.bounds={type:"point",cx:N.x,cy:N.y});break}case"ELLIPSE":if(z.center){if(B){const N=this._sampleEllipsePoints(z);this._drawComplexPath(N,!1,B.pattern,B.ltscale,v,E,u),N.forEach(J=>x(J.x,J.y,J.z||0))}else this._ellipseSegs(z,v,E);Y.bounds={type:"point",cx:z.center.x,cy:z.center.y}}break;case"SPLINE":{const N=z.controlPoints??z.fitPoints;if((N==null?void 0:N.length)>=2){const J=N.length>=3?(()=>{const ie=N.length*10,X=[];for(let W=0;W<=ie;W++){const ce=W/ie;X.push(this._catmullRom(N,ce))}return X})():N;B?(this._drawComplexPath(J,!!z.closed,B.pattern,B.ltscale,v,E,u),J.forEach(ie=>x(ie.x,ie.y,ie.z||0))):(this._polylineSegs(J,!1,0,v,E),J.forEach(ie=>x(ie.x,ie.y,ie.z||0))),Y.bounds={type:"point",cx:J[0].x,cy:J[0].y}}break}case"ATTRIB":case"ATTDEF":{if((z.flags??0)&1)break;const N=D.text??z.text??z.textValue??z.defaultValue??"",J=ks(N),ie=D.textHeight??D.height??z.textHeight??z.height??2.5,X=D.rotationAngle??z.rotationAngle??0,W=D.horizAlignment??z.horizAlignment??0,ce=D.vertAlignment??z.vertAlignment??0,de=W!==0||ce!==0?D.alignmentPt??z.alignmentPt??D.insertionPt??z.insertionPt??z.insertionPoint??{x:0,y:0}:D.insertionPt??z.insertionPt??z.insertionPoint??{x:0,y:0};J&&(u.push({text:J,pos:de,height:ie,rotation:X,color:v,alignH:W,alignV:2}),Y.bounds={type:"point",cx:de.x,cy:de.y},this._addTextPick(J,de,ie,W,2),x(de.x,de.y,0));break}case"XLINE":case"RAY":{const N=z.basePoint??z.point??z.startPoint,J=z.direction??z.unitDir??z.vector;if(N&&J){const X=N.x+J.x*1e6,W=N.y+J.y*1e6;P==="XLINE"?E(N.x-J.x*1e6,N.y-J.y*1e6,X,W,0,v):E(N.x,N.y,X,W,0,v),Y.bounds={type:"point",cx:N.x,cy:N.y},x(N.x,N.y)}break}case"SOLID":{const N=[z.corner1||z.pt1||z.point1,z.corner2||z.pt2||z.point2,z.corner3||z.pt3||z.point3,z.corner4||z.pt4||z.point4].filter(Boolean);N.length>=3&&(this._solidMesh(N,v),Y.bounds={type:"point",cx:N[0].x,cy:N[0].y});break}case"TEXT":case"MTEXT":{const N=D.text??z.text??"",J=ks(N),ie=D.textHeight??D.height??z.textHeight??z.height??2.5;let X=0,W=0,ce=0,le;if(P==="TEXT")X=D.rotationAngle??z.rotationAngle??0,W=D.horizAlignment??z.horizAlignment??0,ce=D.vertAlignment??z.vertAlignment??0,W===4&&(ce=2),le=W!==0||ce!==0?D.alignmentPt??z.alignmentPt??D.insertionPt??z.insertionPt??{x:0,y:0}:D.insertionPt??z.insertionPt??z.insertionPoint??{x:0,y:0};else{const de=D.xAxisDir??z.xAxisDir;de&&(X=Math.atan2(de.y,de.x));const pe=D.attachment??z.attachment??D.attachmentPoint??z.attachmentPoint??5;W=[1,4,7].includes(pe)?0:[3,6,9].includes(pe)?2:1,ce=[1,2,3].includes(pe)?3:[7,8,9].includes(pe)?1:2,le=D.insertionPt??z.insertionPt??z.insertionPoint??{x:0,y:0}}if(J){const de={text:J,pos:le,height:ie,rotation:X,color:v,alignH:W,alignV:ce};P==="MTEXT"&&(de.linespacingFactor=D.linespacingFactor??z.linespacingFactor??1,de.rectWidth=D.rectWidth??z.rectWidth??0,de.rectHeight=D.rectHeight??z.rectHeight??0,de.bgFillFlags=D.bgFillFlags??z.bgFillFlags??0,de.bgScale=D.bgScale??z.bgScale??1.5,de.bgColorIndex=D.bgColorIndex??z.bgColorIndex,de.bgColorRgb=D.bgColorRgb??z.bgColorRgb),u.push(de),Y.bounds={type:"point",cx:le.x,cy:le.y},this._addTextPick(J,le,ie,W,ce),x(le.x,le.y,0)}break}case"INSERT":{const N=D.insertionPt??z.insertionPt??z.insertionPoint,J=z.scaleX??((oe=z.scale)==null?void 0:oe.x)??((G=D.scale)==null?void 0:G.x)??1,ie=z.scaleY??((ne=z.scale)==null?void 0:ne.y)??((j=D.scale)==null?void 0:j.y)??1,X=z.rotation??D.rotation??0,W=((xe=D.blockHeaderHandle)==null?void 0:xe.value)??((be=z.blockHeaderHandle)==null?void 0:be.value);if(W!=null){const ce=W.toString(16),le=g.get(ce)??[];if(le.length>0){const de=(Be=(ve=e==null?void 0:e.tables)==null?void 0:ve.blocks)==null?void 0:Be.find(pe=>{var we;return(typeof pe.handle=="object"?(we=pe.handle)==null?void 0:we.value:pe.handle)===W});this._insertEntities(le,{insertionPoint:N??{x:0,y:0,z:0},xScale:J,yScale:ie,rotation:X,basePoint:de==null?void 0:de.basePoint},v,E,u,{entsByOwner:g,blockBase:f})}}N&&(Y.bounds={type:"point",cx:N.x,cy:N.y},x(N.x,N.y,0));break}case"HATCH":{const N=z.paths??D.paths,J=z.solidFill??D.solidFill??!1;if(!(N!=null&&N.length))break;let ie=null;for(const X of N){if(!((Ve=X.points)!=null&&Ve.length)||X.points.length<2)continue;ie||(ie=X.points[0]),((Ne=X.bulges)==null?void 0:Ne.some(ce=>Math.abs(ce)>=1e-6))?this._bulgePolySegs(X.points,X.bulges,!0,v,E,x):(this._polylineSegs(X.points,!0,0,v,E),X.points.forEach(ce=>x(ce.x,ce.y,0)))}J&&this._hatchFill(N,v),ie&&(Y.bounds={type:"point",cx:ie.x,cy:ie.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const N=((ke=D.blockHeaderHandle)==null?void 0:ke.value)??((Xe=z.blockHeaderHandle)==null?void 0:Xe.value);let J=[];if(N!=null){const ie=N.toString(16);J=g.get(ie)??[]}if(J.length>0){for(const W of J){const ce=(W.type||W.typeName||"").toUpperCase(),le=W.data||W,de=this._entityColor(W)||v;if(ce==="LINE"&&le.start&&le.end)E(le.start.x,le.start.y,le.end.x,le.end.y,0,de),x(le.start.x,le.start.y),x(le.end.x,le.end.y);else if(ce==="SOLID"){const pe=[le.corner1||le.pt1,le.corner2||le.pt2,le.corner3||le.pt3,le.corner4||le.pt4].filter(Boolean);pe.length>=3&&(this._solidMesh(pe,de),pe.forEach(Le=>x(Le.x,Le.y)))}else if(ce==="ARC"&&le.center&&le.radius!=null)this._arcSegs(le.center,le.radius,le.startAngle??0,le.endAngle??Math.PI*2,0,de,E);else if(ce==="TEXT"||ce==="MTEXT"){const pe=W.text??le.text??le.textValue??"",Le=ks(pe),we=W.insertionPt??le.insertionPt??le.insertionPoint??{x:0,y:0},Ye=le.textHeight??le.height??W.textHeight??2.5;Le&&(u.push({text:Le,pos:we,height:Ye,rotation:le.rotationAngle??0,color:de,alignH:1,alignV:2}),x(we.x,we.y))}else if(ce==="INSERT"){const pe=W.insertionPt??le.insertionPt??le.insertionPoint??{x:0,y:0},Le=le.rotation??W.rotation??0,we=le.scaleX??((tt=le.scale)==null?void 0:tt.x)??((rt=W.scale)==null?void 0:rt.x)??1,Ye=le.scaleY??((gt=le.scale)==null?void 0:gt.y)??((vt=W.scale)==null?void 0:vt.y)??we,V=((ht=W.blockHeaderHandle)==null?void 0:ht.value)??((dt=le.blockHeaderHandle)==null?void 0:dt.value),_e=V==null?void 0:V.toString(16),ue=p.get(_e)??"",ye=_e?g.get(_e)??[]:[];ue.includes("dot")?this._dotMesh(pe,this._arrowDotRadius(ye)*Math.abs(we)||Math.abs(we)*.5,de):ye.length?this._insertEntities(ye,{insertionPoint:pe,xScale:we,yScale:Ye,rotation:Le,basePoint:f.get(_e)},de,E,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(ue,pe,Le,Math.abs(we)||1,de,E),x(pe.x,pe.y)}}const ie=J.find(W=>(W.type||W.typeName||"").toUpperCase()==="LINE"),X=(ie==null?void 0:ie.data)||ie;X!=null&&X.start&&(Y.bounds={type:"point",cx:X.start.x,cy:X.start.y})}else{this._renderDimFallback(D,z,P,v,E,u,x);const ie=D.pt10??z.pt10;ie&&(Y.bounds={type:"point",cx:ie.x,cy:ie.y},x(ie.x,ie.y))}break}case"LEADER":{const N=z.points??D.points;if((N==null?void 0:N.length)>=2){if(this._polylineSegs(N,!1,0,v,E),N.forEach(J=>x(J.x,J.y,J.z||0)),z.arrowheadOn??D.arrowheadOn??!0){const J=N[0],ie=N[1],X=Math.atan2(ie.y-J.y,ie.x-J.x),W=z.arrowSize??D.arrowSize??2.5;this._arrowMesh(J,X,W,v)}Y.bounds={type:"point",cx:N[0].x,cy:N[0].y}}break}case"OLE2FRAME":{const N=D.upperLeft??z.upperLeft??{x:0,y:0,z:0},J=D.lowerRight??z.lowerRight??{x:0,y:0,z:0},ie=D.sourceApp??z.sourceApp??D.source_application??"",X=D.imageDataUrl??z.imageDataUrl;let W=Math.min(N.x,J.x),ce=Math.max(N.x,J.x),le=Math.min(N.y,J.y),de=Math.max(N.y,J.y),pe=ce-W,Le=de-le;const we=N.z||0;if(E(W,le,ce,le,we,v),E(ce,le,ce,de,we,v),E(ce,de,W,de,we,v),E(W,de,W,le,we,v),X)try{const V=(fe=>{const He=fe.split(",")[1],Ue=atob(He),ot=new Uint8Array(Ue.length);for(let An=0;An0,Xi=document.createElement("canvas");Xi.width=kn,Xi.height=Fn;const ir=Xi.getContext("2d"),Bn=ir.createImageData(kn,Fn),mn=Bn.data;if(nr===32){const An=kn*4;for(let sn=0;sn0&&Number.isFinite(W)&&z.push(W)}z.sort((X,W)=>X-W);const P=z.length?z[z.length>>1]:2.5,v=Math.min(Ee*2e-4,P),B=2e4,Y=u.filter(X=>X.underlay),N=u.filter(X=>!X.underlay),J=Y.concat(N),ie=J.length>B?(console.warn(`텍스트 ${J.length}개 → ${B}개로 제한`),N.concat(Y).sort((X,W)=>W.height-X.height).slice(0,B)):J;this._drawTexts(ie,v)}if(this._lineColorAttr=null,this._origColors=null,s.length){const D=new Ct;D.setAttribute("position",new ft(s,3));const Ee=new ft(r,3);D.setAttribute("color",Ee),this._group.add(new pa(D,new Fs({vertexColors:!0}))),this._lineColorAttr=Ee,this._origColors=Float32Array.from(Ee.array)}for(const D of a.values()){if(!D.verts.length)continue;const Ee=new Ct;Ee.setAttribute("position",new ft(D.verts,3)),Ee.setAttribute("color",new ft(D.colors,3));const z=new pa(Ee,new Xm({vertexColors:!0,dashSize:D.dash,gapSize:D.gap}));z.computeLineDistances(),this._group.add(z)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new et(e?658189:16250611),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new ft(p,3)),this._gridMesh=new pa(_,new Fs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Mr(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var A,x,E,S,M,y,T,I,L,w,O,k,U,$;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(F=>String(F))),m=(F,Z,R,re,se,ae)=>{const ge=h(F,Z),he=h(R,re);this._clipSegToRect(ge.x,ge.y,he.x,he.y,f,(oe,G,ne,j)=>{l(oe,G,ne,j,se||0,ae)})},g=(F,Z,R=0)=>{const re=h(F,Z);re.x>=f.minX&&re.x<=f.maxX&&re.y>=f.minY&&re.y<=f.maxY&&c(re.x,re.y,R)},b=(F,Z)=>F>=f.minX&&F<=f.maxX&&Z>=f.minY&&Z<=f.maxY;for(const F of i){const Z=(x=(A=F.ownerHandle)==null?void 0:A.value)==null?void 0:x.toString(16);if(!Z||!s.has(Z)||r.has(Z))continue;if((E=this._hiddenLayers)!=null&&E.size){const he=((S=F.layerHandle)==null?void 0:S.value)??F.layerHandle,oe=(he!=null&&this._layerNameByHandle.get(String(he)))??F.layer??F.layerName;if(oe&&this._hiddenLayers.has(oe))continue}if(_.size){const he=(M=F.layerHandle)==null?void 0:M.value;if(he!=null&&_.has(String(he)))continue}const R=F.data||F,re=(F.type||F.typeName||"").toUpperCase(),se=this._entityColor(F),ae=this._resolveComplexLinetype(F),ge=u.length;try{switch(re){case"LINE":R.start&&R.end&&(ae?this._drawComplexPath([R.start,R.end],!1,ae.pattern,ae.ltscale,se,m,u):m(R.start.x,R.start.y,R.end.x,R.end.y,R.start.z||0,se));break;case"CIRCLE":if(R.center&&R.radius!=null)if(ae){const he=this._sampleArcPoints(R.center,R.radius,0,Math.PI*2,R.center.z||0);this._drawComplexPath(he,!0,ae.pattern,ae.ltscale,se,m,u)}else this._arcSegs(R.center,R.radius,0,Math.PI*2,R.center.z||0,se,m);break;case"ARC":if(R.center&&R.radius!=null)if(ae){const he=this._sampleArcPoints(R.center,R.radius,R.startAngle??0,R.endAngle??Math.PI*2,R.center.z||0);this._drawComplexPath(he,!1,ae.pattern,ae.ltscale,se,m,u)}else this._arcSegs(R.center,R.radius,R.startAngle??0,R.endAngle??Math.PI*2,R.center.z||0,se,m);break;case"LWPOLYLINE":if((y=R.points)!=null&&y.length){const he=(T=R.bulges)==null?void 0:T.some(G=>Math.abs(G)>=1e-6),oe=!!(R.closed||R.flags&1);if(ae){const G=this._samplePolylinePoints(R.points,R.bulges,oe,R.elevation||0);this._drawComplexPath(G,oe,ae.pattern,ae.ltscale,se,m,u),G.forEach(ne=>g(ne.x,ne.y,ne.z))}else he?this._bulgePolySegs(R.points,R.bulges,oe,se,m,g):(this._polylineSegs(R.points,oe,R.elevation||0,se,m),R.points.forEach(G=>g(G.x,G.y,R.elevation||0)))}break;case"POLYLINE":if(ae&&(R.vertices||R.points)){const he=!!(R.closed||R.flags&1),oe=R.vertices||R.points;this._drawComplexPath(oe,he,ae.pattern,ae.ltscale,se,m,u),oe.forEach(G=>g(G.x,G.y,G.z||0))}else this._polylineSegs(R.vertices||R.points,R.closed||R.flags&1,0,se,m);break;case"ELLIPSE":if(R.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(R,se,m);else{const he=R.center.x,oe=R.center.y,G=R.smAxis||R.majorAxis||{x:R.radius||1,y:0},ne=R.axisRatio??R.minorAxisRatio??.5,j=R.startAngle??R.startParameter??0,xe=R.endAngle??R.endParameter??Math.PI*2,be=64;let ve,Be;for(let Ve=0;Ve<=be;Ve++){const Ne=j+(xe-j)*(Ve/be),ke=Math.cos(Ne),Xe=Math.sin(Ne),tt=he+G.x*ke-G.y*ne*Xe,rt=oe+G.y*ke+G.x*ne*Xe;Ve>0&&m(ve,Be,tt,rt,0,se),ve=tt,Be=rt}}break;case"SOLID":{const he=[R.corner1||R.pt1,R.corner2||R.pt2,R.corner3||R.pt3,R.corner4||R.pt4].filter(Boolean);if(he.length>=2)for(let oe=0;oeMath.abs(xe)>=1e-6)?this._bulgePolySegs(G,j,ne,se,m,g):(this._polylineSegs(G,ne,0,se,m),G.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const he=(I=R.fitPoints)!=null&&I.length?R.fitPoints:R.controlPoints;(he==null?void 0:he.length)>=2&&this._polylineSegs(he,!!R.closed,0,se,m);break}case"TEXT":case"MTEXT":{const he=F.text??R.text??"",oe=ks(he);if(!oe)break;const G=(F.textHeight??F.height??R.textHeight??R.height??2.5)*p;let ne=(F.rotationAngle??R.rotationAngle??0)+(h.twist||0),j=0,xe=0,be;if(re==="TEXT")j=F.horizAlignment??R.horizAlignment??0,xe=F.vertAlignment??R.vertAlignment??0,j===4&&(xe=2),be=j!==0||xe!==0?F.alignmentPt??R.alignmentPt??F.insertionPt??R.insertionPt??{x:0,y:0}:F.insertionPt??R.insertionPt??R.insertionPoint??{x:0,y:0};else{const Be=F.xAxisDir??R.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const Ve=F.attachment??R.attachment??F.attachmentPoint??R.attachmentPoint??5;j=[1,4,7].includes(Ve)?0:[3,6,9].includes(Ve)?2:1,xe=[1,2,3].includes(Ve)?3:[7,8,9].includes(Ve)?1:2,be=F.insertionPt??R.insertionPt??R.insertionPoint??{x:0,y:0}}const ve=h(be.x,be.y);if(!b(ve.x,ve.y))break;u.push({text:oe,pos:ve,height:G,rotation:ne,color:se,alignH:j,alignV:xe,underlay:!!d}),g(be.x,be.y);break}case"INSERT":{const he=F.insertionPt??R.insertionPt??R.insertionPoint;if(!he)break;const oe=R.scaleX??((L=R.scale)==null?void 0:L.x)??((w=F.scale)==null?void 0:w.x)??1,G=R.scaleY??((O=R.scale)==null?void 0:O.y)??((k=F.scale)==null?void 0:k.y)??1,ne=((U=F.blockHeaderHandle)==null?void 0:U.value)??(($=R.blockHeaderHandle)==null?void 0:$.value),j=ne!=null?ne.toString(16):null,xe=j?a.get(j)??[]:[];if(xe.length){const be=u.length;this._insertEntities(xe,{insertionPoint:he,xScale:oe,yScale:G,rotation:R.rotation??F.rotation??0,basePoint:o.get(j)},se,m,u,{entsByOwner:a,blockBase:o});for(let ve=be;vege)for(let he=ge;he{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ll(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ma(h)??yl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=xA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*yd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),A=(l.x+c.x)/2,x=(l.y+c.y)/2,E=-f/p,S=h/p,M=u>0?1:-1,y=A+M*E*b,T=x+M*S*b,I=Math.atan2(l.y-T,l.x-y),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const O=I+_*w/L;r.push({x:y+g*Math.cos(O),y:T+g*Math.sin(O),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=vl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),A=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:A,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let m=0;m{let g=Math.max(0,Math.min(m,u));for(let x=0;x1e-9?g/E:0,M=l[x],y=l[x+1],T=M.x+(y.x-M.x)*S,I=M.y+(y.y-M.y)*S,L=(M.z||0)+((y.z||0)-(M.z||0))*S,w=Math.atan2(y.y-M.y,y.x-M.x);return{x:T,y:I,z:L,angle:w}}g-=E}const b=l[l.length-1],A=l[l.length-2];return{x:b.x,y:b.y,z:b.z||0,angle:Math.atan2(b.y-A.y,b.x-A.x)}};if(i.patternLength*s<1e-6)return;let f=0,p=0;const _=i.elements;for(;fb){const x=d(b),E=d(A);a(x.x,x.y,E.x,E.y,x.z,r)}f+=g}else if(m.type==="gap"){const g=Math.abs(m.val||.1)*s;f+=g}else if(m.type==="shape"){const g=d(f);this._renderShapeSymbol(m,g,s,r,a)}else if(m.type==="text"){const g=d(f);if(m.text&&o){const b=(m.scale||.2)*s;let A=g.angle+(m.rotation||0)*Math.PI/180;m.isAbsoluteAngle&&(A=(m.rotation||0)*Math.PI/180);let x=Math.atan2(Math.sin(A),Math.cos(A));x>Math.PI/2?x-=Math.PI:x<-Math.PI/2&&(x+=Math.PI),A=x;const E=Math.cos(A),S=Math.sin(A),M=(m.xOffset||0)*s,y=(m.yOffset||0)*s,T=g.x+(M*E-y*S),I=g.y+(M*S+y*E);o.push({text:m.text,pos:{x:T,y:I,z:g.z},height:Math.max(b,.01),rotation:A,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(A,x)=>({x:f+(A*m-x*g)*o,y:p+(A*g+x*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const y=M/12,T=-.5+y,I=.25*(1-y),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const x=b(.5,0),E=b(-.5,.25),S=b(-.5,-.25);r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,S.x,S.y,_,s),r(S.x,S.y,x.x,x.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let x=b(.3,0);for(let E=1;E<=12;E++){const S=E/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(x.x,x.y,M.x,M.y,_,s),x=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const A=b(-.3,-.3),x=b(.3,-.3),E=b(.3,.3),S=b(-.3,.3);r(A.x,A.y,x.x,x.y,_,s),r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,S.x,S.y,_,s),r(S.x,S.y,A.x,A.y,_,s)}else if(a.includes("TRACK1")){const A=b(0,-.4),x=b(0,.4);r(A.x,A.y,x.x,x.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const A=b(0,.4),x=b(.4,0),E=b(0,-.4),S=b(-.4,0);r(A.x,A.y,x.x,x.y,_,s),r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,S.x,S.y,_,s),r(S.x,S.y,A.x,A.y,_,s)}else{const A=b(.3,0),x=b(-.3,.2),E=b(-.3,-.2);r(A.x,A.y,x.x,x.y,_,s),r(x.x,x.y,E.x,E.y,_,s),r(E.x,E.y,A.x,A.y,_,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ma(a)??yl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ma(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return yl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new ft([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new ft([a,o,l,a,o,l,a,o,l],3));const u=new zt(c,new Yn({vertexColors:!0,side:Ht}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*yd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=vl;m++){const g=o+p*m/vl,b=d*Math.cos(g),A=h*Math.sin(g),x=r.x+b*Math.cos(f)-A*Math.sin(f),E=r.y+b*Math.sin(f)+A*Math.cos(f);_&&i(_.x,_.y,x,E,r.z||0,t),_={x,y:E}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,U=I+k*w*T,$=L+k*O*T,F=Math.atan2(p.y-$,p.x-U),Z=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let R={x:p.x,y:p.y},re=m;for(let se=1;se<=Z;se++){const ae=se/Z,ge=F+S*se/Z,he={x:U+y*Math.cos(ge),y:$+y*Math.sin(ge)},oe=m+(g-m)*ae;this._pushWideSeg(u,R,he,re,oe),R=he,re=oe}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new ft(u,3)),d.computeVertexNormals();const h=new Yn({color:new et(r),side:Ht,depthWrite:!1});if(this._group.add(new zt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=x+y*S*A,I=E+y*M*A,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let O=u;for(let k=1;k<=w;k++){const U=L+m*k/w,$=T+b*Math.cos(U),F=I+b*Math.sin(U);r(O.x,O.y,$,F,0,s),O={x:$,y:F}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new ft(a,3)),c.setAttribute("color",new ft(o,3)),this._group.add(new zt(c,new Yn({vertexColors:!0,side:Ht}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+E*A*m,M=b+E*x*m,y=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Yn({color:new et(t),side:Ht});for(const l of s)try{const c=new df;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const O of w)O.xr&&(r=O.x),O.y>a&&(a=O.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const O=g(w[0]);m.moveTo(O.x,O.y);for(let k=1;kthis._convexHull(w)),S=w=>{if(w.length<3||!E.length)return!1;const O=this._polyCentroid(w);for(const k of E)if(k.length>=3&&this._pointInPoly(k,O))return!0;return!1};if(A.length){m.fillStyle="#ffffff",m.beginPath();for(const O of A)b(O);m.fill("nonzero");const w=x.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const O of w)b(O);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=x.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const y=new ma(_);y.colorSpace=ci,y.magFilter=Wt,y.minFilter=Oi,y.generateMipmaps=!0,y.needsUpdate=!0;const T=new Yn({map:y,color:new et(t),transparent:!0,alphaTest:.4,side:Ht,depthWrite:!1}),I=new is(o,l),L=new zt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const k of e){const U=h.measureText(k||" ");f=Math.max(f,Math.ceil(U.width)),p=Math.max(p,U.actualBoundingBoxAscent||96*.7),_=Math.max(_,U.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,A=r>>8&255,x=r&255;h.fillStyle=`rgb(${b},${A},${x})`,h.textBaseline="alphabetic";let E=m;a===1||a===4?(h.textAlign="center",E=d.width/2):a===2?(h.textAlign="right",E=d.width-m):(h.textAlign="left",E=m);for(let k=0;k0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const O of l)d=Math.max(d,t.measureEm(O||" "));else for(const O of l)d=Math.max(d,(O||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let A=0,x=0;g===0||g===3||g===5?A=h/2:g===2&&(A=-h/2),b===3?x=-f/2:(b===0||b===1)&&(x=f/2);const E=e.rotation||0,S=Math.cos(E),M=Math.sin(E),y=e.pos.x+A*S-x*M,T=e.pos.y+A*M+x*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const O=Ma(e.bgColorIndex);O!=null&&(I=O)}if(r){const O=new is(_,m),k=new Yn({color:new et(I),side:Ht,depthWrite:!1,transparent:!1}),U=new zt(O,k);U.position.set(y,T,.4),U.rotation.z=E,this._group.add(U)}if(a&&!r){const O=_/2,k=m/2,$=[[-O,-k],[O,-k],[O,k],[-O,k],[-O,-k]].map(([F,Z])=>({x:y+F*S-Z*M,y:T+F*M+Z*S}));for(let F=0;F<4;F++){const Z=$[F],R=$[F+1];this._widePolyMesh([Z,R],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Ur.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new uA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const y="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=y;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),O=L.actualBoundingBoxAscent||96*.7,k=L.actualBoundingBoxDescent||96*.2,U=Math.ceil(96*.15);T.width=w+U*2,T.height=Math.ceil(O+k)+U*2,I.font=y;const $=r>>16&255,F=r>>8&255,Z=r&255;I.fillStyle=`rgb(${$},${F},${Z})`,I.textBaseline="alphabetic",I.fillText(e,U,U+O),d={texture:new ma(T),w:T.width,h:T.height,asc:O,pad:U},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let A=0;a===0||a===3||a===5?A=m/2:a===1||a===4?A=0:a===2&&(A=-m/2);let x=0;a!==4&&(o===0||o===1?x=(p+f-b)*g:o===3&&(x=(p-b)*g));const E=new pc({map:h,transparent:!0,depthTest:!1});s&&(E.rotation=s);const S=new Uu(E);S.scale.set(m,_,1),S.position.set(t.x+A,t.y+x,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var y,T,I,L,w,O,k,U,$,F;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),A=Math.sin(g),x=(Z,R)=>{const re=p?Z-p.x:Z,se=p?R-p.y:R;return[f.x+re*_*b-se*m*A,f.y+re*_*A+se*m*b]},E=c?(Z,R)=>c(...x(Z,R)):x,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const Z of e){const R=Z.data||Z,re=(Z.type||Z.typeName||"").toUpperCase();if(re==="ATTDEF")continue;const se=this._resolveBlockColor(Z,i);try{if(re==="LINE"&&R.start&&R.end){const[ae,ge]=E(R.start.x,R.start.y),[he,oe]=E(R.end.x,R.end.y);s(ae,ge,he,oe,0,se)}else if((re==="CIRCLE"||re==="ARC")&&R.center&&R.radius!=null){const[ae,ge]=E(R.center.x,R.center.y),he=R.radius*S,oe=re==="ARC"?(R.startAngle??0)+M:0,G=re==="ARC"?(R.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:ae,y:ge,z:0},he,oe,G,0,se,s)}else if(re==="ELLIPSE"&&R.center){const[ae,ge]=E(R.center.x,R.center.y),he=R.majorAxis??R.smAxis??{x:1,y:0},oe=Math.hypot(he.x??0,he.y??0)*S,G=Math.atan2(he.y??0,he.x??1)+M;this._ellipseSegs({center:{x:ae,y:ge,z:0},majorAxis:{x:oe*Math.cos(G),y:oe*Math.sin(G)},ratio:R.ratio??R.axisRatio??1,startParam:R.startParam??0,endParam:R.endParam??Math.PI*2},se,s)}else if((re==="LWPOLYLINE"||re==="POLYLINE")&&(R.points||R.vertices)){const ge=(R.points??R.vertices).map(ne=>{const[j,xe]=E(ne.x,ne.y);return{x:j,y:xe}}),he=R.bulges??null,oe=!!(R.closed||R.flags&1);let G=!1;if(ge.length>=2&&this._pickFills.length){let ne=0,j=0,xe=1/0,be=1/0,ve=-1/0,Be=-1/0;for(const ke of ge)ne+=ke.x,j+=ke.y,ke.xve&&(ve=ke.x),ke.y>Be&&(Be=ke.y);ne/=ge.length,j/=ge.length;const Ve=Math.max(ve-xe,1e-9),Ne=Math.max(Be-be,1e-9);for(const ke of this._pickFills)if(this._pointInAnyLoop(ke.loops,ne,j)){for(const Xe of ke.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,gt=-1/0,vt=-1/0;for(const Ee of Xe)Ee.xgt&&(gt=Ee.x),Ee.y>vt&&(vt=Ee.y);const ht=Math.max(gt-tt,1e-9),dt=Math.max(vt-rt,1e-9);if(Ve<=ht*1.5&&Ne<=dt*1.5&&ht<=Ve*1.5&&dt<=Ne*1.5){G=!0;break}}if(G)break}}if(!G){const ne=oe?ge.length:ge.length-1;this._polyHasWidth(Z,ne,S)?this._widePolyMesh(ge,he,oe,Z,se,S,null):(he!=null&&he.some(j=>Math.abs(j)>=1e-6)?this._bulgePolySegs(ge,he,oe,se,s):this._polylineSegs(ge,oe,0,se,s),this._fillClosedPolyIfUncovered(ge,he,se))}}else if(re==="POLYLINE_2D"&&o){const ae=(o.get((T=(y=Z.handle)==null?void 0:y.value)==null?void 0:T.toString(16))??[]).filter(ge=>(ge.type||"").toUpperCase().startsWith("VERTEX")&&ge.point);if(ae.length>=2){const ge=ae.map(G=>{const[ne,j]=E(G.point.x,G.point.y);return{x:ne,y:j}}),he=ae.map(G=>G.bulge||0),oe=(R.flags&1)===1;he.some(G=>Math.abs(G)>=1e-6)?this._bulgePolySegs(ge,he,oe,se,s):this._polylineSegs(ge,oe,0,se,s)}}else if(re==="HATCH"){const ae=R.paths??Z.paths;if(ae!=null&&ae.length){const ge=R.solidFill??Z.solidFill??!1,he=ae.map(oe=>({...oe,points:(oe.points??[]).map(G=>{const[ne,j]=E(G.x,G.y);return{x:ne,y:j}})}));if(ge)this._hatchFill(he,se);else for(const oe of he)(((I=oe.points)==null?void 0:I.length)??0)<2||((L=oe.bulges)!=null&&L.some(G=>Math.abs(G)>=1e-6)?this._bulgePolySegs(oe.points,oe.bulges,!0,se,s):this._polylineSegs(oe.points,!0,0,se,s))}}else if(re==="SOLID"){const ae=[R.corner1||R.pt1,R.corner2||R.pt2,R.corner3||R.pt3,R.corner4||R.pt4].filter(Boolean);if(ae.length>=3){const ge=ae.map(he=>{const[oe,G]=E(he.x,he.y);return{x:oe,y:G,z:he.z||0}});this._solidMesh(ge,se)}}else if(re==="INSERT"&&o&&h<8){const ae=((w=Z.blockHeaderHandle)==null?void 0:w.value)??((O=R.blockHeaderHandle)==null?void 0:O.value);if(ae!=null){const ge=ae.toString(16),he=o.get(ge)??[];if(he.length){const oe=Z.insertionPt??R.insertionPt??R.insertionPoint??{x:0,y:0},G=R.scaleX??((k=R.scale)==null?void 0:k.x)??((U=Z.scale)==null?void 0:U.x)??1,ne=R.scaleY??(($=R.scale)==null?void 0:$.y)??((F=Z.scale)==null?void 0:F.y)??1,j=R.rotation??Z.rotation??0;this._insertEntities(he,{insertionPoint:oe,xScale:G,yScale:ne,rotation:j,basePoint:l==null?void 0:l.get(ge)},se,s,r,{entsByOwner:o,blockBase:l,parentXf:E,scale:S,rot:M,depth:h+1})}}}else if((re==="TEXT"||re==="MTEXT"||re==="ATTRIB"||re==="ATTDEF")&&r){if((re==="ATTRIB"||re==="ATTDEF")&&(R.flags??0)&1)continue;const ae=Z.text??R.text??R.textValue??R.defaultValue??"",ge=ks(ae);let he,oe,G=(R.rotationAngle??0)+M;if(re==="MTEXT"){const Ne=Z.attachment??R.attachment??Z.attachmentPoint??R.attachmentPoint??5;he=[1,4,7].includes(Ne)?0:[3,6,9].includes(Ne)?2:1,oe=[1,2,3].includes(Ne)?3:[7,8,9].includes(Ne)?1:2;const ke=Z.xAxisDir??R.xAxisDir;ke&&(G=Math.atan2(ke.y,ke.x)+M)}else he=R.horizAlignment??Z.horizAlignment??0,oe=R.vertAlignment??Z.vertAlignment??0;const ne=re!=="MTEXT"&&(he!==0||oe!==0),j=Z.alignmentPt??R.alignmentPt,xe=Z.insertionPt??R.insertionPt??R.insertionPoint,be=ne?j??xe??{x:0,y:0}:xe??{x:0,y:0},[ve,Be]=E(be.x,be.y),Ve=(R.textHeight??R.height??Z.textHeight??2.5)*S;if(ge){const Ne={text:ge,pos:{x:ve,y:Be},height:Ve,rotation:G,color:se,alignH:he,alignV:oe};re==="MTEXT"&&(Ne.linespacingFactor=Z.linespacingFactor??R.linespacingFactor??1,Ne.rectWidth=(Z.rectWidth??R.rectWidth??0)*S,Ne.rectHeight=(Z.rectHeight??R.rectHeight??0)*S,Ne.bgFillFlags=Z.bgFillFlags??R.bgFillFlags??0,Ne.bgScale=Z.bgScale??R.bgScale??1.5,Ne.bgColorIndex=Z.bgColorIndex??R.bgColorIndex,Ne.bgColorRgb=Z.bgColorRgb??R.bgColorRgb),r.push(Ne)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},A=(S,M,y,T,I)=>{this._arcSegs({x:S,y:M},y,T,I,0,s,r)},x=(S,M,y)=>this._arrowMesh(S,M,y,s),E=(S,M,y,T)=>{M&&S&&a.push({text:M,pos:S,height:y,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,y,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,O=Math.hypot(L,w);if(O<1e-9)return;const k=L/O,U=w/O,$=f/2;S=l.x-k*$,M=l.y-U*$,y=l.x+k*$,T=l.y+U*$}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),y=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:y,y:T}),b(c,{x:S,y:M}),b(u,{x:y,y:T}),x({x:S,y:M,z:0},Math.atan2(M-T,S-y),I),x({x:y,y:T,z:0},Math.atan2(T-M,y-S),I),E(h??{x:(S+y)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),x({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),E(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),x({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),x({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),E(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,y=Math.hypot(c.x-S,c.y-M);if(y<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),A(S,M,y,T,T+L);const w=Math.max(y*.05,.5);x({x:S+Math.cos(T)*y,y:M+Math.sin(T)*y,z:0},T-Math.PI/2,w),x({x:S+Math.cos(T+L)*y,y:M+Math.sin(T+L)*y,z:0},T+L+Math.PI/2,w);const O=T+L/2;E(h??{x:S+Math.cos(O)*y*1.2,y:M+Math.sin(O)*y*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(y*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),E(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=yA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new H(e-r,t,0),new H(e+r,t,0),new H(e,t-r,0),new H(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Fs({color:15085616,depthTest:!1}),c=new pa(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new H(e,t,0),new H(i,s,0)]),a=new Fs({color:15085616,depthTest:!1}),o=new rf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new Fi(new H(d-_,f-m,0),new H(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new H),i=e.getSize(new H),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const SA="modulepreload",bA=function(n){return"/"+n},vd={},MA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=bA(l),l in vd)return;vd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":SA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Sd=/[\uAC00-\uD7A3]/,bd=/[\u1100-\u11FF\u3130-\u318F]/,AA=["cp949","windows-949","euc-kr"];let mr;function EA(){if(mr!==void 0)return mr;for(const n of AA)try{return mr=new TextDecoder(n),mr}catch{}return mr=null,null}function Md(n){if(!n||Sd.test(n)||bd.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=EA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Sd.test(s)||bd.test(s))&&!s.includes("�")?s:n}function TA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),TA(t(n))}class CA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Ed(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Ed(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Ed(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?wA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function wA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const Fp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function RA(n){return Fp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Xt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=RA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class DA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=LA(e,t),t=e.lastReadGroup;break;default:Xt(i,t,e);break}t=e.next()}return i}}function LA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class IA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Xt(i,t,e);break}t=e.next()}return i}}class PA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Xt(i,t,e);break}t=e.next()}return i}}class UA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return x??A??b},g.setLevel=function(L,w){return x=T(L),w!==!1&&S(x),u.call(g)},g.setDefaultLevel=function(L){A=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){x=null,y(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(x=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Bp);var jA=Bp.exports;const nt=JA(jA);nt.setLevel("error");function QA(n){n.registerEntityHandler(DA),n.registerEntityHandler(IA),n.registerEntityHandler(PA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(zA),n.registerEntityHandler(VA),n.registerEntityHandler(WA),n.registerEntityHandler(KA),n.registerEntityHandler(qA),n.registerEntityHandler(ZA)}class eE{constructor(){this._entityHandlers={},QA(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new CA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Hp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=A(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const y={};for(o=r.next();;){if(Xn(o,0,"ENDSEC")){S&&(y[S]=M);break}else o.code===9?(S&&(y[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),y}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Xn(o,0,"ENDSEC");)if(Xn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),E(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Ji(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=x(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=A(!0);break;default:Ji(o),o=r.next()}if(Xn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Xn(o,0,"ENDSEC");)Xn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],y={};let T=0;for(o=r.next();!Xn(o,0,f);)switch(o.code){case 5:y.handle=o.value,o=r.next();break;case 330:y.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Ji(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?y[M.tableRecordsProperty]=M.parseTableRecords():(Ji(o),o=r.next());break;default:Ji(o),o=r.next()}const I=y[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),y}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Xn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=x(o),o=r.next();break;case 11:M.upperRightCorner=x(o),o=r.next();break;case 12:M.center=x(o),o=r.next();break;case 13:M.snapBasePoint=x(o),o=r.next();break;case 14:M.snapSpacing=x(o),o=r.next();break;case 15:M.gridSpacing=x(o),o=r.next();break;case 16:M.viewDirectionFromTarget=x(o),o=r.next();break;case 17:M.viewTarget=x(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=x(o),o=r.next();break;case 111:M.ucsXAxis=x(o),o=r.next();break;case 112:M.ucsYAxis=x(o),o=r.next();break;case 110:M.ucsOrigin=x(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Ji(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},y=0,T;for(nt.debug("LType {"),o=r.next();!Xn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:y=o.value,y>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),y>0&&y!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},y;for(nt.debug("Layer {"),o=r.next();!Xn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,y=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=tE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[y]=M,nt.debug("Layer {"),M={},y=void 0,o=r.next());break;default:Ji(o),o=r.next();break}return nt.debug("}"),S[y]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function A(S){const M=[],y=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===y)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),E(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return y=="ENDSEC"&&(o=r.next()),M}function x(S){const M={};let y=S.code;if(M.x=S.value,y+=10,S=r.next(),S.code!=y)throw new Error("Expected code for point value to be "+y+" but got "+S.code+".");return M.y=S.value,y+=10,S=r.next(),S.code!=y?(r.rewind(),M):(M.z=S.value,M)}function E(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Xn(n,e,t){return n.code===e&&n.value===t}function Ji(n){nt.debug("unhandled group "+Hp(n))}function Hp(n){return n.code+":"+n.value}function tE(n){return Fp[n]}const La=Math.PI/180,nE=48;function iE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*nE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class sE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*La,s=e.next()),s.code===51&&(c=s.value*La,s=e.next()),s.code===73&&(u=s.value,s=e.next()),iE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*La,s=e.next()),s.code===51&&(d=s.value*La,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const A=u+m*b/g,x=f*Math.cos(A),E=p*Math.sin(A);t.points.push({x:r+x*Math.cos(_)-E*Math.sin(_),y:a+x*Math.sin(_)+E*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function Td(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Gt(n.vertices[0]),t.end=Gt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Gt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Gt(n.center);break;case"ELLIPSE":t.center=Gt(n.center),t.majorAxis=Gt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Gt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Gt(r[0])),r[1]&&(t.corner2=Gt(r[1])),r[2]&&(t.corner3=Gt(r[2])),r[3]&&(t.corner4=Gt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Gt(n.startPoint||n.position),t.alignmentPt=Gt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ia,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Gt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Gt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ia),y:Math.sin(n.rotation*Ia)});break;case"INSERT":{t.insertionPoint=Gt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ia;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function rE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=Td(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=Td(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Gt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function aE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Cd(n){return oE(aE(n))}function oE(n){const e=new eE;e.registerEntityHandler(sE);const t=e.parseSync(n);return rE(t)}const zp=/\.dwg$/i,Vp=/\.dxf$/i;function lE(n){return zp.test(n)}function cE(n){return Vp.test(n)}function uE(n){return zp.test(n)||Vp.test(n)}oA("/fonts/NanumGothic-Regular.ttf");const hE=document.getElementById("app"),wd=document.getElementById("status"),Sl=document.getElementById("layerList"),Rd=document.getElementById("layers"),Pa=document.getElementById("spaces");function cs(n,e=!1){wd.textContent=n,wd.classList.toggle("err",e)}const Zt=new vA(hE);Zt.onSelect(n=>{var t;if(!n){cs("deselected");return}const e=n;cs(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Dd=document.getElementById("coordX"),Ld=document.getElementById("coordY");function Id(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}Zt.onPointerWorld(n=>{if(!n){Dd.textContent="—",Ld.textContent="—";return}Dd.textContent=Id(n.x),Ld.textContent=Id(n.y)});function Gp(){var t;const n=Zt.getSpaces(),e=Zt.getActiveSpace();if(Pa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Pa.style.display="none";return}Pa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==Zt.getActiveSpace()&&(Zt.setSpace(i.handleHex),Gp(),Yp(),Zt.fit(),cs(`space ${i.label} · ${i.entityCount} entities`))}),Pa.append(s)}}async function dE(n,e){return cE(e)?Cd(n):lE(e)?Ad(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Ad(new Uint8Array(n)):Cd(n)}async function Wp(n,e){const t=await dE(n,e),i=Mr(t),s=uv(i);return Zt.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),Zt.resize(),t}async function ou(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Wp(await i.arrayBuffer(),t)}async function Xp(n){if(!uE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Wp(await n.arrayBuffer(),n.name)}function Yp(){Sl.innerHTML="";for(const n of Zt.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Sl.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),Zt.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Sl.append(e)}}async function fE(n,e){var r;const i=Mr(e).find(a=>a.handleHex===Zt.getActiveSpace()),s=i?` · ${i.label}`:"";cs(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Gp(),Yp(),Zt.fit()}async function Vr(n,e){cs(`loading ${n}…`);try{await fE(n,await e())}catch(t){cs(`${n}: ${t.message}`,!0),console.error(t)}}document.getElementById("sample").addEventListener("click",()=>{Vr("BasicSample.dwg",()=>ou("/samples/BasicSample.dwg","BasicSample.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{Vr("simple.dxf",()=>ou("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(Vr(e.name,()=>Xp(e)),n.target.value="")});document.getElementById("fit").addEventListener("click",()=>Zt.fit());let bl=!0;document.getElementById("theme").addEventListener("click",()=>{bl=!bl,Zt.setTheme(bl)});document.getElementById("layersBtn").addEventListener("click",()=>{Rd.style.display=Rd.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&Vr(e.name,()=>Xp(e))});const Ml=new URLSearchParams(location.search).get("model");Ml?Vr(Ml,()=>ou(Ml)):cs("ready · Sample DWG / DXF 또는 파일 드롭");window.addEventListener("resize",()=>Zt.resize()); diff --git a/dist2/assets/index-D6ZNOcH_.js b/dist2/assets/index-D6ZNOcH_.js new file mode 100644 index 0000000..c7a1f77 --- /dev/null +++ b/dist2/assets/index-D6ZNOcH_.js @@ -0,0 +1,5531 @@ +var $p=Object.defineProperty;var Jp=(n,e,t)=>e in n?$p(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Jp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Lc="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},jp=0,gu=1,Qp=2,Oa=1,e0=2,_r=3,Bi=0,cn=1,zt=2,fi=0,Hs=1,_u=2,xu=3,yu=4,t0=5,$i=100,n0=101,i0=102,s0=103,r0=104,a0=200,o0=201,l0=202,c0=203,El=204,Tl=205,u0=206,h0=207,d0=208,f0=209,p0=210,m0=211,g0=212,_0=213,x0=214,Cl=0,wl=1,Rl=2,Ws=3,Dl=4,Ll=5,Il=6,Pl=7,Od=0,y0=1,v0=2,Jn=0,Nd=1,kd=2,Fd=3,Bd=4,Hd=5,zd=6,Vd=7,Gd=300,ns=301,Xs=302,Eo=303,To=304,_o=306,Ul=1e3,ui=1001,Ol=1002,Nt=1003,S0=1004,Yr=1005,Xt=1006,Co=1007,Ui=1008,vn=1009,Wd=1010,Xd=1011,Cr=1012,Ic=1013,ei=1014,Pn=1015,_i=1016,Pc=1017,Uc=1018,wr=1020,Yd=35902,Kd=35899,qd=1021,Zd=1022,bn=1023,xi=1026,es=1027,$d=1028,Oc=1029,is=1030,Nc=1031,kc=1033,Na=33776,ka=33777,Fa=33778,Ba=33779,Nl=35840,kl=35841,Fl=35842,Bl=35843,Hl=36196,zl=37492,Vl=37496,Gl=37488,Wl=37489,Ya=37490,Xl=37491,Yl=37808,Kl=37809,ql=37810,Zl=37811,$l=37812,Jl=37813,jl=37814,Ql=37815,ec=37816,tc=37817,nc=37818,ic=37819,sc=37820,rc=37821,ac=36492,oc=36494,lc=36495,cc=36283,uc=36284,Ka=36285,hc=36286,b0=3200,vu=0,M0=1,ci="",pn="srgb",qa="srgb-linear",Za="linear",ft="srgb",_s=7680,Su=519,A0=512,E0=513,T0=514,Fc=515,C0=516,w0=517,Bc=518,R0=519,dc=35044,fc="300 es",Zn=2e3,$a=2001;function D0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function Ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function L0(){const n=Ja("canvas");return n.style.display="block",n}const bu={};function ja(...n){const e="THREE."+n.shift();console.log(e,...n)}function Jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=Jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=Jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function zs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function I0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const P0={[Cl]:wl,[Rl]:Il,[Dl]:Pl,[Ws]:Ll,[wl]:Cl,[Il]:Rl,[Pl]:Dl,[Ll]:Ws};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function U0(n,e){return(n%e+e)%e}function wo(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const O0={DEG2RAD:Ha},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),E=Math.sin(b);g=Math.sin(g*b)/E,o=Math.sin(o*b)/E,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Ro.copy(this).projectOnVector(e),this.sub(Ro)}reflect(e){return this.sub(Ro.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Ro=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],E=s[4],y=s[7],A=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*A,r[3]=a*m+o*E+l*S,r[6]=a*g+o*y+l*M,r[1]=c*_+u*b+d*A,r[4]=c*m+u*E+d*S,r[7]=c*g+u*y+d*M,r[2]=h*_+f*b+p*A,r[5]=h*m+f*E+p*S,r[8]=h*g+f*y+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return zs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Do.makeScale(e,t)),this}rotate(e){return zs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Do.makeRotation(-e)),this}translate(e,t){return zs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Do.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Do=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function N0(){const n={enabled:!0,workingColorSpace:qa,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Vs(s.r),s.g=Vs(s.g),s.b=Vs(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===ci?Za:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return zs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return zs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[qa]:{primaries:e,whitePoint:i,transfer:Za,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=N0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Vs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class k0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=Ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=Ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Io).x}get height(){return this.source.getSize(Io).y}get depth(){return this.source.getSize(Io).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Gd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ul:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Ol:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ul:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Ol:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}jt.DEFAULT_IMAGE=null;jt.DEFAULT_MAPPING=Gd;jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,y=(f+1)/2,A=(g+1)/2,S=(u+h)/4,M=(d+_)/4,v=(p+m)/4;return E>y&&E>A?E<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(E),s=S/i,r=M/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=M/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class H0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent(q0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new xr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const ef={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},Ai={h:0,s:0,l:0},Zr={h:0,s:0,l:0};function Oo(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=U0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=Oo(a,r,e+1/3),this.g=Oo(a,r,e),this.b=Oo(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=ef[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Vs(e.r),this.g=Vs(e.g),this.b=Vs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,No=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,ko=new B,Fo=new B,Bo=new B,Ho=new wt,zo=new wt,Vo=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),No.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(No),c=ri.dot(ri),u=ri.dot(No),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return Ho.setScalar(0),zo.setScalar(0),Vo.setScalar(0),Ho.fromBufferAttribute(e,t),zo.fromBufferAttribute(e,i),Vo.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(Ho,r.x),a.addScaledVector(zo,r.y),a.addScaledVector(Vo,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),ko.subVectors(e,i);const l=bs.dot(ko),c=Ms.dot(ko);if(l<=0&&c<=0)return t.copy(i);Fo.subVectors(e,s);const u=bs.dot(Fo),d=Ms.dot(Fo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Bo.subVectors(e,r);const f=bs.dot(Bo),p=Ms.dot(Bo);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(ar),Jr.subVectors(this.max,ar),As.subVectors(e.a,ar),Es.subVectors(e.b,ar),Ts.subVectors(e.c,ar),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Go(t,As,Es,Ts,Jr)||(t=[1,0,0,0,1,0,0,0,1],!Go(t,As,Es,Ts,Jr))?!1:(jr.crossVectors(Ei,Ti),t=[jr.x,jr.y,jr.z],Go(t,As,Es,Ts,Jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,$r=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,ar=new B,Jr=new B,jr=new B,Xi=new B;function Go(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,Qr=new Ee;let $0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:$0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=dc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;or.subVectors(e,this.center);const t=or.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(or,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Wo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(or.copy(e.center).add(Wo)),this.expandByPoint(or.copy(e.center).sub(Wo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let j0=0;const yn=new Et,Xo=new sn,Cs=new B,fn=new ki,lr=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:j0++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(D0(e)?nf:tf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Xo.lookAt(e),Xo.updateMatrix(),this.applyMatrix4(Xo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==Hs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==El&&(i.blendSrc=this.blendSrc),this.blendDst!==Tl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Ws&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class mc extends er{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const cr=new B,Rs=new B,Ds=new B,Ls=new Ee,ur=new Ee,sf=new Et,ea=new B,hr=new B,ta=new B,Uu=new Ee,Yo=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new mc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new Q0(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new Qa(i,3,0,!1)),ws.setAttribute("uv",new Qa(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),sf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;na(ea.set(-.5,-.5,0),Ds,a,Rs,s,r),na(hr.set(.5,-.5,0),Ds,a,Rs,s,r),na(ta.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Yo.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ea,hr,ta,!1,cr);if(o===null&&(na(hr.set(-.5,.5,0),Ds,a,Rs,s,r),Yo.set(0,1),o=e.ray.intersectTriangle(ea,ta,hr,!1,cr),o===null))return;const l=e.ray.origin.distanceTo(cr);le.far||t.push({distance:l,point:cr.clone(),uv:Sn.getInterpolation(cr,ea,hr,ta,Uu,Yo,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function na(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(ur.x=r*Ls.x-s*Ls.y,ur.y=s*Ls.x+r*Ls.y):ur.copy(Ls),n.copy(e),n.x+=ur.x,n.y+=ur.y,n.applyMatrix4(sf)}const li=new B,Ko=new B,ia=new B,Ci=new B,qo=new B,sa=new B,Zo=new B;class zc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){Ko.copy(e).add(t).multiplyScalar(.5),ia.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(Ko);const r=e.distanceTo(t)*.5,a=-this.direction.dot(ia),o=Ci.dot(this.direction),l=-Ci.dot(ia),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(Ko).addScaledVector(ia,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){qo.subVectors(t,e),sa.subVectors(i,e),Zo.crossVectors(qo,sa);let a=this.direction.dot(Zo),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(sa.crossVectors(Ci,sa));if(l<0)return null;const c=o*this.direction.dot(qo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot(Zo);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends er{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Od,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new zc,ra=new xo,Fu=new B,aa=new B,oa=new B,la=new B,$o=new B,ca=new B,Bu=new B,ua=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=b,A=E;yt.far?null:{distance:c,point:ua.clone(),object:n}}function ha(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,aa),n.getVertexPosition(l,oa),n.getVertexPosition(c,la);const u=tm(n,e,t,i,aa,oa,la,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,aa,oa,la,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(aa,oa,la,h.normal),u.face=h,u.barycoord=d}return u}class rf extends jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const Jo=new B,nm=new B,im=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=Jo.subVectors(i,t).cross(nm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(Jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||im.getNormalMatrix(e),s=this.coplanarPoint(Jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new xo,sm=new Ee(.5,.5),da=new B;class af{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],E=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,g-p,A-b).normalize(),s[1].setComponents(c+a,f+u,g+p,A+b).normalize(),s[2].setComponents(c+o,f+d,g+_,A+E).normalize(),s[3].setComponents(c-o,f-d,g-_,A-E).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,g-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,g-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,g+m,A+y).normalize();else if(t===$a)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=sm.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,da.y=s.normal.y>0?e.max.y:e.min.y,da.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(da)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends er{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const eo=new B,to=new B,Hu=new Et,dr=new zc,fa=new xo,jo=new B,zu=new B;let of=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;jo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(jo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ma extends of{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/M),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Vc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class pf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Rr(r,a,t,o,l,c,0),a}function mf(n,e,t,i,s){let r;if(s===Om(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&Ks(r,r.next)&&(Lr(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(Ks(t,t.next)||At(t.prev,t,t.next)===0)){if(Lr(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Rr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Rm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Sm(n,i,s,r):vm(n)){e.push(l.i,n.i,c.i),Lr(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=bm(rs(n),e),Rr(n,e,t,i,s,r,2)):a===2&&Mm(n,e,t,i,s,r):Rr(rs(n),e,t,i,s,r,1);break}}}function vm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&yr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Sm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=gc(f,p,e,t,i),b=gc(_,m,e,t,i);let E=n.prevZ,y=n.nextZ;for(;E&&E.z>=g&&y&&y.z<=b;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&yr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0||(E=E.prevZ,y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&yr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;E&&E.z>=g;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&yr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&yr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function bm(n,e){let t=n;do{const i=t.prev,s=t.next.next;!Ks(i,s)&&_f(i,t,t.next,s)&&Dr(i,s)&&Dr(s,i)&&(e.push(i.i,t.i,s.i),Lr(t),Lr(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Mm(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Im(a,o)){let l=xf(a,o);a=rs(a,a.next),l=rs(l,l.next),Rr(a,e,t,i,s,r,0),Rr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Am(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&gf(sa.x||t.x===a.x&&wm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function wm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Rm(n,e,t,i){let s=n;do s.z===0&&(s.z=gc(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Dm(s)}function Dm(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function gc(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Lm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function yr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&gf(n,e,t,i,s,r,a,o)}function Im(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Pm(n,e)&&(Dr(n,e)&&Dr(e,n)&&Um(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||Ks(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function Ks(n,e){return n.x===e.x&&n.y===e.y}function _f(n,e,t,i){const s=xa(At(n,e,t)),r=xa(At(n,e,i)),a=xa(At(t,i,n)),o=xa(At(t,i,e));return!!(s!==r&&a!==o||s===0&&_a(n,t,e)||r===0&&_a(n,i,e)||a===0&&_a(t,n,i)||o===0&&_a(t,e,i))}function _a(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function xa(n){return n>0?1:n<0?-1:0}function Pm(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&_f(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Dr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Um(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function xf(n,e){const t=_c(n.i,n.x,n.y),i=_c(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=_c(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Lr(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function _c(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function Om(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Vm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Gm extends er{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=b0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Wm extends er{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Xm extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const ya=new B,va=new Hi,Hn=new B;class vf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(ya,va,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ya,va,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(ya,va,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(ya,va,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends vf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=pc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(Ha*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return pc*2*Math.atan(Math.tan(Ha*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(Ha*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Xc extends vf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class Ym extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===$a)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Km extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class qm extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Zm(i);switch(t){case qd:return n*e;case $d:return n*e/s.components*s.byteLength;case Oc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case Nc:return n*e*2/s.components*s.byteLength;case Zd:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case kc:return n*e*4/s.components*s.byteLength;case Na:case ka:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Fa:case Ba:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case kl:case Bl:return Math.max(n,16)*Math.max(e,8)/4;case Nl:case Fl:return Math.max(n,8)*Math.max(e,8)/2;case Hl:case zl:case Gl:case Wl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Vl:case Ya:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case Zl:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case Jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case ec:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case sc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case ac:case oc:case lc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case cc:case uc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case Ka:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Zm(n){switch(n){case vn:case Wd:return{byteLength:1,components:1};case Cr:case Xd:case _i:return{byteLength:2,components:1};case Pc:case Uc:return{byteLength:2,components:4};case ei:case Ic:case Pn:return{byteLength:4,components:1};case Yd:case Kd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Lc}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Lc);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function Sf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function $m(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,fg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,pg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,gg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,_g=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,yg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,vg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Sg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,bg=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Mg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Ag=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Eg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,Tg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Cg="gl_FragColor = linearToOutputTexel( gl_FragColor );",wg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Rg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Dg=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Lg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ug=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,Og=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Ng=`#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`,kg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Fg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,Bg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Hg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,zg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Vg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Gg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Wg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Xg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,Yg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Kg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,qg=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Zg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,$g=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Jg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,jg=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,Qg=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,e_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,t_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,n_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,i_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,s_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,r_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,a_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,o_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,l_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,c_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,u_=`#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`,h_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,d_=`#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`,f_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,p_=`#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`,m_=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,g_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,__=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,x_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,y_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,v_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,S_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,b_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,M_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,A_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,E_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,T_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,C_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,w_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,R_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,D_=`#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`,L_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,I_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,P_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,U_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,O_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,N_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,k_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,F_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,B_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,H_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,z_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,V_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,G_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,W_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,X_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,Y_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,K_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,q_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,$_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const J_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,j_=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,Q_=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,ex=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,ix=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,sx=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,rx=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,ax=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,ox=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,lx=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,cx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,ux=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,hx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,fx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,px=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,gx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,_x=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,xx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,yx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,vx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Sx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,bx=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Mx=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Ax=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Ex=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,Tx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Cx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,wx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Rx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Dx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Jm,alphahash_pars_fragment:jm,alphamap_fragment:Qm,alphamap_pars_fragment:eg,alphatest_fragment:tg,alphatest_pars_fragment:ng,aomap_fragment:ig,aomap_pars_fragment:sg,batching_pars_vertex:rg,batching_vertex:ag,begin_vertex:og,beginnormal_vertex:lg,bsdfs:cg,iridescence_fragment:ug,bumpmap_pars_fragment:hg,clipping_planes_fragment:dg,clipping_planes_pars_fragment:fg,clipping_planes_pars_vertex:pg,clipping_planes_vertex:mg,color_fragment:gg,color_pars_fragment:_g,color_pars_vertex:xg,color_vertex:yg,common:vg,cube_uv_reflection_fragment:Sg,defaultnormal_vertex:bg,displacementmap_pars_vertex:Mg,displacementmap_vertex:Ag,emissivemap_fragment:Eg,emissivemap_pars_fragment:Tg,colorspace_fragment:Cg,colorspace_pars_fragment:wg,envmap_fragment:Rg,envmap_common_pars_fragment:Dg,envmap_pars_fragment:Lg,envmap_pars_vertex:Ig,envmap_physical_pars_fragment:Gg,envmap_vertex:Pg,fog_vertex:Ug,fog_pars_vertex:Og,fog_fragment:Ng,fog_pars_fragment:kg,gradientmap_pars_fragment:Fg,lightmap_pars_fragment:Bg,lights_lambert_fragment:Hg,lights_lambert_pars_fragment:zg,lights_pars_begin:Vg,lights_toon_fragment:Wg,lights_toon_pars_fragment:Xg,lights_phong_fragment:Yg,lights_phong_pars_fragment:Kg,lights_physical_fragment:qg,lights_physical_pars_fragment:Zg,lights_fragment_begin:$g,lights_fragment_maps:Jg,lights_fragment_end:jg,lightprobes_pars_fragment:Qg,logdepthbuf_fragment:e_,logdepthbuf_pars_fragment:t_,logdepthbuf_pars_vertex:n_,logdepthbuf_vertex:i_,map_fragment:s_,map_pars_fragment:r_,map_particle_fragment:a_,map_particle_pars_fragment:o_,metalnessmap_fragment:l_,metalnessmap_pars_fragment:c_,morphinstance_vertex:u_,morphcolor_vertex:h_,morphnormal_vertex:d_,morphtarget_pars_vertex:f_,morphtarget_vertex:p_,normal_fragment_begin:m_,normal_fragment_maps:g_,normal_pars_fragment:__,normal_pars_vertex:x_,normal_vertex:y_,normalmap_pars_fragment:v_,clearcoat_normal_fragment_begin:S_,clearcoat_normal_fragment_maps:b_,clearcoat_pars_fragment:M_,iridescence_pars_fragment:A_,opaque_fragment:E_,packing:T_,premultiplied_alpha_fragment:C_,project_vertex:w_,dithering_fragment:R_,dithering_pars_fragment:D_,roughnessmap_fragment:L_,roughnessmap_pars_fragment:I_,shadowmap_pars_fragment:P_,shadowmap_pars_vertex:U_,shadowmap_vertex:O_,shadowmask_pars_fragment:N_,skinbase_vertex:k_,skinning_pars_vertex:F_,skinning_vertex:B_,skinnormal_vertex:H_,specularmap_fragment:z_,specularmap_pars_fragment:V_,tonemapping_fragment:G_,tonemapping_pars_fragment:W_,transmission_fragment:X_,transmission_pars_fragment:Y_,uv_pars_fragment:K_,uv_pars_vertex:q_,uv_vertex:Z_,worldpos_vertex:$_,background_vert:J_,background_frag:j_,backgroundCube_vert:Q_,backgroundCube_frag:ex,cube_vert:tx,cube_frag:nx,depth_vert:ix,depth_frag:sx,distance_vert:rx,distance_frag:ax,equirect_vert:ox,equirect_frag:lx,linedashed_vert:cx,linedashed_frag:ux,meshbasic_vert:hx,meshbasic_frag:dx,meshlambert_vert:fx,meshlambert_frag:px,meshmatcap_vert:mx,meshmatcap_frag:gx,meshnormal_vert:_x,meshnormal_frag:xx,meshphong_vert:yx,meshphong_frag:vx,meshphysical_vert:Sx,meshphysical_frag:bx,meshtoon_vert:Mx,meshtoon_frag:Ax,points_vert:Ex,points_frag:Tx,shadow_vert:Cx,shadow_frag:wx,sprite_vert:Rx,sprite_frag:Dx},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:nn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:nn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:nn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:nn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:nn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:nn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:nn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:nn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:nn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:nn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:nn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:nn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:nn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:nn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const Sa={r:0,b:0,g:0},Lx=new Et,bf=new qe;bf.set(-1,0,0,0,1,0,0,0,1);function Ix(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const y=b.backgroundBlurriness>0;E=e.get(E,y)}return E}function p(b){let E=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),E=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,E){const y=f(E);y&&(y.isCubeTexture||y.mapping===_o)?(c===void 0&&(c=new Vt(new Nr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:qs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Lx.makeRotationFromEuler(E.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(bf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:qs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(Sa,yf(n)),t.buffers.color.setClear(Sa.r,Sa.g,Sa.b,E,r)}function g(){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 a},setClearColor:function(b,E=1){a.set(b),o=E,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Px(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function _(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Ic;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Nx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,E=b*4;let y=g.clippingState||null;l.value=y,y=u(p,h,E,f);for(let A=0;A!==E;++A)y[A]=t[A];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Xs;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,fr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,fr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,fr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const g=[];let b=0;for(let M=0;ME-Oi?s-E+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,fr)}}function Bx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),E=new Float32Array(m*p*f),y=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,v,0,M+2/3,v,0,M+2/3,v+1,0,M,v,0,M+2/3,v+1,0,M,v+1,0];b.set(T,_*p*S),E.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,g*p*S)}const A=new Ct;A.setAttribute("position",new Un(b,_)),A.setAttribute("uv",new Un(E,m)),A.setAttribute("faceIndex",new Un(y,g)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=_o,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Hx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:kx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:yo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function zx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:yo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:yo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:yo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function yo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Mf extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new lf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Nr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:qs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new Ym(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Vx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===Eo||f===To)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Mf(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===Eo||f===To,_=f===ns||f===Xs;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===Eo?h.mapping=ns:f===To&&(h.mapping=Xs),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?nf:tf)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const M=new Float32Array(A*S*4*d),v=new jd(M,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Xc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(E,y){a.setSize(E,y),o.setSize(E,y);for(let A=0;A0&&g[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const z1=37297;let V1=0;function G1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function W1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case Za:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+G1(n.getShaderSource(e),o)}else return r}function X1(n,e){const t=W1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const Y1={[Nd]:"Linear",[kd]:"Reinhard",[Fd]:"Cineon",[Bd]:"ACESFilmic",[zd]:"AgX",[Vd]:"Neutral",[Hd]:"Custom"};function K1(n,e){const t=Y1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const ba=new B;function q1(){it.getLuminanceCoefficients(ba);const n=ba.x.toFixed(4),e=ba.y.toFixed(4),t=ba.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function Z1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(vr).join(` +`)}function $1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function J1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function yc(n){return n.replace(j1,ey)}const Q1=new Map;function ey(n,e){let t=$e[e];if(t===void 0){const i=Q1.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return yc(t)}const ty=/#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 Sh(n){return n.replace(ty,ny)}function ny(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(vr).join(` +`),g.length>0&&(g+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(vr).join(` +`),g=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?K1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,X1("linearToOutputTexel",t.outputColorSpace),q1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(vr).join(` +`)),a=yc(a),a=yh(a,t),a=vh(a,t),o=yc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===fc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===fc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);const E=b+m+a,y=b+g+o,A=gh(s,s.VERTEX_SHADER,E),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(_,A),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,A,S);else{const ae=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:g}})}s.deleteShader(A),s.deleteShader(S),v=new za(s,_),T=J1(s,_)}let v;this.getUniforms=function(){return v===void 0&&M(this),v};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,z1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=V1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=A,this.fragmentShader=S,this}let fy=0;class py{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new my(e),t.set(e,i)),i}}class my{constructor(e){this.id=fy++,this.code=e,this.usedTimes=0}}function gy(n){return n===is||n===Ya||n===Ka}function _y(n,e,t,i,s,r){const a=new Qd,o=new py,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===_o?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===M0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&gy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===Hs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(g(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function g(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function E(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=Bm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new dy(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:M}}function xy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function yy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||yy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function Sy(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function by(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let My=0;function Ay(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Ey(n){const e=new Sy,t=by(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,E=0,y=0,A=0,S=0,M=0;c.sort(Ay);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==_||v.rectAreaLength!==m||v.hemiLength!==g||v.numDirectionalShadows!==b||v.numPointShadows!==E||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,v.directionalLength=f,v.pointLength=p,v.spotLength=_,v.rectAreaLength=m,v.hemiLength=g,v.numDirectionalShadows=b,v.numPointShadows=E,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=M,i.version=My++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Cy=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,wy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ry=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Dy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,pr=new B,ol=new B;function Ly(n,e,t){let i=new af;const s=new Ee,r=new Ee,a=new wt,o=new Gm,l=new Wm,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Cy,fragmentShader:wy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Oa;let g=this.type;this.render=function(S,M,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===e0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Oa);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=g!==this.type;U&&M.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===_r){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ys(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Mf(s.x),N.map.depthTexture=new rm(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ys(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Oa?(N.map.depthTexture.compareFunction=D?Bc:Fc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,U=M.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,M.addEventListener("dispose",A)),I=P}if(I.visible=M.visible,I.wireframe=M.wireframe,T===_r?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,M,v,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===_r)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,x){return p?new OffscreenCanvas(R,x):Ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=_(fe,W));const F=x?_(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function E(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?Za:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===wr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===Cr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===wr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===Cr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function M(R){const x=R.target;x.removeEventListener("dispose",M),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ul]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Ol]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[S0]:n.NEAREST_MIPMAP_NEAREST,[Yr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[Co]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[A0]:n.NEVER,[R0]:n.ALWAYS,[E0]:n.LESS,[Fc]:n.LEQUAL,[T0]:n.EQUAL,[Bc]:n.GEQUAL,[C0]:n.GREATER,[w0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===Co||x.magFilter===Yr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===Co||x.minFilter===Yr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Yr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",M));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==qa&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Uy(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Pc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Uc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Yd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===Kd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Wd)return n.BYTE;if(i===Xd)return n.SHORT;if(i===Cr)return n.UNSIGNED_SHORT;if(i===Ic)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===qd)return n.ALPHA;if(i===Zd)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===$d)return n.RED;if(i===Oc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===Nc)return n.RG_INTEGER;if(i===kc)return n.RGBA_INTEGER;if(i===Na||i===ka||i===Fa||i===Ba)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===Na)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===ka)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===Na)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===ka)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===Nl||i===kl||i===Fl||i===Bl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===Nl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===kl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===Hl||i===zl||i===Vl||i===Gl||i===Wl||i===Ya||i===Xl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===Hl||i===zl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Vl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Gl)return r.COMPRESSED_R11_EAC;if(i===Wl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ya)return r.COMPRESSED_RG11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Yl||i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Yl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===ac||i===oc||i===lc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===ac)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===oc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===cc||i===uc||i===Ka||i===hc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===cc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===uc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===Ka)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===wr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const Oy=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Ny=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class ky{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new cf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:Oy,fragmentShader:Ny,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Fy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new ky,g={},b=t.getContextAttributes();let E=null,y=null;const A=[],S=[],M=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Km;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Uo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Uo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Uo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),E=b.envMap,y=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(By.makeRotationFromEuler(y)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(wf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,E){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=E*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function zy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const M=A.program;i.updateUBOMapping(y,M);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),M=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=M-v),y.__size=S,y.__cache={},this}function g(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function b(y){const A=y.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function E(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:E}}const Vy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Gy(){return zn===null&&(zn=new rf(Vy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Wy{constructor(e={}){const{canvas:t=L0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([kc,Nc,Oc]),g=new Set([vn,ei,Cr,wr,Pc,Uc]),b=new Uint32Array(4),E=new Int32Array(4),y=new B;let A=null,S=null;const M=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new af;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Lc}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Gx(V),se.init(),ve=new Uy(V,se),R=new Ox(V,se,e,ve),x=new Iy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new Yx(V),H=new xy,$=new Py(V,se,x,H,R,ve,G),fe=new Vx(I),W=new $m(V),Me=new Px(V,W),F=new Wx(V,W,G,Me),Y=new qx(V,F,W,Me,G),k=new Kx(V,R,$),ge=new Nx(H),re=new _y(I,fe,se,R,Me,ge),ce=new Hy(I,H),he=new vy,ee=new Ty(se),Ge=new Ix(I,fe,x,Y,p,l),we=new Ly(I,Y,R),pe=new zy(V,G,R,x),ye=new Ux(V,se,G),ue=new Xx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),_!==vn&&(T=new $x(_,t.width,t.height,o,s,r));const Ne=new Fy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Xr(C){hs&&hs(C)}function ni(){_n.stop()}function ir(){_n.start()}const _n=new Sf;_n.setAnimationLoop(Xr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",ir),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,M.length),A.init(),M.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),sr(A,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?A=M[M.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=za.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Gy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}za.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(za.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await I0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Ma.origin.copy(this.object.position),Ma.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Ma.direction))ll||8*(1-this._lastQuaternion.dot(this.object.quaternion))>ll||this._lastTargetPosition.distanceToSquared(this.target)>ll?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=ov[e%10];return rv(Math.floor(e/10)*15,t,i)}return 13226457}function Kc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Df(n){return Kc(n.ownerHandle)}function lv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function cv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Ar(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Df(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=lv(o.name??"");if(!l)continue;const c=Kc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:cv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function uv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function cl(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function vc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function mv(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return Lf;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,qc}function kf(n,e){var t=new hv(n,e),i,s,r;do{switch(i=pv(t),s=Yn(t,2,0),s){case 0:r=gv(t);break;case 1:r=Lh(t,If,Pf);break;case 2:mv(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=Lf}if(r!==qc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const E=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Bf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=Hf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Ff){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Ff;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=Hf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>vv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var no={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};$s.MACSTRING=function(n,e,t,i){const s=no[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function Sc(n){return n>=-128&&n<=127}function bv(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Mv(n,e,t):e=Av(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&Jt.LONG_WORDS,r=e&Jt.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const v=i.get(s);v.path,M=v.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,y=this.parsePackedDeltas(M),t==="gvar"&&(A=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return y===void 0&&S(),E==="deltasY"?A:y},set:function(M){y===void 0&&S(),E==="deltasY"?A=M:y=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&Jt.EMBEDDED_PEAK_TUPLE),r=!!(i&Jt.INTERMEDIATE_REGION),a=!!(i&Jt.PRIVATE_POINT_NUMBERS),o=s?void 0:i&Jt.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&Jt.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Hv(t,u,a,o);else if(t.format===12||t.format===13)zv(t,u,t.format);else if(t.format===4)Vv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Gv(t,i),t}function Xv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function Yv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Kv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function jf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function eu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=jf(s.colorRecords[r]);return i==="bgra"?a:Qs(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function rS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=aS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return Qs(n,e)}function Qs(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=jf(n)}else typeof n!="object"&&(n=ho(n,"bgra"));let t=["hsl","hsla"].includes(e)?rS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return Qf(n);default:throw new Error("Unknown color format: "+e)}}var ep={parse:iS,make:sS,getPaletteColor:eu,parseColor:ho,formatColor:Qs};function oS(n,e){let t=e||new Zs;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function Qt(n){this.bindConstructorValues(n)}Qt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",oS(this,n.path))};Qt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};Qt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};Qt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new Zs;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new Zs;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function So(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});So.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function fS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function pS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return fS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function mS(n){const e={};for(let t=0;t1&&l===23){ES(a);continue}r.push([l,a]),a=[]}else a.push(pS(s,l))}return mS(r)}function Er(n,e){return e<=390?e=Va[e]:n?e=n[e-391]:e=void 0,e}function nu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var np=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],_S=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],ip=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],xS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],yS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function vS(n,e,t,i){const s=tu(n,e,n.byteLength,i);return nu(s,i>1?_S:np,t)}function iu(n,e,t,i,s){const r=tu(n,e,t,s);return nu(r,s>1?xS:ip,i)}function SS(n,e,t){const i=tu(n,e,void 0,t);return nu(i,yS)}function bS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function sp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Ec(n,e,t,i,s){let r,a,o,l;const c=new Zs,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,E,y=0,A=[],S,M=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,E=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Ec(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,g=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,E=P._nominalWidthX)}else m=v.topDict._subrs,g=v.topDict._subrsBias;const T=sp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+E),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(D=u.pop()+g,ae=m[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,U(ae),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=_,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-_)?p=le+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ac[u.pop()],Xe=Ac[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+E,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+E,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,U(ae),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=fo(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=hl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=hl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),_=bS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),_=hl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=iu(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Xn(n,p);t.subrs=_.objects,t.subrsBias=fo(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=hS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Zv:u.charset===1?h=$v:u.charset===2?h=Jv:h=MS(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ac:u.encoding===1?f=jv:f=AS(n,e+u.encoding),t.cffEncoding=new Jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=dS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Ec,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Va.length:(t=Va.length+e.length,e.push(n)),t}function CS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function wS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function $S(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var wc={parse:ZS,make:$S,unicodeRanges:Cc,getUnicodeRange:qS};function JS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var mp={parse:ib,make:sb};function rb(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function ab(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=uo(t,r),i}function ob(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Rb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Rb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=op.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=lp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=hp.make(n.glyphs.length),E=wc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=cp.make(n.glyphs),A=qf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),v=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=Kf.make(I,O),Z=O.length>0?up.make(O):void 0,N=dp.make(n),X=Tc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?pp.make(n.metas):void 0,ae=[m,g,b,E,P,A,N,X,y];Z&&ae.push(Z);const ie={gsub:fp,cpal:ep,colr:mp,stat:_p,avar:xp,cvar:yp,fvar:gp,gvar:vp,gasp:Sp,svg:bp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Mp(ae),de=_e.encode(),le=su(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ap(n,e){this.font=n,this.tableName=e}Ap.prototype={searchTag:dl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=dl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function Ob(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Nb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Ep(n){return n[0]===31&&n[1]===139&&n[2]===8}function kb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return kf(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Fb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){bo.call(this,n,"gsub")}function ru(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=ru(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=ru(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dho(e,"raw")):ho(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return eu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=Ob(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Nb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Vb(n){return{template:Wb(n).then(Kb),images:new Map}}function Gb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=qb(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Wb=typeof DecompressionStream=="function"?Yb:Xb;function Xb(n){try{return Promise.resolve(new TextDecoder().decode(Ep(n)?kb(n):n))}catch(e){return Promise.reject(e)}}function Yb(n){if(Ep(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Kb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function qb(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var fl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function Cp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Ga([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Ga(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return au(e.points)}function $b(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Ga(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,po=64,mo=1e4,Dp,as,Lp,Rc;function Ip(n){this.font=n,this.getCommands=function(e){return Rp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function t2(n){return n}function Pp(n){return Math.sign(n)*Math.round(Math.abs(n))}function n2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function i2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function s2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function r2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Up=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Hr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Hr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Hr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Hr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Hr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function zr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Hr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Ur=Object.freeze(new gi(0,0)),a2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Pp}}Ip.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=a2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Lp(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Lp=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Rc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Dp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Mo(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=zr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=zr(o,l)}function o2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=zr(i,t)}function l2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=zr(i,t)}function c2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function u2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function h2(n){n.fv=n.pv}function d2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,E=d.y,y=h.x,A=h.y,S=(p-m)*(E-A)-(_-g)*(b-y),M=p*g-_*m,v=b*A-E*y;f.x=(M*(b-y)-v*(p-m))/S,f.y=(M*(E-A)-v*(_-g))/S}function f2(n){n.rp0=n.stack.pop()}function p2(n){n.rp1=n.stack.pop()}function m2(n){n.rp2=n.stack.pop()}function g2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Mo(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function _2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Mo(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function x2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Mo(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Mo(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){n.loop=n.stack.pop(),n.loop>mo&&(n.loop=mo)}function S2(n){n.round=Pp}function b2(n){n.round=i2}function M2(n){const e=n.stack.pop();n.minDis=e/64}function A2(n){Op(n,!1)}function E2(n){const e=n.stack.pop();n.ip+=e-1}function T2(n){const e=n.stack.pop();n.cvCutIn=e/64}function C2(n){const e=n.stack;e.push(e[e.length-1])}function pl(n){n.stack.pop()}function w2(n){n.stack.length=0}function R2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function D2(n){const e=n.stack;e.push(e.length)}function L2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>mo&&(i=mo),++n.callDepth>po)throw new Error("Hinting call depth exceeded maximum of "+po);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;apo)throw new Error("Hinting call depth exceeded maximum of "+po);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function P2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function U2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function O2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Ur);n&&(a=e.round(a)),s.setRelative(i,Ur,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function J2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function j2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function eM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function tM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function nM(n){n.stack.pop()||Op(n,!0)}function iM(n){}function sM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function rM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function aM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function ml(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function oM(n){const t=n.stack.pop();n.deltaBase=t}function lM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function cM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function uM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function fM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function pM(n){const e=n.stack;let t=e.pop();e.push(-t)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function gM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Ra(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function _M(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function gl(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function xM(n){let e=n.stack.pop();n.round=Up;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function yM(n){let e=n.stack.pop();n.round=Up;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function vM(n){n.round=t2}function SM(n){n.round=s2}function bM(n){n.round=r2}function MM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=zr(o,l)}function AM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function EM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function TM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function CM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function wM(n){n.stack.pop()}function RM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof nr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof nr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof nr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Ao.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Ao.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof ou)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Ao)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function OM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function NM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function _l(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>OM.apply(this,[i,e]);case"12":return i=>NM.apply(this,[i,e]);case"63":return i=>kM.apply(this,[i,e]);case"41":return i=>FM.apply(this,[i,e]);case"21":return i=>zM.apply(this,[i,e]);case"51":return i=>BM.apply(this,[i,e]);case"53":return i=>HM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var VM=gn;function GM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function WM(n){const e=n.get(1);return e===null||!Fi(e)}var XM={startCheck:GM,endCheck:WM};function YM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function KM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=UM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var qM={startCheck:YM,endCheck:KM};function ZM(n,e,t){e[t].setState(n.tag,n.substitution)}function $M(n,e,t){e[t].setState(n.tag,n.substitution)}function xl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=Np(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function e3(n){if(Np(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function i3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function a3(n){return n.index===n.context.length-1}var o3={startCheck:r3,endCheck:a3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function l3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function f3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function x3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function A3(n){const e=n.current,t=n.get(1);return t===null&&Dc(e)||Dc(t)}function E3(n){const e=n.get(1);return e===null||!Dc(e)}var T3={startCheck:A3,endCheck:E3};function C3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var w3=C3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new PM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:o3,latinWordCheck:d3,arabicWordCheck:XM,arabicSentenceCheck:qM,thaiWordCheck:_3,unicodeVariationSequenceCheck:T3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function R3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function D3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new VM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=yl(n),this.names.macintosh=yl(n),this.names.windows=yl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new Zf(this),this.position=new Ib(this),this.substitution=new Bb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new e2(this)),!0)}),this.palettes=new Tp(this),this.layers=new Hb(this),this.svgImages=new zb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new DM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new k3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Lb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(Y3)),s}var q3={parse:K3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function Z3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var $3=new Array(10);function J3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,$3)}])}var j3={parse:Z3,make:J3};function Q3(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Tr(aA(t))})(),this._shared.catch(()=>{Tr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=La((O-h)/m),D=La((P-h)/m);for(let oe=X;oe<=D;oe++)g[oe].push(U);const ae=La((Z-d)/_),ie=La((N-d)/_);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const E=w=>Math.ceil(w.length/4),y=g.reduce((w,U)=>w+E(U),0)+b.reduce((w,U)=>w+E(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),M=this.data,v=(w,U,O,P,Z)=>{M[w*4]=U,M[w*4+1]=O,M[w*4+2]=P,M[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class uA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i/l.capHeightEm,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let E=0;E=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-Da,Z=w-Da,N=U+Da,X=O+Da,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=M+ie*u;this.pos.push(t.x+oe*p-_e*_,t.y+oe*_+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:fc,vertexShader:lA,fragmentShader:cA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const hA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,dA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function fA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const E=g.substring(0,b).trim().toLowerCase(),y=g.substring(b+1).trim(),A=parseFloat(y);isNaN(A)||(E==="s"?c=A:E==="r"?u=A:E==="a"?(u=A,d=!0):E==="u"?(u=A,h=!0):E==="x"?f=A:E==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function pA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=pA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=fA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Fp=new Map;function Bp(n){const e=mA(n);for(const[t,i]of e.entries())Fp.set(t,i)}Bp(hA);Bp(dA);const gA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},_A=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function xA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Fp.get(e);if(!t)return;let i=t.elements;_A.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=gA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const vl=13226457,Sd=64,Sl=72,yA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class vA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Or.shared().catch(()=>{}),this._scene=new Z0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Xc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Wy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new Yy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new xr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,E,y,A,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((y=(E=this._controls)==null?void 0:E.target)==null?void 0:y.x)??s.position.x,g=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Ar(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+10;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?cl(i,this._activeSpaceHex):null,g=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(g.has(R)||g.set(R,[]),g.get(R).push(se))}const b=[];let E=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),E++,!(E&7)&&b.length<1e5&&b.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,M=Ar(e),v=M.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=M.find(R=>R.kind==="model");if(se){const R=cl(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{A($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(_&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,A,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const W=(g.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,A,y):(this._polylineSegs(F,re,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(A(W.x-1,W.y,W.x+1,W.y,W.z||0,H),A(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?A(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):A(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=g.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:g,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,A,y):(this._polylineSegs(re.points,!0,0,H,A),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=g.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?g.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,A),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),sr=ds.createImageData(An,ni),En=sr.data;if(Xr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ma(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ma(R,new Xm({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16250611),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ma(_,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Ar(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var E,y,A,S,M,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},g=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(E=N.ownerHandle)==null?void 0:E.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(_.size){const de=(M=N.layerHandle)==null?void 0:M.value;if(de!=null&&_.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>g(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,g):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>g(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>g(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,g):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),g(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?cl(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Aa(h)??vl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=xA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),E=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,M=u>0?1:-1,v=E+M*A*b,T=y+M*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+_*w/L;r.push({x:v+g*Math.cos(U),y:T+g*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=Sl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),E=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:E,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var m;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let g=0;g{let b=Math.max(0,Math.min(g,u));for(let A=0;A1e-9?b/S:0,v=l[A],T=l[A+1],I=v.x+(T.x-v.x)*M,L=v.y+(T.y-v.y)*M,w=(v.z||0)+((T.z||0)-(v.z||0))*M,U=Math.atan2(T.y-v.y,T.x-v.x);return{x:I,y:L,z:w,angle:U}}b-=S}const E=l[l.length-1],y=l[l.length-2];return{x:E.x,y:E.y,z:E.z||0,angle:Math.atan2(E.y-y.y,E.x-y.x)}};if(i.patternLength*s<1e-6)return;let f=0,p=0;const _=i.elements;for(;fE){const A=d(E),S=d(y);a(A.x,A.y,S.x,S.y,A.z,r)}f+=b}else if(g.type==="gap"){const b=Math.abs(g.val||.1)*s;f+=b}else if(g.type==="shape"){const b=d(f);this._renderShapeSymbol(g,b,s,r,a)}else if(g.type==="text"){const b=d(f);if(g.text&&o){const E=(g.style||"STANDARD").toUpperCase(),y=((m=this._textStyleHeightMap)==null?void 0:m.get(E))||0,S=(y>0?y:g.scale||.2)*s;let M=b.angle+(g.rotation||0)*Math.PI/180;g.isAbsoluteAngle&&(M=(g.rotation||0)*Math.PI/180);let v=Math.atan2(Math.sin(M),Math.cos(M));v>Math.PI/2?v-=Math.PI:v<-Math.PI/2&&(v+=Math.PI),M=v;const T=Math.cos(M),I=Math.sin(M),L=(g.xOffset||0)*s,w=(g.yOffset||0)*s;let U=0;const O=_[p%_.length];O&&O.type==="gap"&&(U=Math.abs(O.val||0)*s/2);const P=U>1e-6?d(f+U):b,Z=P.x+(L*T-w*I),N=P.y+(L*I+w*T);o.push({text:g.text,pos:{x:Z,y:N,z:P.z},height:Math.max(S,.01),rotation:M,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(E,y)=>({x:f+(E*m-y*g)*o,y:p+(E*g+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const v=M/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const y=b(.5,0),A=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,y.x,y.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,M.x,M.y,_,s),y=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const E=b(-.3,-.3),y=b(.3,-.3),A=b(.3,.3),S=b(-.3,.3);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else if(a.includes("TRACK1")){const E=b(0,-.4),y=b(0,.4);r(E.x,E.y,y.x,y.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const E=b(0,.4),y=b(.4,0),A=b(0,-.4),S=b(-.4,0);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else{const E=b(.3,0),y=b(-.3,.2),A=b(-.3,-.2);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,E.x,E.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Aa(a)??vl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Aa(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return vl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=Sl;m++){const g=o+p*m/Sl,b=d*Math.cos(g),E=h*Math.sin(g),y=r.x+b*Math.cos(f)-E*Math.sin(f),A=r.y+b*Math.sin(f)+E*Math.cos(f);_&&i(_.x,_.y,y,A,r.z||0,t),_={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(g-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*E,I=A+v*M*E,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+A*E*m,M=b+A*y*m,v=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new pf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=g(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const U of E)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=y.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const v=new ga(_);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),_=Math.max(_,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,E=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${E},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let E=0,y=0;g===0||g===3||g===5?E=h/2:g===2&&(E=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),M=Math.sin(A),v=e.pos.x+E*S-y*M,T=e.pos.y+E*M+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Aa(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(_,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=_/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*M,y:T+N*M+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Or.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new uA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new ga(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let E=0;a===0||a===3||a===5?E=m/2:a===1||a===4?E=0:a===2&&(E=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*g:o===3&&(y=(p-b)*g));const A=new mc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,_,1),S.position.set(t.x+E,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),E=Math.sin(g),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*_*b-ie*m*E,f.y+ae*_*E+ie*m*b]},A=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+M:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+M;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:M,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+M;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+M)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},E=(S,M,v,T,I)=>{this._arcSegs({x:S,y:M},v,T,I,0,s,r)},y=(S,M,v)=>this._arrowMesh(S,M,v,s),A=(S,M,v,T)=>{M&&S&&a.push({text:M,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,M=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:v,y:T}),b(c,{x:S,y:M}),b(u,{x:v,y:T}),y({x:S,y:M,z:0},Math.atan2(M-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-M,v-S),I),A(h??{x:(S+v)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),A(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,v=Math.hypot(c.x-S,c.y-M);if(v<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),E(S,M,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:M+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:M+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:M+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=yA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ma(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new of(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new ki(new B(d-_,f-m,0),new B(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const SA="modulepreload",bA=function(n){return"/"+n},bd={},MA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=bA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":SA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,AA=["cp949","windows-949","euc-kr"];let gr;function EA(){if(gr!==void 0)return gr;for(const n of AA)try{return gr=new TextDecoder(n),gr}catch{}return gr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=EA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function TA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),TA(t(n))}class CA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?wA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function wA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const Hp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function RA(n){return Hp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=RA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class DA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=LA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function LA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class IA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class PA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class UA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return y??E??b},g.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(g)},g.setDefaultLevel=function(L){E=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){y=null,v(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(y=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(zp);var jA=zp.exports;const nt=JA(jA);nt.setLevel("error");function QA(n){n.registerEntityHandler(DA),n.registerEntityHandler(IA),n.registerEntityHandler(PA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(zA),n.registerEntityHandler(VA),n.registerEntityHandler(WA),n.registerEntityHandler(KA),n.registerEntityHandler(qA),n.registerEntityHandler(ZA)}class eE{constructor(){this._entityHandlers={},QA(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new CA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Vp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=E(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=M);break}else o.code===9?(S&&(v[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),A(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=E(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?v[M.tableRecordsProperty]=M.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=y(o),o=r.next();break;case 11:M.upperRightCorner=y(o),o=r.next();break;case 12:M.center=y(o),o=r.next();break;case 13:M.snapBasePoint=y(o),o=r.next();break;case 14:M.snapSpacing=y(o),o=r.next();break;case 15:M.gridSpacing=y(o),o=r.next();break;case 16:M.viewDirectionFromTarget=y(o),o=r.next();break;case 17:M.viewTarget=y(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 111:M.ucsXAxis=y(o),o=r.next();break;case 112:M.ucsYAxis=y(o),o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,v=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=tE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=M,nt.debug("Layer {"),M={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function E(S){const M=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),M}function y(S){const M={};let v=S.code;if(M.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return M.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),M):(M.z=S.value,M)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Vp(n))}function Vp(n){return n.code+":"+n.value}function tE(n){return Hp[n]}const Ia=Math.PI/180,nE=48;function iE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*nE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class sE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Ia,s=e.next()),s.code===51&&(c=s.value*Ia,s=e.next()),s.code===73&&(u=s.value,s=e.next()),iE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Ia,s=e.next()),s.code===51&&(d=s.value*Ia,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const E=u+m*b/g,y=f*Math.cos(E),A=p*Math.sin(E);t.points.push({x:r+y*Math.cos(_)-A*Math.sin(_),y:a+y*Math.sin(_)+A*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Pa,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Pa),y:Math.sin(n.rotation*Pa)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Pa;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function rE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=wd(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function aE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return oE(aE(n))}function oE(n){const e=new eE;e.registerEntityHandler(sE);const t=e.parseSync(n);return rE(t)}const Gp=/\.dwg$/i,Wp=/\.dxf$/i;function lE(n){return Gp.test(n)}function cE(n){return Wp.test(n)}function uE(n){return Gp.test(n)||Wp.test(n)}oA("/fonts/NanumGothic-Regular.ttf");const hE=document.getElementById("app"),Dd=document.getElementById("status"),bl=document.getElementById("layerList"),Ld=document.getElementById("layers"),Ua=document.getElementById("spaces");function os(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const $t=new vA(hE);$t.onSelect(n=>{var t;if(!n){os("deselected");return}const e=n;os(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}$t.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Xp(){var t;const n=$t.getSpaces(),e=$t.getActiveSpace();if(Ua.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Ua.style.display="none";return}Ua.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==$t.getActiveSpace()&&($t.setSpace(i.handleHex),Xp(),qp(),$t.fit(),os(`space ${i.label} · ${i.entityCount} entities`))}),Ua.append(s)}}async function dE(n,e){return cE(e)?Rd(n):lE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Yp(n,e){const t=await dE(n,e),i=Ar(t),s=uv(i);return $t.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),$t.resize(),t}async function lu(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Yp(await i.arrayBuffer(),t)}async function Kp(n){if(!uE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Yp(await n.arrayBuffer(),n.name)}function qp(){bl.innerHTML="";for(const n of $t.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;bl.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),$t.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),bl.append(e)}}async function fE(n,e){var r;const i=Ar(e).find(a=>a.handleHex===$t.getActiveSpace()),s=i?` · ${i.label}`:"";os(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Xp(),qp(),$t.fit()}async function Gr(n,e){os(`loading ${n}…`);try{await fE(n,await e())}catch(t){os(`${n}: ${t.message}`,!0),console.error(t)}}document.getElementById("sample").addEventListener("click",()=>{Gr("BasicSample.dwg",()=>lu("/samples/BasicSample.dwg","BasicSample.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{Gr("simple.dxf",()=>lu("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(Gr(e.name,()=>Kp(e)),n.target.value="")});document.getElementById("fit").addEventListener("click",()=>$t.fit());let Ml=!0;document.getElementById("theme").addEventListener("click",()=>{Ml=!Ml,$t.setTheme(Ml)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&Gr(e.name,()=>Kp(e))});const Al=new URLSearchParams(location.search).get("model");Al?Gr(Al,()=>lu(Al)):os("ready · Sample DWG / DXF 또는 파일 드롭");window.addEventListener("resize",()=>$t.resize()); diff --git a/dist2/assets/index-DKDsCNGO.js b/dist2/assets/index-DKDsCNGO.js new file mode 100644 index 0000000..348828c --- /dev/null +++ b/dist2/assets/index-DKDsCNGO.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],_=r[a+3];if(d!==_||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*_;m<0&&(h=-h,f=-f,p=-p,_=-_,m=-m);let g=1-o;if(m<.9995){const b=Math.acos(m),E=Math.sin(b);g=Math.sin(g*b)/E,o=Math.sin(o*b)/E,l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o}else{l=l*g+h*o,c=c*g+f*o,u=u*g+p*o,d=d*g+_*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],_=s[0],m=s[3],g=s[6],b=s[1],E=s[4],y=s[7],A=s[2],S=s[5],M=s[8];return r[0]=a*_+o*b+l*A,r[3]=a*m+o*E+l*S,r[6]=a*g+o*y+l*M,r[1]=c*_+u*b+d*A,r[4]=c*m+u*E+d*S,r[7]=c*g+u*y+d*M,r[2]=h*_+f*b+p*A,r[5]=h*m+f*E+p*S,r[8]=h*g+f*y+p*M,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const _=1/p;return e[0]=d*_,e[1]=(s*c-u*i)*_,e[2]=(o*i-s*a)*_,e[3]=h*_,e[4]=(u*t-s*l)*_,e[5]=(s*r-o*t)*_,e[6]=f*_,e[7]=(i*l-c*t)*_,e[8]=(a*t-i*r)*_,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],_=l[2],m=l[6],g=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-_)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+_)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+g-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const E=(c+1)/2,y=(f+1)/2,A=(g+1)/2,S=(u+h)/4,M=(d+_)/4,v=(p+m)/4;return E>y&&E>A?E<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(E),s=S/i,r=M/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=M/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-_)*(d-_)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-_)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+g-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const _=f*c-l*p;if(_<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const g=1/(m+_+h);return a=_*g,o=h*g,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const _=1/u;d*=_,h*=_,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,_=h.length;p<_;p++){const m=h[p],g=a[m.materialIndex],b=Math.max(m.start,f.start),E=Math.min(o.count,Math.min(m.start+m.count,f.start+f.count));for(let y=b,A=E;yt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],_=r[9],m=r[10],g=r[11],b=r[12],E=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,g-p,A-b).normalize(),s[1].setComponents(c+a,f+u,g+p,A+b).normalize(),s[2].setComponents(c+o,f+d,g+_,A+E).normalize(),s[3].setComponents(c-o,f-d,g-_,A-E).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,g-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,g-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,g+m,A+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/M),d.push(1-ae/v),N+=1}}for(let ae=0;ae0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),_=Math.max(o,l,c),m=Math.max(u,d,h),g=_c(f,p,e,t,i),b=_c(_,m,e,t,i);let E=n.prevZ,y=n.nextZ;for(;E&&E.z>=g&&y&&y.z<=b;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0||(E=E.prevZ,y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;E&&E.z>=g;){if(E.x>=f&&E.x<=_&&E.y>=p&&E.y<=m&&E!==s&&E!==a&&Sr(o,u,l,d,c,h,E.x,E.y)&&At(E.prev,E,E.next)>=0)return!1;E=E.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=_&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const _=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=_,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let E=b.isScene===!0?b.background:null;if(E&&E.isTexture){const y=b.backgroundBlurriness>0;E=e.get(E,y)}return E}function p(b){let E=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),E=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||E)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function _(b,E){const y=f(E);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,M){this.matrixWorld.copyPosition(M.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=E.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(E.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=E.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,E){b.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,E,r)}function g(){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 a},setClearColor:function(b,E=1){a.set(b),o=E,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:_,dispose:g}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let X=Z[N];X===void 0&&(X={},Z[N]=X);let D=X[U.id];D===void 0&&(D={},X[U.id]=D);let ae=D[P];return ae===void 0&&(ae=h(l()),D[P]=ae),ae}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const X=U.getAttributes();for(const D in X)if(X[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function _(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let ae=P[X];if(ae===void 0&&(X==="instanceMatrix"&&L.instanceMatrix&&(ae=L.instanceMatrix),X==="instanceColor"&&L.instanceColor&&(ae=L.instanceColor)),ae!==void 0){const ie=ae.normalized,oe=ae.itemSize,_e=e.get(ae);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||ae.gpuType===Pc;if(ae.isInterleavedBufferAttribute){const J=ae.data,xe=J.stride,Ae=ae.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";M="mediump"}return M==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),_=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),g=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),E=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:_,maxCubemapSize:m,maxAttributes:g,maxVertexUniforms:b,maxVaryings:E,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,_=d.clipIntersection,m=d.clipShadows,g=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,E=b*4;let y=g.clippingState||null;l.value=y,y=u(p,h,E,f);for(let A=0;A!==E;++A)y[A]=t[A];g.clippingState=y,this.numIntersection=_?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const _=d!==null?d.length:0;let m=null;if(_!==0){if(m=l.value,p!==!0||m===null){const g=f+_*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),g&&d.render(_,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),g=4*(this._cubeSize-_);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,g,3*_,2*_),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,g,3*_,2*_),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),_=r/p,m=isFinite(r)?1+Math.floor(u*_):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const g=[];let b=0;for(let M=0;ME-Oi?s-E+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,_=3,m=2,g=1,b=new Float32Array(_*p*f),E=new Float32Array(m*p*f),y=new Float32Array(g*p*f);for(let S=0;S2?0:-1,T=[M,v,0,M+2/3,v,0,M+2/3,v+1,0,M,v,0,M+2/3,v+1,0,M,v+1,0];b.set(T,_*p*S),E.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,g*p*S)}const A=new Ct;A.setAttribute("position",new Un(b,_)),A.setAttribute("uv",new Un(E,m)),A.setAttribute("faceIndex",new Un(y,g)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const _=new Af(p.height);return _.fromEquirectangularTexture(n,h),e.set(h,_),h.addEventListener("dispose",c),o(_.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,_=f===ns||f===Ys;if(p||_){let m=t.get(h);const g=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==g)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||_&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let _=0;_=65535?sf:nf)(h,1);m.version=_;const g=r.get(d);g&&e.remove(g),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const M=new Float32Array(A*S*4*d),v=new Qd(M,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,_,m=null,g=[],b=!1;this.setSize=function(E,y){a.setSize(E,y),o.setSize(E,y);for(let A=0;A0&&g[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),g=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),g.length>0&&(g+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),g=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,g=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#define gl_FragColor pc_fragColor","#define gl_FragDepthEXT gl_FragDepth","#define texture2D texture","#define textureCube texture","#define texture2DProj textureProj","#define texture2DLodEXT textureLod","#define texture2DProjLodEXT textureProjLod","#define textureCubeLodEXT textureLod","#define texture2DGradEXT textureGrad","#define texture2DProjGradEXT textureProjGrad","#define textureCubeGradEXT textureGrad"].join(` +`)+` +`+g);const E=b+m+a,y=b+g+o,A=gh(s,s.VERTEX_SHADER,E),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(_,A),s.attachShader(_,S),t.index0AttributeName!==void 0?s.bindAttribLocation(_,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(_,0,"position"),s.linkProgram(_);function M(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(_)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let X=!0,D=!0;if(s.getProgramParameter(_,s.LINK_STATUS)===!1)if(X=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,_,A,S);else{const ae=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(_,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+ae+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:X,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:g}})}s.deleteShader(A),s.deleteShader(S),v=new Va(s,_),T=Q1(s,_)}let v;this.getUniforms=function(){return v===void 0&&M(this),v};let T;this.getAttributes=function(){return T===void 0&&M(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(_,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(_),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=_,this.vertexShader=A,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function _(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,X=e.get(v.envMap||Z,N),D=X&&X.mapping===xo?X.image.height:null,ae=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(ae){const Ne=Kn[ae];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!X,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,W=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,re=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:ae,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&X.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:W,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:re,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:W&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:re&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(g(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function g(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function E(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function M(){o.dispose()}return{getParameters:_,getProgramCacheKey:m,getUniforms:E,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:M}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,_,m,g){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:_,renderOrder:h.renderOrder,z:m,group:g},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=_,b.renderOrder=h.renderOrder,b.z=m,b.group=g),e++,b}function l(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,_,m,g){const b=o(h,f,p,_,m,g);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,_=0,m=0,g=0,b=0,E=0,y=0,A=0,S=0,M=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==_||v.rectAreaLength!==m||v.hemiLength!==g||v.numDirectionalShadows!==b||v.numPointShadows!==E||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==M)&&(i.directional.length=f,i.spot.length=_,i.rectArea.length=m,i.point.length=p,i.hemi.length=g,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=E,i.pointShadowMap.length=E,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=E,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=M,v.directionalLength=f,v.pointLength=p,v.spotLength=_,v.rectAreaLength=m,v.hemiLength=g,v.numDirectionalShadows=b,v.numPointShadows=E,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=M,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,_=0;const m=u.matrixWorldInverse;for(let g=0,b=c.length;g=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const _=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let g=this.type;this.render=function(S,M,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=g!==this.type;U&&M.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/X.x),s.x=r.x*X.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/X.y),s.y=r.y*X.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const ae=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||M.map&&M.alphaTest>0||M.alphaToCoverage===!0){const w=I.uuid,U=M.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,M.addEventListener("dispose",A)),I=P}if(I.visible=M.visible,I.wireframe=M.wireframe,T===yr?I.side=M.shadowSide!==null?M.shadowSide:M.side:I.side=M.shadowSide!==null?M.shadowSide:d[M.side],I.alphaMap=M.alphaMap,I.alphaTest=M.alphaToCoverage===!0?.5:M.alphaTest,I.map=M.map,I.clipShadows=M.clipShadows,I.clippingPlanes=M.clippingPlanes,I.clipIntersection=M.clipIntersection,I.displacementMap=M.displacementMap,I.displacementScale=M.displacementScale,I.displacementBias=M.displacementBias,I.wireframeLinewidth=M.wireframeLinewidth,I.linewidth=M.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,M,v,T,I){if(S.visible===!1)return;if(S.layers.test(M.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(X=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=X>=2);let ae=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function _(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),W=Math.floor(H*$.height);h===void 0&&(h=_(fe,W));const F=x?_(fe,W):h;return F.width=fe,F.height=W,F.getContext("2d").drawImage(R,0,0,fe,W),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+W+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function g(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function E(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let W;H&&(W=e.get("EXT_texture_norm16"),W||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&W&&(F=W.R16_EXT),G===n.SHORT&&W&&(F=W.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&W&&(F=W.RG16_EXT),G===n.SHORT&&W&&(F=W.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&W&&(F=W.RGB16_EXT),G===n.SHORT&&W&&(F=W.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&W&&(F=W.RGBA16_EXT),G===n.SHORT&&W&&(F=W.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return g(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function M(R){const x=R.target;x.removeEventListener("dispose",M),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function X(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function ae(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",M));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const W=$[R.__cacheKey];W!==void 0&&($[R.__cacheKey].usedTimes--,W.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let W=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,re,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,re,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,re,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,re,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,re,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,re,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,W,F,null):t.texImage2D($,fe,Y,he,ee,0,W,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),W=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,W,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,W=$.length>1;if(W||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const re=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,re,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,W=i.get(R),F=x.length>1;if(F)for(let re=0;re0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,W.__webglFramebuffer);for(let re=0;re0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=X,this.setTexture2DArray=D,this.setTexture3D=ae,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const _=typeof XRWebGLBinding<"u",m=new By,g={},b=t.getContextAttributes();let E=null,y=null;const A=[],S=[],M=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const X=new B,D=new B;function ae(z,ne,J){X.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=X.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=g.alphaTest);const b=e.get(g),E=b.envMap,y=b.envMapRotation;E&&(m.envMap.value=E,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),E.isCubeTexture&&E.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=g.reflectivity,m.ior.value=g.ior,m.refractionRatio.value=g.refractionRatio),g.lightMap&&(m.lightMap.value=g.lightMap,m.lightMapIntensity.value=g.lightMapIntensity,t(g.lightMap,m.lightMapTransform)),g.aoMap&&(m.aoMap.value=g.aoMap,m.aoMapIntensity.value=g.aoMapIntensity,t(g.aoMap,m.aoMapTransform))}function a(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform))}function o(m,g){m.dashSize.value=g.dashSize,m.totalSize.value=g.dashSize+g.gapSize,m.scale.value=g.scale}function l(m,g,b,E){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.size.value=g.size*b,m.scale.value=E*.5,g.map&&(m.map.value=g.map,t(g.map,m.uvTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function c(m,g){m.diffuse.value.copy(g.color),m.opacity.value=g.opacity,m.rotation.value=g.rotation,g.map&&(m.map.value=g.map,t(g.map,m.mapTransform)),g.alphaMap&&(m.alphaMap.value=g.alphaMap,t(g.alphaMap,m.alphaMapTransform)),g.alphaTest>0&&(m.alphaTest.value=g.alphaTest)}function u(m,g){m.specular.value.copy(g.specular),m.shininess.value=Math.max(g.shininess,1e-4)}function d(m,g){g.gradientMap&&(m.gradientMap.value=g.gradientMap)}function h(m,g){m.metalness.value=g.metalness,g.metalnessMap&&(m.metalnessMap.value=g.metalnessMap,t(g.metalnessMap,m.metalnessMapTransform)),m.roughness.value=g.roughness,g.roughnessMap&&(m.roughnessMap.value=g.roughnessMap,t(g.roughnessMap,m.roughnessMapTransform)),g.envMap&&(m.envMapIntensity.value=g.envMapIntensity)}function f(m,g,b){m.ior.value=g.ior,g.sheen>0&&(m.sheenColor.value.copy(g.sheenColor).multiplyScalar(g.sheen),m.sheenRoughness.value=g.sheenRoughness,g.sheenColorMap&&(m.sheenColorMap.value=g.sheenColorMap,t(g.sheenColorMap,m.sheenColorMapTransform)),g.sheenRoughnessMap&&(m.sheenRoughnessMap.value=g.sheenRoughnessMap,t(g.sheenRoughnessMap,m.sheenRoughnessMapTransform))),g.clearcoat>0&&(m.clearcoat.value=g.clearcoat,m.clearcoatRoughness.value=g.clearcoatRoughness,g.clearcoatMap&&(m.clearcoatMap.value=g.clearcoatMap,t(g.clearcoatMap,m.clearcoatMapTransform)),g.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=g.clearcoatRoughnessMap,t(g.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),g.clearcoatNormalMap&&(m.clearcoatNormalMap.value=g.clearcoatNormalMap,t(g.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(g.clearcoatNormalScale),g.side===cn&&m.clearcoatNormalScale.value.negate())),g.dispersion>0&&(m.dispersion.value=g.dispersion),g.iridescence>0&&(m.iridescence.value=g.iridescence,m.iridescenceIOR.value=g.iridescenceIOR,m.iridescenceThicknessMinimum.value=g.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=g.iridescenceThicknessRange[1],g.iridescenceMap&&(m.iridescenceMap.value=g.iridescenceMap,t(g.iridescenceMap,m.iridescenceMapTransform)),g.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=g.iridescenceThicknessMap,t(g.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),g.transmission>0&&(m.transmission.value=g.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),g.transmissionMap&&(m.transmissionMap.value=g.transmissionMap,t(g.transmissionMap,m.transmissionMapTransform)),m.thickness.value=g.thickness,g.thicknessMap&&(m.thicknessMap.value=g.thicknessMap,t(g.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=g.attenuationDistance,m.attenuationColor.value.copy(g.attenuationColor)),g.anisotropy>0&&(m.anisotropyVector.value.set(g.anisotropy*Math.cos(g.anisotropyRotation),g.anisotropy*Math.sin(g.anisotropyRotation)),g.anisotropyMap&&(m.anisotropyMap.value=g.anisotropyMap,t(g.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=g.specularIntensity,m.specularColor.value.copy(g.specularColor),g.specularColorMap&&(m.specularColorMap.value=g.specularColorMap,t(g.specularColorMap,m.specularColorMapTransform)),g.specularIntensityMap&&(m.specularIntensityMap.value=g.specularIntensityMap,t(g.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,g){g.matcap&&(m.matcap.value=g.matcap)}function _(m,g){const b=e.get(g).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const M=A.program;i.updateUBOMapping(y,M);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),M=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,M,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=M-v),y.__size=S,y.__cache={},this}function g(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function b(y){const A=y.target;A.removeEventListener("dispose",b);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function E(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:E}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const _=f,m=new Set([Fc,kc,Nc]),g=new Set([vn,ei,wr,Rr,Uc,Oc]),b=new Uint32Array(4),E=new Int32Array(4),y=new B;let A=null,S=null;const M=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,X=null,D=-1,ae=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return X===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,W,F,Y,re,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),W=new jm(V),Me=new Ox(V,W),F=new Yx(V,W,G,Me),Y=new $x(V,F,W,Me,G),k=new Zx(V,R,$),ge=new Fx(H),re=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=re.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),_!==vn&&(T=new jx(_,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(_===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(X===null||te)&&T.begin(I,X);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,X),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,M.length),A.init(),M.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(A,C,K)}X!==null&&N===0&&($.updateMultisampleRenderTarget(X),$.updateRenderTargetMipmap(X)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,ae=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,M.pop(),M.length>0?A=M[M.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(X===null||X.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==ae)){const bt=C===ae&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||ae!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),ae!==C&&(ae=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=X!==null?H.get(X).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],_=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const E=-_/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1_.length).map(_=>{let m=parseFloat(_);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const _=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=_;else if(r.indexOf(_)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),_==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=_;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(_)>-1)a.type?(d.apply(this),a={type:_}):a.type=_;else{if(s.indexOf(_)>-1)throw new Error("Unsupported path command: "+_+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(_)>-1?o.push(""):_==="."?!a.type||m.indexOf(_)>-1?l=!0:o[o.length-1]+=_:l=!0}if(l)throw new Error("Unexpected character: "+_+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const _=this.commands[p];for(const m in _)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+_[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-_[m]:_[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let M=0;if(t==="gvar"){if(M=_.privatePoints.length||d.length,!M){const v=i.get(s);v.path,M=v.points.length,M+=4}}else t==="cvar"&&(M=i.length);this.offset=m,this.relativeOffset=g,y=this.parsePackedDeltas(M),t==="gvar"&&(A=this.parsePackedDeltas(M))};return{configurable:!0,get:function(){return y===void 0&&S(),E==="deltasY"?A:y},set:function(M){y===void 0&&S(),E==="deltasY"?A=M:y=M}}};Object.defineProperty(_,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(_,"deltasY",b.call(this,"deltasY")),h+=_.variationDataSize,delete _.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,_=0,m,g,b,E,y=0,A=[],S,M=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,E=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,g=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,E=P._nominalWidthX)}else m=v.topDict._subrs,g=v.topDict._subrsBias;const T=rp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+E),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,X,D,ae,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),L(p,_);break;case 5:for(;u.length>0;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,_),u.length!==0);)_+=u.shift(),c.lineTo(p,_);break;case 7:for(;u.length>0&&(_+=u.shift(),c.lineTo(p,_),u.length!==0);)p+=u.shift(),c.lineTo(p,_);break;case 8:for(;u.length>0;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 10:if(D=u.pop()+g,ae=m[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}M++,U(ae),M--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),_=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 34:r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=_,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 36:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;case 37:r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-_)?p=le+u.shift():_=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,_);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+E,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+E,h=!0),_+=u.pop(),p+=u.pop(),L(p,_);break;case 22:u.length>1&&!h&&(I=u.shift()+E,h=!0),p+=u.pop(),L(p,_);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);p+=u.shift(),_+=u.shift(),c.lineTo(p,_);break;case 25:for(;u.length>6;)p+=u.shift(),_+=u.shift(),c.lineTo(p,_);r=p+u.shift(),a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,_=l+u.shift(),c.curveTo(r,a,o,l,p,_);break;case 27:for(u.length&1&&(_+=u.shift());u.length>0;)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l,c.curveTo(r,a,o,l,p,_);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,ae=n.gsubrs[D],ae){if(M>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}M++,U(ae),M--}break;case 30:for(;u.length>0&&(r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=_,o=r+u.shift(),l=a+u.shift(),_=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_),u.length!==0);)r=p,a=_+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),_=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,_);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],X=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|X)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),_=AS(n,e,p.objects);u._fdArray=_,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,_.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),_=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=_,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,_.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,_=Xn(n,p);t.subrs=_.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let _=0;n.weightClass>=600&&(_|=n.macStyleValues.BOLD),n.italicAngle<0&&(_|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:_,createdTimestamp:n.createdTimestamp}),g=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=dp.make(n.glyphs.length),E=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),A=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),M=n.getEnglishName("fontSubfamily"),v=S+" "+M;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+M);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),X=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:M,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,ae=[m,g,b,E,P,A,N,X,y];Z&&ae.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&ae.push(Ae)}}D&&ae.push(D);const _e=Ap(ae),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const _=new Image(f,p);return _.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:_}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let _=n;_<=e;_++){let m=s[_][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[_][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]<_[p]?h=h*(r[p]-d.intermediateStartTuple[p]+Number.EPSILON)/(_[p]-d.intermediateStartTuple[p]+Number.EPSILON):h=h*(d.intermediateEndTuple[p]-r[p]+Number.EPSILON)/(d.intermediateEndTuple[p]-_[p]+Number.EPSILON);else{if(r[p]Math.max(0,_[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(_[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,_=c.y,m=u.x,g=u.y,b=d.x,E=d.y,y=h.x,A=h.y,S=(p-m)*(E-A)-(_-g)*(b-y),M=p*g-_*m,v=b*A-E*y;f.x=(M*(b-y)-v*(p-m))/S,f.y=(M*(E-A)-v*(_-g))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const _=c[d];s.setRelative(_,_,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,_=Math.abs(_),n&&(g=r.cvt[o],i&&Math.abs(_-g)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const _=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),g=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),X=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=X;oe<=D;oe++)g[oe].push(U);const ae=Ia((Z-d)/_),ie=Ia((N-d)/_);for(let oe=ae;oe<=ie;oe++)b[oe].push(U)});const E=w=>Math.ceil(w.length/4),y=g.reduce((w,U)=>w+E(U),0)+b.reduce((w,U)=>w+E(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),M=this.data,v=(w,U,O,P,Z)=>{M[w*4]=U,M[w*4+1]=O,M[w*4+2]=P,M[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i/l.capHeightEm,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),_=Math.sin(s),m=(r>>16&255)/255,g=(r>>8&255)/255,b=(r&255)/255;for(let E=0;E=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,X=O+La,D=this.pos.length/3;for(const[ae,ie]of[[P,Z],[N,Z],[N,X],[P,X]]){const oe=S+(v+ae)*u,_e=M+ie*u;this.pos.push(t.x+oe*p-_e*_,t.y+oe*_+_e*p,1),this.emuv.push(ae,ie),this.gbase.push(I.base),this.color.push(m,g,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let _=0;_0){const _=e[0];_.startsWith('"')&&_.endsWith('"')?(s="text",o=_.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=_,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const E=g.substring(0,b).trim().toLowerCase(),y=g.substring(b+1).trim(),A=parseFloat(y);isNaN(A)||(E==="s"?c=A:E==="r"?u=A:E==="a"?(u=A,d=!0):E==="u"?(u=A,h=!0):E==="x"?f=A:E==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,E,y,A,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],_=d[5],m=((y=(E=this._controls)==null?void 0:E.target)==null?void 0:y.x)??s.position.x,g=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:g+a*c*f+o*u*_,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const _=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,g=new Map;for(const se of i){const R=(X=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:X.toString(16);R!=null&&(g.has(R)||g.set(R,[]),g.get(R).push(se))}const b=[];let E=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),E++,!(E&7)&&b.length<1e5&&b.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,W=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,W,F,fe,W,F)}else s.push(se,R,H,x,G,H),r.push(fe,W,F,fe,W,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,M=Hs(e),v=M.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=M.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var W,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(W=$.ownerHandle)==null?void 0:W.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,W,F,Y,re)=>{A($,fe,W,F,S,re)},H=($,fe,W=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:g,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(ae=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:ae.toString(16);if(_&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const W=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(W!=null&&this._layerNameByHandle.get(String(W)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(W,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const W=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const W=(de=x.bulges)==null?void 0:de.some(re=>Math.abs(re)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const re=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(re,F,$.pattern,$.ltscale,H,A,u),re.forEach(ce=>y(ce.x,ce.y,ce.z))}else W?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(re=>y(re.x,re.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const W=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,W,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const W=(g.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(W.length>=2){const F=W.map(he=>he.point),Y=W.map(he=>he.bulge||0),re=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,re,ce);this._drawComplexPath(he,re,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,re,H,A,y):(this._polylineSegs(F,re,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const W=x.position||x;typeof W.x=="number"&&(A(W.x-1,W.y,W.x+1,W.y,W.z||0,H),A(W.x,W.y-1,W.x,W.y+1,W.z||0,H),fe.bounds={type:"point",cx:W.x,cy:W.y});break}case"ELLIPSE":if(x.center){if($){const W=this._sampleEllipsePoints(x);this._drawComplexPath(W,!1,$.pattern,$.ltscale,H,A,u),W.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const W=x.controlPoints??x.fitPoints;if((W==null?void 0:W.length)>=2){const F=W.length>=3?(()=>{const Y=W.length*10,re=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;re.push(this._catmullRom(W,he))}return re})():W;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const W=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:re,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const W=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(W&&F){const re=W.x+F.x*1e6,ce=W.y+F.y*1e6;G==="XLINE"?A(W.x-F.x*1e6,W.y-F.y*1e6,re,ce,0,H):A(W.x,W.y,re,ce,0,H),fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y)}break}case"SOLID":{const W=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);W.length>=3&&(this._solidMesh(W,H),fe.bounds={type:"point",cx:W[0].x,cy:W[0].y});break}case"TEXT":case"MTEXT":{const W=se.text??x.text??"",F=Fs(W),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let re=0,ce=0,he=0,ee;if(G==="TEXT")re=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(re=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:re,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const W=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,re=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=g.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:W??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:re,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:g,blockBase:f})}}W&&(fe.bounds={type:"point",cx:W.x,cy:W.y},y(W.x,W.y,0));break}case"HATCH":{const W=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(W!=null&&W.length))break;let Y=null;for(const re of W){if(!((Oe=re.points)!=null&&Oe.length)||re.points.length<2)continue;Y||(Y=re.points[0]),((Xe=re.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(re.points,re.bulges,!0,H,A,y):(this._polylineSegs(re.points,!0,0,H,A),re.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(W,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const W=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(W!=null){const Y=W.toString(16);F=g.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?g.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:g,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),re=(Y==null?void 0:Y.data)||Y;re!=null&&re.start&&(fe.bounds={type:"point",cx:re.start.x,cy:re.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const W=x.points??se.points;if((W==null?void 0:W.length)>=2){if(this._polylineSegs(W,!1,0,H,A),W.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=W[0],Y=W[1],re=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,re,ce,H)}fe.bounds={type:"point",cx:W[0].x,cy:W[0].y}}break}case"OLE2FRAME":{const W=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",re=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(W.x,F.x),he=Math.max(W.x,F.x),ee=Math.min(W.y,F.y),ge=Math.max(W.y,F.y),we=he-ce,Ge=ge-ee;const k=W.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),re)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((re,ce)=>re-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(re=>re.underlay),W=u.filter(re=>!re.underlay),F=fe.concat(W),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),W.concat(fe).sort((re,ce)=>ce.height-re.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const _=new Ct;_.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(_,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),_=f-(s.y||0),m=c*p-u*_,g=u*p+c*_;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(g-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(_,m)=>{let g=0;return _r.maxX&&(g|=2),mr.maxY&&(g|=8),g};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const _=f||p;let m=0,g=0;_&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),g=r.maxY):_&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),g=r.minY):_&2?(g=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(g=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),_===f?(e=m,t=g,f=h(e,t)):(i=m,s=g,p=h(i,s))}}_emitModelThroughViewport(e,t){var E,y,A,S,M,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,_=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,X,D,ae,ie,oe)=>{const _e=h(N,X),de=h(D,ae);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},g=(N,X,D=0)=>{const ae=h(N,X);ae.x>=f.minX&&ae.x<=f.maxX&&ae.y>=f.minY&&ae.y<=f.maxY&&c(ae.x,ae.y,D)},b=(N,X)=>N>=f.minX&&N<=f.maxX&&X>=f.minY&&X<=f.maxY;for(const N of i){const X=(y=(E=N.ownerHandle)==null?void 0:E.value)==null?void 0:y.toString(16);if(!X||!s.has(X)||r.has(X))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(_.size){const de=(M=N.layerHandle)==null?void 0:M.value;if(de!=null&&_.has(String(de)))continue}const D=N.data||N,ae=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(ae){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>g(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,g):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>g(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>g(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,g):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>g(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(ae==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),g(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const _=4*Math.atan(u),m=Math.abs(_)/2,g=p/2/Math.sin(m),b=g*Math.cos(m),E=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,M=u>0?1:-1,v=E+M*A*b,T=y+M*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(_)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+_*w/L;r.push({x:v+g*Math.cos(U),y:T+g*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const _=r+u*p/d,m=o*Math.cos(_),g=l*Math.sin(_),b=i.x+m*Math.cos(c)-g*Math.sin(c),E=i.y+m*Math.sin(c)+g*Math.cos(c);h.push({x:b,y:E,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var m;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let g=0;g{let b=Math.max(0,Math.min(g,u));for(let A=0;A1e-9?b/S:0,v=l[A],T=l[A+1],I=v.x+(T.x-v.x)*M,L=v.y+(T.y-v.y)*M,w=(v.z||0)+((T.z||0)-(v.z||0))*M,U=Math.atan2(T.y-v.y,T.x-v.x);return{x:I,y:L,z:w,angle:U}}b-=S}const E=l[l.length-1],y=l[l.length-2];return{x:E.x,y:E.y,z:E.z||0,angle:Math.atan2(E.y-y.y,E.x-y.x)}};if(i.patternLength*s<1e-6)return;let f=0,p=0;const _=i.elements;for(;fE){const A=d(E),S=d(y);a(A.x,A.y,S.x,S.y,A.z,r)}f+=b}else if(g.type==="gap"){const b=Math.abs(g.val||.1)*s;f+=b}else if(g.type==="shape"){const b=d(f);this._renderShapeSymbol(g,b,s,r,a)}else if(g.type==="text"){const b=d(f);if(g.text&&o){const E=(g.style||"STANDARD").toUpperCase(),y=((m=this._textStyleHeightMap)==null?void 0:m.get(E))||0,S=(y>0?y:g.scale||.2)*s;let M=b.angle+(g.rotation||0)*Math.PI/180;g.isAbsoluteAngle&&(M=(g.rotation||0)*Math.PI/180);let v=Math.atan2(Math.sin(M),Math.cos(M));v>Math.PI/2?v-=Math.PI:v<-Math.PI/2&&(v+=Math.PI),M=v;const T=Math.cos(M),I=Math.sin(M),L=(g.xOffset||0)*s,w=(g.yOffset||0)*s;let U=0;const O=_[p%_.length];O&&O.type==="gap"&&(U=Math.abs(O.val||0)*s/2);const P=U>1e-6?d(f+U):b,Z=P.x+(L*T-w*I),N=P.y+(L*I+w*T);o.push({text:g.text,pos:{x:Z,y:N,z:P.z},height:Math.max(S,.01),rotation:M,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),_=t.z||0,m=Math.cos(l),g=Math.sin(l),b=(E,y)=>({x:f+(E*m-y*g)*o,y:p+(E*g+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let M=0;M<=12;M++){const v=M/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,_,s)}const y=b(.5,0),A=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,y.x,y.y,_,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,M=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,M.x,M.y,_,s),y=M}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const E=b(-.3,-.3),y=b(.3,-.3),A=b(.3,.3),S=b(-.3,.3);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else if(a.includes("TRACK1")){const E=b(0,-.4),y=b(0,.4);r(E.x,E.y,y.x,y.y,_,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const E=b(0,.4),y=b(.4,0),A=b(0,-.4),S=b(-.4,0);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,S.x,S.y,_,s),r(S.x,S.y,E.x,E.y,_,s)}else{const E=b(.3,0),y=b(-.3,.2),A=b(-.3,-.2);r(E.x,E.y,y.x,y.y,_,s),r(y.x,y.y,A.x,A.y,_,s),r(A.x,A.y,E.x,E.y,_,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let _=null;for(let m=0;m<=bl;m++){const g=o+p*m/bl,b=d*Math.cos(g),E=h*Math.sin(g),y=r.x+b*Math.cos(f)-E*Math.sin(f),A=r.y+b*Math.sin(f)+E*Math.cos(f);_&&i(_.x,_.y,y,A,r.z||0,t),_={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},_={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,_.x,_.y,0),e.push(f.x,f.y,0,_.x,_.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),X=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},ae=m;for(let ie=1;ie<=X;ie++){const oe=ie/X,_e=N+S*ie/X,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(g-m)*oe;this._pushWideSeg(u,D,de,ae,le),D=de,ae=le}o&&(o(p.x,p.y),o(_.x,_.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*E,I=A+v*M*E,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,_=0;for(const m of e)p+=m.x,_+=m.y;p/=e.length,_/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,_))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=g+A*E*m,M=b+A*y*m,v=Math.atan2(o.y-M,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&_>g*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,_=document.createElement("canvas");_.width=d,_.height=h;const m=_.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const g=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=g(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const U of E)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const M=y.filter(w=>!S(w));if(M.length){m.fillStyle="#ffffff",m.beginPath();for(const w of M)b(w);m.fill("evenodd")}const v=new _a(_);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,_=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),_=Math.max(_,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),g=Math.ceil(p+_+96*.35);d.width=f+m*2,d.height=g*e.length+m*2,h.font=u;const b=r>>16&255,E=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${E},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,_=h*p,m=f*p,g=e.alignH??1,b=e.alignV??2;let E=0,y=0;g===0||g===3||g===5?E=h/2:g===2&&(E=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),M=Math.sin(A),v=e.pos.x+E*S-y*M,T=e.pos.y+E*M+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(_,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=_/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,X])=>({x:v+N*S-X*M,y:T+N*M+X*S}));for(let N=0;N<4;N++){const X=Z[N],D=Z[N+1];this._widePolyMesh([X,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,X=r&255;I.fillStyle=`rgb(${Z},${N},${X})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,_=i*d.h/f,m=_*(d.w/d.h),g=_/d.h,b=d.h/2;let E=0;a===0||a===3||a===5?E=m/2:a===1||a===4?E=0:a===2&&(E=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*g:o===3&&(y=(p-b)*g));const A=new gc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,_,1),S.position.set(t.x+E,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,_=t.xScale??1,m=t.yScale??1,g=t.rotation??0,b=Math.cos(g),E=Math.sin(g),y=(X,D)=>{const ae=p?X-p.x:X,ie=p?D-p.y:D;return[f.x+ae*_*b-ie*m*E,f.y+ae*_*E+ie*m*b]},A=c?(X,D)=>c(...y(X,D)):y,S=u*Math.max(Math.abs(_),Math.abs(m)),M=d+g;for(const X of e){const D=X.data||X,ae=(X.type||X.typeName||"").toUpperCase();if(ae==="ATTDEF")continue;const ie=this._resolveBlockColor(X,i);try{if(ae==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((ae==="CIRCLE"||ae==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=ae==="ARC"?(D.startAngle??0)+M:0,z=ae==="ARC"?(D.endAngle??Math.PI*2)+M:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(ae==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+M;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((ae==="LWPOLYLINE"||ae==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(X,ne,S)?this._widePolyMesh(_e,de,le,X,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(ae==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=X.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(ae==="HATCH"){const oe=D.paths??X.paths;if(oe!=null&&oe.length){const _e=D.solidFill??X.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(ae==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(ae==="INSERT"&&o&&h<8){const oe=((w=X.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=X.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=X.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=X.scale)==null?void 0:N.y)??1,J=D.rotation??X.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:M,depth:h+1})}}}else if((ae==="TEXT"||ae==="MTEXT"||ae==="ATTRIB"||ae==="ATTDEF")&&r){if((ae==="ATTRIB"||ae==="ATTDEF")&&(D.flags??0)&1)continue;const oe=X.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+M;if(ae==="MTEXT"){const Ue=X.attachment??D.attachment??X.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=X.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+M)}else de=D.horizAlignment??X.horizAlignment??0,le=D.vertAlignment??X.vertAlignment??0;const ne=ae!=="MTEXT"&&(de!==0||le!==0),J=X.alignmentPt??D.alignmentPt,xe=X.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??X.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};ae==="MTEXT"&&(Ue.linespacingFactor=X.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(X.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(X.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=X.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=X.bgScale??D.bgScale??1.5,Ue.bgColorIndex=X.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=X.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,_=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",g=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,M)=>{!S||!M||(r(S.x,S.y,M.x,M.y,0,s),o(S.x,S.y),o(M.x,M.y))},E=(S,M,v,T,I)=>{this._arcSegs({x:S,y:M},v,T,I,0,s,r)},y=(S,M,v)=>this._arrowMesh(S,M,v,s),A=(S,M,v,T)=>{M&&S&&a.push({text:M,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,M,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,M=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(_))>.5,w=f/2;S=l.x-(L?0:w),M=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:M},{x:v,y:T}),b(c,{x:S,y:M}),b(u,{x:v,y:T}),y({x:S,y:M,z:0},Math.atan2(M-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-M,v-S),I),A(h??{x:(S+v)/2,y:(M+T)/2},m||g(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${g(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},M=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),M),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),M),A(h??l,m||`Ø${g(f)}`,Math.max(M*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,M=l.y,v=Math.hypot(c.x-S,c.y-M);if(v<1e-9)return;let T=Math.atan2(c.y-M,c.x-S),I=Math.atan2(u.y-M,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),E(S,M,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:M+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:M+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:M+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],_=e.clientY-this._downXY[1];if(Math.hypot(p,_)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,_=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const _=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),g=new ki(new B(d-_,f-m,0),new B(h+_,p+m,0));return g.min.max(t.min),g.max.min(t.max),g}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=g.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}g.name=_,g.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},g.methodFactory=m||h,g.getLevel=function(){return y??E??b},g.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(g)},g.setDefaultLevel=function(L){E=T(L),M()||g.setLevel(L,!1)},g.resetLevel=function(){y=null,v(),u.call(g)},g.enableAll=function(L){g.setLevel(g.levels.TRACE,L)},g.disableAll=function(L){g.setLevel(g.levels.SILENT,L)},g.rebuild=function(){if(a!==g&&(b=T(a.getLevel())),u.call(g),a===g)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=M();I!=null&&(y=T(I)),u.call(g)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var g=r[m];return g||(g=r[m]=new f(m,a.methodFactory)),g};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=E(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,M=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=M);break}else o.code===9?(S&&(v[S]=M),S=o.value):o.code===10?M={x:o.value}:o.code===20?M.y=o.value:o.code===30?M.z=o.value:M=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const M=d();nt.debug("}"),A(M),M.name?S[M.name]=M:nt.error('block with handle "'+M.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=E(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const M=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===M.dxfSymbolName?v[M.tableRecordsProperty]=M.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[M.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+M.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function _(){const S=[];let M={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:M.name=o.value,o=r.next();break;case 10:M.lowerLeftCorner=y(o),o=r.next();break;case 11:M.upperRightCorner=y(o),o=r.next();break;case 12:M.center=y(o),o=r.next();break;case 13:M.snapBasePoint=y(o),o=r.next();break;case 14:M.snapSpacing=y(o),o=r.next();break;case 15:M.gridSpacing=y(o),o=r.next();break;case 16:M.viewDirectionFromTarget=y(o),o=r.next();break;case 17:M.viewTarget=y(o),o=r.next();break;case 42:M.lensLength=o.value,o=r.next();break;case 43:M.frontClippingPlane=o.value,o=r.next();break;case 44:M.backClippingPlane=o.value,o=r.next();break;case 45:M.viewHeight=o.value,o=r.next();break;case 50:M.snapRotationAngle=o.value,o=r.next();break;case 51:M.viewTwistAngle=o.value,o=r.next();break;case 79:M.orthographicType=o.value,o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 111:M.ucsXAxis=y(o),o=r.next();break;case 112:M.ucsYAxis=y(o),o=r.next();break;case 110:M.ucsOrigin=y(o),o=r.next();break;case 281:M.renderMode=o.value,o=r.next();break;case 281:M.defaultLightingType=o.value,o=r.next();break;case 292:M.defaultLightingOn=o.value,o=r.next();break;case 330:M.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:M.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(M),nt.debug("ViewPort {"),M={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(M),S}function m(){const S={};let M={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,T=o.value,o=r.next();break;case 3:M.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(M.pattern=[]),o=r.next();break;case 40:M.patternLength=o.value,o=r.next();break;case 49:M.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==M.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=M,M={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=M,S}function g(){const S={};let M={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:M.name=o.value,v=o.value,o=r.next();break;case 62:M.visible=o.value>=0,M.colorIndex=Math.abs(o.value),M.color=iE(M.colorIndex),o=r.next();break;case 70:M.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=M,nt.debug("Layer {"),M={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=M,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:_},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:g}};function E(S){const M=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),M.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),M}function y(S){const M={};let v=S.code;if(M.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return M.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),M):(M.z=S.value,M)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,_=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const g=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=g;b++){const E=u+m*b/g,y=f*Math.cos(E),A=p*Math.sin(E);t.points.push({x:r+y*Math.cos(_)-A*Math.sin(_),y:a+y*Math.sin(_)+A*Math.cos(_)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const _=wd(p,i);_.ownerHandle={value:f},a.push(_)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-DWytTzhk.js b/dist2/assets/index-DWytTzhk.js new file mode 100644 index 0000000..a6af81d --- /dev/null +++ b/dist2/assets/index-DWytTzhk.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],g=r[a+3];if(d!==g||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*g;m<0&&(h=-h,f=-f,p=-p,g=-g,m=-m);let _=1-o;if(m<.9995){const M=Math.acos(m),b=Math.sin(M);_=Math.sin(_*M)/b,o=Math.sin(o*M)/b,l=l*_+h*o,c=c*_+f*o,u=u*_+p*o,d=d*_+g*o}else{l=l*_+h*o,c=c*_+f*o,u=u*_+p*o,d=d*_+g*o;const M=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=M,c*=M,u*=M,d*=M}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],g=s[0],m=s[3],_=s[6],M=s[1],b=s[4],y=s[7],A=s[2],S=s[5],E=s[8];return r[0]=a*g+o*M+l*A,r[3]=a*m+o*b+l*S,r[6]=a*_+o*y+l*E,r[1]=c*g+u*M+d*A,r[4]=c*m+u*b+d*S,r[7]=c*_+u*y+d*E,r[2]=h*g+f*M+p*A,r[5]=h*m+f*b+p*S,r[8]=h*_+f*y+p*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/p;return e[0]=d*g,e[1]=(s*c-u*i)*g,e[2]=(o*i-s*a)*g,e[3]=h*g,e[4]=(u*t-s*l)*g,e[5]=(s*r-o*t)*g,e[6]=f*g,e[7]=(i*l-c*t)*g,e[8]=(a*t-i*r)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],g=l[2],m=l[6],_=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-g)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+g)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const b=(c+1)/2,y=(f+1)/2,A=(_+1)/2,S=(u+h)/4,E=(d+g)/4,v=(p+m)/4;return b>y&&b>A?b<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(b),s=S/i,r=E/i):y>A?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):A<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(A),i=E/r,s=v/r),this.set(i,s,r,t),this}let M=Math.sqrt((m-p)*(m-p)+(d-g)*(d-g)+(h-u)*(h-u));return Math.abs(M)<.001&&(M=1),this.x=(m-p)/M,this.y=(d-g)/M,this.z=(h-u)/M,this.w=Math.acos((c+f+_-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const g=f*c-l*p;if(g<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const _=1/(m+g+h);return a=g*_,o=h*_,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const g=1/u;d*=g,h*=g,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,g=h.length;pt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],g=r[9],m=r[10],_=r[11],M=r[12],b=r[13],y=r[14],A=r[15];if(s[0].setComponents(c-a,f-u,_-p,A-M).normalize(),s[1].setComponents(c+a,f+u,_+p,A+M).normalize(),s[2].setComponents(c+o,f+d,_+g,A+b).normalize(),s[3].setComponents(c-o,f-d,_-g,A-b).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,_-m,A-y).normalize();else if(s[4].setComponents(c-l,f-h,_-m,A-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,_+m,A+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/E),d.push(1-re/v),N+=1}}for(let re=0;re0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),g=Math.max(o,l,c),m=Math.max(u,d,h),_=_c(f,p,e,t,i),M=_c(g,m,e,t,i);let b=n.prevZ,y=n.nextZ;for(;b&&b.z>=_&&y&&y.z<=M;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=m&&b!==s&&b!==a&&Sr(o,u,l,d,c,h,b.x,b.y)&&At(b.prev,b,b.next)>=0||(b=b.prevZ,y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;b&&b.z>=_;){if(b.x>=f&&b.x<=g&&b.y>=p&&b.y<=m&&b!==s&&b!==a&&Sr(o,u,l,d,c,h,b.x,b.y)&&At(b.prev,b,b.next)>=0)return!1;b=b.prevZ}for(;y&&y.z<=M;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const g=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=g,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(M){let b=M.isScene===!0?M.background:null;if(b&&b.isTexture){const y=M.backgroundBlurriness>0;b=e.get(b,y)}return b}function p(M){let b=!1;const y=f(M);y===null?m(a,o):y&&y.isColor&&(m(y,1),b=!0);const A=n.xr.getEnvironmentBlendMode();A==="additive"?t.buffers.color.setClear(0,0,0,1,r):A==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||b)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function g(M,b){const y=f(b);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(A,S,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=b.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(b.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),M.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=b.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),M.unshift(l,l.geometry,l.material,0,0,null))}function m(M,b){M.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,b,r)}function _(){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 a},setClearColor:function(M,b=1){a.set(M),o=b,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(M){o=M,m(a,o)},render:p,addToRenderList:g,dispose:_}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let W=Z[N];W===void 0&&(W={},Z[N]=W);let D=W[U.id];D===void 0&&(D={},W[U.id]=D);let re=D[P];return re===void 0&&(re=h(l()),D[P]=re),re}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const W=U.getAttributes();for(const D in W)if(W[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function g(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let re=P[W];if(re===void 0&&(W==="instanceMatrix"&&L.instanceMatrix&&(re=L.instanceMatrix),W==="instanceColor"&&L.instanceColor&&(re=L.instanceColor)),re!==void 0){const ie=re.normalized,oe=re.itemSize,_e=e.get(re);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||re.gpuType===Pc;if(re.isInterleavedBufferAttribute){const J=re.data,xe=J.stride,Ae=re.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),_=n.getParameter(n.MAX_VERTEX_ATTRIBS),M=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),b=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),A=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:g,maxCubemapSize:m,maxAttributes:_,maxVertexUniforms:M,maxVaryings:b,maxFragmentUniforms:y,maxSamples:A,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,g=d.clipIntersection,m=d.clipShadows,_=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const M=r?0:i,b=M*4;let y=_.clippingState||null;l.value=y,y=u(p,h,b,f);for(let A=0;A!==b;++A)y[A]=t[A];_.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=M}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const g=d!==null?d.length:0;let m=null;if(g!==0){if(m=l.value,p!==!0||m===null){const _=f+g*4,M=h.matrixWorldInverse;o.getNormalMatrix(M),(m===null||m.length<_)&&(m=new Float32Array(_));for(let b=0,y=f;b!==g;++b,y+=4)a.copy(d[b]).applyMatrix4(M,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=g,e.numIntersection=0,m}}const Oi=4,sh=[.125,.215,.35,.446,.526,.582],Ji=20,Bx=256,mr=new Yc,rh=new Qe;let il=null,sl=0,rl=0,al=!1;const Hx=new B;class ah{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,r={}){const{size:a=256,position:o=Hx}=r;il=this._renderer.getRenderTarget(),sl=this._renderer.getActiveCubeFace(),rl=this._renderer.getActiveMipmapLevel(),al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?A:0,A,A),d.setRenderTarget(s),_&&d.render(g,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=M}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),_=4*(this._cubeSize-g);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,_,3*g,2*g),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,_,3*g,2*g),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),g=r/p,m=isFinite(r)?1+Math.floor(u*g):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const _=[];let M=0;for(let E=0;Eb-Oi?s-b+Oi:0),S=4*(this._cubeSize-y);Us(t,A,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,g=3,m=2,_=1,M=new Float32Array(g*p*f),b=new Float32Array(m*p*f),y=new Float32Array(_*p*f);for(let S=0;S2?0:-1,T=[E,v,0,E+2/3,v,0,E+2/3,v+1,0,E,v,0,E+2/3,v+1,0,E,v+1,0];M.set(T,g*p*S),b.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,_*p*S)}const A=new Ct;A.setAttribute("position",new Un(M,g)),A.setAttribute("uv",new Un(b,m)),A.setAttribute("faceIndex",new Un(y,_)),i.push(new Vt(A,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const g=new Af(p.height);return g.fromEquirectangularTexture(n,h),e.set(h,g),h.addEventListener("dispose",c),o(g.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,g=f===ns||f===Ys;if(p||g){let m=t.get(h);const _=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==_)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const M=h.image;return p&&M&&M.height>0||g&&M&&l(M)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let g=0;g=65535?sf:nf)(h,1);m.version=g;const _=r.get(d);_&&e.remove(_),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(A/e.maxTextureSize),A=e.maxTextureSize);const E=new Float32Array(A*S*4*d),v=new Qd(E,A,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,g,m=null,_=[],M=!1;this.setSize=function(b,y){a.setSize(b,y),o.setSize(b,y);for(let A=0;A<_.length;A++){const S=_[A];S.setSize&&S.setSize(b,y)}},this.setEffects=function(b){_=b,M=_.length>0&&_[0].isRenderPass===!0;const y=a.width,A=a.height;for(let S=0;S<_.length;S++){const E=_[S];E.setSize&&E.setSize(y,A)}},this.begin=function(b,y){if(p||b.toneMapping===Jn&&_.length===0)return!1;if(m=y,y!==null){const A=y.width,S=y.height;(a.width!==A||a.height!==S)&&this.setSize(A,S)}return M===!1&&b.setRenderTarget(a),g=b.toneMapping,b.toneMapping=Jn,!0},this.hasRenderPass=function(){return M},this.end=function(b,y){b.toneMapping=g,p=!0;let A=a,S=o;for(let E=0;E<_.length;E++){const v=_[E];if(v.enabled!==!1&&(v.render(b,S,A,y),v.needsSwap!==!1)){const T=A;A=S,S=T}}if(h!==b.outputColorSpace||f!==b.toneMapping){h=b.outputColorSpace,f=b.toneMapping,c.defines={},it.getTransfer(h)===ft&&(c.defines.SRGB_TRANSFER="");const E=Jx[f];E&&(c.defines[E]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=A.texture,b.setRenderTarget(m),b.render(u,d),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Ef=new Jt,yc=new Ks(1,1),Tf=new Qd,Cf=new G0,wf=new cf,uh=[],hh=[],dh=new Float32Array(16),fh=new Float32Array(9),ph=new Float32Array(4);function ir(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),_.length>0&&(_+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),_=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(M=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,_=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#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(` +`)+` +`+_);const b=M+m+a,y=M+_+o,A=gh(s,s.VERTEX_SHADER,b),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(g,A),s.attachShader(g,S),t.index0AttributeName!==void 0?s.bindAttribLocation(g,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g);function E(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(g)||"",U=s.getShaderInfoLog(A)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let W=!0,D=!0;if(s.getProgramParameter(g,s.LINK_STATUS)===!1)if(W=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,g,A,S);else{const re=xh(s,A,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+re+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:W,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:_}})}s.deleteShader(A),s.deleteShader(S),v=new Va(s,g),T=Q1(s,g)}let v;this.getUniforms=function(){return v===void 0&&E(this),v};let T;this.getAttributes=function(){return T===void 0&&E(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(g,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=A,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function g(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,W=e.get(v.envMap||Z,N),D=W&&W.mapping===xo?W.image.height:null,re=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(re){const Ne=Kn[re];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!W,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,X=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,ae=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:re,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&W.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:X,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:ae,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:X&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(_(T,v),M(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function _(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function M(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function b(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function A(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function E(){o.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:b,acquireProgram:y,releaseProgram:A,releaseShaderCache:S,programs:c,dispose:E}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,g,m,_){let M=n[e];return M===void 0?(M={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:g,renderOrder:h.renderOrder,z:m,group:_},n[e]=M):(M.id=h.id,M.object=h,M.geometry=f,M.material=p,M.materialVariant=a(h),M.groupOrder=g,M.renderOrder=h.renderOrder,M.z=m,M.group=_),e++,M}function l(h,f,p,g,m,_){const M=o(h,f,p,g,m,_);p.transmission>0?i.push(M):p.transparent===!0?s.push(M):t.push(M)}function c(h,f,p,g,m,_){const M=o(h,f,p,g,m,_);p.transmission>0?i.unshift(M):p.transparent===!0?s.unshift(M):t.unshift(M)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,g=0,m=0,_=0,M=0,b=0,y=0,A=0,S=0,E=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==g||v.rectAreaLength!==m||v.hemiLength!==_||v.numDirectionalShadows!==M||v.numPointShadows!==b||v.numSpotShadows!==y||v.numSpotMaps!==A||v.numLightProbes!==E)&&(i.directional.length=f,i.spot.length=g,i.rectArea.length=m,i.point.length=p,i.hemi.length=_,i.directionalShadow.length=M,i.directionalShadowMap.length=M,i.pointShadow.length=b,i.pointShadowMap.length=b,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=M,i.pointShadowMatrix.length=b,i.spotLightMatrix.length=y+A-S,i.spotLightMap.length=A,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=E,v.directionalLength=f,v.pointLength=p,v.spotLength=g,v.rectAreaLength=m,v.hemiLength=_,v.numDirectionalShadows=M,v.numPointShadows=b,v.numSpotShadows=y,v.numSpotMaps=A,v.numLightProbes=E,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,g=0;const m=u.matrixWorldInverse;for(let _=0,M=c.length;_=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let _=this.type;this.render=function(S,E,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=_!==this.type;U&&E.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/W.x),s.x=r.x*W.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/W.y),s.y=r.y*W.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const re=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const w=I.uuid,U=E.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,E.addEventListener("dispose",A)),I=P}if(I.visible=E.visible,I.wireframe=E.wireframe,T===yr?I.side=E.shadowSide!==null?E.shadowSide:E.side:I.side=E.shadowSide!==null?E.shadowSide:d[E.side],I.alphaMap=E.alphaMap,I.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,I.map=E.map,I.clipShadows=E.clipShadows,I.clippingPlanes=E.clippingPlanes,I.clipIntersection=E.clipIntersection,I.displacementMap=E.displacementMap,I.displacementScale=E.displacementScale,I.displacementBias=E.displacementBias,I.wireframeLinewidth=E.wireframeLinewidth,I.linewidth=E.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,E,v,T,I){if(S.visible===!1)return;if(S.layers.test(E.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=W>=2);let re=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),X=Math.floor(H*$.height);h===void 0&&(h=g(fe,X));const F=x?g(fe,X):h;return F.width=fe,F.height=X,F.getContext("2d").drawImage(R,0,0,fe,X),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+X+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function _(R){return R.generateMipmaps}function M(R){n.generateMipmap(R)}function b(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let X;H&&(X=e.get("EXT_texture_norm16"),X||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&X&&(F=X.R16_EXT),G===n.SHORT&&X&&(F=X.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&X&&(F=X.RG16_EXT),G===n.SHORT&&X&&(F=X.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&X&&(F=X.RGB16_EXT),G===n.SHORT&&X&&(F=X.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&X&&(F=X.RGBA16_EXT),G===n.SHORT&&X&&(F=X.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function A(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return _(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function E(R){const x=R.target;x.removeEventListener("dispose",E),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function W(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function re(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",E));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const X=$[R.__cacheKey];X!==void 0&&($[R.__cacheKey].usedTimes--,X.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let X=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,ae,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,ae,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,ae,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ae,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,ae,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,ae,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,ae,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,ae,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,ae,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,X,F,null):t.texImage2D($,fe,Y,he,ee,0,X,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=A(x.stencilBuffer,$),X=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,X,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,X=$.length>1;if(X||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const ae=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,ae,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,X=i.get(R),F=x.length>1;if(F)for(let ae=0;ae0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,X.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,X.__webglFramebuffer);for(let ae=0;ae0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=W,this.setTexture2DArray=D,this.setTexture3D=re,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const g=typeof XRWebGLBinding<"u",m=new By,_={},M=t.getContextAttributes();let b=null,y=null;const A=[],S=[],E=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=A[z];return ne===void 0&&(ne=new Oo,A[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=A[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,A[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=A[xe];Ae&&Ae.connect(J)}}const W=new B,D=new B;function re(z,ne,J){W.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=W.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=_.alphaTest);const M=e.get(_),b=M.envMap,y=M.envMapRotation;b&&(m.envMap.value=b,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),b.isCubeTexture&&b.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=_.reflectivity,m.ior.value=_.ior,m.refractionRatio.value=_.refractionRatio),_.lightMap&&(m.lightMap.value=_.lightMap,m.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,m.lightMapTransform)),_.aoMap&&(m.aoMap.value=_.aoMap,m.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,m.aoMapTransform))}function a(m,_){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,_.map&&(m.map.value=_.map,t(_.map,m.mapTransform))}function o(m,_){m.dashSize.value=_.dashSize,m.totalSize.value=_.dashSize+_.gapSize,m.scale.value=_.scale}function l(m,_,M,b){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,m.size.value=_.size*M,m.scale.value=b*.5,_.map&&(m.map.value=_.map,t(_.map,m.uvTransform)),_.alphaMap&&(m.alphaMap.value=_.alphaMap,t(_.alphaMap,m.alphaMapTransform)),_.alphaTest>0&&(m.alphaTest.value=_.alphaTest)}function c(m,_){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,m.rotation.value=_.rotation,_.map&&(m.map.value=_.map,t(_.map,m.mapTransform)),_.alphaMap&&(m.alphaMap.value=_.alphaMap,t(_.alphaMap,m.alphaMapTransform)),_.alphaTest>0&&(m.alphaTest.value=_.alphaTest)}function u(m,_){m.specular.value.copy(_.specular),m.shininess.value=Math.max(_.shininess,1e-4)}function d(m,_){_.gradientMap&&(m.gradientMap.value=_.gradientMap)}function h(m,_){m.metalness.value=_.metalness,_.metalnessMap&&(m.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,m.metalnessMapTransform)),m.roughness.value=_.roughness,_.roughnessMap&&(m.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,m.roughnessMapTransform)),_.envMap&&(m.envMapIntensity.value=_.envMapIntensity)}function f(m,_,M){m.ior.value=_.ior,_.sheen>0&&(m.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),m.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(m.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,m.sheenColorMapTransform)),_.sheenRoughnessMap&&(m.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,m.sheenRoughnessMapTransform))),_.clearcoat>0&&(m.clearcoat.value=_.clearcoat,m.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(m.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,m.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(m.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===cn&&m.clearcoatNormalScale.value.negate())),_.dispersion>0&&(m.dispersion.value=_.dispersion),_.iridescence>0&&(m.iridescence.value=_.iridescence,m.iridescenceIOR.value=_.iridescenceIOR,m.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(m.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,m.iridescenceMapTransform)),_.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),_.transmission>0&&(m.transmission.value=_.transmission,m.transmissionSamplerMap.value=M.texture,m.transmissionSamplerSize.value.set(M.width,M.height),_.transmissionMap&&(m.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,m.transmissionMapTransform)),m.thickness.value=_.thickness,_.thicknessMap&&(m.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=_.attenuationDistance,m.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(m.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(m.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=_.specularIntensity,m.specularColor.value.copy(_.specularColor),_.specularColorMap&&(m.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,m.specularColorMapTransform)),_.specularIntensityMap&&(m.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,_){_.matcap&&(m.matcap.value=_.matcap)}function g(m,_){const M=e.get(_).light;m.referencePosition.value.setFromMatrixPosition(M.matrixWorld),m.nearDistance.value=M.shadow.camera.near,m.farDistance.value=M.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,A){const S=A.program;i.uniformBlockBinding(y,S)}function c(y,A){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",M));const E=A.program;i.updateUBOMapping(y,E);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const A=d();y.__bindingPointIndex=A;const S=n.createBuffer(),E=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,E,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,A,S),S}function d(){for(let y=0;y0&&(S+=E-v),y.__size=S,y.__cache={},this}function _(y){const A={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(A.boundary=4,A.storage=4):y.isVector2?(A.boundary=8,A.storage=8):y.isVector3||y.isColor?(A.boundary=16,A.storage=12):y.isVector4?(A.boundary=16,A.storage=16):y.isMatrix3?(A.boundary=48,A.storage=48):y.isMatrix4?(A.boundary=64,A.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(A.boundary=16,A.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),A}function M(y){const A=y.target;A.removeEventListener("dispose",M);const S=a.indexOf(A.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[A.id]),delete s[A.id],delete r[A.id]}function b(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:b}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const g=f,m=new Set([Fc,kc,Nc]),_=new Set([vn,ei,wr,Rr,Uc,Oc]),M=new Uint32Array(4),b=new Int32Array(4),y=new B;let A=null,S=null;const E=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,W=null,D=-1,re=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return W===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,X,F,Y,ae,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),X=new jm(V),Me=new Ox(V,X),F=new Yx(V,X,G,Me),Y=new $x(V,F,X,Me,G),k=new Zx(V,R,$),ge=new Fx(H),ae=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=ae.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),g!==vn&&(T=new jx(g,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(g===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(W===null||te)&&T.begin(I,W);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,W),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),A=he.get(C,E.length),A.init(),E.push(A),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),A.finish(),I.sortObjects===!0&&A.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(A,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=A.opaque,Re=A.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(A,C,K)}W!==null&&N===0&&($.updateMultisampleRenderTarget(W),$.updateRenderTargetMipmap(W)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,re=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,E.pop(),E.length>0?A=E[E.length-1]:A=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&A.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==re)){const bt=C===re&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||re!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),re!==C&&(re=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=W!==null?H.get(W).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=W!==null?H.get(W).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],g=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const b=-g/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1g.length).map(g=>{let m=parseFloat(g);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const g=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=g;else if(r.indexOf(g)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),g==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=g;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(g)>-1)a.type?(d.apply(this),a={type:g}):a.type=g;else{if(s.indexOf(g)>-1)throw new Error("Unsupported path command: "+g+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(g)>-1?o.push(""):g==="."?!a.type||m.indexOf(g)>-1?l=!0:o[o.length-1]+=g:l=!0}if(l)throw new Error("Unexpected character: "+g+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const g=this.commands[p];for(const m in g)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+g[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-g[m]:g[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,A;const S=()=>{let E=0;if(t==="gvar"){if(E=g.privatePoints.length||d.length,!E){const v=i.get(s);v.path,E=v.points.length,E+=4}}else t==="cvar"&&(E=i.length);this.offset=m,this.relativeOffset=_,y=this.parsePackedDeltas(E),t==="gvar"&&(A=this.parsePackedDeltas(E))};return{configurable:!0,get:function(){return y===void 0&&S(),b==="deltasY"?A:y},set:function(E){y===void 0&&S(),b==="deltasY"?A=E:y=E}}};Object.defineProperty(g,"deltas",M.call(this,"deltas")),t==="gvar"&&Object.defineProperty(g,"deltasY",M.call(this,"deltasY")),h+=g.variationDataSize,delete g.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,g=0,m,_,M,b,y=0,A=[],S,E=0;const v=n.tables.cff2||n.tables.cff;if(M=v.topDict._defaultWidthX,b=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,_=P._subrsBias,i>1?(A=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(M=P._defaultWidthX,b=P._nominalWidthX)}else m=v.topDict._subrs,_=v.topDict._subrsBias;const T=rp(n,c);let I=M;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+b),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,W,D,re,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+b,h=!0),g+=u.pop(),L(p,g);break;case 5:for(;u.length>0;)p+=u.shift(),g+=u.shift(),c.lineTo(p,g);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,g),u.length!==0);)g+=u.shift(),c.lineTo(p,g);break;case 7:for(;u.length>0&&(g+=u.shift(),c.lineTo(p,g),u.length!==0);)p+=u.shift(),c.lineTo(p,g);break;case 8:for(;u.length>0;)r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 10:if(D=u.pop()+_,re=m[D],re){if(E>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}E++,U(re),E--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),g=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 34:r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=g,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 36:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 37:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-g)?p=le+u.shift():g=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+b,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(A,y,s));var J=u.pop(),xe=S?S.length:A.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+b,h=!0),g+=u.pop(),p+=u.pop(),L(p,g);break;case 22:u.length>1&&!h&&(I=u.shift()+b,h=!0),p+=u.pop(),L(p,g);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);p+=u.shift(),g+=u.shift(),c.lineTo(p,g);break;case 25:for(;u.length>6;)p+=u.shift(),g+=u.shift(),c.lineTo(p,g);r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 27:for(u.length&1&&(g+=u.shift());u.length>0;)r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l,c.curveTo(r,a,o,l,p,g);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,re=n.gsubrs[D],re){if(E>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}E++,U(re),E--}break;case 30:for(;u.length>0&&(r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g),u.length!==0);)r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),g=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),g=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g),u.length!==0);)r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],W=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|W)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),g=AS(n,e,p.objects);u._fdArray=g,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,g.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),g=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=g,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,g.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,g=Xn(n,p);t.subrs=g.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let g=0;n.weightClass>=600&&(g|=n.macStyleValues.BOLD),n.italicAngle<0&&(g|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:g,createdTimestamp:n.createdTimestamp}),_=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),M=dp.make(n.glyphs.length),b=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),A=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),E=n.getEnglishName("fontSubfamily"),v=S+" "+E;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+E);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),W=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:E,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,re=[m,_,M,b,P,A,N,W,y];Z&&re.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&re.push(Ae)}}D&&re.push(D);const _e=Ap(re),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const g=new Image(f,p);return g.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:g}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let g=n;g<=e;g++){let m=s[g][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[g][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]Math.max(0,g[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(g[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,g=c.y,m=u.x,_=u.y,M=d.x,b=d.y,y=h.x,A=h.y,S=(p-m)*(b-A)-(g-_)*(M-y),E=p*_-g*m,v=M*A-b*y;f.x=(E*(M-y)-v*(p-m))/S,f.y=(E*(b-A)-v*(g-_))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const g=c[d];s.setRelative(g,g,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,g=Math.abs(g),n&&(_=r.cvt[o],i&&Math.abs(g-_)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const g=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),_=Array.from({length:ln},()=>[]),M=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),W=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=W;oe<=D;oe++)_[oe].push(U);const re=Ia((Z-d)/g),ie=Ia((N-d)/g);for(let oe=re;oe<=ie;oe++)M[oe].push(U)});const b=w=>Math.ceil(w.length/4),y=_.reduce((w,U)=>w+b(U),0)+M.reduce((w,U)=>w+b(U),0),A=2+ln*2+y+a.length*2,S=this.alloc(A),E=this.data,v=(w,U,O,P,Z)=>{E[w*4]=U,E[w*4+1]=O,E[w*4+2]=P,E[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),g=Math.sin(s),m=(r>>16&255)/255,_=(r>>8&255)/255,M=(r&255)/255;for(let b=0;b=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,W=O+La,D=this.pos.length/3;for(const[re,ie]of[[P,Z],[N,Z],[N,W],[P,W]]){const oe=S+(v+re)*u,_e=E+ie*u;this.pos.push(t.x+oe*p-_e*g,t.y+oe*g+_e*p,1),this.emuv.push(re,ie),this.gbase.push(I.base),this.color.push(m,_,M)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let g=0;g0){const g=e[0];g.startsWith('"')&&g.endsWith('"')?(s="text",o=g.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=g,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const b=_.substring(0,M).trim().toLowerCase(),y=_.substring(M+1).trim(),A=parseFloat(y);isNaN(A)||(b==="s"?c=A:b==="r"?u=A:b==="a"?(u=A,d=!0):b==="u"?(u=A,h=!0):b==="x"?f=A:b==="y"&&(p=A))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var M,b,y,A,S;const i=(M=this._renderer)==null?void 0:M.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],g=d[5],m=((y=(b=this._controls)==null?void 0:b.target)==null?void 0:y.x)??s.position.x,_=((S=(A=this._controls)==null?void 0:A.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:_+a*c*f+o*u*g,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const g=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,_=new Map;for(const se of i){const R=(W=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:W.toString(16);R!=null&&(_.has(R)||_.set(R,[]),_.get(R).push(se))}const M=[];let b=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),b++,!(b&7)&&M.length<1e5&&M.push(se,R))},A=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,X=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,X,F,fe,X,F)}else s.push(se,R,H,x,G,H),r.push(fe,X,F,fe,X,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,E=Hs(e),v=E.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=E.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var X,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(X=$.ownerHandle)==null?void 0:X.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,X,F,Y,ae)=>{A($,fe,X,F,S,ae)},H=($,fe,X=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:_,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(re=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:re.toString(16);if(g&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const X=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(X!=null&&this._layerNameByHandle.get(String(X)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,A,u):A(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const X=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(X,!0,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const X=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(X,!1,$.pattern,$.ltscale,H,A,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,A);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const X=(de=x.bulges)==null?void 0:de.some(ae=>Math.abs(ae)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const ae=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(ae,F,$.pattern,$.ltscale,H,A,u),ae.forEach(ce=>y(ce.x,ce.y,ce.z))}else X?this._bulgePolySegs(x.points,x.bulges,F,H,A,y):(this._polylineSegs(x.points,F,x.elevation||0,H,A),x.points.forEach(ae=>y(ae.x,ae.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const X=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,X,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,A);break;case"POLYLINE_2D":{const X=(_.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(X.length>=2){const F=X.map(he=>he.point),Y=X.map(he=>he.bulge||0),ae=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,ae,ce);this._drawComplexPath(he,ae,$.pattern,$.ltscale,H,A,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,ae,H,A,y):(this._polylineSegs(F,ae,ce,H,A),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const X=x.position||x;typeof X.x=="number"&&(A(X.x-1,X.y,X.x+1,X.y,X.z||0,H),A(X.x,X.y-1,X.x,X.y+1,X.z||0,H),fe.bounds={type:"point",cx:X.x,cy:X.y});break}case"ELLIPSE":if(x.center){if($){const X=this._sampleEllipsePoints(x);this._drawComplexPath(X,!1,$.pattern,$.ltscale,H,A,u),X.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,A);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const X=x.controlPoints??x.fitPoints;if((X==null?void 0:X.length)>=2){const F=X.length>=3?(()=>{const Y=X.length*10,ae=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;ae.push(this._catmullRom(X,he))}return ae})():X;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,A,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,A),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const X=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(X),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,ae=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:ae,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const X=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(X&&F){const ae=X.x+F.x*1e6,ce=X.y+F.y*1e6;G==="XLINE"?A(X.x-F.x*1e6,X.y-F.y*1e6,ae,ce,0,H):A(X.x,X.y,ae,ce,0,H),fe.bounds={type:"point",cx:X.x,cy:X.y},y(X.x,X.y)}break}case"SOLID":{const X=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);X.length>=3&&(this._solidMesh(X,H),fe.bounds={type:"point",cx:X[0].x,cy:X[0].y});break}case"TEXT":case"MTEXT":{const X=se.text??x.text??"",F=Fs(X),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let ae=0,ce=0,he=0,ee;if(G==="TEXT")ae=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(ae=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:ae,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const X=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,ae=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=_.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:X??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:ae,basePoint:ge==null?void 0:ge.basePoint},H,A,u,{entsByOwner:_,blockBase:f})}}X&&(fe.bounds={type:"point",cx:X.x,cy:X.y},y(X.x,X.y,0));break}case"HATCH":{const X=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(X!=null&&X.length))break;let Y=null;for(const ae of X){if(!((Oe=ae.points)!=null&&Oe.length)||ae.points.length<2)continue;Y||(Y=ae.points[0]),((Xe=ae.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(ae.points,ae.bulges,!0,H,A,y):(this._polylineSegs(ae.points,!0,0,H,A),ae.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(X,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const X=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(X!=null){const Y=X.toString(16);F=_.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)A(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,A);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?_.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,A,u,{entsByOwner:_,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,A),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),ae=(Y==null?void 0:Y.data)||Y;ae!=null&&ae.start&&(fe.bounds={type:"point",cx:ae.start.x,cy:ae.start.y})}else{this._renderDimFallback(se,x,G,H,A,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const X=x.points??se.points;if((X==null?void 0:X.length)>=2){if(this._polylineSegs(X,!1,0,H,A),X.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=X[0],Y=X[1],ae=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,ae,ce,H)}fe.bounds={type:"point",cx:X[0].x,cy:X[0].y}}break}case"OLE2FRAME":{const X=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",ae=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(X.x,F.x),he=Math.max(X.x,F.x),ee=Math.min(X.y,F.y),ge=Math.max(X.y,F.y),we=he-ce,Ge=ge-ee;const k=X.z||0;if(A(ce,ee,he,ee,k,H),A(he,ee,he,ge,k,H),A(he,ge,ce,ge,k,H),A(ce,ge,ce,ee,k,H),ae)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((ae,ce)=>ae-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(ae=>ae.underlay),X=u.filter(ae=>!ae.underlay),F=fe.concat(X),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),X.concat(fe).sort((ae,ce)=>ce.height-ae.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(M,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const g=new Ct;g.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(g,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),g=f-(s.y||0),m=c*p-u*g,_=u*p+c*g;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(_-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(g,m)=>{let _=0;return gr.maxX&&(_|=2),mr.maxY&&(_|=8),_};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const g=f||p;let m=0,_=0;g&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),_=r.maxY):g&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),_=r.minY):g&2?(_=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(_=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),g===f?(e=m,t=_,f=h(e,t)):(i=m,s=_,p=h(i,s))}}_emitModelThroughViewport(e,t){var b,y,A,S,E,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,g=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,W,D,re,ie,oe)=>{const _e=h(N,W),de=h(D,re);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},_=(N,W,D=0)=>{const re=h(N,W);re.x>=f.minX&&re.x<=f.maxX&&re.y>=f.minY&&re.y<=f.maxY&&c(re.x,re.y,D)},M=(N,W)=>N>=f.minX&&N<=f.maxX&&W>=f.minY&&W<=f.maxY;for(const N of i){const W=(y=(b=N.ownerHandle)==null?void 0:b.value)==null?void 0:y.toString(16);if(!W||!s.has(W)||r.has(W))continue;if((A=this._hiddenLayers)!=null&&A.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(g.size){const de=(E=N.layerHandle)==null?void 0:E.value;if(de!=null&&g.has(String(de)))continue}const D=N.data||N,re=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(re){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>_(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,_):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>_(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>_(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,_):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>_(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(re==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!M(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),_(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const g=4*Math.atan(u),m=Math.abs(g)/2,_=p/2/Math.sin(m),M=_*Math.cos(m),b=(l.x+c.x)/2,y=(l.y+c.y)/2,A=-f/p,S=h/p,E=u>0?1:-1,v=b+E*A*M,T=y+E*S*M,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(g)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+g*w/L;r.push({x:v+_*Math.cos(U),y:T+_*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const g=r+u*p/d,m=o*Math.cos(g),_=l*Math.sin(g),M=i.x+m*Math.cos(c)-_*Math.sin(c),b=i.y+m*Math.sin(c)+_*Math.cos(c);h.push({x:M,y:b,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var M;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let b=0;b{let y=Math.max(0,Math.min(b,u));for(let E=0;E1e-9?y/v:0,I=l[E],L=l[E+1],w=I.x+(L.x-I.x)*T,U=I.y+(L.y-I.y)*T,O=(I.z||0)+((L.z||0)-(I.z||0))*T,P=Math.atan2(L.y-I.y,L.x-I.x);return{x:w,y:U,z:O,angle:P}}y-=v}const A=l[l.length-1],S=l[l.length-2];return{x:A.x,y:A.y,z:A.z||0,angle:Math.atan2(A.y-S.y,A.x-S.x)}},h=i.elements||[],f=i.patternLength*s;if(f<1e-6||!h.length)return;let p=0;for(const b of h){if(b.type==="shape")break;b.type==="dash"?p+=Math.max((b.val||.05)*s,.01*s):b.type==="gap"&&(p+=Math.abs(b.val||.1)*s)}let g=0,m=0,_=-1;for(;gA){const E=d(A),v=d(S);a(E.x,E.y,v.x,v.y,E.z,r)}g+=y}else if(b.type==="gap"){const y=Math.abs(b.val||.1)*s;g+=y}else if(b.type==="shape"){_=g;const y=d(g);this._renderShapeSymbol(b,y,s,r,a)}else if(b.type==="text"){const y=d(g);if(b.text&&o){const A=(b.style||"STANDARD").toUpperCase(),S=((M=this._textStyleHeightMap)==null?void 0:M.get(A))||0,v=(S>0?S:b.scale||.2)*s;let T=y.angle+(b.rotation||0)*Math.PI/180;b.isAbsoluteAngle&&(T=(b.rotation||0)*Math.PI/180);let I=Math.atan2(Math.sin(T),Math.cos(T));I>Math.PI/2?I-=Math.PI:I<-Math.PI/2&&(I+=Math.PI),T=I;const L=Math.cos(T),w=Math.sin(T),U=(b.xOffset||0)*s,O=0;let P;if(_>=0){const W=_+f/2;P=d(Math.min(W,u))}else{let W=0;const D=h[m%h.length];D&&D.type==="gap"&&(W=Math.abs(D.val||0)*s/2),P=W>1e-6?d(g+W):y}const Z=P.x+(U*L-O*w),N=P.y+(U*w+O*L);o.push({text:b.text,pos:{x:Z,y:N,z:P.z},height:Math.max(v,.01),rotation:T,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),g=t.z||0,m=Math.cos(l),_=Math.sin(l),M=(b,y)=>({x:f+(b*m-y*_)*o,y:p+(b*_+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let E=0;E<=12;E++){const v=E/12,T=-.5+v,I=.25*(1-v),L=M(T,I),w=M(T,-I);r(L.x,L.y,w.x,w.y,g,s)}const y=M(.5,0),A=M(-.5,.25),S=M(-.5,-.25);r(y.x,y.y,A.x,A.y,g,s),r(A.x,A.y,S.x,S.y,g,s),r(S.x,S.y,y.x,y.y,g,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=M(.3,0);for(let A=1;A<=12;A++){const S=A/12*Math.PI*2,E=M(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,E.x,E.y,g,s),y=E}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const b=M(-.3,-.3),y=M(.3,-.3),A=M(.3,.3),S=M(-.3,.3);r(b.x,b.y,y.x,y.y,g,s),r(y.x,y.y,A.x,A.y,g,s),r(A.x,A.y,S.x,S.y,g,s),r(S.x,S.y,b.x,b.y,g,s)}else if(a.includes("TRACK1")){const b=M(0,-.4),y=M(0,.4);r(b.x,b.y,y.x,y.y,g,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const b=M(0,.4),y=M(.4,0),A=M(0,-.4),S=M(-.4,0);r(b.x,b.y,y.x,y.y,g,s),r(y.x,y.y,A.x,A.y,g,s),r(A.x,A.y,S.x,S.y,g,s),r(S.x,S.y,b.x,b.y,g,s)}else{const b=M(.3,0),y=M(-.3,.2),A=M(-.3,-.2);r(b.x,b.y,y.x,y.y,g,s),r(y.x,y.y,A.x,A.y,g,s),r(A.x,A.y,b.x,b.y,g,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let g=null;for(let m=0;m<=bl;m++){const _=o+p*m/bl,M=d*Math.cos(_),b=h*Math.sin(_),y=r.x+M*Math.cos(f)-b*Math.sin(f),A=r.y+M*Math.sin(f)+b*Math.cos(f);g&&i(g.x,g.y,y,A,r.z||0,t),g={x:y,y:A}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},g={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,g.x,g.y,0),e.push(f.x,f.y,0,g.x,g.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),W=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},re=m;for(let ie=1;ie<=W;ie++){const oe=ie/W,_e=N+S*ie/W,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(_-m)*oe;this._pushWideSeg(u,D,de,re,le),D=de,re=le}o&&(o(p.x,p.y),o(g.x,g.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*b,I=A+v*E*b,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+M*Math.cos(P),N=I+M*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,g=0;for(const m of e)p+=m.x,g+=m.y;p/=e.length,g/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,g))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=_+A*b*m,E=M+A*y*m,v=Math.atan2(o.y-E,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=M.x),M.y>r&&(r=M.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let M=0;M1e-9&&g>_*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,g=document.createElement("canvas");g.width=d,g.height=h;const m=g.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const _=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),M=w=>{if(w.length<3)return;const U=_(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!A.length)return!1;const U=this._polyCentroid(w);for(const O of A)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(b.length){m.fillStyle="#ffffff",m.beginPath();for(const U of b)M(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)M(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const E=y.filter(w=>!S(w));if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const w of E)M(w);m.fill("evenodd")}const v=new _a(g);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,g=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),g=Math.max(g,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),_=Math.ceil(p+g+96*.35);d.width=f+m*2,d.height=_*e.length+m*2,h.font=u;const M=r>>16&255,b=r>>8&255,y=r&255;h.fillStyle=`rgb(${M},${b},${y})`,h.textBaseline="alphabetic";let A=m;a===1||a===4?(h.textAlign="center",A=d.width/2):a===2?(h.textAlign="right",A=d.width-m):(h.textAlign="left",A=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,g=h*p,m=f*p,_=e.alignH??1,M=e.alignV??2;let b=0,y=0;_===0||_===3||_===5?b=h/2:_===2&&(b=-h/2),M===3?y=-f/2:(M===0||M===1)&&(y=f/2);const A=e.rotation||0,S=Math.cos(A),E=Math.sin(A),v=e.pos.x+b*S-y*E,T=e.pos.y+b*E+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(g,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=A,this._group.add(P)}if(a&&!r){const U=g/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,W])=>({x:v+N*S-W*E,y:T+N*E+W*S}));for(let N=0;N<4;N++){const W=Z[N],D=Z[N+1];this._widePolyMesh([W,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,W=r&255;I.fillStyle=`rgb(${Z},${N},${W})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,g=i*d.h/f,m=g*(d.w/d.h),_=g/d.h,M=d.h/2;let b=0;a===0||a===3||a===5?b=m/2:a===1||a===4?b=0:a===2&&(b=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-M)*_:o===3&&(y=(p-M)*_));const A=new gc({map:h,transparent:!0,depthTest:!1});s&&(A.rotation=s);const S=new Nu(A);S.scale.set(m,g,1),S.position.set(t.x+b,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,g=t.xScale??1,m=t.yScale??1,_=t.rotation??0,M=Math.cos(_),b=Math.sin(_),y=(W,D)=>{const re=p?W-p.x:W,ie=p?D-p.y:D;return[f.x+re*g*M-ie*m*b,f.y+re*g*b+ie*m*M]},A=c?(W,D)=>c(...y(W,D)):y,S=u*Math.max(Math.abs(g),Math.abs(m)),E=d+_;for(const W of e){const D=W.data||W,re=(W.type||W.typeName||"").toUpperCase();if(re==="ATTDEF")continue;const ie=this._resolveBlockColor(W,i);try{if(re==="LINE"&&D.start&&D.end){const[oe,_e]=A(D.start.x,D.start.y),[de,le]=A(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((re==="CIRCLE"||re==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=A(D.center.x,D.center.y),de=D.radius*S,le=re==="ARC"?(D.startAngle??0)+E:0,z=re==="ARC"?(D.endAngle??Math.PI*2)+E:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(re==="ELLIPSE"&&D.center){const[oe,_e]=A(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+E;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((re==="LWPOLYLINE"||re==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=A(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(W,ne,S)?this._widePolyMesh(_e,de,le,W,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(re==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=W.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=A(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(re==="HATCH"){const oe=D.paths??W.paths;if(oe!=null&&oe.length){const _e=D.solidFill??W.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=A(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(re==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=A(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(re==="INSERT"&&o&&h<8){const oe=((w=W.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=W.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=W.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=W.scale)==null?void 0:N.y)??1,J=D.rotation??W.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:A,scale:S,rot:E,depth:h+1})}}}else if((re==="TEXT"||re==="MTEXT"||re==="ATTRIB"||re==="ATTDEF")&&r){if((re==="ATTRIB"||re==="ATTDEF")&&(D.flags??0)&1)continue;const oe=W.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+E;if(re==="MTEXT"){const Ue=W.attachment??D.attachment??W.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=W.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+E)}else de=D.horizAlignment??W.horizAlignment??0,le=D.vertAlignment??W.vertAlignment??0;const ne=re!=="MTEXT"&&(de!==0||le!==0),J=W.alignmentPt??D.alignmentPt,xe=W.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=A(Ae.x,Ae.y),ze=(D.textHeight??D.height??W.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};re==="MTEXT"&&(Ue.linespacingFactor=W.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(W.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(W.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=W.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=W.bgScale??D.bgScale??1.5,Ue.bgColorIndex=W.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=W.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,g=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",_=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),M=(S,E)=>{!S||!E||(r(S.x,S.y,E.x,E.y,0,s),o(S.x,S.y),o(E.x,E.y))},b=(S,E,v,T,I)=>{this._arcSegs({x:S,y:E},v,T,I,0,s,r)},y=(S,E,v)=>this._arrowMesh(S,E,v,s),A=(S,E,v,T)=>{E&&S&&a.push({text:E,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,E,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,E=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(g))>.5,w=f/2;S=l.x-(L?0:w),E=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);M({x:S,y:E},{x:v,y:T}),M(c,{x:S,y:E}),M(u,{x:v,y:T}),y({x:S,y:E,z:0},Math.atan2(E-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-E,v-S),I),A(h??{x:(S+v)/2,y:(E+T)/2},m||_(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);M(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),A(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${_(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},E=Math.max(f/2*.05,.5);M(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),E),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),E),A(h??l,m||`Ø${_(f)}`,Math.max(E*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,E=l.y,v=Math.hypot(c.x-S,c.y-E);if(v<1e-9)return;let T=Math.atan2(c.y-E,c.x-S),I=Math.atan2(u.y-E,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),b(S,E,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:E+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:E+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;A(h??{x:S+Math.cos(U)*v*1.2,y:E+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;M(l,c),A(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],g=e.clientY-this._downXY[1];if(Math.hypot(p,g)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,g=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let M=0;M+1d)||!(p>f))return t.clone();const g=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),_=new ki(new B(d-g,f-m,0),new B(h+g,p+m,0));return _.min.max(t.min),_.max.min(t.max),_}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=_.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}_.name=g,_.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},_.methodFactory=m||h,_.getLevel=function(){return y??b??M},_.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(_)},_.setDefaultLevel=function(L){b=T(L),E()||_.setLevel(L,!1)},_.resetLevel=function(){y=null,v(),u.call(_)},_.enableAll=function(L){_.setLevel(_.levels.TRACE,L)},_.disableAll=function(L){_.setLevel(_.levels.SILENT,L)},_.rebuild=function(){if(a!==_&&(M=T(a.getLevel())),u.call(_),a===_)for(var L in r)r[L].rebuild()},M=T(a?a.getLevel():"WARN");var I=E();I!=null&&(y=T(I)),u.call(_)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var _=r[m];return _||(_=r[m]=new f(m,a.methodFactory)),_};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=b(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,E=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=E);break}else o.code===9?(S&&(v[S]=E),S=o.value):o.code===10?E={x:o.value}:o.code===20?E.y=o.value:o.code===30?E.z=o.value:E=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const E=d();nt.debug("}"),A(E),E.name?S[E.name]=E:nt.error('block with handle "'+E.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=b(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),M[o.value]?(nt.debug(o.value+" Table {"),S[M[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const E=M[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===E.dxfSymbolName?v[E.tableRecordsProperty]=E.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[E.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+E.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function g(){const S=[];let E={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:E.name=o.value,o=r.next();break;case 10:E.lowerLeftCorner=y(o),o=r.next();break;case 11:E.upperRightCorner=y(o),o=r.next();break;case 12:E.center=y(o),o=r.next();break;case 13:E.snapBasePoint=y(o),o=r.next();break;case 14:E.snapSpacing=y(o),o=r.next();break;case 15:E.gridSpacing=y(o),o=r.next();break;case 16:E.viewDirectionFromTarget=y(o),o=r.next();break;case 17:E.viewTarget=y(o),o=r.next();break;case 42:E.lensLength=o.value,o=r.next();break;case 43:E.frontClippingPlane=o.value,o=r.next();break;case 44:E.backClippingPlane=o.value,o=r.next();break;case 45:E.viewHeight=o.value,o=r.next();break;case 50:E.snapRotationAngle=o.value,o=r.next();break;case 51:E.viewTwistAngle=o.value,o=r.next();break;case 79:E.orthographicType=o.value,o=r.next();break;case 110:E.ucsOrigin=y(o),o=r.next();break;case 111:E.ucsXAxis=y(o),o=r.next();break;case 112:E.ucsYAxis=y(o),o=r.next();break;case 110:E.ucsOrigin=y(o),o=r.next();break;case 281:E.renderMode=o.value,o=r.next();break;case 281:E.defaultLightingType=o.value,o=r.next();break;case 292:E.defaultLightingOn=o.value,o=r.next();break;case 330:E.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:E.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(E),nt.debug("ViewPort {"),E={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(E),S}function m(){const S={};let E={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:E.name=o.value,T=o.value,o=r.next();break;case 3:E.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(E.pattern=[]),o=r.next();break;case 40:E.patternLength=o.value,o=r.next();break;case 49:E.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==E.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=E,E={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=E,S}function _(){const S={};let E={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:E.name=o.value,v=o.value,o=r.next();break;case 62:E.visible=o.value>=0,E.colorIndex=Math.abs(o.value),E.color=iE(E.colorIndex),o=r.next();break;case 70:E.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=E,nt.debug("Layer {"),E={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=E,S}const M={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:g},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:_}};function b(S){const E=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),A(I),E.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),E}function y(S){const E={};let v=S.code;if(E.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return E.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),E):(E.z=S.value,E)}function A(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,g=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const _=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let M=0;M<=_;M++){const b=u+m*M/_,y=f*Math.cos(b),A=p*Math.sin(b);t.points.push({x:r+y*Math.cos(g)-A*Math.sin(g),y:a+y*Math.sin(g)+A*Math.cos(g)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const g=wd(p,i);g.ownerHandle={value:f},a.push(g)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/assets/index-DqhEmXLr.js b/dist2/assets/index-DqhEmXLr.js new file mode 100644 index 0000000..3412dbe --- /dev/null +++ b/dist2/assets/index-DqhEmXLr.js @@ -0,0 +1,5531 @@ +var jp=Object.defineProperty;var Qp=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var Gt=(n,e,t)=>Qp(n,typeof e!="symbol"?e+"":e,t);(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const a of r.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */const Ic="185",di={ROTATE:0,DOLLY:1,PAN:2},Pi={ROTATE:0,PAN:1,DOLLY_PAN:2,DOLLY_ROTATE:3},e0=0,gu=1,t0=2,Na=1,n0=2,yr=3,Bi=0,cn=1,zt=2,fi=0,zs=1,_u=2,xu=3,yu=4,i0=5,$i=100,s0=101,r0=102,a0=103,o0=104,l0=200,c0=201,u0=202,h0=203,Tl=204,Cl=205,d0=206,f0=207,p0=208,m0=209,g0=210,_0=211,x0=212,y0=213,v0=214,wl=0,Rl=1,Dl=2,Xs=3,Ll=4,Il=5,Pl=6,Ul=7,Nd=0,S0=1,b0=2,Jn=0,kd=1,Fd=2,Bd=3,Hd=4,zd=5,Vd=6,Gd=7,Wd=300,ns=301,Ys=302,To=303,Co=304,xo=306,Ol=1e3,ui=1001,Nl=1002,Nt=1003,M0=1004,Kr=1005,Xt=1006,wo=1007,Ui=1008,vn=1009,Xd=1010,Yd=1011,wr=1012,Pc=1013,ei=1014,Pn=1015,_i=1016,Uc=1017,Oc=1018,Rr=1020,Kd=35902,qd=35899,Zd=1021,$d=1022,bn=1023,xi=1026,es=1027,Jd=1028,Nc=1029,is=1030,kc=1031,Fc=1033,ka=33776,Fa=33777,Ba=33778,Ha=33779,kl=35840,Fl=35841,Bl=35842,Hl=35843,zl=36196,Vl=37492,Gl=37496,Wl=37488,Xl=37489,Ka=37490,Yl=37491,Kl=37808,ql=37809,Zl=37810,$l=37811,Jl=37812,jl=37813,Ql=37814,ec=37815,tc=37816,nc=37817,ic=37818,sc=37819,rc=37820,ac=37821,oc=36492,lc=36494,cc=36495,uc=36283,hc=36284,qa=36285,dc=36286,A0=3200,vu=0,E0=1,ci="",pn="srgb",Za="srgb-linear",$a="linear",ft="srgb",_s=7680,Su=519,T0=512,C0=513,w0=514,Bc=515,R0=516,D0=517,Hc=518,L0=519,fc=35044,pc="300 es",Zn=2e3,Ja=2001;function I0(n){for(let e=n.length-1;e>=0;--e)if(n[e]>=65535)return!0;return!1}function ja(n){return document.createElementNS("http://www.w3.org/1999/xhtml",n)}function P0(){const n=ja("canvas");return n.style.display="block",n}const bu={};function Qa(...n){const e="THREE."+n.shift();console.log(e,...n)}function jd(n){const e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){const t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return n}function Ye(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n)}}function at(...n){n=jd(n);const e="THREE."+n.shift();{const t=n[0];t&&t.isStackTrace?console.error(t.getError(e)):console.error(e,...n)}}function Vs(...n){const e=n.join(" ");e in bu||(bu[e]=!0,Ye(...n))}function U0(n,e,t){return new Promise(function(i,s){function r(){switch(n.clientWaitSync(e,n.SYNC_FLUSH_COMMANDS_BIT,0)){case n.WAIT_FAILED:s();break;case n.TIMEOUT_EXPIRED:setTimeout(r,t);break;default:i()}}setTimeout(r,t)})}const O0={[wl]:Rl,[Dl]:Pl,[Ll]:Ul,[Xs]:Il,[Rl]:wl,[Pl]:Dl,[Ul]:Ll,[Il]:Xs};class Gi{addEventListener(e,t){this._listeners===void 0&&(this._listeners={});const i=this._listeners;i[e]===void 0&&(i[e]=[]),i[e].indexOf(t)===-1&&i[e].push(t)}hasEventListener(e,t){const i=this._listeners;return i===void 0?!1:i[e]!==void 0&&i[e].indexOf(t)!==-1}removeEventListener(e,t){const i=this._listeners;if(i===void 0)return;const s=i[e];if(s!==void 0){const r=s.indexOf(t);r!==-1&&s.splice(r,1)}}dispatchEvent(e){const t=this._listeners;if(t===void 0)return;const i=t[e.type];if(i!==void 0){e.target=this;const s=i.slice(0);for(let r=0,a=s.length;r>8&255]+qt[n>>16&255]+qt[n>>24&255]+"-"+qt[e&255]+qt[e>>8&255]+"-"+qt[e>>16&15|64]+qt[e>>24&255]+"-"+qt[t&63|128]+qt[t>>8&255]+"-"+qt[t>>16&255]+qt[t>>24&255]+qt[i&255]+qt[i>>8&255]+qt[i>>16&255]+qt[i>>24&255]).toLowerCase()}function je(n,e,t){return Math.max(e,Math.min(t,n))}function N0(n,e){return(n%e+e)%e}function Ro(n,e,t){return(1-t)*n+t*e}function qn(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return n/4294967295;case Uint16Array:return n/65535;case Uint8Array:return n/255;case Int32Array:return Math.max(n/2147483647,-1);case Int16Array:return Math.max(n/32767,-1);case Int8Array:return Math.max(n/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}function _t(n,e){switch(e.constructor){case Float32Array:return n;case Uint32Array:return Math.round(n*4294967295);case Uint16Array:return Math.round(n*65535);case Uint8Array:return Math.round(n*255);case Int32Array:return Math.round(n*2147483647);case Int16Array:return Math.round(n*32767);case Int8Array:return Math.round(n*127);default:throw new Error("THREE.MathUtils: Invalid component type.")}}const k0={DEG2RAD:za},cu=class cu{constructor(e=0,t=0){this.x=e,this.y=t}get width(){return this.x}set width(e){this.x=e}get height(){return this.y}set height(e){this.y=e}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){const t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){const i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,a=this.y-e.y;return this.x=r*i-a*s+e.x,this.y=r*s+a*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};cu.prototype.isVector2=!0;let Ee=cu;class Hi{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=!0,this._x=e,this._y=t,this._z=i,this._w=s}static slerpFlat(e,t,i,s,r,a,o){let l=i[s+0],c=i[s+1],u=i[s+2],d=i[s+3],h=r[a+0],f=r[a+1],p=r[a+2],g=r[a+3];if(d!==g||l!==h||c!==f||u!==p){let m=l*h+c*f+u*p+d*g;m<0&&(h=-h,f=-f,p=-p,g=-g,m=-m);let _=1-o;if(m<.9995){const b=Math.acos(m),A=Math.sin(b);_=Math.sin(_*b)/A,o=Math.sin(o*b)/A,l=l*_+h*o,c=c*_+f*o,u=u*_+p*o,d=d*_+g*o}else{l=l*_+h*o,c=c*_+f*o,u=u*_+p*o,d=d*_+g*o;const b=1/Math.sqrt(l*l+c*c+u*u+d*d);l*=b,c*=b,u*=b,d*=b}}e[t]=l,e[t+1]=c,e[t+2]=u,e[t+3]=d}static multiplyQuaternionsFlat(e,t,i,s,r,a){const o=i[s],l=i[s+1],c=i[s+2],u=i[s+3],d=r[a],h=r[a+1],f=r[a+2],p=r[a+3];return e[t]=o*p+u*d+l*f-c*h,e[t+1]=l*p+u*h+c*d-o*f,e[t+2]=c*p+u*f+o*h-l*d,e[t+3]=u*p-o*d-l*h-c*f,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback()}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback()}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback()}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback()}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=!0){const i=e._x,s=e._y,r=e._z,a=e._order,o=Math.cos,l=Math.sin,c=o(i/2),u=o(s/2),d=o(r/2),h=l(i/2),f=l(s/2),p=l(r/2);switch(a){case"XYZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"YXZ":this._x=h*u*d+c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"ZXY":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d-h*f*p;break;case"ZYX":this._x=h*u*d-c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d+h*f*p;break;case"YZX":this._x=h*u*d+c*f*p,this._y=c*f*d+h*u*p,this._z=c*u*p-h*f*d,this._w=c*u*d-h*f*p;break;case"XZY":this._x=h*u*d-c*f*p,this._y=c*f*d-h*u*p,this._z=c*u*p+h*f*d,this._w=c*u*d+h*f*p;break;default:Ye("Quaternion: .setFromEuler() encountered an unknown order: "+a)}return t===!0&&this._onChangeCallback(),this}setFromAxisAngle(e,t){const i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){const t=e.elements,i=t[0],s=t[4],r=t[8],a=t[1],o=t[5],l=t[9],c=t[2],u=t[6],d=t[10],h=i+o+d;if(h>0){const f=.5/Math.sqrt(h+1);this._w=.25/f,this._x=(u-l)*f,this._y=(r-c)*f,this._z=(a-s)*f}else if(i>o&&i>d){const f=2*Math.sqrt(1+i-o-d);this._w=(u-l)/f,this._x=.25*f,this._y=(s+a)/f,this._z=(r+c)/f}else if(o>d){const f=2*Math.sqrt(1+o-i-d);this._w=(r-c)/f,this._x=(s+a)/f,this._y=.25*f,this._z=(l+u)/f}else{const f=2*Math.sqrt(1+d-i-o);this._w=(a-s)/f,this._x=(r+c)/f,this._y=(l+u)/f,this._z=.25*f}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(je(this.dot(e),-1,1)))}rotateTowards(e,t){const i=this.angleTo(e);if(i===0)return this;const s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){const i=e._x,s=e._y,r=e._z,a=e._w,o=t._x,l=t._y,c=t._z,u=t._w;return this._x=i*u+a*o+s*c-r*l,this._y=s*u+a*l+r*o-i*c,this._z=r*u+a*c+i*l-s*o,this._w=a*u-i*o-s*l-r*c,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,a=e._w,o=this.dot(e);o<0&&(i=-i,s=-s,r=-r,a=-a,o=-o);let l=1-t;if(o<.9995){const c=Math.acos(o),u=Math.sin(c);l=Math.sin(l*c)/u,t=Math.sin(t*c)/u,this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this._onChangeCallback()}else this._x=this._x*l+i*t,this._y=this._y*l+s*t,this._z=this._z*l+r*t,this._w=this._w*l+a*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){const e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const uu=class uu{constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Mu.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Mu.setFromAxisAngle(e,t))}applyMatrix3(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=e.elements,a=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*a,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*a,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*a,this}applyQuaternion(e){const t=this.x,i=this.y,s=this.z,r=e.x,a=e.y,o=e.z,l=e.w,c=2*(a*s-o*i),u=2*(o*t-r*s),d=2*(r*i-a*t);return this.x=t+l*c+a*d-o*u,this.y=i+l*u+o*c-r*d,this.z=s+l*d+r*u-a*c,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){const t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){const i=e.x,s=e.y,r=e.z,a=t.x,o=t.y,l=t.z;return this.x=s*l-r*o,this.y=r*a-i*l,this.z=i*o-s*a,this}projectOnVector(e){const t=e.lengthSq();if(t===0)return this.set(0,0,0);const i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Do.copy(this).projectOnVector(e),this.sub(Do)}reflect(e){return this.sub(Do.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){const t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;const i=this.dot(e)/t;return Math.acos(je(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){const t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){const s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){const t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};uu.prototype.isVector3=!0;let B=uu;const Do=new B,Mu=new Hi,hu=class hu{constructor(e,t,i,s,r,a,o,l,c){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,a,o,l,c)}set(e,t,i,s,r,a,o,l,c){const u=this.elements;return u[0]=e,u[1]=s,u[2]=o,u[3]=t,u[4]=r,u[5]=l,u[6]=i,u[7]=a,u[8]=c,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){const t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){const t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){const i=e.elements,s=t.elements,r=this.elements,a=i[0],o=i[3],l=i[6],c=i[1],u=i[4],d=i[7],h=i[2],f=i[5],p=i[8],g=s[0],m=s[3],_=s[6],b=s[1],A=s[4],y=s[7],M=s[2],S=s[5],E=s[8];return r[0]=a*g+o*b+l*M,r[3]=a*m+o*A+l*S,r[6]=a*_+o*y+l*E,r[1]=c*g+u*b+d*M,r[4]=c*m+u*A+d*S,r[7]=c*_+u*y+d*E,r[2]=h*g+f*b+p*M,r[5]=h*m+f*A+p*S,r[8]=h*_+f*y+p*E,this}multiplyScalar(e){const t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8];return t*a*u-t*o*c-i*r*u+i*o*l+s*r*c-s*a*l}invert(){const e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],o=e[5],l=e[6],c=e[7],u=e[8],d=u*a-o*c,h=o*l-u*r,f=c*r-a*l,p=t*d+i*h+s*f;if(p===0)return this.set(0,0,0,0,0,0,0,0,0);const g=1/p;return e[0]=d*g,e[1]=(s*c-u*i)*g,e[2]=(o*i-s*a)*g,e[3]=h*g,e[4]=(u*t-s*l)*g,e[5]=(s*r-o*t)*g,e[6]=f*g,e[7]=(i*l-c*t)*g,e[8]=(a*t-i*r)*g,this}transpose(){let e;const t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){const t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,a,o){const l=Math.cos(r),c=Math.sin(r);return this.set(i*l,i*c,-i*(l*a+c*o)+a+e,-s*c,s*l,-s*(-c*a+l*o)+o+t,0,0,1),this}scale(e,t){return Vs("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Lo.makeScale(e,t)),this}rotate(e){return Vs("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Lo.makeRotation(-e)),this}translate(e,t){return Vs("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Lo.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){const t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){const t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return!1;return!0}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){const i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}};hu.prototype.isMatrix3=!0;let qe=hu;const Lo=new qe,Au=new qe().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Eu=new qe().set(3.2409699,-1.5373832,-.4986108,-.9692436,1.8759675,.0415551,.0556301,-.203977,1.0569715);function F0(){const n={enabled:!0,workingColorSpace:Za,spaces:{},convert:function(s,r,a){return this.enabled===!1||r===a||!r||!a||(this.spaces[r].transfer===ft&&(s.r=mi(s.r),s.g=mi(s.g),s.b=mi(s.b)),this.spaces[r].primaries!==this.spaces[a].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[a].fromXYZ)),this.spaces[a].transfer===ft&&(s.r=Gs(s.r),s.g=Gs(s.g),s.b=Gs(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===ci?$a:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s)},_getMatrix:function(s,r,a){return s.copy(this.spaces[r].toXYZ).multiply(this.spaces[a].fromXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace},fromWorkingColorSpace:function(s,r){return Vs("ColorManagement: .fromWorkingColorSpace() has been renamed to .workingToColorSpace()."),n.workingToColorSpace(s,r)},toWorkingColorSpace:function(s,r){return Vs("ColorManagement: .toWorkingColorSpace() has been renamed to .colorSpaceToWorking()."),n.colorSpaceToWorking(s,r)}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[Za]:{primaries:e,whitePoint:i,transfer:$a,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:pn},outputColorSpaceConfig:{drawingBufferColorSpace:pn}},[pn]:{primaries:e,whitePoint:i,transfer:ft,toXYZ:Au,fromXYZ:Eu,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:pn}}}),n}const it=F0();function mi(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function Gs(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}let xs;class B0{static getDataURL(e,t="image/png"){if(/^data:/i.test(e.src)||typeof HTMLCanvasElement>"u")return e.src;let i;if(e instanceof HTMLCanvasElement)i=e;else{xs===void 0&&(xs=ja("canvas")),xs.width=e.width,xs.height=e.height;const s=xs.getContext("2d");e instanceof ImageData?s.putImageData(e,0,0):s.drawImage(e,0,0,e.width,e.height),i=xs}return i.toDataURL(t)}static sRGBToLinear(e){if(typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap){const t=ja("canvas");t.width=e.width,t.height=e.height;const i=t.getContext("2d");i.drawImage(e,0,0,e.width,e.height);const s=i.getImageData(0,0,e.width,e.height),r=s.data;for(let a=0;a1),this.pmremVersion=0,this.normalized=!1}get width(){return this.source.getSize(Po).x}get height(){return this.source.getSize(Po).y}get depth(){return this.source.getSize(Po).z}get image(){return this.source.data}set image(e){this.source.data=e}updateMatrix(){this.matrix.setUvTransform(this.offset.x,this.offset.y,this.repeat.x,this.repeat.y,this.rotation,this.center.x,this.center.y)}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}clone(){return new this.constructor().copy(this)}copy(e){return this.name=e.name,this.source=e.source,this.mipmaps=e.mipmaps.slice(0),this.mapping=e.mapping,this.channel=e.channel,this.wrapS=e.wrapS,this.wrapT=e.wrapT,this.magFilter=e.magFilter,this.minFilter=e.minFilter,this.anisotropy=e.anisotropy,this.format=e.format,this.internalFormat=e.internalFormat,this.type=e.type,this.normalized=e.normalized,this.offset.copy(e.offset),this.repeat.copy(e.repeat),this.center.copy(e.center),this.rotation=e.rotation,this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrix.copy(e.matrix),this.generateMipmaps=e.generateMipmaps,this.premultiplyAlpha=e.premultiplyAlpha,this.flipY=e.flipY,this.unpackAlignment=e.unpackAlignment,this.colorSpace=e.colorSpace,this.renderTarget=e.renderTarget,this.isRenderTargetTexture=e.isRenderTargetTexture,this.isArrayTexture=e.isArrayTexture,this.userData=JSON.parse(JSON.stringify(e.userData)),this.needsUpdate=!0,this}setValues(e){for(const t in e){const i=e[t];if(i===void 0){Ye(`Texture.setValues(): parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Texture.setValues(): property '${t}' does not exist.`);continue}s&&i&&s.isVector2&&i.isVector2||s&&i&&s.isVector3&&i.isVector3||s&&i&&s.isMatrix3&&i.isMatrix3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";if(!t&&e.textures[this.uuid]!==void 0)return e.textures[this.uuid];const i={metadata:{version:4.7,type:"Texture",generator:"Texture.toJSON"},uuid:this.uuid,name:this.name,image:this.source.toJSON(e).uuid,mapping:this.mapping,channel:this.channel,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],center:[this.center.x,this.center.y],rotation:this.rotation,wrap:[this.wrapS,this.wrapT],format:this.format,internalFormat:this.internalFormat,type:this.type,normalized:this.normalized,colorSpace:this.colorSpace,minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy,flipY:this.flipY,generateMipmaps:this.generateMipmaps,premultiplyAlpha:this.premultiplyAlpha,unpackAlignment:this.unpackAlignment};return Object.keys(this.userData).length>0&&(i.userData=this.userData),t||(e.textures[this.uuid]=i),i}dispose(){this.dispatchEvent({type:"dispose"})}transformUv(e){if(this.mapping!==Wd)return e;if(e.applyMatrix3(this.matrix),e.x<0||e.x>1)switch(this.wrapS){case Ol:e.x=e.x-Math.floor(e.x);break;case ui:e.x=e.x<0?0:1;break;case Nl:Math.abs(Math.floor(e.x)%2)===1?e.x=Math.ceil(e.x)-e.x:e.x=e.x-Math.floor(e.x);break}if(e.y<0||e.y>1)switch(this.wrapT){case Ol:e.y=e.y-Math.floor(e.y);break;case ui:e.y=e.y<0?0:1;break;case Nl:Math.abs(Math.floor(e.y)%2)===1?e.y=Math.ceil(e.y)-e.y:e.y=e.y-Math.floor(e.y);break}return this.flipY&&(e.y=1-e.y),e}set needsUpdate(e){e===!0&&(this.version++,this.source.needsUpdate=!0)}set needsPMREMUpdate(e){e===!0&&this.pmremVersion++}}Jt.DEFAULT_IMAGE=null;Jt.DEFAULT_MAPPING=Wd;Jt.DEFAULT_ANISOTROPY=1;const du=class du{constructor(e=0,t=0,i=0,s=1){this.x=e,this.y=t,this.z=i,this.w=s}get width(){return this.z}set width(e){this.z=e}get height(){return this.w}set height(e){this.w=e}set(e,t,i,s){return this.x=e,this.y=t,this.z=i,this.w=s,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this.w=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setW(e){return this.w=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("THREE.Vector4: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w!==void 0?e.w:1,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this}applyMatrix4(e){const t=this.x,i=this.y,s=this.z,r=this.w,a=e.elements;return this.x=a[0]*t+a[4]*i+a[8]*s+a[12]*r,this.y=a[1]*t+a[5]*i+a[9]*s+a[13]*r,this.z=a[2]*t+a[6]*i+a[10]*s+a[14]*r,this.w=a[3]*t+a[7]*i+a[11]*s+a[15]*r,this}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this.w/=e.w,this}divideScalar(e){return this.multiplyScalar(1/e)}setAxisAngleFromQuaternion(e){this.w=2*Math.acos(e.w);const t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this}setAxisAngleFromRotationMatrix(e){let t,i,s,r;const l=e.elements,c=l[0],u=l[4],d=l[8],h=l[1],f=l[5],p=l[9],g=l[2],m=l[6],_=l[10];if(Math.abs(u-h)<.01&&Math.abs(d-g)<.01&&Math.abs(p-m)<.01){if(Math.abs(u+h)<.1&&Math.abs(d+g)<.1&&Math.abs(p+m)<.1&&Math.abs(c+f+_-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;const A=(c+1)/2,y=(f+1)/2,M=(_+1)/2,S=(u+h)/4,E=(d+g)/4,v=(p+m)/4;return A>y&&A>M?A<.01?(i=0,s=.707106781,r=.707106781):(i=Math.sqrt(A),s=S/i,r=E/i):y>M?y<.01?(i=.707106781,s=0,r=.707106781):(s=Math.sqrt(y),i=S/s,r=v/s):M<.01?(i=.707106781,s=.707106781,r=0):(r=Math.sqrt(M),i=E/r,s=v/r),this.set(i,s,r,t),this}let b=Math.sqrt((m-p)*(m-p)+(d-g)*(d-g)+(h-u)*(h-u));return Math.abs(b)<.001&&(b=1),this.x=(m-p)/b,this.y=(d-g)/b,this.z=(h-u)/b,this.w=Math.acos((c+f+_-1)/2),this}setFromMatrixPosition(e){const t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this.w=t[15],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this}clamp(e,t){return this.x=je(this.x,e.x,t.x),this.y=je(this.y,e.y,t.y),this.z=je(this.z,e.z,t.z),this.w=je(this.w,e.w,t.w),this}clampScalar(e,t){return this.x=je(this.x,e,t),this.y=je(this.y,e,t),this.z=je(this.z,e,t),this.w=je(this.w,e,t),this}clampLength(e,t){const i=this.length();return this.divideScalar(i||1).multiplyScalar(je(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this.w=e.w+(t.w-e.w)*i,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};du.prototype.isVector4=!0;let wt=du;class V0 extends Gi{constructor(e=1,t=1,i={}){super(),i=Object.assign({generateMipmaps:!1,internalFormat:null,minFilter:Xt,depthBuffer:!0,stencilBuffer:!1,resolveDepthBuffer:!0,resolveStencilBuffer:!0,depthTexture:null,samples:0,count:1,depth:1,multiview:!1,useArrayDepthTexture:!1},i),this.isRenderTarget=!0,this.width=e,this.height=t,this.depth=i.depth,this.scissor=new wt(0,0,e,t),this.scissorTest=!1,this.viewport=new wt(0,0,e,t),this.textures=[];const s={width:e,height:t,depth:i.depth},r=new Jt(s),a=i.count;for(let o=0;o1);this.dispose()}this.viewport.set(0,0,e,t),this.scissor.set(0,0,e,t)}clone(){return new this.constructor().copy(this)}copy(e){this.width=e.width,this.height=e.height,this.depth=e.depth,this.scissor.copy(e.scissor),this.scissorTest=e.scissorTest,this.viewport.copy(e.viewport),this.textures.length=0;for(let t=0,i=e.textures.length;t>>0}enable(e){this.mask|=1<1){for(let t=0;t1){for(let i=0;i0&&(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.matrixAutoUpdate===!1&&(s.matrixAutoUpdate=!1),this.morphTargetDictionary!==void 0&&(s.morphTargetDictionary=Object.assign({},this.morphTargetDictionary)),this.morphTargetInfluences!==void 0&&(s.morphTargetInfluences=this.morphTargetInfluences.slice()),this.isInstancedMesh&&(s.type="InstancedMesh",s.count=this.count,s.instanceMatrix=this.instanceMatrix.toJSON(),this.instanceColor!==null&&(s.instanceColor=this.instanceColor.toJSON())),this.isBatchedMesh&&(s.type="BatchedMesh",s.perObjectFrustumCulled=this.perObjectFrustumCulled,s.sortObjects=this.sortObjects,s.drawRanges=this._drawRanges,s.reservedRanges=this._reservedRanges,s.geometryInfo=this._geometryInfo.map(o=>({...o,boundingBox:o.boundingBox?o.boundingBox.toJSON():void 0,boundingSphere:o.boundingSphere?o.boundingSphere.toJSON():void 0})),s.instanceInfo=this._instanceInfo.map(o=>({...o})),s.availableInstanceIds=this._availableInstanceIds.slice(),s.availableGeometryIds=this._availableGeometryIds.slice(),s.nextIndexStart=this._nextIndexStart,s.nextVertexStart=this._nextVertexStart,s.geometryCount=this._geometryCount,s.maxInstanceCount=this._maxInstanceCount,s.maxVertexCount=this._maxVertexCount,s.maxIndexCount=this._maxIndexCount,s.geometryInitialized=this._geometryInitialized,s.matricesTexture=this._matricesTexture.toJSON(e),s.indirectTexture=this._indirectTexture.toJSON(e),this._colorsTexture!==null&&(s.colorsTexture=this._colorsTexture.toJSON(e)),this.boundingSphere!==null&&(s.boundingSphere=this.boundingSphere.toJSON()),this.boundingBox!==null&&(s.boundingBox=this.boundingBox.toJSON()));function r(o,l){return o[l.uuid]===void 0&&(o[l.uuid]=l.toJSON(e)),l.uuid}if(this.isScene)this.background&&(this.background.isColor?s.background=this.background.toJSON():this.background.isTexture&&(s.background=this.background.toJSON(e).uuid)),this.environment&&this.environment.isTexture&&this.environment.isRenderTargetTexture!==!0&&(s.environment=this.environment.toJSON(e).uuid);else if(this.isMesh||this.isLine||this.isPoints){s.geometry=r(e.geometries,this.geometry);const o=this.geometry.parameters;if(o!==void 0&&o.shapes!==void 0){const l=o.shapes;if(Array.isArray(l))for(let c=0,u=l.length;c0){s.children=[];for(let o=0;o0){s.animations=[];for(let o=0;o0&&(i.geometries=o),l.length>0&&(i.materials=l),c.length>0&&(i.textures=c),u.length>0&&(i.images=u),d.length>0&&(i.shapes=d),h.length>0&&(i.skeletons=h),f.length>0&&(i.animations=f),p.length>0&&(i.nodes=p)}return i.object=s,i;function a(o){const l=[];for(const c in o){const u=o[c];delete u.metadata,l.push(u)}return l}}clone(e){return new this.constructor().copy(this,e)}copy(e,t=!0){if(this.name=e.name,this.up.copy(e.up),this.position.copy(e.position),this.rotation.order=e.rotation.order,this.quaternion.copy(e.quaternion),this.scale.copy(e.scale),this.pivot=e.pivot!==null?e.pivot.clone():null,this.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,this.matrixWorldAutoUpdate=e.matrixWorldAutoUpdate,this.matrixWorldNeedsUpdate=e.matrixWorldNeedsUpdate,this.layers.mask=e.layers.mask,this.visible=e.visible,this.castShadow=e.castShadow,this.receiveShadow=e.receiveShadow,this.frustumCulled=e.frustumCulled,this.renderOrder=e.renderOrder,this.static=e.static,this.animations=e.animations.slice(),this.userData=JSON.parse(JSON.stringify(e.userData)),t===!0)for(let i=0;if+p?(c.inputState.pinching=!1,this.dispatchEvent({type:"pinchend",handedness:e.handedness,target:this})):!c.inputState.pinching&&h<=f-p&&(c.inputState.pinching=!0,this.dispatchEvent({type:"pinchstart",handedness:e.handedness,target:this}))}else l!==null&&e.gripSpace&&(r=t.getPose(e.gripSpace,i),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:e,target:this})));o!==null&&(s=t.getPose(e.targetRaySpace,i),s===null&&r!==null&&(s=r),s!==null&&(o.matrix.fromArray(s.transform.matrix),o.matrix.decompose(o.position,o.rotation,o.scale),o.matrixWorldNeedsUpdate=!0,s.linearVelocity?(o.hasLinearVelocity=!0,o.linearVelocity.copy(s.linearVelocity)):o.hasLinearVelocity=!1,s.angularVelocity?(o.hasAngularVelocity=!0,o.angularVelocity.copy(s.angularVelocity)):o.hasAngularVelocity=!1,this.dispatchEvent($0)))}return o!==null&&(o.visible=s!==null),l!==null&&(l.visible=r!==null),c!==null&&(c.visible=a!==null),this}_getHandJoint(e,t){if(e.joints[t.jointName]===void 0){const i=new vr;i.matrixAutoUpdate=!1,i.visible=!1,e.joints[t.jointName]=i,e.add(i)}return e.joints[t.jointName]}}const tf={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},Ai={h:0,s:0,l:0},$r={h:0,s:0,l:0};function No(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}class Qe{constructor(e,t,i){return this.isColor=!0,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){const s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s)}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=pn){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,it.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=it.workingColorSpace){return this.r=e,this.g=t,this.b=i,it.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=it.workingColorSpace){if(e=N0(e,1),t=je(t,0,1),i=je(i,0,1),t===0)this.r=this.g=this.b=i;else{const r=i<=.5?i*(1+t):i+t-i*t,a=2*i-r;this.r=No(a,r,e+1/3),this.g=No(a,r,e),this.b=No(a,r,e-1/3)}return it.colorSpaceToWorking(this,s),this}setStyle(e,t=pn){function i(r){r!==void 0&&parseFloat(r)<1&&Ye("Color: Alpha component of "+e+" will be ignored.")}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r;const a=s[1],o=s[2];switch(a){case"rgb":case"rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setRGB(Math.min(100,parseInt(r[1],10))/100,Math.min(100,parseInt(r[2],10))/100,Math.min(100,parseInt(r[3],10))/100,t);break;case"hsl":case"hsla":if(r=/^\s*(\d*\.?\d+)\s*,\s*(\d*\.?\d+)\%\s*,\s*(\d*\.?\d+)\%\s*(?:,\s*(\d*\.?\d+)\s*)?$/.exec(o))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:Ye("Color: Unknown color model "+e)}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){const r=s[1],a=r.length;if(a===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(a===6)return this.setHex(parseInt(r,16),t);Ye("Color: Invalid hex color "+e)}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=pn){const i=tf[e.toLowerCase()];return i!==void 0?this.setHex(i,t):Ye("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=mi(e.r),this.g=mi(e.g),this.b=mi(e.b),this}copyLinearToSRGB(e){return this.r=Gs(e.r),this.g=Gs(e.g),this.b=Gs(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=pn){return it.workingToColorSpace(Zt.copy(this),e),Math.round(je(Zt.r*255,0,255))*65536+Math.round(je(Zt.g*255,0,255))*256+Math.round(je(Zt.b*255,0,255))}getHexString(e=pn){return("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=it.workingColorSpace){it.workingToColorSpace(Zt.copy(this),t);const i=Zt.r,s=Zt.g,r=Zt.b,a=Math.max(i,s,r),o=Math.min(i,s,r);let l,c;const u=(o+a)/2;if(o===a)l=0,c=0;else{const d=a-o;switch(c=u<=.5?d/(a+o):d/(2-a-o),a){case i:l=(s-r)/d+(s0&&(t.object.backgroundBlurriness=this.backgroundBlurriness),this.backgroundIntensity!==1&&(t.object.backgroundIntensity=this.backgroundIntensity),t.object.backgroundRotation=this.backgroundRotation.toArray(),this.environmentIntensity!==1&&(t.object.environmentIntensity=this.environmentIntensity),t.object.environmentRotation=this.environmentRotation.toArray(),t}}const Rn=new B,ri=new B,ko=new B,ai=new B,bs=new B,Ms=new B,Pu=new B,Fo=new B,Bo=new B,Ho=new B,zo=new wt,Vo=new wt,Go=new wt;class Sn{constructor(e=new B,t=new B,i=new B){this.a=e,this.b=t,this.c=i}static getNormal(e,t,i,s){s.subVectors(i,t),Rn.subVectors(e,t),s.cross(Rn);const r=s.lengthSq();return r>0?s.multiplyScalar(1/Math.sqrt(r)):s.set(0,0,0)}static getBarycoord(e,t,i,s,r){Rn.subVectors(s,t),ri.subVectors(i,t),ko.subVectors(e,t);const a=Rn.dot(Rn),o=Rn.dot(ri),l=Rn.dot(ko),c=ri.dot(ri),u=ri.dot(ko),d=a*c-o*o;if(d===0)return r.set(0,0,0),null;const h=1/d,f=(c*l-o*u)*h,p=(a*u-o*l)*h;return r.set(1-f-p,p,f)}static containsPoint(e,t,i,s){return this.getBarycoord(e,t,i,s,ai)===null?!1:ai.x>=0&&ai.y>=0&&ai.x+ai.y<=1}static getInterpolation(e,t,i,s,r,a,o,l){return this.getBarycoord(e,t,i,s,ai)===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,ai.x),l.addScaledVector(a,ai.y),l.addScaledVector(o,ai.z),l)}static getInterpolatedAttribute(e,t,i,s,r,a){return zo.setScalar(0),Vo.setScalar(0),Go.setScalar(0),zo.fromBufferAttribute(e,t),Vo.fromBufferAttribute(e,i),Go.fromBufferAttribute(e,s),a.setScalar(0),a.addScaledVector(zo,r.x),a.addScaledVector(Vo,r.y),a.addScaledVector(Go,r.z),a}static isFrontFacing(e,t,i,s){return Rn.subVectors(i,t),ri.subVectors(e,t),Rn.cross(ri).dot(s)<0}set(e,t,i){return this.a.copy(e),this.b.copy(t),this.c.copy(i),this}setFromPointsAndIndices(e,t,i,s){return this.a.copy(e[t]),this.b.copy(e[i]),this.c.copy(e[s]),this}setFromAttributeAndIndices(e,t,i,s){return this.a.fromBufferAttribute(e,t),this.b.fromBufferAttribute(e,i),this.c.fromBufferAttribute(e,s),this}clone(){return new this.constructor().copy(this)}copy(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this}getArea(){return Rn.subVectors(this.c,this.b),ri.subVectors(this.a,this.b),Rn.cross(ri).length()*.5}getMidpoint(e){return e.addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)}getNormal(e){return Sn.getNormal(this.a,this.b,this.c,e)}getPlane(e){return e.setFromCoplanarPoints(this.a,this.b,this.c)}getBarycoord(e,t){return Sn.getBarycoord(e,this.a,this.b,this.c,t)}getInterpolation(e,t,i,s,r){return Sn.getInterpolation(e,this.a,this.b,this.c,t,i,s,r)}containsPoint(e){return Sn.containsPoint(e,this.a,this.b,this.c)}isFrontFacing(e){return Sn.isFrontFacing(this.a,this.b,this.c,e)}intersectsBox(e){return e.intersectsTriangle(this)}closestPointToPoint(e,t){const i=this.a,s=this.b,r=this.c;let a,o;bs.subVectors(s,i),Ms.subVectors(r,i),Fo.subVectors(e,i);const l=bs.dot(Fo),c=Ms.dot(Fo);if(l<=0&&c<=0)return t.copy(i);Bo.subVectors(e,s);const u=bs.dot(Bo),d=Ms.dot(Bo);if(u>=0&&d<=u)return t.copy(s);const h=l*d-u*c;if(h<=0&&l>=0&&u<=0)return a=l/(l-u),t.copy(i).addScaledVector(bs,a);Ho.subVectors(e,r);const f=bs.dot(Ho),p=Ms.dot(Ho);if(p>=0&&f<=p)return t.copy(r);const g=f*c-l*p;if(g<=0&&c>=0&&p<=0)return o=c/(c-p),t.copy(i).addScaledVector(Ms,o);const m=u*p-f*d;if(m<=0&&d-u>=0&&f-p>=0)return Pu.subVectors(r,s),o=(d-u)/(d-u+(f-p)),t.copy(s).addScaledVector(Pu,o);const _=1/(m+g+h);return a=g*_,o=h*_,t.copy(i).addScaledVector(bs,a).addScaledVector(Ms,o)}equals(e){return e.a.equals(this.a)&&e.b.equals(this.b)&&e.c.equals(this.c)}}class ki{constructor(e=new B(1/0,1/0,1/0),t=new B(-1/0,-1/0,-1/0)){this.isBox3=!0,this.min=e,this.max=t}set(e,t){return this.min.copy(e),this.max.copy(t),this}setFromArray(e){this.makeEmpty();for(let t=0,i=e.length;t=this.min.x&&e.x<=this.max.x&&e.y>=this.min.y&&e.y<=this.max.y&&e.z>=this.min.z&&e.z<=this.max.z}containsBox(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z}getParameter(e,t){return t.set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))}intersectsBox(e){return e.max.x>=this.min.x&&e.min.x<=this.max.x&&e.max.y>=this.min.y&&e.min.y<=this.max.y&&e.max.z>=this.min.z&&e.min.z<=this.max.z}intersectsSphere(e){return this.clampPoint(e.center,Dn),Dn.distanceToSquared(e.center)<=e.radius*e.radius}intersectsPlane(e){let t,i;return e.normal.x>0?(t=e.normal.x*this.min.x,i=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,i=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,i+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,i+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,i+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,i+=e.normal.z*this.min.z),t<=-e.constant&&i>=-e.constant}intersectsTriangle(e){if(this.isEmpty())return!1;this.getCenter(lr),jr.subVectors(this.max,lr),As.subVectors(e.a,lr),Es.subVectors(e.b,lr),Ts.subVectors(e.c,lr),Ei.subVectors(Es,As),Ti.subVectors(Ts,Es),Wi.subVectors(As,Ts);let t=[0,-Ei.z,Ei.y,0,-Ti.z,Ti.y,0,-Wi.z,Wi.y,Ei.z,0,-Ei.x,Ti.z,0,-Ti.x,Wi.z,0,-Wi.x,-Ei.y,Ei.x,0,-Ti.y,Ti.x,0,-Wi.y,Wi.x,0];return!Wo(t,As,Es,Ts,jr)||(t=[1,0,0,0,1,0,0,0,1],!Wo(t,As,Es,Ts,jr))?!1:(Qr.crossVectors(Ei,Ti),t=[Qr.x,Qr.y,Qr.z],Wo(t,As,Es,Ts,jr))}clampPoint(e,t){return t.copy(e).clamp(this.min,this.max)}distanceToPoint(e){return this.clampPoint(e,Dn).distanceTo(e)}getBoundingSphere(e){return this.isEmpty()?e.makeEmpty():(this.getCenter(e.center),e.radius=this.getSize(Dn).length()*.5),e}intersect(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this}union(e){return this.min.min(e.min),this.max.max(e.max),this}applyMatrix4(e){return this.isEmpty()?this:(oi[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(e),oi[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(e),oi[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(e),oi[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(e),oi[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(e),oi[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(e),oi[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(e),oi[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(e),this.setFromPoints(oi),this)}translate(e){return this.min.add(e),this.max.add(e),this}equals(e){return e.min.equals(this.min)&&e.max.equals(this.max)}toJSON(){return{min:this.min.toArray(),max:this.max.toArray()}}fromJSON(e){return this.min.fromArray(e.min),this.max.fromArray(e.max),this}}const oi=[new B,new B,new B,new B,new B,new B,new B,new B],Dn=new B,Jr=new ki,As=new B,Es=new B,Ts=new B,Ei=new B,Ti=new B,Wi=new B,lr=new B,jr=new B,Qr=new B,Xi=new B;function Wo(n,e,t,i,s){for(let r=0,a=n.length-3;r<=a;r+=3){Xi.fromArray(n,r);const o=s.x*Math.abs(Xi.x)+s.y*Math.abs(Xi.y)+s.z*Math.abs(Xi.z),l=e.dot(Xi),c=t.dot(Xi),u=i.dot(Xi);if(Math.max(-Math.max(l,c,u),Math.min(l,c,u))>o)return!1}return!0}const Ut=new B,ea=new Ee;let j0=0;class Un extends Gi{constructor(e,t,i=!1){if(super(),Array.isArray(e))throw new TypeError("THREE.BufferAttribute: array should be a Typed Array.");this.isBufferAttribute=!0,Object.defineProperty(this,"id",{value:j0++}),this.name="",this.array=e,this.itemSize=t,this.count=e!==void 0?e.length/t:0,this.normalized=i,this.usage=fc,this.updateRanges=[],this.gpuType=Pn,this.version=0}onUploadCallback(){}set needsUpdate(e){e===!0&&this.version++}setUsage(e){return this.usage=e,this}addUpdateRange(e,t){this.updateRanges.push({start:e,count:t})}clearUpdateRanges(){this.updateRanges.length=0}copy(e){return this.name=e.name,this.array=new e.array.constructor(e.array),this.itemSize=e.itemSize,this.count=e.count,this.normalized=e.normalized,this.usage=e.usage,this.gpuType=e.gpuType,this}copyAt(e,t,i){e*=this.itemSize,i*=t.itemSize;for(let s=0,r=this.itemSize;sthis.radius*this.radius&&(t.sub(this.center).normalize(),t.multiplyScalar(this.radius).add(this.center)),t}getBoundingBox(e){return this.isEmpty()?(e.makeEmpty(),e):(e.set(this.center,this.center),e.expandByScalar(this.radius),e)}applyMatrix4(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this}translate(e){return this.center.add(e),this}expandByPoint(e){if(this.isEmpty())return this.center.copy(e),this.radius=0,this;cr.subVectors(e,this.center);const t=cr.lengthSq();if(t>this.radius*this.radius){const i=Math.sqrt(t),s=(i-this.radius)*.5;this.center.addScaledVector(cr,s/i),this.radius+=s}return this}union(e){return e.isEmpty()?this:this.isEmpty()?(this.copy(e),this):(this.center.equals(e.center)===!0?this.radius=Math.max(this.radius,e.radius):(Xo.subVectors(e.center,this.center).setLength(e.radius),this.expandByPoint(cr.copy(e.center).add(Xo)),this.expandByPoint(cr.copy(e.center).sub(Xo))),this)}equals(e){return e.center.equals(this.center)&&e.radius===this.radius}clone(){return new this.constructor().copy(this)}toJSON(){return{radius:this.radius,center:this.center.toArray()}}fromJSON(e){return this.radius=e.radius,this.center.fromArray(e.center),this}}let em=0;const yn=new Et,Yo=new sn,Cs=new B,fn=new ki,ur=new ki,Ht=new B;class Ct extends Gi{constructor(){super(),this.isBufferGeometry=!0,Object.defineProperty(this,"id",{value:em++}),this.uuid=pi(),this.name="",this.type="BufferGeometry",this.index=null,this.indirect=null,this.indirectOffset=0,this.attributes={},this.morphAttributes={},this.morphTargetsRelative=!1,this.groups=[],this.boundingBox=null,this.boundingSphere=null,this.drawRange={start:0,count:1/0},this.userData={},this._transformed=!1}getIndex(){return this.index}setIndex(e){return Array.isArray(e)?this.index=new(I0(e)?sf:nf)(e,1):this.index=e,this}setIndirect(e,t=0){return this.indirect=e,this.indirectOffset=t,this}getIndirect(){return this.indirect}getAttribute(e){return this.attributes[e]}setAttribute(e,t){return this.attributes[e]=t,this}deleteAttribute(e){return delete this.attributes[e],this}hasAttribute(e){return this.attributes[e]!==void 0}addGroup(e,t,i=0){this.groups.push({start:e,count:t,materialIndex:i})}clearGroups(){this.groups=[]}setDrawRange(e,t){this.drawRange.start=e,this.drawRange.count=t}applyMatrix4(e){const t=this.attributes.position;t!==void 0&&(t.applyMatrix4(e),t.needsUpdate=!0);const i=this.attributes.normal;if(i!==void 0){const r=new qe().getNormalMatrix(e);i.applyNormalMatrix(r),i.needsUpdate=!0}const s=this.attributes.tangent;return s!==void 0&&(s.transformDirection(e),s.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this._transformed=!0,this}applyQuaternion(e){return yn.makeRotationFromQuaternion(e),this.applyMatrix4(yn),this}rotateX(e){return yn.makeRotationX(e),this.applyMatrix4(yn),this}rotateY(e){return yn.makeRotationY(e),this.applyMatrix4(yn),this}rotateZ(e){return yn.makeRotationZ(e),this.applyMatrix4(yn),this}translate(e,t,i){return yn.makeTranslation(e,t,i),this.applyMatrix4(yn),this}scale(e,t,i){return yn.makeScale(e,t,i),this.applyMatrix4(yn),this}lookAt(e){return Yo.lookAt(e),Yo.updateMatrix(),this.applyMatrix4(Yo.matrix),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(Cs).negate(),this.translate(Cs.x,Cs.y,Cs.z),this}setFromPoints(e){const t=this.getAttribute("position");if(t===void 0){const i=[];for(let s=0,r=e.length;st.count&&Ye("BufferGeometry: Buffer size too small for points data. Use .dispose() and create a new geometry."),t.needsUpdate=!0}return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new ki);const e=this.attributes.position,t=this.morphAttributes.position;if(e&&e.isGLBufferAttribute){at("BufferGeometry.computeBoundingBox(): GLBufferAttribute requires a manual bounding box.",this),this.boundingBox.set(new B(-1/0,-1/0,-1/0),new B(1/0,1/0,1/0));return}if(e!==void 0){if(this.boundingBox.setFromBufferAttribute(e),t)for(let i=0,s=t.length;i0&&(e.userData=this.userData),this.parameters!==void 0&&this._transformed!==!0){const l=this.parameters;for(const c in l)l[c]!==void 0&&(e[c]=l[c]);return e}e.data={attributes:{}};const t=this.index;t!==null&&(e.data.index={type:t.array.constructor.name,array:Array.prototype.slice.call(t.array)});const i=this.attributes;for(const l in i){const c=i[l];e.data.attributes[l]=c.toJSON(e.data)}const s={};let r=!1;for(const l in this.morphAttributes){const c=this.morphAttributes[l],u=[];for(let d=0,h=c.length;d0&&(s[l]=u,r=!0)}r&&(e.data.morphAttributes=s,e.data.morphTargetsRelative=this.morphTargetsRelative);const a=this.groups;a.length>0&&(e.data.groups=JSON.parse(JSON.stringify(a)));const o=this.boundingSphere;return o!==null&&(e.data.boundingSphere=o.toJSON()),e}clone(){return new this.constructor().copy(this)}copy(e){this.index=null,this.attributes={},this.morphAttributes={},this.groups=[],this.boundingBox=null,this.boundingSphere=null;const t={};this.name=e.name;const i=e.index;i!==null&&this.setIndex(i.clone());const s=e.attributes;for(const c in s){const u=s[c];this.setAttribute(c,u.clone(t))}const r=e.morphAttributes;for(const c in r){const u=[],d=r[c];for(let h=0,f=d.length;h0!=e>0&&this.version++,this._alphaTest=e}onBeforeRender(){}onBeforeCompile(){}customProgramCacheKey(){return this.onBeforeCompile.toString()}setValues(e){if(e!==void 0)for(const t in e){const i=e[t];if(i===void 0){Ye(`Material: parameter '${t}' has value of undefined.`);continue}const s=this[t];if(s===void 0){Ye(`Material: '${t}' is not a property of THREE.${this.type}.`);continue}s&&s.isColor?s.set(i):s&&s.isVector2&&i&&i.isVector2||s&&s.isEuler&&i&&i.isEuler||s&&s.isVector3&&i&&i.isVector3?s.copy(i):this[t]=i}}toJSON(e){const t=e===void 0||typeof e=="string";t&&(e={textures:{},images:{}});const i={metadata:{version:4.7,type:"Material",generator:"Material.toJSON"}};i.uuid=this.uuid,i.type=this.type,this.name!==""&&(i.name=this.name),this.color&&this.color.isColor&&(i.color=this.color.getHex()),this.roughness!==void 0&&(i.roughness=this.roughness),this.metalness!==void 0&&(i.metalness=this.metalness),this.sheen!==void 0&&(i.sheen=this.sheen),this.sheenColor&&this.sheenColor.isColor&&(i.sheenColor=this.sheenColor.getHex()),this.sheenRoughness!==void 0&&(i.sheenRoughness=this.sheenRoughness),this.emissive&&this.emissive.isColor&&(i.emissive=this.emissive.getHex()),this.emissiveIntensity!==void 0&&this.emissiveIntensity!==1&&(i.emissiveIntensity=this.emissiveIntensity),this.specular&&this.specular.isColor&&(i.specular=this.specular.getHex()),this.specularIntensity!==void 0&&(i.specularIntensity=this.specularIntensity),this.specularColor&&this.specularColor.isColor&&(i.specularColor=this.specularColor.getHex()),this.shininess!==void 0&&(i.shininess=this.shininess),this.clearcoat!==void 0&&(i.clearcoat=this.clearcoat),this.clearcoatRoughness!==void 0&&(i.clearcoatRoughness=this.clearcoatRoughness),this.clearcoatMap&&this.clearcoatMap.isTexture&&(i.clearcoatMap=this.clearcoatMap.toJSON(e).uuid),this.clearcoatRoughnessMap&&this.clearcoatRoughnessMap.isTexture&&(i.clearcoatRoughnessMap=this.clearcoatRoughnessMap.toJSON(e).uuid),this.clearcoatNormalMap&&this.clearcoatNormalMap.isTexture&&(i.clearcoatNormalMap=this.clearcoatNormalMap.toJSON(e).uuid,i.clearcoatNormalScale=this.clearcoatNormalScale.toArray()),this.sheenColorMap&&this.sheenColorMap.isTexture&&(i.sheenColorMap=this.sheenColorMap.toJSON(e).uuid),this.sheenRoughnessMap&&this.sheenRoughnessMap.isTexture&&(i.sheenRoughnessMap=this.sheenRoughnessMap.toJSON(e).uuid),this.dispersion!==void 0&&(i.dispersion=this.dispersion),this.iridescence!==void 0&&(i.iridescence=this.iridescence),this.iridescenceIOR!==void 0&&(i.iridescenceIOR=this.iridescenceIOR),this.iridescenceThicknessRange!==void 0&&(i.iridescenceThicknessRange=this.iridescenceThicknessRange),this.iridescenceMap&&this.iridescenceMap.isTexture&&(i.iridescenceMap=this.iridescenceMap.toJSON(e).uuid),this.iridescenceThicknessMap&&this.iridescenceThicknessMap.isTexture&&(i.iridescenceThicknessMap=this.iridescenceThicknessMap.toJSON(e).uuid),this.anisotropy!==void 0&&(i.anisotropy=this.anisotropy),this.anisotropyRotation!==void 0&&(i.anisotropyRotation=this.anisotropyRotation),this.anisotropyMap&&this.anisotropyMap.isTexture&&(i.anisotropyMap=this.anisotropyMap.toJSON(e).uuid),this.map&&this.map.isTexture&&(i.map=this.map.toJSON(e).uuid),this.matcap&&this.matcap.isTexture&&(i.matcap=this.matcap.toJSON(e).uuid),this.alphaMap&&this.alphaMap.isTexture&&(i.alphaMap=this.alphaMap.toJSON(e).uuid),this.lightMap&&this.lightMap.isTexture&&(i.lightMap=this.lightMap.toJSON(e).uuid,i.lightMapIntensity=this.lightMapIntensity),this.aoMap&&this.aoMap.isTexture&&(i.aoMap=this.aoMap.toJSON(e).uuid,i.aoMapIntensity=this.aoMapIntensity),this.bumpMap&&this.bumpMap.isTexture&&(i.bumpMap=this.bumpMap.toJSON(e).uuid,i.bumpScale=this.bumpScale),this.normalMap&&this.normalMap.isTexture&&(i.normalMap=this.normalMap.toJSON(e).uuid,i.normalMapType=this.normalMapType,i.normalScale=this.normalScale.toArray()),this.displacementMap&&this.displacementMap.isTexture&&(i.displacementMap=this.displacementMap.toJSON(e).uuid,i.displacementScale=this.displacementScale,i.displacementBias=this.displacementBias),this.roughnessMap&&this.roughnessMap.isTexture&&(i.roughnessMap=this.roughnessMap.toJSON(e).uuid),this.metalnessMap&&this.metalnessMap.isTexture&&(i.metalnessMap=this.metalnessMap.toJSON(e).uuid),this.emissiveMap&&this.emissiveMap.isTexture&&(i.emissiveMap=this.emissiveMap.toJSON(e).uuid),this.specularMap&&this.specularMap.isTexture&&(i.specularMap=this.specularMap.toJSON(e).uuid),this.specularIntensityMap&&this.specularIntensityMap.isTexture&&(i.specularIntensityMap=this.specularIntensityMap.toJSON(e).uuid),this.specularColorMap&&this.specularColorMap.isTexture&&(i.specularColorMap=this.specularColorMap.toJSON(e).uuid),this.envMap&&this.envMap.isTexture&&(i.envMap=this.envMap.toJSON(e).uuid,this.combine!==void 0&&(i.combine=this.combine)),this.envMapRotation!==void 0&&(i.envMapRotation=this.envMapRotation.toArray()),this.envMapIntensity!==void 0&&(i.envMapIntensity=this.envMapIntensity),this.reflectivity!==void 0&&(i.reflectivity=this.reflectivity),this.refractionRatio!==void 0&&(i.refractionRatio=this.refractionRatio),this.gradientMap&&this.gradientMap.isTexture&&(i.gradientMap=this.gradientMap.toJSON(e).uuid),this.transmission!==void 0&&(i.transmission=this.transmission),this.transmissionMap&&this.transmissionMap.isTexture&&(i.transmissionMap=this.transmissionMap.toJSON(e).uuid),this.thickness!==void 0&&(i.thickness=this.thickness),this.thicknessMap&&this.thicknessMap.isTexture&&(i.thicknessMap=this.thicknessMap.toJSON(e).uuid),this.attenuationDistance!==void 0&&this.attenuationDistance!==1/0&&(i.attenuationDistance=this.attenuationDistance),this.attenuationColor!==void 0&&(i.attenuationColor=this.attenuationColor.getHex()),this.size!==void 0&&(i.size=this.size),this.shadowSide!==null&&(i.shadowSide=this.shadowSide),this.sizeAttenuation!==void 0&&(i.sizeAttenuation=this.sizeAttenuation),this.blending!==zs&&(i.blending=this.blending),this.side!==Bi&&(i.side=this.side),this.vertexColors===!0&&(i.vertexColors=!0),this.opacity<1&&(i.opacity=this.opacity),this.transparent===!0&&(i.transparent=!0),this.blendSrc!==Tl&&(i.blendSrc=this.blendSrc),this.blendDst!==Cl&&(i.blendDst=this.blendDst),this.blendEquation!==$i&&(i.blendEquation=this.blendEquation),this.blendSrcAlpha!==null&&(i.blendSrcAlpha=this.blendSrcAlpha),this.blendDstAlpha!==null&&(i.blendDstAlpha=this.blendDstAlpha),this.blendEquationAlpha!==null&&(i.blendEquationAlpha=this.blendEquationAlpha),this.blendColor&&this.blendColor.isColor&&(i.blendColor=this.blendColor.getHex()),this.blendAlpha!==0&&(i.blendAlpha=this.blendAlpha),this.depthFunc!==Xs&&(i.depthFunc=this.depthFunc),this.depthTest===!1&&(i.depthTest=this.depthTest),this.depthWrite===!1&&(i.depthWrite=this.depthWrite),this.colorWrite===!1&&(i.colorWrite=this.colorWrite),this.stencilWriteMask!==255&&(i.stencilWriteMask=this.stencilWriteMask),this.stencilFunc!==Su&&(i.stencilFunc=this.stencilFunc),this.stencilRef!==0&&(i.stencilRef=this.stencilRef),this.stencilFuncMask!==255&&(i.stencilFuncMask=this.stencilFuncMask),this.stencilFail!==_s&&(i.stencilFail=this.stencilFail),this.stencilZFail!==_s&&(i.stencilZFail=this.stencilZFail),this.stencilZPass!==_s&&(i.stencilZPass=this.stencilZPass),this.stencilWrite===!0&&(i.stencilWrite=this.stencilWrite),this.rotation!==void 0&&this.rotation!==0&&(i.rotation=this.rotation),this.polygonOffset===!0&&(i.polygonOffset=!0),this.polygonOffsetFactor!==0&&(i.polygonOffsetFactor=this.polygonOffsetFactor),this.polygonOffsetUnits!==0&&(i.polygonOffsetUnits=this.polygonOffsetUnits),this.linewidth!==void 0&&this.linewidth!==1&&(i.linewidth=this.linewidth),this.dashSize!==void 0&&(i.dashSize=this.dashSize),this.gapSize!==void 0&&(i.gapSize=this.gapSize),this.scale!==void 0&&(i.scale=this.scale),this.dithering===!0&&(i.dithering=!0),this.alphaTest>0&&(i.alphaTest=this.alphaTest),this.alphaHash===!0&&(i.alphaHash=!0),this.alphaToCoverage===!0&&(i.alphaToCoverage=!0),this.premultipliedAlpha===!0&&(i.premultipliedAlpha=!0),this.forceSinglePass===!0&&(i.forceSinglePass=!0),this.allowOverride===!1&&(i.allowOverride=!1),this.wireframe===!0&&(i.wireframe=!0),this.wireframeLinewidth>1&&(i.wireframeLinewidth=this.wireframeLinewidth),this.wireframeLinecap!=="round"&&(i.wireframeLinecap=this.wireframeLinecap),this.wireframeLinejoin!=="round"&&(i.wireframeLinejoin=this.wireframeLinejoin),this.flatShading===!0&&(i.flatShading=!0),this.visible===!1&&(i.visible=!1),this.toneMapped===!1&&(i.toneMapped=!1),this.fog===!1&&(i.fog=!1),Object.keys(this.userData).length>0&&(i.userData=this.userData);function s(r){const a=[];for(const o in r){const l=r[o];delete l.metadata,a.push(l)}return a}if(t){const r=s(e.textures),a=s(e.images);r.length>0&&(i.textures=r),a.length>0&&(i.images=a)}return i}fromJSON(e,t){if(e.uuid!==void 0&&(this.uuid=e.uuid),e.name!==void 0&&(this.name=e.name),e.color!==void 0&&this.color!==void 0&&this.color.setHex(e.color),e.roughness!==void 0&&(this.roughness=e.roughness),e.metalness!==void 0&&(this.metalness=e.metalness),e.sheen!==void 0&&(this.sheen=e.sheen),e.sheenColor!==void 0&&(this.sheenColor=new Qe().setHex(e.sheenColor)),e.sheenRoughness!==void 0&&(this.sheenRoughness=e.sheenRoughness),e.emissive!==void 0&&this.emissive!==void 0&&this.emissive.setHex(e.emissive),e.specular!==void 0&&this.specular!==void 0&&this.specular.setHex(e.specular),e.specularIntensity!==void 0&&(this.specularIntensity=e.specularIntensity),e.specularColor!==void 0&&this.specularColor!==void 0&&this.specularColor.setHex(e.specularColor),e.shininess!==void 0&&(this.shininess=e.shininess),e.clearcoat!==void 0&&(this.clearcoat=e.clearcoat),e.clearcoatRoughness!==void 0&&(this.clearcoatRoughness=e.clearcoatRoughness),e.dispersion!==void 0&&(this.dispersion=e.dispersion),e.iridescence!==void 0&&(this.iridescence=e.iridescence),e.iridescenceIOR!==void 0&&(this.iridescenceIOR=e.iridescenceIOR),e.iridescenceThicknessRange!==void 0&&(this.iridescenceThicknessRange=e.iridescenceThicknessRange),e.transmission!==void 0&&(this.transmission=e.transmission),e.thickness!==void 0&&(this.thickness=e.thickness),e.attenuationDistance!==void 0&&(this.attenuationDistance=e.attenuationDistance),e.attenuationColor!==void 0&&this.attenuationColor!==void 0&&this.attenuationColor.setHex(e.attenuationColor),e.anisotropy!==void 0&&(this.anisotropy=e.anisotropy),e.anisotropyRotation!==void 0&&(this.anisotropyRotation=e.anisotropyRotation),e.fog!==void 0&&(this.fog=e.fog),e.flatShading!==void 0&&(this.flatShading=e.flatShading),e.blending!==void 0&&(this.blending=e.blending),e.combine!==void 0&&(this.combine=e.combine),e.side!==void 0&&(this.side=e.side),e.shadowSide!==void 0&&(this.shadowSide=e.shadowSide),e.opacity!==void 0&&(this.opacity=e.opacity),e.transparent!==void 0&&(this.transparent=e.transparent),e.alphaTest!==void 0&&(this.alphaTest=e.alphaTest),e.alphaHash!==void 0&&(this.alphaHash=e.alphaHash),e.depthFunc!==void 0&&(this.depthFunc=e.depthFunc),e.depthTest!==void 0&&(this.depthTest=e.depthTest),e.depthWrite!==void 0&&(this.depthWrite=e.depthWrite),e.colorWrite!==void 0&&(this.colorWrite=e.colorWrite),e.blendSrc!==void 0&&(this.blendSrc=e.blendSrc),e.blendDst!==void 0&&(this.blendDst=e.blendDst),e.blendEquation!==void 0&&(this.blendEquation=e.blendEquation),e.blendSrcAlpha!==void 0&&(this.blendSrcAlpha=e.blendSrcAlpha),e.blendDstAlpha!==void 0&&(this.blendDstAlpha=e.blendDstAlpha),e.blendEquationAlpha!==void 0&&(this.blendEquationAlpha=e.blendEquationAlpha),e.blendColor!==void 0&&this.blendColor!==void 0&&this.blendColor.setHex(e.blendColor),e.blendAlpha!==void 0&&(this.blendAlpha=e.blendAlpha),e.stencilWriteMask!==void 0&&(this.stencilWriteMask=e.stencilWriteMask),e.stencilFunc!==void 0&&(this.stencilFunc=e.stencilFunc),e.stencilRef!==void 0&&(this.stencilRef=e.stencilRef),e.stencilFuncMask!==void 0&&(this.stencilFuncMask=e.stencilFuncMask),e.stencilFail!==void 0&&(this.stencilFail=e.stencilFail),e.stencilZFail!==void 0&&(this.stencilZFail=e.stencilZFail),e.stencilZPass!==void 0&&(this.stencilZPass=e.stencilZPass),e.stencilWrite!==void 0&&(this.stencilWrite=e.stencilWrite),e.wireframe!==void 0&&(this.wireframe=e.wireframe),e.wireframeLinewidth!==void 0&&(this.wireframeLinewidth=e.wireframeLinewidth),e.wireframeLinecap!==void 0&&(this.wireframeLinecap=e.wireframeLinecap),e.wireframeLinejoin!==void 0&&(this.wireframeLinejoin=e.wireframeLinejoin),e.rotation!==void 0&&(this.rotation=e.rotation),e.linewidth!==void 0&&(this.linewidth=e.linewidth),e.dashSize!==void 0&&(this.dashSize=e.dashSize),e.gapSize!==void 0&&(this.gapSize=e.gapSize),e.scale!==void 0&&(this.scale=e.scale),e.polygonOffset!==void 0&&(this.polygonOffset=e.polygonOffset),e.polygonOffsetFactor!==void 0&&(this.polygonOffsetFactor=e.polygonOffsetFactor),e.polygonOffsetUnits!==void 0&&(this.polygonOffsetUnits=e.polygonOffsetUnits),e.dithering!==void 0&&(this.dithering=e.dithering),e.alphaToCoverage!==void 0&&(this.alphaToCoverage=e.alphaToCoverage),e.premultipliedAlpha!==void 0&&(this.premultipliedAlpha=e.premultipliedAlpha),e.forceSinglePass!==void 0&&(this.forceSinglePass=e.forceSinglePass),e.allowOverride!==void 0&&(this.allowOverride=e.allowOverride),e.visible!==void 0&&(this.visible=e.visible),e.toneMapped!==void 0&&(this.toneMapped=e.toneMapped),e.userData!==void 0&&(this.userData=e.userData),e.vertexColors!==void 0&&(typeof e.vertexColors=="number"?this.vertexColors=e.vertexColors>0:this.vertexColors=e.vertexColors),e.size!==void 0&&(this.size=e.size),e.sizeAttenuation!==void 0&&(this.sizeAttenuation=e.sizeAttenuation),e.map!==void 0&&(this.map=t[e.map]||null),e.matcap!==void 0&&(this.matcap=t[e.matcap]||null),e.alphaMap!==void 0&&(this.alphaMap=t[e.alphaMap]||null),e.bumpMap!==void 0&&(this.bumpMap=t[e.bumpMap]||null),e.bumpScale!==void 0&&(this.bumpScale=e.bumpScale),e.normalMap!==void 0&&(this.normalMap=t[e.normalMap]||null),e.normalMapType!==void 0&&(this.normalMapType=e.normalMapType),e.normalScale!==void 0){let i=e.normalScale;Array.isArray(i)===!1&&(i=[i,i]),this.normalScale=new Ee().fromArray(i)}return e.displacementMap!==void 0&&(this.displacementMap=t[e.displacementMap]||null),e.displacementScale!==void 0&&(this.displacementScale=e.displacementScale),e.displacementBias!==void 0&&(this.displacementBias=e.displacementBias),e.roughnessMap!==void 0&&(this.roughnessMap=t[e.roughnessMap]||null),e.metalnessMap!==void 0&&(this.metalnessMap=t[e.metalnessMap]||null),e.emissiveMap!==void 0&&(this.emissiveMap=t[e.emissiveMap]||null),e.emissiveIntensity!==void 0&&(this.emissiveIntensity=e.emissiveIntensity),e.specularMap!==void 0&&(this.specularMap=t[e.specularMap]||null),e.specularIntensityMap!==void 0&&(this.specularIntensityMap=t[e.specularIntensityMap]||null),e.specularColorMap!==void 0&&(this.specularColorMap=t[e.specularColorMap]||null),e.envMap!==void 0&&(this.envMap=t[e.envMap]||null),e.envMapRotation!==void 0&&this.envMapRotation.fromArray(e.envMapRotation),e.envMapIntensity!==void 0&&(this.envMapIntensity=e.envMapIntensity),e.reflectivity!==void 0&&(this.reflectivity=e.reflectivity),e.refractionRatio!==void 0&&(this.refractionRatio=e.refractionRatio),e.lightMap!==void 0&&(this.lightMap=t[e.lightMap]||null),e.lightMapIntensity!==void 0&&(this.lightMapIntensity=e.lightMapIntensity),e.aoMap!==void 0&&(this.aoMap=t[e.aoMap]||null),e.aoMapIntensity!==void 0&&(this.aoMapIntensity=e.aoMapIntensity),e.gradientMap!==void 0&&(this.gradientMap=t[e.gradientMap]||null),e.clearcoatMap!==void 0&&(this.clearcoatMap=t[e.clearcoatMap]||null),e.clearcoatRoughnessMap!==void 0&&(this.clearcoatRoughnessMap=t[e.clearcoatRoughnessMap]||null),e.clearcoatNormalMap!==void 0&&(this.clearcoatNormalMap=t[e.clearcoatNormalMap]||null),e.clearcoatNormalScale!==void 0&&(this.clearcoatNormalScale=new Ee().fromArray(e.clearcoatNormalScale)),e.iridescenceMap!==void 0&&(this.iridescenceMap=t[e.iridescenceMap]||null),e.iridescenceThicknessMap!==void 0&&(this.iridescenceThicknessMap=t[e.iridescenceThicknessMap]||null),e.transmissionMap!==void 0&&(this.transmissionMap=t[e.transmissionMap]||null),e.thicknessMap!==void 0&&(this.thicknessMap=t[e.thicknessMap]||null),e.anisotropyMap!==void 0&&(this.anisotropyMap=t[e.anisotropyMap]||null),e.sheenColorMap!==void 0&&(this.sheenColorMap=t[e.sheenColorMap]||null),e.sheenRoughnessMap!==void 0&&(this.sheenRoughnessMap=t[e.sheenRoughnessMap]||null),this}clone(){return new this.constructor().copy(this)}copy(e){this.name=e.name,this.blending=e.blending,this.side=e.side,this.vertexColors=e.vertexColors,this.opacity=e.opacity,this.transparent=e.transparent,this.blendSrc=e.blendSrc,this.blendDst=e.blendDst,this.blendEquation=e.blendEquation,this.blendSrcAlpha=e.blendSrcAlpha,this.blendDstAlpha=e.blendDstAlpha,this.blendEquationAlpha=e.blendEquationAlpha,this.blendColor.copy(e.blendColor),this.blendAlpha=e.blendAlpha,this.depthFunc=e.depthFunc,this.depthTest=e.depthTest,this.depthWrite=e.depthWrite,this.stencilWriteMask=e.stencilWriteMask,this.stencilFunc=e.stencilFunc,this.stencilRef=e.stencilRef,this.stencilFuncMask=e.stencilFuncMask,this.stencilFail=e.stencilFail,this.stencilZFail=e.stencilZFail,this.stencilZPass=e.stencilZPass,this.stencilWrite=e.stencilWrite;const t=e.clippingPlanes;let i=null;if(t!==null){const s=t.length;i=new Array(s);for(let r=0;r!==s;++r)i[r]=t[r].clone()}return this.clippingPlanes=i,this.clipIntersection=e.clipIntersection,this.clipShadows=e.clipShadows,this.shadowSide=e.shadowSide,this.colorWrite=e.colorWrite,this.precision=e.precision,this.polygonOffset=e.polygonOffset,this.polygonOffsetFactor=e.polygonOffsetFactor,this.polygonOffsetUnits=e.polygonOffsetUnits,this.dithering=e.dithering,this.alphaTest=e.alphaTest,this.alphaHash=e.alphaHash,this.alphaToCoverage=e.alphaToCoverage,this.premultipliedAlpha=e.premultipliedAlpha,this.forceSinglePass=e.forceSinglePass,this.allowOverride=e.allowOverride,this.visible=e.visible,this.toneMapped=e.toneMapped,this.userData=JSON.parse(JSON.stringify(e.userData)),this}dispose(){this.dispatchEvent({type:"dispose"})}set needsUpdate(e){e===!0&&this.version++}}class gc extends nr{constructor(e){super(),this.isSpriteMaterial=!0,this.type="SpriteMaterial",this.color=new Qe(16777215),this.map=null,this.alphaMap=null,this.rotation=0,this.sizeAttenuation=!0,this.transparent=!0,this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.alphaMap=e.alphaMap,this.rotation=e.rotation,this.sizeAttenuation=e.sizeAttenuation,this.fog=e.fog,this}}let ws;const hr=new B,Rs=new B,Ds=new B,Ls=new Ee,dr=new Ee,rf=new Et,ta=new B,fr=new B,na=new B,Uu=new Ee,Ko=new Ee,Ou=new Ee;class Nu extends sn{constructor(e=new gc){if(super(),this.isSprite=!0,this.type="Sprite",ws===void 0){ws=new Ct;const t=new Float32Array([-.5,-.5,0,0,0,.5,-.5,0,1,0,.5,.5,0,1,1,-.5,.5,0,0,1]),i=new tm(t,5);ws.setIndex([0,1,2,0,2,3]),ws.setAttribute("position",new eo(i,3,0,!1)),ws.setAttribute("uv",new eo(i,2,3,!1))}this.geometry=ws,this.material=e,this.center=new Ee(.5,.5),this.count=1}raycast(e,t){e.camera===null&&at('Sprite: "Raycaster.camera" needs to be set in order to raycast against sprites.'),Rs.setFromMatrixScale(this.matrixWorld),rf.copy(e.camera.matrixWorld),this.modelViewMatrix.multiplyMatrices(e.camera.matrixWorldInverse,this.matrixWorld),Ds.setFromMatrixPosition(this.modelViewMatrix),e.camera.isPerspectiveCamera&&this.material.sizeAttenuation===!1&&Rs.multiplyScalar(-Ds.z);const i=this.material.rotation;let s,r;i!==0&&(r=Math.cos(i),s=Math.sin(i));const a=this.center;ia(ta.set(-.5,-.5,0),Ds,a,Rs,s,r),ia(fr.set(.5,-.5,0),Ds,a,Rs,s,r),ia(na.set(.5,.5,0),Ds,a,Rs,s,r),Uu.set(0,0),Ko.set(1,0),Ou.set(1,1);let o=e.ray.intersectTriangle(ta,fr,na,!1,hr);if(o===null&&(ia(fr.set(-.5,.5,0),Ds,a,Rs,s,r),Ko.set(0,1),o=e.ray.intersectTriangle(ta,na,fr,!1,hr),o===null))return;const l=e.ray.origin.distanceTo(hr);le.far||t.push({distance:l,point:hr.clone(),uv:Sn.getInterpolation(hr,ta,fr,na,Uu,Ko,Ou,new Ee),face:null,object:this})}copy(e,t){return super.copy(e,t),e.center!==void 0&&this.center.copy(e.center),this.material=e.material,this}}function ia(n,e,t,i,s,r){Ls.subVectors(n,t).addScalar(.5).multiply(i),s!==void 0?(dr.x=r*Ls.x-s*Ls.y,dr.y=s*Ls.x+r*Ls.y):dr.copy(Ls),n.copy(e),n.x+=dr.x,n.y+=dr.y,n.applyMatrix4(rf)}const li=new B,qo=new B,sa=new B,Ci=new B,Zo=new B,ra=new B,$o=new B;class Vc{constructor(e=new B,t=new B(0,0,-1)){this.origin=e,this.direction=t}set(e,t){return this.origin.copy(e),this.direction.copy(t),this}copy(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this}at(e,t){return t.copy(this.origin).addScaledVector(this.direction,e)}lookAt(e){return this.direction.copy(e).sub(this.origin).normalize(),this}recast(e){return this.origin.copy(this.at(e,li)),this}closestPointToPoint(e,t){t.subVectors(e,this.origin);const i=t.dot(this.direction);return i<0?t.copy(this.origin):t.copy(this.origin).addScaledVector(this.direction,i)}distanceToPoint(e){return Math.sqrt(this.distanceSqToPoint(e))}distanceSqToPoint(e){const t=li.subVectors(e,this.origin).dot(this.direction);return t<0?this.origin.distanceToSquared(e):(li.copy(this.origin).addScaledVector(this.direction,t),li.distanceToSquared(e))}distanceSqToSegment(e,t,i,s){qo.copy(e).add(t).multiplyScalar(.5),sa.copy(t).sub(e).normalize(),Ci.copy(this.origin).sub(qo);const r=e.distanceTo(t)*.5,a=-this.direction.dot(sa),o=Ci.dot(this.direction),l=-Ci.dot(sa),c=Ci.lengthSq(),u=Math.abs(1-a*a);let d,h,f,p;if(u>0)if(d=a*l-o,h=a*o-l,p=r*u,d>=0)if(h>=-p)if(h<=p){const g=1/u;d*=g,h*=g,f=d*(d+a*h+2*o)+h*(a*d+h+2*l)+c}else h=r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h=-r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;else h<=-p?(d=Math.max(0,-(-a*r+o)),h=d>0?-r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c):h<=p?(d=0,h=Math.min(Math.max(-r,-l),r),f=h*(h+2*l)+c):(d=Math.max(0,-(a*r+o)),h=d>0?r:Math.min(Math.max(-r,-l),r),f=-d*d+h*(h+2*l)+c);else h=a>0?-r:r,d=Math.max(0,-(a*h+o)),f=-d*d+h*(h+2*l)+c;return i&&i.copy(this.origin).addScaledVector(this.direction,d),s&&s.copy(qo).addScaledVector(sa,h),f}intersectSphere(e,t){li.subVectors(e.center,this.origin);const i=li.dot(this.direction),s=li.dot(li)-i*i,r=e.radius*e.radius;if(s>r)return null;const a=Math.sqrt(r-s),o=i-a,l=i+a;return l<0?null:o<0?this.at(l,t):this.at(o,t)}intersectsSphere(e){return e.radius<0?!1:this.distanceSqToPoint(e.center)<=e.radius*e.radius}distanceToPlane(e){const t=e.normal.dot(this.direction);if(t===0)return e.distanceToPoint(this.origin)===0?0:null;const i=-(this.origin.dot(e.normal)+e.constant)/t;return i>=0?i:null}intersectPlane(e,t){const i=this.distanceToPlane(e);return i===null?null:this.at(i,t)}intersectsPlane(e){const t=e.distanceToPoint(this.origin);return t===0||e.normal.dot(this.direction)*t<0}intersectBox(e,t){let i,s,r,a,o,l;const c=1/this.direction.x,u=1/this.direction.y,d=1/this.direction.z,h=this.origin;return c>=0?(i=(e.min.x-h.x)*c,s=(e.max.x-h.x)*c):(i=(e.max.x-h.x)*c,s=(e.min.x-h.x)*c),u>=0?(r=(e.min.y-h.y)*u,a=(e.max.y-h.y)*u):(r=(e.max.y-h.y)*u,a=(e.min.y-h.y)*u),i>a||r>s||((r>i||isNaN(i))&&(i=r),(a=0?(o=(e.min.z-h.z)*d,l=(e.max.z-h.z)*d):(o=(e.max.z-h.z)*d,l=(e.min.z-h.z)*d),i>l||o>s)||((o>i||i!==i)&&(i=o),(l=0?i:s,t)}intersectsBox(e){return this.intersectBox(e,li)!==null}intersectTriangle(e,t,i,s,r){Zo.subVectors(t,e),ra.subVectors(i,e),$o.crossVectors(Zo,ra);let a=this.direction.dot($o),o;if(a>0){if(s)return null;o=1}else if(a<0)o=-1,a=-a;else return null;Ci.subVectors(this.origin,e);const l=o*this.direction.dot(ra.crossVectors(Ci,ra));if(l<0)return null;const c=o*this.direction.dot(Zo.cross(Ci));if(c<0||l+c>a)return null;const u=-o*Ci.dot($o);return u<0?null:this.at(u/a,r)}applyMatrix4(e){return this.origin.applyMatrix4(e),this.direction.transformDirection(e),this}equals(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}clone(){return new this.constructor().copy(this)}}class Wn extends nr{constructor(e){super(),this.isMeshBasicMaterial=!0,this.type="MeshBasicMaterial",this.color=new Qe(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 ss,this.combine=Nd,this.reflectivity=1,this.refractionRatio=.98,this.wireframe=!1,this.wireframeLinewidth=1,this.wireframeLinecap="round",this.wireframeLinejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.lightMap=e.lightMap,this.lightMapIntensity=e.lightMapIntensity,this.aoMap=e.aoMap,this.aoMapIntensity=e.aoMapIntensity,this.specularMap=e.specularMap,this.alphaMap=e.alphaMap,this.envMap=e.envMap,this.envMapRotation.copy(e.envMapRotation),this.combine=e.combine,this.reflectivity=e.reflectivity,this.refractionRatio=e.refractionRatio,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.fog=e.fog,this}}const ku=new Et,Yi=new Vc,aa=new yo,Fu=new B,oa=new B,la=new B,ca=new B,Jo=new B,ua=new B,Bu=new B,ha=new B;class Vt extends sn{constructor(e=new Ct,t=new Wn){super(),this.isMesh=!0,this.type="Mesh",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.count=1,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),e.morphTargetInfluences!==void 0&&(this.morphTargetInfluences=e.morphTargetInfluences.slice()),e.morphTargetDictionary!==void 0&&(this.morphTargetDictionary=Object.assign({},e.morphTargetDictionary)),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}updateMorphTargets(){const t=this.geometry.morphAttributes,i=Object.keys(t);if(i.length>0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;r(e.far-e.near)**2))&&(ku.copy(r).invert(),Yi.copy(e.ray).applyMatrix4(ku),!(i.boundingBox!==null&&Yi.intersectsBox(i.boundingBox)===!1)&&this._computeIntersections(e,t,Yi)))}_computeIntersections(e,t,i){let s;const r=this.geometry,a=this.material,o=r.index,l=r.attributes.position,c=r.attributes.uv,u=r.attributes.uv1,d=r.attributes.normal,h=r.groups,f=r.drawRange;if(o!==null)if(Array.isArray(a))for(let p=0,g=h.length;pt.far?null:{distance:c,point:ha.clone(),object:n}}function da(n,e,t,i,s,r,a,o,l,c){n.getVertexPosition(o,oa),n.getVertexPosition(l,la),n.getVertexPosition(c,ca);const u=im(n,e,t,i,oa,la,ca,Bu);if(u){const d=new B;Sn.getBarycoord(Bu,oa,la,ca,d),s&&(u.uv=Sn.getInterpolatedAttribute(s,o,l,c,d,new Ee)),r&&(u.uv1=Sn.getInterpolatedAttribute(r,o,l,c,d,new Ee)),a&&(u.normal=Sn.getInterpolatedAttribute(a,o,l,c,d,new B),u.normal.dot(i.direction)>0&&u.normal.multiplyScalar(-1));const h={a:o,b:l,c,normal:new B,materialIndex:0};Sn.getNormal(oa,la,ca,h.normal),u.face=h,u.barycoord=d}return u}class af extends Jt{constructor(e=null,t=1,i=1,s,r,a,o,l,c=Nt,u=Nt,d,h){super(null,a,o,l,c,u,s,r,d,h),this.isDataTexture=!0,this.image={data:e,width:t,height:i},this.generateMipmaps=!1,this.flipY=!1,this.unpackAlignment=1}}const jo=new B,sm=new B,rm=new qe;class Li{constructor(e=new B(1,0,0),t=0){this.isPlane=!0,this.normal=e,this.constant=t}set(e,t){return this.normal.copy(e),this.constant=t,this}setComponents(e,t,i,s){return this.normal.set(e,t,i),this.constant=s,this}setFromNormalAndCoplanarPoint(e,t){return this.normal.copy(e),this.constant=-t.dot(this.normal),this}setFromCoplanarPoints(e,t,i){const s=jo.subVectors(i,t).cross(sm.subVectors(e,t)).normalize();return this.setFromNormalAndCoplanarPoint(s,e),this}copy(e){return this.normal.copy(e.normal),this.constant=e.constant,this}normalize(){const e=1/this.normal.length();return this.normal.multiplyScalar(e),this.constant*=e,this}negate(){return this.constant*=-1,this.normal.negate(),this}distanceToPoint(e){return this.normal.dot(e)+this.constant}distanceToSphere(e){return this.distanceToPoint(e.center)-e.radius}projectPoint(e,t){return t.copy(e).addScaledVector(this.normal,-this.distanceToPoint(e))}intersectLine(e,t,i=!0){const s=e.delta(jo),r=this.normal.dot(s);if(r===0)return this.distanceToPoint(e.start)===0?t.copy(e.start):null;const a=-(e.start.dot(this.normal)+this.constant)/r;return i===!0&&(a<0||a>1)?null:t.copy(e.start).addScaledVector(s,a)}intersectsLine(e){const t=this.distanceToPoint(e.start),i=this.distanceToPoint(e.end);return t<0&&i>0||i<0&&t>0}intersectsBox(e){return e.intersectsPlane(this)}intersectsSphere(e){return e.intersectsPlane(this)}coplanarPoint(e){return e.copy(this.normal).multiplyScalar(-this.constant)}applyMatrix4(e,t){const i=t||rm.getNormalMatrix(e),s=this.coplanarPoint(jo).applyMatrix4(e),r=this.normal.applyMatrix3(i).normalize();return this.constant=-s.dot(r),this}translate(e){return this.constant-=e.dot(this.normal),this}equals(e){return e.normal.equals(this.normal)&&e.constant===this.constant}clone(){return new this.constructor().copy(this)}}const Ki=new yo,am=new Ee(.5,.5),fa=new B;class of{constructor(e=new Li,t=new Li,i=new Li,s=new Li,r=new Li,a=new Li){this.planes=[e,t,i,s,r,a]}set(e,t,i,s,r,a){const o=this.planes;return o[0].copy(e),o[1].copy(t),o[2].copy(i),o[3].copy(s),o[4].copy(r),o[5].copy(a),this}copy(e){const t=this.planes;for(let i=0;i<6;i++)t[i].copy(e.planes[i]);return this}setFromProjectionMatrix(e,t=Zn,i=!1){const s=this.planes,r=e.elements,a=r[0],o=r[1],l=r[2],c=r[3],u=r[4],d=r[5],h=r[6],f=r[7],p=r[8],g=r[9],m=r[10],_=r[11],b=r[12],A=r[13],y=r[14],M=r[15];if(s[0].setComponents(c-a,f-u,_-p,M-b).normalize(),s[1].setComponents(c+a,f+u,_+p,M+b).normalize(),s[2].setComponents(c+o,f+d,_+g,M+A).normalize(),s[3].setComponents(c-o,f-d,_-g,M-A).normalize(),i)s[4].setComponents(l,h,m,y).normalize(),s[5].setComponents(c-l,f-h,_-m,M-y).normalize();else if(s[4].setComponents(c-l,f-h,_-m,M-y).normalize(),t===Zn)s[5].setComponents(c+l,f+h,_+m,M+y).normalize();else if(t===Ja)s[5].setComponents(l,h,m,y).normalize();else throw new Error("THREE.Frustum.setFromProjectionMatrix(): Invalid coordinate system: "+t);return this}intersectsObject(e){if(e.boundingSphere!==void 0)e.boundingSphere===null&&e.computeBoundingSphere(),Ki.copy(e.boundingSphere).applyMatrix4(e.matrixWorld);else{const t=e.geometry;t.boundingSphere===null&&t.computeBoundingSphere(),Ki.copy(t.boundingSphere).applyMatrix4(e.matrixWorld)}return this.intersectsSphere(Ki)}intersectsSprite(e){Ki.center.set(0,0,0);const t=am.distanceTo(e.center);return Ki.radius=.7071067811865476+t,Ki.applyMatrix4(e.matrixWorld),this.intersectsSphere(Ki)}intersectsSphere(e){const t=this.planes,i=e.center,s=-e.radius;for(let r=0;r<6;r++)if(t[r].distanceToPoint(i)0?e.max.x:e.min.x,fa.y=s.normal.y>0?e.max.y:e.min.y,fa.z=s.normal.z>0?e.max.z:e.min.z,s.distanceToPoint(fa)<0)return!1}return!0}containsPoint(e){const t=this.planes;for(let i=0;i<6;i++)if(t[i].distanceToPoint(e)<0)return!1;return!0}clone(){return new this.constructor().copy(this)}}class Bs extends nr{constructor(e){super(),this.isLineBasicMaterial=!0,this.type="LineBasicMaterial",this.color=new Qe(16777215),this.map=null,this.linewidth=1,this.linecap="round",this.linejoin="round",this.fog=!0,this.setValues(e)}copy(e){return super.copy(e),this.color.copy(e.color),this.map=e.map,this.linewidth=e.linewidth,this.linecap=e.linecap,this.linejoin=e.linejoin,this.fog=e.fog,this}}const to=new B,no=new B,Hu=new Et,pr=new Vc,pa=new yo,Qo=new B,zu=new B;let lf=class extends sn{constructor(e=new Ct,t=new Bs){super(),this.isLine=!0,this.type="Line",this.geometry=e,this.material=t,this.morphTargetDictionary=void 0,this.morphTargetInfluences=void 0,this.updateMorphTargets()}copy(e,t){return super.copy(e,t),this.material=Array.isArray(e.material)?e.material.slice():e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[0];for(let s=1,r=t.count;s0){const s=t[i[0]];if(s!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let r=0,a=s.length;ri)return;Qo.applyMatrix4(n.matrixWorld);const c=e.ray.origin.distanceTo(Qo);if(!(ce.far))return{distance:c,point:zu.clone().applyMatrix4(n.matrixWorld),index:a,face:null,faceIndex:null,barycoord:null,object:n}}const Vu=new B,Gu=new B;class ga extends lf{constructor(e,t){super(e,t),this.isLineSegments=!0,this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.index===null){const t=e.attributes.position,i=[];for(let s=0,r=t.count;s0?1:-1,u.push(D.x,D.y,D.z),d.push(oe/E),d.push(1-re/v),N+=1}}for(let re=0;re0)l=s-1;else{l=s;break}if(s=l,i[s]===a)return s/(r-1);const u=i[s],h=i[s+1]-u,f=(a-u)/h;return(s+f)/(r-1)}getTangent(e,t){let s=e-1e-4,r=e+1e-4;s<0&&(s=0),r>1&&(r=1);const a=this.getPoint(s),o=this.getPoint(r),l=t||(a.isVector2?new Ee:new B);return l.copy(o).sub(a).normalize(),l}getTangentAt(e,t){const i=this.getUtoTmapping(e);return this.getTangent(i,t)}computeFrenetFrames(e,t=!1){const i=new B,s=[],r=[],a=[],o=new B,l=new Et;for(let f=0;f<=e;f++){const p=f/e;s[f]=this.getTangentAt(p,new B)}r[0]=new B,a[0]=new B;let c=Number.MAX_VALUE;const u=Math.abs(s[0].x),d=Math.abs(s[0].y),h=Math.abs(s[0].z);u<=c&&(c=u,i.set(1,0,0)),d<=c&&(c=d,i.set(0,1,0)),h<=c&&i.set(0,0,1),o.crossVectors(s[0],i).normalize(),r[0].crossVectors(s[0],o),a[0].crossVectors(s[0],r[0]);for(let f=1;f<=e;f++){if(r[f]=r[f-1].clone(),a[f]=a[f-1].clone(),o.crossVectors(s[f-1],s[f]),o.length()>Number.EPSILON){o.normalize();const p=Math.acos(je(s[f-1].dot(s[f]),-1,1));r[f].applyMatrix4(l.makeRotationAxis(o,p))}a[f].crossVectors(s[f],r[f])}if(t===!0){let f=Math.acos(je(r[0].dot(r[e]),-1,1));f/=e,s[0].dot(o.crossVectors(r[0],r[e]))>0&&(f=-f);for(let p=1;p<=e;p++)r[p].applyMatrix4(l.makeRotationAxis(s[p],f*p)),a[p].crossVectors(s[p],r[p])}return{tangents:s,normals:r,binormals:a}}clone(){return new this.constructor().copy(this)}copy(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}toJSON(){const e={metadata:{version:4.7,type:"Curve",generator:"Curve.toJSON"}};return e.arcLengthDivisions=this.arcLengthDivisions,e.type=this.type,e}fromJSON(e){return this.arcLengthDivisions=e.arcLengthDivisions,this}}class Gc extends ti{constructor(e=0,t=0,i=1,s=1,r=0,a=Math.PI*2,o=!1,l=0){super(),this.isEllipseCurve=!0,this.type="EllipseCurve",this.aX=e,this.aY=t,this.xRadius=i,this.yRadius=s,this.aStartAngle=r,this.aEndAngle=a,this.aClockwise=o,this.aRotation=l}getPoint(e,t=new Ee){const i=t,s=Math.PI*2;let r=this.aEndAngle-this.aStartAngle;const a=Math.abs(r)s;)r-=s;r0?0:(Math.floor(Math.abs(o)/r)+1)*r:l===0&&o===r-1&&(o=r-2,l=1);let c,u;this.closed||o>0?c=s[(o-1)%r]:(Xu.subVectors(s[0],s[1]).add(s[0]),c=Xu);const d=s[o%r],h=s[(o+1)%r];if(this.closed||o+2s.length-2?s.length-1:a+1],d=s[a>s.length-3?s.length-1:a+2];return i.set(Yu(o,l.x,c.x,u.x,d.x),Yu(o,l.y,c.y,u.y,d.y)),i}copy(e){super.copy(e),this.points=[];for(let t=0,i=e.points.length;t=i){const a=s[r]-i,o=this.curves[r],l=o.getLength(),c=l===0?0:1-a/l;return o.getPointAt(c,t)}r++}return null}getLength(){const e=this.getCurveLengths();return e[e.length-1]}updateArcLengths(){this.needsUpdate=!0,this.cacheLengths=null,this.getCurveLengths()}getCurveLengths(){if(this.cacheLengths&&this.cacheLengths.length===this.curves.length)return this.cacheLengths;const e=[];let t=0;for(let i=0,s=this.curves.length;i1&&!t[t.length-1].equals(t[0])&&t.push(t[0]),t}copy(e){super.copy(e),this.curves=[];for(let t=0,i=e.curves.length;t0){const d=c.getPoint(0);d.equals(this.currentPoint)||this.lineTo(d.x,d.y)}this.curves.push(c);const u=c.getPoint(1);return this.currentPoint.copy(u),this}copy(e){return super.copy(e),this.currentPoint.copy(e.currentPoint),this}toJSON(){const e=super.toJSON();return e.currentPoint=this.currentPoint.toArray(),e}fromJSON(e){return super.fromJSON(e),this.currentPoint.fromArray(e.currentPoint),this}};class mf extends qu{constructor(e){super(e),this.uuid=pi(),this.type="Shape",this.holes=[]}getPointsHoles(e){const t=[];for(let i=0,s=this.holes.length;i80*t){o=n[0],l=n[1];let u=o,d=l;for(let h=t;hu&&(u=f),p>d&&(d=p)}c=Math.max(u-o,d-l),c=c!==0?32767/c:0}return Dr(r,a,t,o,l,c,0),a}function gf(n,e,t,i,s){let r;if(s===km(n,e,t,i)>0)for(let a=e;a=e;a-=i)r=Zu(a/i|0,n[a],n[a+1],r);return r&&qs(r,r.next)&&(Ir(r),r=r.next),r}function rs(n,e){if(!n)return n;e||(e=n);let t=n,i;do if(i=!1,!t.steiner&&(qs(t,t.next)||At(t.prev,t,t.next)===0)){if(Ir(t),t=e=t.prev,t===t.next)break;i=!0}else t=t.next;while(i||t!==e);return e}function Dr(n,e,t,i,s,r,a){if(!n)return;!a&&r&&Lm(n,i,s,r);let o=n;for(;n.prev!==n.next;){const l=n.prev,c=n.next;if(r?Mm(n,i,s,r):bm(n)){e.push(l.i,n.i,c.i),Ir(n),n=c.next,o=c.next;continue}if(n=c,n===o){a?a===1?(n=Am(rs(n),e),Dr(n,e,t,i,s,r,2)):a===2&&Em(n,e,t,i,s,r):Dr(rs(n),e,t,i,s,r,1);break}}}function bm(n){const e=n.prev,t=n,i=n.next;if(At(e,t,i)>=0)return!1;const s=e.x,r=t.x,a=i.x,o=e.y,l=t.y,c=i.y,u=Math.min(s,r,a),d=Math.min(o,l,c),h=Math.max(s,r,a),f=Math.max(o,l,c);let p=i.next;for(;p!==e;){if(p.x>=u&&p.x<=h&&p.y>=d&&p.y<=f&&Sr(s,o,r,l,a,c,p.x,p.y)&&At(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Mm(n,e,t,i){const s=n.prev,r=n,a=n.next;if(At(s,r,a)>=0)return!1;const o=s.x,l=r.x,c=a.x,u=s.y,d=r.y,h=a.y,f=Math.min(o,l,c),p=Math.min(u,d,h),g=Math.max(o,l,c),m=Math.max(u,d,h),_=_c(f,p,e,t,i),b=_c(g,m,e,t,i);let A=n.prevZ,y=n.nextZ;for(;A&&A.z>=_&&y&&y.z<=b;){if(A.x>=f&&A.x<=g&&A.y>=p&&A.y<=m&&A!==s&&A!==a&&Sr(o,u,l,d,c,h,A.x,A.y)&&At(A.prev,A,A.next)>=0||(A=A.prevZ,y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;A&&A.z>=_;){if(A.x>=f&&A.x<=g&&A.y>=p&&A.y<=m&&A!==s&&A!==a&&Sr(o,u,l,d,c,h,A.x,A.y)&&At(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;y&&y.z<=b;){if(y.x>=f&&y.x<=g&&y.y>=p&&y.y<=m&&y!==s&&y!==a&&Sr(o,u,l,d,c,h,y.x,y.y)&&At(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function Am(n,e){let t=n;do{const i=t.prev,s=t.next.next;!qs(i,s)&&xf(i,t,t.next,s)&&Lr(i,s)&&Lr(s,i)&&(e.push(i.i,t.i,s.i),Ir(t),Ir(t.next),t=n=s),t=t.next}while(t!==n);return rs(t)}function Em(n,e,t,i,s,r){let a=n;do{let o=a.next.next;for(;o!==a.prev;){if(a.i!==o.i&&Um(a,o)){let l=yf(a,o);a=rs(a,a.next),l=rs(l,l.next),Dr(a,e,t,i,s,r,0),Dr(l,e,t,i,s,r,0);return}o=o.next}a=a.next}while(a!==n)}function Tm(n,e,t,i){const s=[];for(let r=0,a=e.length;r=t.next.y&&t.next.y!==t.y){const d=t.x+(s-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(d<=i&&d>r&&(r=d,a=t.x=t.x&&t.x>=l&&i!==t.x&&_f(sa.x||t.x===a.x&&Dm(a,t)))&&(a=t,u=d)}t=t.next}while(t!==o);return a}function Dm(n,e){return At(n.prev,n,e.prev)<0&&At(e.next,n,n.next)<0}function Lm(n,e,t,i){let s=n;do s.z===0&&(s.z=_c(s.x,s.y,e,t,i)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==n);s.prevZ.nextZ=null,s.prevZ=null,Im(s)}function Im(n){let e,t=1;do{let i=n,s;n=null;let r=null;for(e=0;i;){e++;let a=i,o=0;for(let c=0;c0||l>0&&a;)o!==0&&(l===0||!a||i.z<=a.z)?(s=i,i=i.nextZ,o--):(s=a,a=a.nextZ,l--),r?r.nextZ=s:n=s,s.prevZ=r,r=s;i=a}r.nextZ=null,t*=2}while(e>1);return n}function _c(n,e,t,i,s){return n=(n-t)*s|0,e=(e-i)*s|0,n=(n|n<<8)&16711935,n=(n|n<<4)&252645135,n=(n|n<<2)&858993459,n=(n|n<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,n|e<<1}function Pm(n){let e=n,t=n;do(e.x=(n-a)*(r-o)&&(n-a)*(i-o)>=(t-a)*(e-o)&&(t-a)*(r-o)>=(s-a)*(i-o)}function Sr(n,e,t,i,s,r,a,o){return!(n===a&&e===o)&&_f(n,e,t,i,s,r,a,o)}function Um(n,e){return n.next.i!==e.i&&n.prev.i!==e.i&&!Om(n,e)&&(Lr(n,e)&&Lr(e,n)&&Nm(n,e)&&(At(n.prev,n,e.prev)||At(n,e.prev,e))||qs(n,e)&&At(n.prev,n,n.next)>0&&At(e.prev,e,e.next)>0)}function At(n,e,t){return(e.y-n.y)*(t.x-e.x)-(e.x-n.x)*(t.y-e.y)}function qs(n,e){return n.x===e.x&&n.y===e.y}function xf(n,e,t,i){const s=ya(At(n,e,t)),r=ya(At(n,e,i)),a=ya(At(t,i,n)),o=ya(At(t,i,e));return!!(s!==r&&a!==o||s===0&&xa(n,t,e)||r===0&&xa(n,i,e)||a===0&&xa(t,n,i)||o===0&&xa(t,e,i))}function xa(n,e,t){return e.x<=Math.max(n.x,t.x)&&e.x>=Math.min(n.x,t.x)&&e.y<=Math.max(n.y,t.y)&&e.y>=Math.min(n.y,t.y)}function ya(n){return n>0?1:n<0?-1:0}function Om(n,e){let t=n;do{if(t.i!==n.i&&t.next.i!==n.i&&t.i!==e.i&&t.next.i!==e.i&&xf(t,t.next,n,e))return!0;t=t.next}while(t!==n);return!1}function Lr(n,e){return At(n.prev,n,n.next)<0?At(n,e,n.next)>=0&&At(n,n.prev,e)>=0:At(n,e,n.prev)<0||At(n,n.next,e)<0}function Nm(n,e){let t=n,i=!1;const s=(n.x+e.x)/2,r=(n.y+e.y)/2;do t.y>r!=t.next.y>r&&t.next.y!==t.y&&s<(t.next.x-t.x)*(r-t.y)/(t.next.y-t.y)+t.x&&(i=!i),t=t.next;while(t!==n);return i}function yf(n,e){const t=xc(n.i,n.x,n.y),i=xc(e.i,e.x,e.y),s=n.next,r=e.prev;return n.next=e,e.prev=n,t.next=s,s.prev=t,i.next=t,t.prev=i,r.next=i,i.prev=r,i}function Zu(n,e,t,i){const s=xc(n,e,t);return i?(s.next=i.next,s.prev=i,i.next.prev=s,i.next=s):(s.prev=s,s.next=s),s}function Ir(n){n.next.prev=n.prev,n.prev.next=n.next,n.prevZ&&(n.prevZ.nextZ=n.nextZ),n.nextZ&&(n.nextZ.prevZ=n.prevZ)}function xc(n,e,t){return{i:n,x:e,y:t,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function km(n,e,t,i){let s=0;for(let r=e,a=t-i;r2&&n[e-1].equals(n[0])&&n.pop()}function Ju(n,e){for(let t=0;t0&&(t.defines=this.defines),t.vertexShader=this.vertexShader,t.fragmentShader=this.fragmentShader,t.lights=this.lights,t.clipping=this.clipping;const i={};for(const s in this.extensions)this.extensions[s]===!0&&(i[s]=!0);return Object.keys(i).length>0&&(t.extensions=i),t}fromJSON(e,t){if(super.fromJSON(e,t),e.uniforms!==void 0)for(const i in e.uniforms){const s=e.uniforms[i];switch(this.uniforms[i]={},s.type){case"t":this.uniforms[i].value=t[s.value]||null;break;case"c":this.uniforms[i].value=new Qe().setHex(s.value);break;case"v2":this.uniforms[i].value=new Ee().fromArray(s.value);break;case"v3":this.uniforms[i].value=new B().fromArray(s.value);break;case"v4":this.uniforms[i].value=new wt().fromArray(s.value);break;case"m3":this.uniforms[i].value=new qe().fromArray(s.value);break;case"m4":this.uniforms[i].value=new Et().fromArray(s.value);break;default:this.uniforms[i].value=s.value}}if(e.defines!==void 0&&(this.defines=e.defines),e.vertexShader!==void 0&&(this.vertexShader=e.vertexShader),e.fragmentShader!==void 0&&(this.fragmentShader=e.fragmentShader),e.glslVersion!==void 0&&(this.glslVersion=e.glslVersion),e.extensions!==void 0)for(const i in e.extensions)this.extensions[i]=e.extensions[i];return e.lights!==void 0&&(this.lights=e.lights),e.clipping!==void 0&&(this.clipping=e.clipping),this}}class Wm extends On{constructor(e){super(e),this.isRawShaderMaterial=!0,this.type="RawShaderMaterial"}}class Xm extends nr{constructor(e){super(),this.isMeshDepthMaterial=!0,this.type="MeshDepthMaterial",this.depthPacking=A0,this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.wireframe=!1,this.wireframeLinewidth=1,this.setValues(e)}copy(e){return super.copy(e),this.depthPacking=e.depthPacking,this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this.wireframe=e.wireframe,this.wireframeLinewidth=e.wireframeLinewidth,this}}class Ym extends nr{constructor(e){super(),this.isMeshDistanceMaterial=!0,this.type="MeshDistanceMaterial",this.map=null,this.alphaMap=null,this.displacementMap=null,this.displacementScale=1,this.displacementBias=0,this.setValues(e)}copy(e){return super.copy(e),this.map=e.map,this.alphaMap=e.alphaMap,this.displacementMap=e.displacementMap,this.displacementScale=e.displacementScale,this.displacementBias=e.displacementBias,this}}class Km extends Bs{constructor(e){super(),this.isLineDashedMaterial=!0,this.type="LineDashedMaterial",this.scale=1,this.dashSize=3,this.gapSize=1,this.setValues(e)}copy(e){return super.copy(e),this.scale=e.scale,this.dashSize=e.dashSize,this.gapSize=e.gapSize,this}}const va=new B,Sa=new Hi,Hn=new B;class Sf extends sn{constructor(){super(),this.isCamera=!0,this.type="Camera",this.matrixWorldInverse=new Et,this.projectionMatrix=new Et,this.projectionMatrixInverse=new Et,this.coordinateSystem=Zn,this._reversedDepth=!1}get reversedDepth(){return this._reversedDepth}copy(e,t){return super.copy(e,t),this.matrixWorldInverse.copy(e.matrixWorldInverse),this.projectionMatrix.copy(e.projectionMatrix),this.projectionMatrixInverse.copy(e.projectionMatrixInverse),this.coordinateSystem=e.coordinateSystem,this}getWorldDirection(e){return super.getWorldDirection(e).negate()}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}updateWorldMatrix(e,t,i=!1){super.updateWorldMatrix(e,t,i),this.matrixWorld.decompose(va,Sa,Hn),Hn.x===1&&Hn.y===1&&Hn.z===1?this.matrixWorldInverse.copy(this.matrixWorld).invert():this.matrixWorldInverse.compose(va,Sa,Hn.set(1,1,1)).invert()}clone(){return new this.constructor().copy(this)}}const wi=new B,Qu=new Ee,eh=new Ee;class In extends Sf{constructor(e=50,t=1,i=.1,s=2e3){super(),this.isPerspectiveCamera=!0,this.type="PerspectiveCamera",this.fov=e,this.zoom=1,this.near=i,this.far=s,this.focus=10,this.aspect=t,this.view=null,this.filmGauge=35,this.filmOffset=0,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.fov=e.fov,this.zoom=e.zoom,this.near=e.near,this.far=e.far,this.focus=e.focus,this.aspect=e.aspect,this.view=e.view===null?null:Object.assign({},e.view),this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this}setFocalLength(e){const t=.5*this.getFilmHeight()/e;this.fov=mc*2*Math.atan(t),this.updateProjectionMatrix()}getFocalLength(){const e=Math.tan(za*.5*this.fov);return .5*this.getFilmHeight()/e}getEffectiveFOV(){return mc*2*Math.atan(Math.tan(za*.5*this.fov)/this.zoom)}getFilmWidth(){return this.filmGauge*Math.min(this.aspect,1)}getFilmHeight(){return this.filmGauge/Math.max(this.aspect,1)}getViewBounds(e,t,i){wi.set(-1,-1,.5).applyMatrix4(this.projectionMatrixInverse),t.set(wi.x,wi.y).multiplyScalar(-e/wi.z),wi.set(1,1,.5).applyMatrix4(this.projectionMatrixInverse),i.set(wi.x,wi.y).multiplyScalar(-e/wi.z)}getViewSize(e,t){return this.getViewBounds(e,Qu,eh),t.subVectors(eh,Qu)}setViewOffset(e,t,i,s,r,a){this.aspect=e/t,this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=this.near;let t=e*Math.tan(za*.5*this.fov)/this.zoom,i=2*t,s=this.aspect*i,r=-.5*s;const a=this.view;if(this.view!==null&&this.view.enabled){const l=a.fullWidth,c=a.fullHeight;r+=a.offsetX*s/l,t-=a.offsetY*i/c,s*=a.width/l,i*=a.height/c}const o=this.filmOffset;o!==0&&(r+=e*o/this.getFilmWidth()),this.projectionMatrix.makePerspective(r,r+s,t,t-i,e,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.fov=this.fov,t.object.zoom=this.zoom,t.object.near=this.near,t.object.far=this.far,t.object.focus=this.focus,t.object.aspect=this.aspect,this.view!==null&&(t.object.view=Object.assign({},this.view)),t.object.filmGauge=this.filmGauge,t.object.filmOffset=this.filmOffset,t}}class Yc extends Sf{constructor(e=-1,t=1,i=1,s=-1,r=.1,a=2e3){super(),this.isOrthographicCamera=!0,this.type="OrthographicCamera",this.zoom=1,this.view=null,this.left=e,this.right=t,this.top=i,this.bottom=s,this.near=r,this.far=a,this.updateProjectionMatrix()}copy(e,t){return super.copy(e,t),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.near=e.near,this.far=e.far,this.zoom=e.zoom,this.view=e.view===null?null:Object.assign({},e.view),this}setViewOffset(e,t,i,s,r,a){this.view===null&&(this.view={enabled:!0,fullWidth:1,fullHeight:1,offsetX:0,offsetY:0,width:1,height:1}),this.view.enabled=!0,this.view.fullWidth=e,this.view.fullHeight=t,this.view.offsetX=i,this.view.offsetY=s,this.view.width=r,this.view.height=a,this.updateProjectionMatrix()}clearViewOffset(){this.view!==null&&(this.view.enabled=!1),this.updateProjectionMatrix()}updateProjectionMatrix(){const e=(this.right-this.left)/(2*this.zoom),t=(this.top-this.bottom)/(2*this.zoom),i=(this.right+this.left)/2,s=(this.top+this.bottom)/2;let r=i-e,a=i+e,o=s+t,l=s-t;if(this.view!==null&&this.view.enabled){const c=(this.right-this.left)/this.view.fullWidth/this.zoom,u=(this.top-this.bottom)/this.view.fullHeight/this.zoom;r+=c*this.view.offsetX,a=r+c*this.view.width,o-=u*this.view.offsetY,l=o-u*this.view.height}this.projectionMatrix.makeOrthographic(r,a,o,l,this.near,this.far,this.coordinateSystem,this.reversedDepth),this.projectionMatrixInverse.copy(this.projectionMatrix).invert()}toJSON(e){const t=super.toJSON(e);return t.object.zoom=this.zoom,t.object.left=this.left,t.object.right=this.right,t.object.top=this.top,t.object.bottom=this.bottom,t.object.near=this.near,t.object.far=this.far,this.view!==null&&(t.object.view=Object.assign({},this.view)),t}}const Is=-90,Ps=1;class qm extends sn{constructor(e,t,i){super(),this.type="CubeCamera",this.renderTarget=i,this.coordinateSystem=null,this.activeMipmapLevel=0;const s=new In(Is,Ps,e,t);s.layers=this.layers,this.add(s);const r=new In(Is,Ps,e,t);r.layers=this.layers,this.add(r);const a=new In(Is,Ps,e,t);a.layers=this.layers,this.add(a);const o=new In(Is,Ps,e,t);o.layers=this.layers,this.add(o);const l=new In(Is,Ps,e,t);l.layers=this.layers,this.add(l);const c=new In(Is,Ps,e,t);c.layers=this.layers,this.add(c)}updateCoordinateSystem(){const e=this.coordinateSystem,t=this.children.concat(),[i,s,r,a,o,l]=t;for(const c of t)this.remove(c);if(e===Zn)i.up.set(0,1,0),i.lookAt(1,0,0),s.up.set(0,1,0),s.lookAt(-1,0,0),r.up.set(0,0,-1),r.lookAt(0,1,0),a.up.set(0,0,1),a.lookAt(0,-1,0),o.up.set(0,1,0),o.lookAt(0,0,1),l.up.set(0,1,0),l.lookAt(0,0,-1);else if(e===Ja)i.up.set(0,-1,0),i.lookAt(-1,0,0),s.up.set(0,-1,0),s.lookAt(1,0,0),r.up.set(0,0,1),r.lookAt(0,1,0),a.up.set(0,0,-1),a.lookAt(0,-1,0),o.up.set(0,-1,0),o.lookAt(0,0,1),l.up.set(0,-1,0),l.lookAt(0,0,-1);else throw new Error("THREE.CubeCamera.updateCoordinateSystem(): Invalid coordinate system: "+e);for(const c of t)this.add(c),c.updateMatrixWorld()}update(e,t){this.parent===null&&this.updateMatrixWorld();const{renderTarget:i,activeMipmapLevel:s}=this;this.coordinateSystem!==e.coordinateSystem&&(this.coordinateSystem=e.coordinateSystem,this.updateCoordinateSystem());const[r,a,o,l,c,u]=this.children,d=e.getRenderTarget(),h=e.getActiveCubeFace(),f=e.getActiveMipmapLevel(),p=e.xr.enabled;e.xr.enabled=!1;const g=i.texture.generateMipmaps;i.texture.generateMipmaps=!1;let m=!1;e.isWebGLRenderer===!0?m=e.state.buffers.depth.getReversed():m=e.reversedDepthBuffer,e.setRenderTarget(i,0,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,r),e.setRenderTarget(i,1,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,a),e.setRenderTarget(i,2,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,o),e.setRenderTarget(i,3,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,l),e.setRenderTarget(i,4,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,c),i.texture.generateMipmaps=g,e.setRenderTarget(i,5,s),m&&e.autoClear===!1&&e.clearDepth(),e.render(t,u),e.setRenderTarget(d,h,f),e.xr.enabled=p,i.texture.needsPMREMUpdate=!0}}class Zm extends In{constructor(e=[]){super(),this.isArrayCamera=!0,this.isMultiViewCamera=!1,this.cameras=e}}class th{constructor(e=1,t=0,i=0){this.radius=e,this.phi=t,this.theta=i}set(e,t,i){return this.radius=e,this.phi=t,this.theta=i,this}copy(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this}makeSafe(){return this.phi=je(this.phi,1e-6,Math.PI-1e-6),this}setFromVector3(e){return this.setFromCartesianCoords(e.x,e.y,e.z)}setFromCartesianCoords(e,t,i){return this.radius=Math.sqrt(e*e+t*t+i*i),this.radius===0?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e,i),this.phi=Math.acos(je(t/this.radius,-1,1))),this}clone(){return new this.constructor().copy(this)}}const fu=class fu{constructor(e,t,i,s){this.elements=[1,0,0,1],e!==void 0&&this.set(e,t,i,s)}identity(){return this.set(1,0,0,1),this}fromArray(e,t=0){for(let i=0;i<4;i++)this.elements[i]=e[i+t];return this}set(e,t,i,s){const r=this.elements;return r[0]=e,r[2]=t,r[1]=i,r[3]=s,this}};fu.prototype.isMatrix2=!0;let nh=fu;class $m extends Gi{constructor(e,t=null){super(),this.object=e,this.domElement=t,this.enabled=!0,this.state=-1,this.keys={},this.mouseButtons={LEFT:null,MIDDLE:null,RIGHT:null},this.touches={ONE:null,TWO:null}}connect(e){if(e===void 0){Ye("Controls: connect() now requires an element.");return}this.domElement!==null&&this.disconnect(),this.domElement=e}disconnect(){}dispose(){}update(){}}function ih(n,e,t,i){const s=Jm(i);switch(t){case Zd:return n*e;case Jd:return n*e/s.components*s.byteLength;case Nc:return n*e/s.components*s.byteLength;case is:return n*e*2/s.components*s.byteLength;case kc:return n*e*2/s.components*s.byteLength;case $d:return n*e*3/s.components*s.byteLength;case bn:return n*e*4/s.components*s.byteLength;case Fc:return n*e*4/s.components*s.byteLength;case ka:case Fa:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Ba:case Ha:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Fl:case Hl:return Math.max(n,16)*Math.max(e,8)/4;case kl:case Bl:return Math.max(n,8)*Math.max(e,8)/2;case zl:case Vl:case Wl:case Xl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*8;case Gl:case Ka:case Yl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case Kl:return Math.floor((n+3)/4)*Math.floor((e+3)/4)*16;case ql:return Math.floor((n+4)/5)*Math.floor((e+3)/4)*16;case Zl:return Math.floor((n+4)/5)*Math.floor((e+4)/5)*16;case $l:return Math.floor((n+5)/6)*Math.floor((e+4)/5)*16;case Jl:return Math.floor((n+5)/6)*Math.floor((e+5)/6)*16;case jl:return Math.floor((n+7)/8)*Math.floor((e+4)/5)*16;case Ql:return Math.floor((n+7)/8)*Math.floor((e+5)/6)*16;case ec:return Math.floor((n+7)/8)*Math.floor((e+7)/8)*16;case tc:return Math.floor((n+9)/10)*Math.floor((e+4)/5)*16;case nc:return Math.floor((n+9)/10)*Math.floor((e+5)/6)*16;case ic:return Math.floor((n+9)/10)*Math.floor((e+7)/8)*16;case sc:return Math.floor((n+9)/10)*Math.floor((e+9)/10)*16;case rc:return Math.floor((n+11)/12)*Math.floor((e+9)/10)*16;case ac:return Math.floor((n+11)/12)*Math.floor((e+11)/12)*16;case oc:case lc:case cc:return Math.ceil(n/4)*Math.ceil(e/4)*16;case uc:case hc:return Math.ceil(n/4)*Math.ceil(e/4)*8;case qa:case dc:return Math.ceil(n/4)*Math.ceil(e/4)*16}throw new Error(`Unable to determine texture byte length for ${t} format.`)}function Jm(n){switch(n){case vn:case Xd:return{byteLength:1,components:1};case wr:case Yd:case _i:return{byteLength:2,components:1};case Uc:case Oc:return{byteLength:2,components:4};case ei:case Pc:case Pn:return{byteLength:4,components:1};case Kd:case qd:return{byteLength:4,components:3}}throw new Error(`THREE.TextureUtils: Unknown texture type ${n}.`)}typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:Ic}}));typeof window<"u"&&(window.__THREE__?Ye("WARNING: Multiple instances of Three.js being imported."):window.__THREE__=Ic);/** + * @license + * Copyright 2010-2026 Three.js Authors + * SPDX-License-Identifier: MIT + */function bf(){let n=null,e=!1,t=null,i=null;function s(r,a){t(r,a),i=n.requestAnimationFrame(s)}return{start:function(){e!==!0&&t!==null&&n!==null&&(i=n.requestAnimationFrame(s),e=!0)},stop:function(){n!==null&&n.cancelAnimationFrame(i),e=!1},setAnimationLoop:function(r){t=r},setContext:function(r){n=r}}}function jm(n){const e=new WeakMap;function t(o,l){const c=o.array,u=o.usage,d=c.byteLength,h=n.createBuffer();n.bindBuffer(l,h),n.bufferData(l,c,u),o.onUploadCallback();let f;if(c instanceof Float32Array)f=n.FLOAT;else if(typeof Float16Array<"u"&&c instanceof Float16Array)f=n.HALF_FLOAT;else if(c instanceof Uint16Array)o.isFloat16BufferAttribute?f=n.HALF_FLOAT:f=n.UNSIGNED_SHORT;else if(c instanceof Int16Array)f=n.SHORT;else if(c instanceof Uint32Array)f=n.UNSIGNED_INT;else if(c instanceof Int32Array)f=n.INT;else if(c instanceof Int8Array)f=n.BYTE;else if(c instanceof Uint8Array)f=n.UNSIGNED_BYTE;else if(c instanceof Uint8ClampedArray)f=n.UNSIGNED_BYTE;else throw new Error("THREE.WebGLAttributes: Unsupported buffer data format: "+c);return{buffer:h,type:f,bytesPerElement:c.BYTES_PER_ELEMENT,version:o.version,size:d}}function i(o,l,c){const u=l.array,d=l.updateRanges;if(n.bindBuffer(c,o),d.length===0)n.bufferSubData(c,0,u);else{d.sort((f,p)=>f.start-p.start);let h=0;for(let f=1;f 0 + vec4 plane; + #ifdef ALPHA_TO_COVERAGE + float distanceToPlane, distanceGradient; + float clipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + clipOpacity *= smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + if ( clipOpacity == 0.0 ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + float unionClipOpacity = 1.0; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + distanceToPlane = - dot( vClipPosition, plane.xyz ) + plane.w; + distanceGradient = fwidth( distanceToPlane ) / 2.0; + unionClipOpacity *= 1.0 - smoothstep( - distanceGradient, distanceGradient, distanceToPlane ); + } + #pragma unroll_loop_end + clipOpacity *= 1.0 - unionClipOpacity; + #endif + diffuseColor.a *= clipOpacity; + if ( diffuseColor.a == 0.0 ) discard; + #else + #pragma unroll_loop_start + for ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + if ( dot( vClipPosition, plane.xyz ) > plane.w ) discard; + } + #pragma unroll_loop_end + #if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES + bool clipped = true; + #pragma unroll_loop_start + for ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) { + plane = clippingPlanes[ i ]; + clipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped; + } + #pragma unroll_loop_end + if ( clipped ) discard; + #endif + #endif +#endif`,mg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; + uniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ]; +#endif`,gg=`#if NUM_CLIPPING_PLANES > 0 + varying vec3 vClipPosition; +#endif`,_g=`#if NUM_CLIPPING_PLANES > 0 + vClipPosition = - mvPosition.xyz; +#endif`,xg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + diffuseColor *= vColor; +#endif`,yg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) + varying vec4 vColor; +#endif`,vg=`#if defined( USE_COLOR ) || defined( USE_COLOR_ALPHA ) || defined( USE_INSTANCING_COLOR ) || defined( USE_BATCHING_COLOR ) + varying vec4 vColor; +#endif`,Sg=`#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 + vColor *= color; +#elif defined( USE_COLOR ) + vColor.rgb *= color; +#endif +#ifdef USE_INSTANCING_COLOR + vColor.rgb *= instanceColor.rgb; +#endif +#ifdef USE_BATCHING_COLOR + vColor *= getBatchingColor( getIndirectIndex( gl_DrawID ) ); +#endif`,bg=`#define PI 3.141592653589793 +#define PI2 6.283185307179586 +#define PI_HALF 1.5707963267948966 +#define RECIPROCAL_PI 0.3183098861837907 +#define RECIPROCAL_PI2 0.15915494309189535 +#define EPSILON 1e-6 +#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +#define whiteComplement( a ) ( 1.0 - saturate( a ) ) +float pow2( const in float x ) { return x*x; } +vec3 pow2( const in vec3 x ) { return x*x; } +float pow3( const in float x ) { return x*x*x; } +float pow4( const in float x ) { float x2 = x*x; return x2*x2; } +float max3( const in vec3 v ) { return max( max( v.x, v.y ), v.z ); } +float average( const in vec3 v ) { return dot( v, vec3( 0.3333333 ) ); } +highp float rand( const in vec2 uv ) { + const highp float a = 12.9898, b = 78.233, c = 43758.5453; + highp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI ); + return fract( sin( sn ) * c ); +} +#ifdef HIGH_PRECISION + float precisionSafeLength( vec3 v ) { return length( v ); } +#else + float precisionSafeLength( vec3 v ) { + float maxComponent = max3( abs( v ) ); + return length( v / maxComponent ) * maxComponent; + } +#endif +struct IncidentLight { + vec3 color; + vec3 direction; + bool visible; +}; +struct ReflectedLight { + vec3 directDiffuse; + vec3 directSpecular; + vec3 indirectDiffuse; + vec3 indirectSpecular; +}; +#ifdef USE_ALPHAHASH + varying vec3 vPosition; +#endif +vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); +} +#define inverseTransformDirection transformDirectionByInverseViewMatrix +vec3 transformNormalByInverseViewMatrix( in vec3 normal, in mat4 viewMatrix ) { + return normalize( ( vec4( normal, 0.0 ) * viewMatrix ).xyz ); +} +vec3 transformDirectionByInverseViewMatrix( in vec3 dir, in mat4 viewMatrix ) { + return normalize( ( vec4( dir, 0.0 ) * viewMatrix ).xyz ); +} +bool isPerspectiveMatrix( mat4 m ) { + return m[ 2 ][ 3 ] == - 1.0; +} +vec2 equirectUv( in vec3 dir ) { + float u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5; + float v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5; + return vec2( u, v ); +} +vec3 BRDF_Lambert( const in vec3 diffuseColor ) { + return RECIPROCAL_PI * diffuseColor; +} +vec3 F_Schlick( const in vec3 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 ); +} +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`,Mg=`#ifdef ENVMAP_TYPE_CUBE_UV + #define cubeUV_minMipLevel 4.0 + #define cubeUV_minTileSize 16.0 + float getFace( vec3 direction ) { + vec3 absDirection = abs( direction ); + float face = - 1.0; + if ( absDirection.x > absDirection.z ) { + if ( absDirection.x > absDirection.y ) + face = direction.x > 0.0 ? 0.0 : 3.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } else { + if ( absDirection.z > absDirection.y ) + face = direction.z > 0.0 ? 2.0 : 5.0; + else + face = direction.y > 0.0 ? 1.0 : 4.0; + } + return face; + } + vec2 getUV( vec3 direction, float face ) { + vec2 uv; + if ( face == 0.0 ) { + uv = vec2( direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 1.0 ) { + uv = vec2( - direction.x, - direction.z ) / abs( direction.y ); + } else if ( face == 2.0 ) { + uv = vec2( - direction.x, direction.y ) / abs( direction.z ); + } else if ( face == 3.0 ) { + uv = vec2( - direction.z, direction.y ) / abs( direction.x ); + } else if ( face == 4.0 ) { + uv = vec2( - direction.x, direction.z ) / abs( direction.y ); + } else { + uv = vec2( direction.x, direction.y ) / abs( direction.z ); + } + return 0.5 * ( uv + 1.0 ); + } + vec3 bilinearCubeUV( sampler2D envMap, vec3 direction, float mipInt ) { + float face = getFace( direction ); + float filterInt = max( cubeUV_minMipLevel - mipInt, 0.0 ); + mipInt = max( mipInt, cubeUV_minMipLevel ); + float faceSize = exp2( mipInt ); + highp vec2 uv = getUV( direction, face ) * ( faceSize - 2.0 ) + 1.0; + if ( face > 2.0 ) { + uv.y += faceSize; + face -= 3.0; + } + uv.x += face * faceSize; + uv.x += filterInt * 3.0 * cubeUV_minTileSize; + uv.y += 4.0 * ( exp2( CUBEUV_MAX_MIP ) - faceSize ); + uv.x *= CUBEUV_TEXEL_WIDTH; + uv.y *= CUBEUV_TEXEL_HEIGHT; + #ifdef texture2DGradEXT + return texture2DGradEXT( envMap, uv, vec2( 0.0 ), vec2( 0.0 ) ).rgb; + #else + return texture2D( envMap, uv ).rgb; + #endif + } + #define cubeUV_r0 1.0 + #define cubeUV_m0 - 2.0 + #define cubeUV_r1 0.8 + #define cubeUV_m1 - 1.0 + #define cubeUV_r4 0.4 + #define cubeUV_m4 2.0 + #define cubeUV_r5 0.305 + #define cubeUV_m5 3.0 + #define cubeUV_r6 0.21 + #define cubeUV_m6 4.0 + float roughnessToMip( float roughness ) { + float mip = 0.0; + if ( roughness >= cubeUV_r1 ) { + mip = ( cubeUV_r0 - roughness ) * ( cubeUV_m1 - cubeUV_m0 ) / ( cubeUV_r0 - cubeUV_r1 ) + cubeUV_m0; + } else if ( roughness >= cubeUV_r4 ) { + mip = ( cubeUV_r1 - roughness ) * ( cubeUV_m4 - cubeUV_m1 ) / ( cubeUV_r1 - cubeUV_r4 ) + cubeUV_m1; + } else if ( roughness >= cubeUV_r5 ) { + mip = ( cubeUV_r4 - roughness ) * ( cubeUV_m5 - cubeUV_m4 ) / ( cubeUV_r4 - cubeUV_r5 ) + cubeUV_m4; + } else if ( roughness >= cubeUV_r6 ) { + mip = ( cubeUV_r5 - roughness ) * ( cubeUV_m6 - cubeUV_m5 ) / ( cubeUV_r5 - cubeUV_r6 ) + cubeUV_m5; + } else { + mip = - 2.0 * log2( 1.16 * roughness ); } + return mip; + } + vec4 textureCubeUV( sampler2D envMap, vec3 sampleDir, float roughness ) { + float mip = clamp( roughnessToMip( roughness ), cubeUV_m0, CUBEUV_MAX_MIP ); + float mipF = fract( mip ); + float mipInt = floor( mip ); + vec3 color0 = bilinearCubeUV( envMap, sampleDir, mipInt ); + if ( mipF == 0.0 ) { + return vec4( color0, 1.0 ); + } else { + vec3 color1 = bilinearCubeUV( envMap, sampleDir, mipInt + 1.0 ); + return vec4( mix( color0, color1, mipF ), 1.0 ); + } + } +#endif`,Ag=`vec3 transformedNormal = objectNormal; +#ifdef USE_TANGENT + vec3 transformedTangent = objectTangent; +#endif +#ifdef USE_BATCHING + mat3 bm = mat3( batchingMatrix ); + transformedNormal /= vec3( dot( bm[ 0 ], bm[ 0 ] ), dot( bm[ 1 ], bm[ 1 ] ), dot( bm[ 2 ], bm[ 2 ] ) ); + transformedNormal = bm * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = bm * transformedTangent; + #endif +#endif +#ifdef USE_INSTANCING + mat3 im = mat3( instanceMatrix ); + transformedNormal /= vec3( dot( im[ 0 ], im[ 0 ] ), dot( im[ 1 ], im[ 1 ] ), dot( im[ 2 ], im[ 2 ] ) ); + transformedNormal = im * transformedNormal; + #ifdef USE_TANGENT + transformedTangent = im * transformedTangent; + #endif +#endif +transformedNormal = normalMatrix * transformedNormal; +#ifdef FLIP_SIDED + transformedNormal = - transformedNormal; +#endif +#ifdef USE_TANGENT + transformedTangent = ( modelViewMatrix * vec4( transformedTangent, 0.0 ) ).xyz; +#endif`,Eg=`#ifdef USE_DISPLACEMENTMAP + uniform sampler2D displacementMap; + uniform float displacementScale; + uniform float displacementBias; +#endif`,Tg=`#ifdef USE_DISPLACEMENTMAP + transformed += normalize( objectNormal ) * ( texture2D( displacementMap, vDisplacementMapUv ).x * displacementScale + displacementBias ); +#endif`,Cg=`#ifdef USE_EMISSIVEMAP + vec4 emissiveColor = texture2D( emissiveMap, vEmissiveMapUv ); + #ifdef DECODE_VIDEO_TEXTURE_EMISSIVE + emissiveColor = sRGBTransferEOTF( emissiveColor ); + #endif + totalEmissiveRadiance *= emissiveColor.rgb; +#endif`,wg=`#ifdef USE_EMISSIVEMAP + uniform sampler2D emissiveMap; +#endif`,Rg="gl_FragColor = linearToOutputTexel( gl_FragColor );",Dg=`vec4 LinearTransferOETF( in vec4 value ) { + return value; +} +vec4 sRGBTransferEOTF( in vec4 value ) { + return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a ); +} +vec4 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 ); +}`,Lg=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vec3 cameraToFrag; + if ( isOrthographic ) { + cameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToFrag = normalize( vWorldPosition - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vec3 reflectVec = reflect( cameraToFrag, worldNormal ); + #else + vec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio ); + #endif + #else + vec3 reflectVec = vReflect; + #endif + #ifdef ENVMAP_TYPE_CUBE + vec4 envColor = textureCube( envMap, envMapRotation * reflectVec ); + #ifdef ENVMAP_BLENDING_MULTIPLY + outgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_MIX ) + outgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity ); + #elif defined( ENVMAP_BLENDING_ADD ) + outgoingLight += envColor.xyz * specularStrength * reflectivity; + #endif + #endif +#endif`,Ig=`#ifdef USE_ENVMAP + uniform float envMapIntensity; + uniform mat3 envMapRotation; + #ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; + #else + uniform sampler2D envMap; + #endif +#endif`,Pg=`#ifdef USE_ENVMAP + uniform float reflectivity; + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + varying vec3 vWorldPosition; + uniform float refractionRatio; + #else + varying vec3 vReflect; + #endif +#endif`,Ug=`#ifdef USE_ENVMAP + #if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( LAMBERT ) + #define ENV_WORLDPOS + #endif + #ifdef ENV_WORLDPOS + + varying vec3 vWorldPosition; + #else + varying vec3 vReflect; + uniform float refractionRatio; + #endif +#endif`,Og=`#ifdef USE_ENVMAP + #ifdef ENV_WORLDPOS + vWorldPosition = worldPosition.xyz; + #else + vec3 cameraToVertex; + if ( isOrthographic ) { + cameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) ); + } else { + cameraToVertex = normalize( worldPosition.xyz - cameraPosition ); + } + vec3 worldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #ifdef ENVMAP_MODE_REFLECTION + vReflect = reflect( cameraToVertex, worldNormal ); + #else + vReflect = refract( cameraToVertex, worldNormal, refractionRatio ); + #endif + #endif +#endif`,Ng=`#ifdef USE_FOG + vFogDepth = - mvPosition.z; +#endif`,kg=`#ifdef USE_FOG + varying float vFogDepth; +#endif`,Fg=`#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`,Bg=`#ifdef USE_FOG + uniform vec3 fogColor; + varying float vFogDepth; + #ifdef FOG_EXP2 + uniform float fogDensity; + #else + uniform float fogNear; + uniform float fogFar; + #endif +#endif`,Hg=`#ifdef USE_GRADIENTMAP + uniform sampler2D gradientMap; +#endif +vec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) { + float dotNL = dot( normal, lightDirection ); + vec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 ); + #ifdef USE_GRADIENTMAP + return vec3( texture2D( gradientMap, coord ).r ); + #else + 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 +}`,zg=`#ifdef USE_LIGHTMAP + uniform sampler2D lightMap; + uniform float lightMapIntensity; +#endif`,Vg=`LambertMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularStrength = specularStrength;`,Gg=`varying vec3 vViewPosition; +struct LambertMaterial { + vec3 diffuseColor; + float specularStrength; +}; +void RE_Direct_Lambert( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Lambert( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in LambertMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Lambert +#define RE_IndirectDiffuse RE_IndirectDiffuse_Lambert`,Wg=`uniform bool receiveShadow; +uniform vec3 ambientLightColor; +#if defined( USE_LIGHT_PROBES ) + uniform vec3 lightProbe[ 9 ]; +#endif +vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) { + float x = normal.x, y = normal.y, z = normal.z; + vec3 result = shCoefficients[ 0 ] * 0.886227; + result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y; + result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z; + result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x; + result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y; + result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z; + result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 ); + result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z; + result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y ); + return result; +} +vec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in vec3 normal ) { + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe ); + return irradiance; +} +vec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) { + vec3 irradiance = ambientLightColor; + return irradiance; +} +float getDistanceAttenuation( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) { + float distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 ); + if ( cutoffDistance > 0.0 ) { + distanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) ); + } + return distanceFalloff; +} +float getSpotAttenuation( const in float coneCosine, const in float penumbraCosine, const in float angleCosine ) { + return smoothstep( coneCosine, penumbraCosine, angleCosine ); +} +#if NUM_DIR_LIGHTS > 0 + struct DirectionalLight { + vec3 direction; + vec3 color; + }; + uniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ]; + void getDirectionalLightInfo( const in DirectionalLight directionalLight, out IncidentLight light ) { + light.color = directionalLight.color; + light.direction = directionalLight.direction; + light.visible = true; + } +#endif +#if NUM_POINT_LIGHTS > 0 + struct PointLight { + vec3 position; + vec3 color; + float distance; + float decay; + }; + uniform PointLight pointLights[ NUM_POINT_LIGHTS ]; + void getPointLightInfo( const in PointLight pointLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = pointLight.position - geometryPosition; + light.direction = normalize( lVector ); + float lightDistance = length( lVector ); + light.color = pointLight.color; + light.color *= getDistanceAttenuation( lightDistance, pointLight.distance, pointLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } +#endif +#if NUM_SPOT_LIGHTS > 0 + struct SpotLight { + vec3 position; + vec3 direction; + vec3 color; + float distance; + float decay; + float coneCos; + float penumbraCos; + }; + uniform SpotLight spotLights[ NUM_SPOT_LIGHTS ]; + void getSpotLightInfo( const in SpotLight spotLight, const in vec3 geometryPosition, out IncidentLight light ) { + vec3 lVector = spotLight.position - geometryPosition; + light.direction = normalize( lVector ); + float angleCos = dot( light.direction, spotLight.direction ); + float spotAttenuation = getSpotAttenuation( spotLight.coneCos, spotLight.penumbraCos, angleCos ); + if ( spotAttenuation > 0.0 ) { + float lightDistance = length( lVector ); + light.color = spotLight.color * spotAttenuation; + light.color *= getDistanceAttenuation( lightDistance, spotLight.distance, spotLight.decay ); + light.visible = ( light.color != vec3( 0.0 ) ); + } else { + light.color = vec3( 0.0 ); + light.visible = false; + } + } +#endif +#if NUM_RECT_AREA_LIGHTS > 0 + struct RectAreaLight { + vec3 color; + vec3 position; + vec3 halfWidth; + vec3 halfHeight; + }; + uniform sampler2D ltc_1; uniform sampler2D ltc_2; + uniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ]; +#endif +#if NUM_HEMI_LIGHTS > 0 + struct HemisphereLight { + vec3 direction; + vec3 skyColor; + vec3 groundColor; + }; + uniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ]; + vec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in vec3 normal ) { + float dotNL = dot( normal, hemiLight.direction ); + float hemiDiffuseWeight = 0.5 * dotNL + 0.5; + vec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight ); + return irradiance; + } +#endif +#include `,Xg=`#ifdef USE_ENVMAP + vec3 getIBLIrradiance( const in vec3 normal ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 worldNormal = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * worldNormal, 1.0 ); + return PI * envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + vec3 getIBLRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 reflectVec = reflect( - viewDir, normal ); + reflectVec = normalize( mix( reflectVec, normal, pow4( roughness ) ) ); + reflectVec = transformDirectionByInverseViewMatrix( reflectVec, viewMatrix ); + vec4 envMapColor = textureCubeUV( envMap, envMapRotation * reflectVec, roughness ); + return envMapColor.rgb * envMapIntensity; + #else + return vec3( 0.0 ); + #endif + } + #ifdef USE_ANISOTROPY + vec3 getIBLAnisotropyRadiance( const in vec3 viewDir, const in vec3 normal, const in float roughness, const in vec3 bitangent, const in float anisotropy ) { + #ifdef ENVMAP_TYPE_CUBE_UV + vec3 bentNormal = cross( bitangent, viewDir ); + bentNormal = normalize( cross( bentNormal, bitangent ) ); + bentNormal = normalize( mix( bentNormal, normal, pow2( pow2( 1.0 - anisotropy * ( 1.0 - roughness ) ) ) ) ); + return getIBLRadiance( viewDir, bentNormal, roughness ); + #else + return vec3( 0.0 ); + #endif + } + #endif +#endif`,Yg=`ToonMaterial material; +material.diffuseColor = diffuseColor.rgb;`,Kg=`varying vec3 vViewPosition; +struct ToonMaterial { + vec3 diffuseColor; +}; +void RE_Direct_Toon( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + vec3 irradiance = getGradientIrradiance( geometryNormal, directLight.direction ) * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +void RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in ToonMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_Toon +#define RE_IndirectDiffuse RE_IndirectDiffuse_Toon`,qg=`BlinnPhongMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.specularColor = specular; +material.specularShininess = shininess; +material.specularStrength = specularStrength;`,Zg=`varying vec3 vViewPosition; +struct BlinnPhongMaterial { + vec3 diffuseColor; + vec3 specularColor; + float specularShininess; + float specularStrength; +}; +void RE_Direct_BlinnPhong( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); + reflectedLight.directSpecular += irradiance * BRDF_BlinnPhong( directLight.direction, geometryViewDir, geometryNormal, material.specularColor, material.specularShininess ) * material.specularStrength; +} +void RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) { + reflectedLight.indirectDiffuse += irradiance * BRDF_Lambert( material.diffuseColor ); +} +#define RE_Direct RE_Direct_BlinnPhong +#define RE_IndirectDiffuse RE_IndirectDiffuse_BlinnPhong`,$g=`PhysicalMaterial material; +material.diffuseColor = diffuseColor.rgb; +material.diffuseContribution = diffuseColor.rgb * ( 1.0 - metalnessFactor ); +material.metalness = metalnessFactor; +vec3 dxy = max( abs( dFdx( nonPerturbedNormal ) ), abs( dFdy( nonPerturbedNormal ) ) ); +float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z ); +material.roughness = max( roughnessFactor, 0.0525 );material.roughness += geometryRoughness; +material.roughness = min( material.roughness, 1.0 ); +#ifdef IOR + material.ior = ior; + #ifdef USE_SPECULAR + float specularIntensityFactor = specularIntensity; + vec3 specularColorFactor = specularColor; + #ifdef USE_SPECULAR_COLORMAP + specularColorFactor *= texture2D( specularColorMap, vSpecularColorMapUv ).rgb; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + specularIntensityFactor *= texture2D( specularIntensityMap, vSpecularIntensityMapUv ).a; + #endif + material.specularF90 = mix( specularIntensityFactor, 1.0, metalnessFactor ); + #else + float specularIntensityFactor = 1.0; + vec3 specularColorFactor = vec3( 1.0 ); + material.specularF90 = 1.0; + #endif + material.specularColor = min( pow2( ( material.ior - 1.0 ) / ( material.ior + 1.0 ) ) * specularColorFactor, vec3( 1.0 ) ) * specularIntensityFactor; + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); +#else + material.specularColor = vec3( 0.04 ); + material.specularColorBlended = mix( material.specularColor, diffuseColor.rgb, metalnessFactor ); + material.specularF90 = 1.0; +#endif +#ifdef USE_CLEARCOAT + material.clearcoat = clearcoat; + material.clearcoatRoughness = clearcoatRoughness; + material.clearcoatF0 = vec3( 0.04 ); + material.clearcoatF90 = 1.0; + #ifdef USE_CLEARCOATMAP + material.clearcoat *= texture2D( clearcoatMap, vClearcoatMapUv ).x; + #endif + #ifdef USE_CLEARCOAT_ROUGHNESSMAP + material.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vClearcoatRoughnessMapUv ).y; + #endif + material.clearcoat = saturate( material.clearcoat ); material.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 ); + material.clearcoatRoughness += geometryRoughness; + material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 ); +#endif +#ifdef USE_DISPERSION + material.dispersion = dispersion; +#endif +#ifdef USE_IRIDESCENCE + material.iridescence = iridescence; + material.iridescenceIOR = iridescenceIOR; + #ifdef USE_IRIDESCENCEMAP + material.iridescence *= texture2D( iridescenceMap, vIridescenceMapUv ).r; + #endif + #ifdef USE_IRIDESCENCE_THICKNESSMAP + material.iridescenceThickness = (iridescenceThicknessMaximum - iridescenceThicknessMinimum) * texture2D( iridescenceThicknessMap, vIridescenceThicknessMapUv ).g + iridescenceThicknessMinimum; + #else + material.iridescenceThickness = iridescenceThicknessMaximum; + #endif +#endif +#ifdef USE_SHEEN + material.sheenColor = sheenColor; + #ifdef USE_SHEEN_COLORMAP + material.sheenColor *= texture2D( sheenColorMap, vSheenColorMapUv ).rgb; + #endif + material.sheenRoughness = clamp( sheenRoughness, 0.0001, 1.0 ); + #ifdef USE_SHEEN_ROUGHNESSMAP + material.sheenRoughness *= texture2D( sheenRoughnessMap, vSheenRoughnessMapUv ).a; + #endif +#endif +#ifdef USE_ANISOTROPY + #ifdef USE_ANISOTROPYMAP + mat2 anisotropyMat = mat2( anisotropyVector.x, anisotropyVector.y, - anisotropyVector.y, anisotropyVector.x ); + vec3 anisotropyPolar = texture2D( anisotropyMap, vAnisotropyMapUv ).rgb; + vec2 anisotropyV = anisotropyMat * normalize( 2.0 * anisotropyPolar.rg - vec2( 1.0 ) ) * anisotropyPolar.b; + #else + vec2 anisotropyV = anisotropyVector; + #endif + material.anisotropy = length( anisotropyV ); + if( material.anisotropy == 0.0 ) { + anisotropyV = vec2( 1.0, 0.0 ); + } else { + anisotropyV /= material.anisotropy; + material.anisotropy = saturate( material.anisotropy ); + } + 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`,Jg=`uniform sampler2D dfgLUT; +struct PhysicalMaterial { + vec3 diffuseColor; + vec3 diffuseContribution; + vec3 specularColor; + vec3 specularColorBlended; + float roughness; + float metalness; + float specularF90; + float dispersion; + #ifdef USE_CLEARCOAT + float clearcoat; + float clearcoatRoughness; + vec3 clearcoatF0; + float clearcoatF90; + #endif + #ifdef USE_IRIDESCENCE + float iridescence; + float iridescenceIOR; + float iridescenceThickness; + vec3 iridescenceFresnel; + vec3 iridescenceF0; + vec3 iridescenceFresnelDielectric; + vec3 iridescenceFresnelMetallic; + #endif + #ifdef USE_SHEEN + vec3 sheenColor; + float sheenRoughness; + #endif + #ifdef IOR + float ior; + #endif + #ifdef USE_TRANSMISSION + float transmission; + float transmissionAlpha; + float thickness; + float attenuationDistance; + vec3 attenuationColor; + #endif + #ifdef USE_ANISOTROPY + float anisotropy; + float alphaT; + vec3 anisotropyT; + vec3 anisotropyB; + #endif +}; +vec3 clearcoatSpecularDirect = vec3( 0.0 ); +vec3 clearcoatSpecularIndirect = vec3( 0.0 ); +vec3 sheenSpecularDirect = vec3( 0.0 ); +vec3 sheenSpecularIndirect = vec3(0.0 ); +vec3 Schlick_to_F0( const in vec3 f, const in float f90, const in float dotVH ) { + float x = clamp( 1.0 - dotVH, 0.0, 1.0 ); + float x2 = x * x; + float x5 = clamp( x * x2 * x2, 0.0, 0.9999 ); + return ( f - vec3( f90 ) * x5 ) / ( 1.0 - x5 ); +} +float V_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) { + float a2 = pow2( alpha ); + float gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) ); + float gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); +} +float D_GGX( const in float alpha, const in float dotNH ) { + float a2 = pow2( alpha ); + float denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; + return RECIPROCAL_PI * a2 / pow2( denom ); +} +#ifdef USE_ANISOTROPY + float V_GGX_SmithCorrelated_Anisotropic( const in float alphaT, const in float alphaB, const in float dotTV, const in float dotBV, const in float dotTL, const in float dotBL, const in float dotNV, const in float dotNL ) { + float gv = dotNL * length( vec3( alphaT * dotTV, alphaB * dotBV, dotNV ) ); + float gl = dotNV * length( vec3( alphaT * dotTL, alphaB * dotBL, dotNL ) ); + return 0.5 / max( gv + gl, EPSILON ); + } + float D_GGX_Anisotropic( const in float alphaT, const in float alphaB, const in float dotNH, const in float dotTH, const in float dotBH ) { + float a2 = alphaT * alphaB; + highp vec3 v = vec3( alphaB * dotTH, alphaT * dotBH, a2 * dotNH ); + highp float v2 = dot( v, v ); + float w2 = a2 / v2; + return RECIPROCAL_PI * a2 * pow2 ( w2 ); + } +#endif +#ifdef USE_CLEARCOAT + vec3 BRDF_GGX_Clearcoat( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material) { + vec3 f0 = material.clearcoatF0; + float f90 = material.clearcoatF90; + float roughness = material.clearcoatRoughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + return F * ( V * D ); + } +#endif +vec3 BRDF_GGX( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 f0 = material.specularColorBlended; + float f90 = material.specularF90; + float roughness = material.roughness; + float alpha = pow2( roughness ); + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float dotVH = saturate( dot( viewDir, halfDir ) ); + vec3 F = F_Schlick( f0, f90, dotVH ); + #ifdef USE_IRIDESCENCE + F = mix( F, material.iridescenceFresnel, material.iridescence ); + #endif + #ifdef USE_ANISOTROPY + float dotTL = dot( material.anisotropyT, lightDir ); + float dotTV = dot( material.anisotropyT, viewDir ); + float dotTH = dot( material.anisotropyT, halfDir ); + float dotBL = dot( material.anisotropyB, lightDir ); + float dotBV = dot( material.anisotropyB, viewDir ); + float dotBH = dot( material.anisotropyB, halfDir ); + float V = V_GGX_SmithCorrelated_Anisotropic( material.alphaT, alpha, dotTV, dotBV, dotTL, dotBL, dotNV, dotNL ); + float D = D_GGX_Anisotropic( material.alphaT, alpha, dotNH, dotTH, dotBH ); + #else + float V = V_GGX_SmithCorrelated( alpha, dotNL, dotNV ); + float D = D_GGX( alpha, dotNH ); + #endif + return F * ( V * D ); +} +vec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) { + const float LUT_SIZE = 64.0; + const float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE; + const float LUT_BIAS = 0.5 / LUT_SIZE; + float dotNV = saturate( dot( N, V ) ); + vec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) ); + uv = uv * LUT_SCALE + LUT_BIAS; + return uv; +} +float LTC_ClippedSphereFormFactor( const in vec3 f ) { + float l = length( f ); + return max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 ); +} +vec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) { + float x = dot( v1, v2 ); + float y = abs( x ); + float a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y; + float b = 3.4175940 + ( 4.1616724 + y ) * y; + float v = a / b; + float theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v; + return cross( v1, v2 ) * theta_sintheta; +} +vec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) { + vec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ]; + vec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ]; + vec3 lightNormal = cross( v1, v2 ); + if( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 ); + vec3 T1, T2; + T1 = normalize( V - N * dot( V, N ) ); + T2 = - cross( N, T1 ); + mat3 mat = mInv * transpose( mat3( T1, T2, N ) ); + vec3 coords[ 4 ]; + coords[ 0 ] = mat * ( rectCoords[ 0 ] - P ); + coords[ 1 ] = mat * ( rectCoords[ 1 ] - P ); + coords[ 2 ] = mat * ( rectCoords[ 2 ] - P ); + coords[ 3 ] = mat * ( rectCoords[ 3 ] - P ); + coords[ 0 ] = normalize( coords[ 0 ] ); + coords[ 1 ] = normalize( coords[ 1 ] ); + coords[ 2 ] = normalize( coords[ 2 ] ); + coords[ 3 ] = normalize( coords[ 3 ] ); + vec3 vectorFormFactor = vec3( 0.0 ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] ); + vectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] ); + float result = LTC_ClippedSphereFormFactor( vectorFormFactor ); + return vec3( result ); +} +#if defined( USE_SHEEN ) +float D_Charlie( float roughness, float dotNH ) { + float alpha = pow2( roughness ); + float invAlpha = 1.0 / alpha; + float cos2h = dotNH * dotNH; + float sin2h = max( 1.0 - cos2h, 0.0078125 ); + return ( 2.0 + invAlpha ) * pow( sin2h, invAlpha * 0.5 ) / ( 2.0 * PI ); +} +float V_Neubelt( float dotNV, float dotNL ) { + return saturate( 1.0 / ( 4.0 * ( dotNL + dotNV - dotNL * dotNV ) ) ); +} +vec3 BRDF_Sheen( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, vec3 sheenColor, const in float sheenRoughness ) { + vec3 halfDir = normalize( lightDir + viewDir ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + float dotNH = saturate( dot( normal, halfDir ) ); + float D = D_Charlie( sheenRoughness, dotNH ); + float V = V_Neubelt( dotNV, dotNL ); + return sheenColor * ( D * V ); +} +#endif +float IBLSheenBRDF( const in vec3 normal, const in vec3 viewDir, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + float r2 = roughness * roughness; + float rInv = 1.0 / ( roughness + 0.1 ); + float a = -1.9362 + 1.0678 * roughness + 0.4573 * r2 - 0.8469 * rInv; + float b = -0.6014 + 0.5538 * roughness - 0.4670 * r2 - 0.1255 * rInv; + float DG = exp( a * dotNV + b ); + return saturate( DG ); +} +vec3 EnvironmentBRDF( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness ) { + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + return specularColor * fab.x + specularF90 * fab.y; +} +#ifdef USE_IRIDESCENCE +void computeMultiscatteringIridescence( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float iridescence, const in vec3 iridescenceF0, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#else +void computeMultiscattering( const in vec3 normal, const in vec3 viewDir, const in vec3 specularColor, const in float specularF90, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) { +#endif + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 fab = texture2D( dfgLUT, vec2( roughness, dotNV ) ).rg; + #ifdef USE_IRIDESCENCE + vec3 Fr = mix( specularColor, iridescenceF0, iridescence ); + #else + vec3 Fr = specularColor; + #endif + vec3 FssEss = Fr * fab.x + specularF90 * fab.y; + float Ess = fab.x + fab.y; + float Ems = 1.0 - Ess; + vec3 Favg = Fr + ( 1.0 - Fr ) * 0.047619; vec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg ); + singleScatter += FssEss; + multiScatter += Fms * Ems; +} +vec3 BRDF_GGX_Multiscatter( const in vec3 lightDir, const in vec3 viewDir, const in vec3 normal, const in PhysicalMaterial material ) { + vec3 singleScatter = BRDF_GGX( lightDir, viewDir, normal, material ); + float dotNL = saturate( dot( normal, lightDir ) ); + float dotNV = saturate( dot( normal, viewDir ) ); + vec2 dfgV = texture2D( dfgLUT, vec2( material.roughness, dotNV ) ).rg; + vec2 dfgL = texture2D( dfgLUT, vec2( material.roughness, dotNL ) ).rg; + vec3 FssEss_V = material.specularColorBlended * dfgV.x + material.specularF90 * dfgV.y; + vec3 FssEss_L = material.specularColorBlended * dfgL.x + material.specularF90 * dfgL.y; + float Ess_V = dfgV.x + dfgV.y; + float Ess_L = dfgL.x + dfgL.y; + float Ems_V = 1.0 - Ess_V; + float Ems_L = 1.0 - Ess_L; + vec3 Favg = material.specularColorBlended + ( 1.0 - material.specularColorBlended ) * 0.047619; + vec3 Fms = FssEss_V * FssEss_L * Favg / ( 1.0 - Ems_V * Ems_L * Favg + EPSILON ); + float compensationFactor = Ems_V * Ems_L; + vec3 multiScatter = Fms * compensationFactor; + return singleScatter + multiScatter; +} +#if NUM_RECT_AREA_LIGHTS > 0 + void RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 normal = geometryNormal; + vec3 viewDir = geometryViewDir; + vec3 position = geometryPosition; + vec3 lightPos = rectAreaLight.position; + vec3 halfWidth = rectAreaLight.halfWidth; + vec3 halfHeight = rectAreaLight.halfHeight; + vec3 lightColor = rectAreaLight.color; + float roughness = material.roughness; + vec3 rectCoords[ 4 ]; + rectCoords[ 0 ] = lightPos + halfWidth - halfHeight; rectCoords[ 1 ] = lightPos - halfWidth - halfHeight; + rectCoords[ 2 ] = lightPos - halfWidth + halfHeight; + rectCoords[ 3 ] = lightPos + halfWidth + halfHeight; + vec2 uv = LTC_Uv( normal, viewDir, roughness ); + vec4 t1 = texture2D( ltc_1, uv ); + vec4 t2 = texture2D( ltc_2, uv ); + mat3 mInv = mat3( + vec3( t1.x, 0, t1.y ), + vec3( 0, 1, 0 ), + vec3( t1.z, 0, t1.w ) + ); + vec3 fresnel = ( material.specularColorBlended * t2.x + ( material.specularF90 - material.specularColorBlended ) * t2.y ); + reflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords ); + reflectedLight.directDiffuse += lightColor * material.diffuseContribution * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords ); + #ifdef USE_CLEARCOAT + vec3 Ncc = geometryClearcoatNormal; + vec2 uvClearcoat = LTC_Uv( Ncc, viewDir, material.clearcoatRoughness ); + vec4 t1Clearcoat = texture2D( ltc_1, uvClearcoat ); + vec4 t2Clearcoat = texture2D( ltc_2, uvClearcoat ); + mat3 mInvClearcoat = mat3( + vec3( t1Clearcoat.x, 0, t1Clearcoat.y ), + vec3( 0, 1, 0 ), + vec3( t1Clearcoat.z, 0, t1Clearcoat.w ) + ); + vec3 fresnelClearcoat = material.clearcoatF0 * t2Clearcoat.x + ( material.clearcoatF90 - material.clearcoatF0 ) * t2Clearcoat.y; + clearcoatSpecularDirect += lightColor * fresnelClearcoat * LTC_Evaluate( Ncc, viewDir, position, mInvClearcoat, rectCoords ); + #endif + } +#endif +void RE_Direct_Physical( const in IncidentLight directLight, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + float dotNL = saturate( dot( geometryNormal, directLight.direction ) ); + vec3 irradiance = dotNL * directLight.color; + #ifdef USE_CLEARCOAT + float dotNLcc = saturate( dot( geometryClearcoatNormal, directLight.direction ) ); + vec3 ccIrradiance = dotNLcc * directLight.color; + clearcoatSpecularDirect += ccIrradiance * BRDF_GGX_Clearcoat( directLight.direction, geometryViewDir, geometryClearcoatNormal, material ); + #endif + #ifdef USE_SHEEN + + sheenSpecularDirect += irradiance * BRDF_Sheen( directLight.direction, geometryViewDir, geometryNormal, material.sheenColor, material.sheenRoughness ); + + float sheenAlbedoV = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenAlbedoL = IBLSheenBRDF( geometryNormal, directLight.direction, material.sheenRoughness ); + + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * max( sheenAlbedoV, sheenAlbedoL ); + + irradiance *= sheenEnergyComp; + + #endif + reflectedLight.directSpecular += irradiance * BRDF_GGX_Multiscatter( directLight.direction, geometryViewDir, geometryNormal, material ); + reflectedLight.directDiffuse += irradiance * BRDF_Lambert( material.diffuseContribution ); +} +void RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) { + vec3 diffuse = irradiance * BRDF_Lambert( material.diffuseContribution ); + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + diffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectDiffuse += diffuse; +} +void RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in vec3 geometryPosition, const in vec3 geometryNormal, const in vec3 geometryViewDir, const in vec3 geometryClearcoatNormal, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) { + #ifdef USE_CLEARCOAT + clearcoatSpecularIndirect += clearcoatRadiance * EnvironmentBRDF( geometryClearcoatNormal, geometryViewDir, material.clearcoatF0, material.clearcoatF90, material.clearcoatRoughness ); + #endif + #ifdef USE_SHEEN + sheenSpecularIndirect += irradiance * material.sheenColor * IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ) * RECIPROCAL_PI; + #endif + vec3 singleScatteringDielectric = vec3( 0.0 ); + vec3 multiScatteringDielectric = vec3( 0.0 ); + vec3 singleScatteringMetallic = vec3( 0.0 ); + vec3 multiScatteringMetallic = vec3( 0.0 ); + #ifdef USE_IRIDESCENCE + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.iridescence, material.iridescenceFresnelDielectric, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscatteringIridescence( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.iridescence, material.iridescenceFresnelMetallic, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #else + computeMultiscattering( geometryNormal, geometryViewDir, material.specularColor, material.specularF90, material.roughness, singleScatteringDielectric, multiScatteringDielectric ); + computeMultiscattering( geometryNormal, geometryViewDir, material.diffuseColor, material.specularF90, material.roughness, singleScatteringMetallic, multiScatteringMetallic ); + #endif + vec3 singleScattering = mix( singleScatteringDielectric, singleScatteringMetallic, material.metalness ); + vec3 multiScattering = mix( multiScatteringDielectric, multiScatteringMetallic, material.metalness ); + vec3 totalScatteringDielectric = singleScatteringDielectric + multiScatteringDielectric; + vec3 diffuse = material.diffuseContribution * ( 1.0 - totalScatteringDielectric ); + vec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI; + vec3 indirectSpecular = radiance * singleScattering; + indirectSpecular += multiScattering * cosineWeightedIrradiance; + vec3 indirectDiffuse = diffuse * cosineWeightedIrradiance; + #ifdef USE_SHEEN + float sheenAlbedo = IBLSheenBRDF( geometryNormal, geometryViewDir, material.sheenRoughness ); + float sheenEnergyComp = 1.0 - max3( material.sheenColor ) * sheenAlbedo; + indirectSpecular *= sheenEnergyComp; + indirectDiffuse *= sheenEnergyComp; + #endif + reflectedLight.indirectSpecular += indirectSpecular; + reflectedLight.indirectDiffuse += indirectDiffuse; +} +#define RE_Direct RE_Direct_Physical +#define RE_Direct_RectArea RE_Direct_RectArea_Physical +#define RE_IndirectDiffuse RE_IndirectDiffuse_Physical +#define RE_IndirectSpecular RE_IndirectSpecular_Physical +float computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) { + return saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion ); +}`,jg=` +vec3 geometryPosition = - vViewPosition; +vec3 geometryNormal = normal; +vec3 geometryViewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition ); +vec3 geometryClearcoatNormal = vec3( 0.0 ); +#ifdef USE_CLEARCOAT + geometryClearcoatNormal = clearcoatNormal; +#endif +#ifdef USE_IRIDESCENCE + float dotNVi = saturate( dot( normal, geometryViewDir ) ); + if ( material.iridescenceThickness == 0.0 ) { + material.iridescence = 0.0; + } else { + material.iridescence = saturate( material.iridescence ); + } + if ( material.iridescence > 0.0 ) { + material.iridescenceFresnelDielectric = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.specularColor ); + material.iridescenceFresnelMetallic = evalIridescence( 1.0, material.iridescenceIOR, dotNVi, material.iridescenceThickness, material.diffuseColor ); + material.iridescenceFresnel = mix( material.iridescenceFresnelDielectric, material.iridescenceFresnelMetallic, material.metalness ); + material.iridescenceF0 = Schlick_to_F0( material.iridescenceFresnel, 1.0, dotNVi ); + } +#endif +IncidentLight directLight; +#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct ) + PointLight pointLight; + #if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0 + PointLightShadow pointLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) { + pointLight = pointLights[ i ]; + getPointLightInfo( pointLight, geometryPosition, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS ) && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + pointLightShadow = pointLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowIntensity, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct ) + SpotLight spotLight; + vec4 spotColor; + vec3 spotLightCoord; + bool inSpotLightMap; + #if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) { + spotLight = spotLights[ i ]; + getSpotLightInfo( spotLight, geometryPosition, directLight ); + #if ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #define SPOT_LIGHT_MAP_INDEX UNROLLED_LOOP_INDEX + #elif ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + #define SPOT_LIGHT_MAP_INDEX NUM_SPOT_LIGHT_MAPS + #else + #define SPOT_LIGHT_MAP_INDEX ( UNROLLED_LOOP_INDEX - NUM_SPOT_LIGHT_SHADOWS + NUM_SPOT_LIGHT_SHADOWS_WITH_MAPS ) + #endif + #if ( SPOT_LIGHT_MAP_INDEX < NUM_SPOT_LIGHT_MAPS ) + spotLightCoord = vSpotLightCoord[ i ].xyz / vSpotLightCoord[ i ].w; + inSpotLightMap = all( lessThan( abs( spotLightCoord * 2. - 1. ), vec3( 1.0 ) ) ); + spotColor = texture2D( spotLightMap[ SPOT_LIGHT_MAP_INDEX ], spotLightCoord.xy ); + directLight.color = inSpotLightMap ? directLight.color * spotColor.rgb : directLight.color; + #endif + #undef SPOT_LIGHT_MAP_INDEX + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + spotLightShadow = spotLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowIntensity, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct ) + DirectionalLight directionalLight; + #if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLightShadow; + #endif + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) { + directionalLight = directionalLights[ i ]; + getDirectionalLightInfo( directionalLight, directLight ); + #if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS ) + directionalLightShadow = directionalLightShadows[ i ]; + directLight.color *= ( directLight.visible && receiveShadow ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowIntensity, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + #endif + RE_Direct( directLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea ) + RectAreaLight rectAreaLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) { + rectAreaLight = rectAreaLights[ i ]; + RE_Direct_RectArea( rectAreaLight, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); + } + #pragma unroll_loop_end +#endif +#if defined( RE_IndirectDiffuse ) + vec3 iblIrradiance = vec3( 0.0 ); + vec3 irradiance = getAmbientLightIrradiance( ambientLightColor ); + #if defined( USE_LIGHT_PROBES ) + irradiance += getLightProbeIrradiance( lightProbe, geometryNormal ); + #endif + #if ( NUM_HEMI_LIGHTS > 0 ) + #pragma unroll_loop_start + for ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) { + irradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometryNormal ); + } + #pragma unroll_loop_end + #endif + #ifdef USE_LIGHT_PROBES_GRID + vec3 probeWorldPos = ( ( vec4( geometryPosition, 1.0 ) - viewMatrix[ 3 ] ) * viewMatrix ).xyz; + vec3 probeWorldNormal = transformNormalByInverseViewMatrix( geometryNormal, viewMatrix ); + irradiance += getLightProbeGridIrradiance( probeWorldPos, probeWorldNormal ); + #endif +#endif +#if defined( RE_IndirectSpecular ) + vec3 radiance = vec3( 0.0 ); + vec3 clearcoatRadiance = vec3( 0.0 ); +#endif`,Qg=`#if defined( RE_IndirectDiffuse ) + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + vec3 lightMapIrradiance = lightMapTexel.rgb * lightMapIntensity; + irradiance += lightMapIrradiance; + #endif + #if defined( USE_ENVMAP ) && defined( ENVMAP_TYPE_CUBE_UV ) + #if defined( STANDARD ) || defined( LAMBERT ) || defined( PHONG ) + iblIrradiance += getIBLIrradiance( geometryNormal ); + #endif + #endif +#endif +#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular ) + #ifdef USE_ANISOTROPY + radiance += getIBLAnisotropyRadiance( geometryViewDir, geometryNormal, material.roughness, material.anisotropyB, material.anisotropy ); + #else + radiance += getIBLRadiance( geometryViewDir, geometryNormal, material.roughness ); + #endif + #ifdef USE_CLEARCOAT + clearcoatRadiance += getIBLRadiance( geometryViewDir, geometryClearcoatNormal, material.clearcoatRoughness ); + #endif +#endif`,e_=`#if defined( RE_IndirectDiffuse ) + #if defined( LAMBERT ) || defined( PHONG ) + irradiance += iblIrradiance; + #endif + RE_IndirectDiffuse( irradiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif +#if defined( RE_IndirectSpecular ) + RE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometryPosition, geometryNormal, geometryViewDir, geometryClearcoatNormal, material, reflectedLight ); +#endif`,t_=`#ifdef USE_LIGHT_PROBES_GRID +uniform highp sampler3D probesSH; +uniform vec3 probesMin; +uniform vec3 probesMax; +uniform vec3 probesResolution; +vec3 getLightProbeGridIrradiance( vec3 worldPos, vec3 worldNormal ) { + vec3 res = probesResolution; + vec3 gridRange = probesMax - probesMin; + vec3 resMinusOne = res - 1.0; + vec3 probeSpacing = gridRange / resMinusOne; + vec3 samplePos = worldPos + worldNormal * probeSpacing * 0.5; + vec3 uvw = clamp( ( samplePos - probesMin ) / gridRange, 0.0, 1.0 ); + uvw = uvw * resMinusOne / res + 0.5 / res; + float nz = res.z; + float paddedSlices = nz + 2.0; + float atlasDepth = 7.0 * paddedSlices; + float uvZBase = uvw.z * nz + 1.0; + vec4 s0 = texture( probesSH, vec3( uvw.xy, ( uvZBase ) / atlasDepth ) ); + vec4 s1 = texture( probesSH, vec3( uvw.xy, ( uvZBase + paddedSlices ) / atlasDepth ) ); + vec4 s2 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 2.0 * paddedSlices ) / atlasDepth ) ); + vec4 s3 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 3.0 * paddedSlices ) / atlasDepth ) ); + vec4 s4 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 4.0 * paddedSlices ) / atlasDepth ) ); + vec4 s5 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 5.0 * paddedSlices ) / atlasDepth ) ); + vec4 s6 = texture( probesSH, vec3( uvw.xy, ( uvZBase + 6.0 * paddedSlices ) / atlasDepth ) ); + vec3 c0 = s0.xyz; + vec3 c1 = vec3( s0.w, s1.xy ); + vec3 c2 = vec3( s1.zw, s2.x ); + vec3 c3 = s2.yzw; + vec3 c4 = s3.xyz; + vec3 c5 = vec3( s3.w, s4.xy ); + vec3 c6 = vec3( s4.zw, s5.x ); + vec3 c7 = s5.yzw; + vec3 c8 = s6.xyz; + float x = worldNormal.x, y = worldNormal.y, z = worldNormal.z; + vec3 result = c0 * 0.886227; + result += c1 * 2.0 * 0.511664 * y; + result += c2 * 2.0 * 0.511664 * z; + result += c3 * 2.0 * 0.511664 * x; + result += c4 * 2.0 * 0.429043 * x * y; + result += c5 * 2.0 * 0.429043 * y * z; + result += c6 * ( 0.743125 * z * z - 0.247708 ); + result += c7 * 2.0 * 0.429043 * x * z; + result += c8 * 0.429043 * ( x * x - y * y ); + return max( result, vec3( 0.0 ) ); +} +#endif`,n_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + gl_FragDepth = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5; +#endif`,i_=`#if defined( USE_LOGARITHMIC_DEPTH_BUFFER ) + uniform float logDepthBufFC; + varying float vFragDepth; + varying float vIsPerspective; +#endif`,s_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + varying float vFragDepth; + varying float vIsPerspective; +#endif`,r_=`#ifdef USE_LOGARITHMIC_DEPTH_BUFFER + vFragDepth = 1.0 + gl_Position.w; + vIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) ); +#endif`,a_=`#ifdef USE_MAP + vec4 sampledDiffuseColor = texture2D( map, vMapUv ); + #ifdef DECODE_VIDEO_TEXTURE + sampledDiffuseColor = sRGBTransferEOTF( sampledDiffuseColor ); + #endif + diffuseColor *= sampledDiffuseColor; +#endif`,o_=`#ifdef USE_MAP + uniform sampler2D map; +#endif`,l_=`#if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + #if defined( USE_POINTS_UV ) + vec2 uv = vUv; + #else + vec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy; + #endif +#endif +#ifdef USE_MAP + diffuseColor *= texture2D( map, uv ); +#endif +#ifdef USE_ALPHAMAP + diffuseColor.a *= texture2D( alphaMap, uv ).g; +#endif`,c_=`#if defined( USE_POINTS_UV ) + varying vec2 vUv; +#else + #if defined( USE_MAP ) || defined( USE_ALPHAMAP ) + uniform mat3 uvTransform; + #endif +#endif +#ifdef USE_MAP + uniform sampler2D map; +#endif +#ifdef USE_ALPHAMAP + uniform sampler2D alphaMap; +#endif`,u_=`float metalnessFactor = metalness; +#ifdef USE_METALNESSMAP + vec4 texelMetalness = texture2D( metalnessMap, vMetalnessMapUv ); + metalnessFactor *= texelMetalness.b; +#endif`,h_=`#ifdef USE_METALNESSMAP + uniform sampler2D metalnessMap; +#endif`,d_=`#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`,f_=`#if defined( USE_MORPHCOLORS ) + vColor *= morphTargetBaseInfluence; + for ( int i = 0; i < MORPHTARGETS_COUNT; i ++ ) { + #if defined( USE_COLOR_ALPHA ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ) * morphTargetInfluences[ i ]; + #elif defined( USE_COLOR ) + if ( morphTargetInfluences[ i ] != 0.0 ) vColor += getMorph( gl_VertexID, i, 2 ).rgb * morphTargetInfluences[ i ]; + #endif + } +#endif`,p_=`#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`,m_=`#ifdef USE_MORPHTARGETS + #ifndef USE_INSTANCING_MORPH + uniform float morphTargetBaseInfluence; + uniform float morphTargetInfluences[ MORPHTARGETS_COUNT ]; + #endif + uniform sampler2DArray morphTargetsTexture; + uniform ivec2 morphTargetsTextureSize; + vec4 getMorph( const in int vertexIndex, const in int morphTargetIndex, const in int offset ) { + int texelIndex = vertexIndex * MORPHTARGETS_TEXTURE_STRIDE + offset; + int y = texelIndex / morphTargetsTextureSize.x; + int x = texelIndex - y * morphTargetsTextureSize.x; + ivec3 morphUV = ivec3( x, y, morphTargetIndex ); + return texelFetch( morphTargetsTexture, morphUV, 0 ); + } +#endif`,g_=`#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`,__=`float faceDirection = gl_FrontFacing ? 1.0 : - 1.0; +#ifdef FLAT_SHADED + vec3 fdx = dFdx( vViewPosition ); + vec3 fdy = dFdy( vViewPosition ); + vec3 normal = normalize( cross( fdx, fdy ) ); +#else + vec3 normal = normalize( vNormal ); + #ifdef DOUBLE_SIDED + normal *= faceDirection; + #endif +#endif +#if defined( USE_NORMALMAP_TANGENTSPACE ) || defined( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) + #ifdef USE_TANGENT + mat3 tbn = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn = getTangentFrame( - vViewPosition, normal, + #if defined( USE_NORMALMAP ) + vNormalMapUv + #elif defined( USE_CLEARCOAT_NORMALMAP ) + vClearcoatNormalMapUv + #else + vUv + #endif + ); + #endif + #ifdef DOUBLE_SIDED + tbn[0] *= faceDirection; + tbn[1] *= faceDirection; + #endif +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + #ifdef USE_TANGENT + mat3 tbn2 = mat3( normalize( vTangent ), normalize( vBitangent ), normal ); + #else + mat3 tbn2 = getTangentFrame( - vViewPosition, normal, vClearcoatNormalMapUv ); + #endif + #ifdef DOUBLE_SIDED + tbn2[0] *= faceDirection; + tbn2[1] *= faceDirection; + #endif +#endif +vec3 nonPerturbedNormal = normal;`,x_=`#ifdef USE_NORMALMAP_OBJECTSPACE + normal = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #ifdef FLIP_SIDED + normal = - normal; + #endif + #ifdef DOUBLE_SIDED + normal = normal * faceDirection; + #endif + normal = normalize( normalMatrix * normal ); +#elif defined( USE_NORMALMAP_TANGENTSPACE ) + vec3 mapN = texture2D( normalMap, vNormalMapUv ).xyz * 2.0 - 1.0; + #if defined( USE_PACKED_NORMALMAP ) + mapN = vec3( mapN.xy, sqrt( saturate( 1.0 - dot( mapN.xy, mapN.xy ) ) ) ); + #endif + mapN.xy *= normalScale; + normal = normalize( tbn * mapN ); +#elif defined( USE_BUMPMAP ) + normal = perturbNormalArb( - vViewPosition, normal, dHdxy_fwd(), faceDirection ); +#endif`,y_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,v_=`#ifndef FLAT_SHADED + varying vec3 vNormal; + #ifdef USE_TANGENT + varying vec3 vTangent; + varying vec3 vBitangent; + #endif +#endif`,S_=`#ifndef FLAT_SHADED + vNormal = normalize( transformedNormal ); + #ifdef USE_TANGENT + vTangent = normalize( transformedTangent ); + vBitangent = normalize( cross( vNormal, vTangent ) * tangent.w ); + #ifdef FLIP_SIDED + vBitangent = - vBitangent; + #endif + #endif +#endif`,b_=`#ifdef USE_NORMALMAP + uniform sampler2D normalMap; + uniform vec2 normalScale; +#endif +#ifdef USE_NORMALMAP_OBJECTSPACE + uniform mat3 normalMatrix; +#endif +#if ! defined ( USE_TANGENT ) && ( defined ( USE_NORMALMAP_TANGENTSPACE ) || defined ( USE_CLEARCOAT_NORMALMAP ) || defined( USE_ANISOTROPY ) ) + mat3 getTangentFrame( vec3 eye_pos, vec3 surf_norm, vec2 uv ) { + vec3 q0 = dFdx( eye_pos.xyz ); + vec3 q1 = dFdy( eye_pos.xyz ); + vec2 st0 = dFdx( uv.st ); + vec2 st1 = dFdy( uv.st ); + vec3 N = surf_norm; + vec3 q1perp = cross( q1, N ); + vec3 q0perp = cross( N, q0 ); + vec3 T = q1perp * st0.x + q0perp * st1.x; + vec3 B = q1perp * st0.y + q0perp * st1.y; + float det = max( dot( T, T ), dot( B, B ) ); + float scale = ( det == 0.0 ) ? 0.0 : inversesqrt( det ); + return mat3( T * scale, B * scale, N ); + } +#endif`,M_=`#ifdef USE_CLEARCOAT + vec3 clearcoatNormal = nonPerturbedNormal; +#endif`,A_=`#ifdef USE_CLEARCOAT_NORMALMAP + vec3 clearcoatMapN = texture2D( clearcoatNormalMap, vClearcoatNormalMapUv ).xyz * 2.0 - 1.0; + clearcoatMapN.xy *= clearcoatNormalScale; + clearcoatNormal = normalize( tbn2 * clearcoatMapN ); +#endif`,E_=`#ifdef USE_CLEARCOATMAP + uniform sampler2D clearcoatMap; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform sampler2D clearcoatNormalMap; + uniform vec2 clearcoatNormalScale; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform sampler2D clearcoatRoughnessMap; +#endif`,T_=`#ifdef USE_IRIDESCENCEMAP + uniform sampler2D iridescenceMap; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform sampler2D iridescenceThicknessMap; +#endif`,C_=`#ifdef OPAQUE +diffuseColor.a = 1.0; +#endif +#ifdef USE_TRANSMISSION +diffuseColor.a *= material.transmissionAlpha; +#endif +gl_FragColor = vec4( outgoingLight, diffuseColor.a );`,w_=`vec3 packNormalToRGB( const in vec3 normal ) { + return normalize( normal ) * 0.5 + 0.5; +} +vec3 unpackRGBToNormal( const in vec3 rgb ) { + return 2.0 * rgb.xyz - 1.0; +} +const float PackUpscale = 256. / 255.;const float UnpackDownscale = 255. / 256.;const float ShiftRight8 = 1. / 256.; +const float Inv255 = 1. / 255.; +const vec4 PackFactors = vec4( 1.0, 256.0, 256.0 * 256.0, 256.0 * 256.0 * 256.0 ); +const vec2 UnpackFactors2 = vec2( UnpackDownscale, 1.0 / PackFactors.g ); +const vec3 UnpackFactors3 = vec3( UnpackDownscale / PackFactors.rg, 1.0 / PackFactors.b ); +const vec4 UnpackFactors4 = vec4( UnpackDownscale / PackFactors.rgb, 1.0 / PackFactors.a ); +vec4 packDepthToRGBA( const in float v ) { + if( v <= 0.0 ) + return vec4( 0., 0., 0., 0. ); + if( v >= 1.0 ) + return vec4( 1., 1., 1., 1. ); + float vuf; + float af = modf( v * PackFactors.a, vuf ); + float bf = modf( vuf * ShiftRight8, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec4( vuf * Inv255, gf * PackUpscale, bf * PackUpscale, af ); +} +vec3 packDepthToRGB( const in float v ) { + if( v <= 0.0 ) + return vec3( 0., 0., 0. ); + if( v >= 1.0 ) + return vec3( 1., 1., 1. ); + float vuf; + float bf = modf( v * PackFactors.b, vuf ); + float gf = modf( vuf * ShiftRight8, vuf ); + return vec3( vuf * Inv255, gf * PackUpscale, bf ); +} +vec2 packDepthToRG( const in float v ) { + if( v <= 0.0 ) + return vec2( 0., 0. ); + if( v >= 1.0 ) + return vec2( 1., 1. ); + float vuf; + float gf = modf( v * 256., vuf ); + return vec2( vuf * Inv255, gf ); +} +float unpackRGBAToDepth( const in vec4 v ) { + return dot( v, UnpackFactors4 ); +} +float unpackRGBToDepth( const in vec3 v ) { + return dot( v, UnpackFactors3 ); +} +float unpackRGToDepth( const in vec2 v ) { + return v.r * UnpackFactors2.r + v.g * UnpackFactors2.g; +} +vec4 pack2HalfToRGBA( const in vec2 v ) { + vec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ) ); + return vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w ); +} +vec2 unpackRGBATo2Half( const in vec4 v ) { + return vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) ); +} +float viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) { + return ( viewZ + near ) / ( near - far ); +} +float orthographicDepthToViewZ( const in float depth, const in float near, const in float far ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + + return depth * ( far - near ) - far; + #else + return depth * ( near - far ) - near; + #endif +} +float viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) { + return ( ( near + viewZ ) * far ) / ( ( far - near ) * viewZ ); +} +float perspectiveDepthToViewZ( const in float depth, const in float near, const in float far ) { + + #ifdef USE_REVERSED_DEPTH_BUFFER + return ( near * far ) / ( ( near - far ) * depth - near ); + #else + return ( near * far ) / ( ( far - near ) * depth - far ); + #endif +}`,R_=`#ifdef PREMULTIPLIED_ALPHA + gl_FragColor.rgb *= gl_FragColor.a; +#endif`,D_=`vec4 mvPosition = vec4( transformed, 1.0 ); +#ifdef USE_BATCHING + mvPosition = batchingMatrix * mvPosition; +#endif +#ifdef USE_INSTANCING + mvPosition = instanceMatrix * mvPosition; +#endif +mvPosition = modelViewMatrix * mvPosition; +gl_Position = projectionMatrix * mvPosition;`,L_=`#ifdef DITHERING + gl_FragColor.rgb = dithering( gl_FragColor.rgb ); +#endif`,I_=`#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`,P_=`float roughnessFactor = roughness; +#ifdef USE_ROUGHNESSMAP + vec4 texelRoughness = texture2D( roughnessMap, vRoughnessMapUv ); + roughnessFactor *= texelRoughness.g; +#endif`,U_=`#ifdef USE_ROUGHNESSMAP + uniform sampler2D roughnessMap; +#endif`,O_=`#if NUM_SPOT_LIGHT_COORDS > 0 + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#if NUM_SPOT_LIGHT_MAPS > 0 + uniform sampler2D spotLightMap[ NUM_SPOT_LIGHT_MAPS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #else + uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #else + uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #elif defined( SHADOWMAP_TYPE_BASIC ) + uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float interleavedGradientNoise( vec2 position ) { + return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) ); + } + vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) { + const float goldenAngle = 2.399963229728653; + float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) ); + float theta = float( sampleIndex ) * goldenAngle + phi; + return vec2( cos( theta ), sin( theta ) ) * r; + } + #endif + #if defined( SHADOWMAP_TYPE_PCF ) + float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + shadowCoord.z += shadowBias; + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 texelSize = vec2( 1.0 ) / shadowMapSize; + float radius = shadowRadius * texelSize.x; + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + shadow = ( + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) + + texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_VSM ) + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg; + float mean = distribution.x; + float variance = distribution.y * distribution.y; + #ifdef USE_REVERSED_DEPTH_BUFFER + float hard_shadow = step( mean, shadowCoord.z ); + #else + float hard_shadow = step( shadowCoord.z, mean ); + #endif + + if ( hard_shadow == 1.0 ) { + shadow = 1.0; + } else { + variance = max( variance, 0.0000001 ); + float d = shadowCoord.z - mean; + float p_max = variance / ( variance + d * d ); + p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 ); + shadow = max( hard_shadow, p_max ); + } + } + return mix( 1.0, shadow, shadowIntensity ); + } + #else + float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) { + float shadow = 1.0; + shadowCoord.xyz /= shadowCoord.w; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadowCoord.z -= shadowBias; + #else + shadowCoord.z += shadowBias; + #endif + bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0; + bool frustumTest = inFrustum && shadowCoord.z <= 1.0; + if ( frustumTest ) { + float depth = texture2D( shadowMap, shadowCoord.xy ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + shadow = step( depth, shadowCoord.z ); + #else + shadow = step( shadowCoord.z, depth ); + #endif + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #if defined( SHADOWMAP_TYPE_PCF ) + float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 bd3D = normalize( lightToPosition ); + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + #ifdef USE_REVERSED_DEPTH_BUFFER + float dp = ( shadowCameraNear * ( shadowCameraFar - viewSpaceZ ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp -= shadowBias; + #else + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + #endif + float texelSize = shadowRadius / shadowMapSize.x; + vec3 absDir = abs( bd3D ); + vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 ); + tangent = normalize( cross( bd3D, tangent ) ); + vec3 bitangent = cross( bd3D, tangent ); + float phi = interleavedGradientNoise( gl_FragCoord.xy ) * PI2; + vec2 sample0 = vogelDiskSample( 0, 5, phi ); + vec2 sample1 = vogelDiskSample( 1, 5, phi ); + vec2 sample2 = vogelDiskSample( 2, 5, phi ); + vec2 sample3 = vogelDiskSample( 3, 5, phi ); + vec2 sample4 = vogelDiskSample( 4, 5, phi ); + shadow = ( + texture( shadowMap, vec4( bd3D + ( tangent * sample0.x + bitangent * sample0.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample1.x + bitangent * sample1.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample2.x + bitangent * sample2.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample3.x + bitangent * sample3.y ) * texelSize, dp ) ) + + texture( shadowMap, vec4( bd3D + ( tangent * sample4.x + bitangent * sample4.y ) * texelSize, dp ) ) + ) * 0.2; + } + return mix( 1.0, shadow, shadowIntensity ); + } + #elif defined( SHADOWMAP_TYPE_BASIC ) + float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) { + float shadow = 1.0; + vec3 lightToPosition = shadowCoord.xyz; + vec3 absVec = abs( lightToPosition ); + float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z ); + if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) { + float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) ); + dp += shadowBias; + vec3 bd3D = normalize( lightToPosition ); + float depth = textureCube( shadowMap, bd3D ).r; + #ifdef USE_REVERSED_DEPTH_BUFFER + depth = 1.0 - depth; + #endif + shadow = step( dp, depth ); + } + return mix( 1.0, shadow, shadowIntensity ); + } + #endif + #endif +#endif`,N_=`#if NUM_SPOT_LIGHT_COORDS > 0 + uniform mat4 spotLightMatrix[ NUM_SPOT_LIGHT_COORDS ]; + varying vec4 vSpotLightCoord[ NUM_SPOT_LIGHT_COORDS ]; +#endif +#ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + uniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ]; + varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ]; + struct DirectionalLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ]; + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + struct SpotLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + }; + uniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ]; + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + uniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ]; + varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ]; + struct PointLightShadow { + float shadowIntensity; + float shadowBias; + float shadowNormalBias; + float shadowRadius; + vec2 shadowMapSize; + float shadowCameraNear; + float shadowCameraFar; + }; + uniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ]; + #endif +#endif`,k_=`#if ( defined( USE_SHADOWMAP ) && ( NUM_DIR_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0 ) ) || ( NUM_SPOT_LIGHT_COORDS > 0 ) + #ifdef HAS_NORMAL + vec3 shadowWorldNormal = transformNormalByInverseViewMatrix( transformedNormal, viewMatrix ); + #else + vec3 shadowWorldNormal = vec3( 0.0 ); + #endif + vec4 shadowWorldPosition; +#endif +#if defined( USE_SHADOWMAP ) + #if NUM_DIR_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 ); + vDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + shadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 ); + vPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end + #endif +#endif +#if NUM_SPOT_LIGHT_COORDS > 0 + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_COORDS; i ++ ) { + shadowWorldPosition = worldPosition; + #if ( defined( USE_SHADOWMAP ) && UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS ) + shadowWorldPosition.xyz += shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias; + #endif + vSpotLightCoord[ i ] = spotLightMatrix[ i ] * shadowWorldPosition; + } + #pragma unroll_loop_end +#endif`,F_=`float getShadowMask() { + float shadow = 1.0; + #ifdef USE_SHADOWMAP + #if NUM_DIR_LIGHT_SHADOWS > 0 + DirectionalLightShadow directionalLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) { + directionalLight = directionalLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowIntensity, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_SPOT_LIGHT_SHADOWS > 0 + SpotLightShadow spotLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) { + spotLight = spotLightShadows[ i ]; + shadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowIntensity, spotLight.shadowBias, spotLight.shadowRadius, vSpotLightCoord[ i ] ) : 1.0; + } + #pragma unroll_loop_end + #endif + #if NUM_POINT_LIGHT_SHADOWS > 0 && ( defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_BASIC ) ) + PointLightShadow pointLight; + #pragma unroll_loop_start + for ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) { + pointLight = pointLightShadows[ i ]; + shadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowIntensity, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0; + } + #pragma unroll_loop_end + #endif + #endif + return shadow; +}`,B_=`#ifdef USE_SKINNING + mat4 boneMatX = getBoneMatrix( skinIndex.x ); + mat4 boneMatY = getBoneMatrix( skinIndex.y ); + mat4 boneMatZ = getBoneMatrix( skinIndex.z ); + mat4 boneMatW = getBoneMatrix( skinIndex.w ); +#endif`,H_=`#ifdef USE_SKINNING + uniform mat4 bindMatrix; + uniform mat4 bindMatrixInverse; + uniform highp sampler2D boneTexture; + mat4 getBoneMatrix( const in float i ) { + int size = textureSize( boneTexture, 0 ).x; + int j = int( i ) * 4; + int x = j % size; + int y = j / size; + vec4 v1 = texelFetch( boneTexture, ivec2( x, y ), 0 ); + vec4 v2 = texelFetch( boneTexture, ivec2( x + 1, y ), 0 ); + vec4 v3 = texelFetch( boneTexture, ivec2( x + 2, y ), 0 ); + vec4 v4 = texelFetch( boneTexture, ivec2( x + 3, y ), 0 ); + return mat4( v1, v2, v3, v4 ); + } +#endif`,z_=`#ifdef USE_SKINNING + vec4 skinVertex = bindMatrix * vec4( transformed, 1.0 ); + vec4 skinned = vec4( 0.0 ); + skinned += boneMatX * skinVertex * skinWeight.x; + skinned += boneMatY * skinVertex * skinWeight.y; + skinned += boneMatZ * skinVertex * skinWeight.z; + skinned += boneMatW * skinVertex * skinWeight.w; + transformed = ( bindMatrixInverse * skinned ).xyz; +#endif`,V_=`#ifdef USE_SKINNING + mat4 skinMatrix = mat4( 0.0 ); + skinMatrix += skinWeight.x * boneMatX; + skinMatrix += skinWeight.y * boneMatY; + skinMatrix += skinWeight.z * boneMatZ; + skinMatrix += skinWeight.w * boneMatW; + skinMatrix = bindMatrixInverse * skinMatrix * bindMatrix; + objectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz; + #ifdef USE_TANGENT + objectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz; + #endif +#endif`,G_=`float specularStrength; +#ifdef USE_SPECULARMAP + vec4 texelSpecular = texture2D( specularMap, vSpecularMapUv ); + specularStrength = texelSpecular.r; +#else + specularStrength = 1.0; +#endif`,W_=`#ifdef USE_SPECULARMAP + uniform sampler2D specularMap; +#endif`,X_=`#if defined( TONE_MAPPING ) + gl_FragColor.rgb = toneMapping( gl_FragColor.rgb ); +#endif`,Y_=`#ifndef saturate +#define saturate( a ) clamp( a, 0.0, 1.0 ) +#endif +uniform float toneMappingExposure; +vec3 LinearToneMapping( vec3 color ) { + return saturate( toneMappingExposure * color ); +} +vec3 ReinhardToneMapping( vec3 color ) { + color *= toneMappingExposure; + return saturate( color / ( vec3( 1.0 ) + color ) ); +} +vec3 CineonToneMapping( vec3 color ) { + color *= toneMappingExposure; + color = max( vec3( 0.0 ), color - 0.004 ); + return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); +} +vec3 RRTAndODTFit( vec3 v ) { + vec3 a = v * ( v + 0.0245786 ) - 0.000090537; + vec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081; + return a / b; +} +vec3 ACESFilmicToneMapping( vec3 color ) { + const mat3 ACESInputMat = mat3( + vec3( 0.59719, 0.07600, 0.02840 ), vec3( 0.35458, 0.90834, 0.13383 ), + vec3( 0.04823, 0.01566, 0.83777 ) + ); + const mat3 ACESOutputMat = mat3( + vec3( 1.60475, -0.10208, -0.00327 ), vec3( -0.53108, 1.10813, -0.07276 ), + vec3( -0.07367, -0.00605, 1.07602 ) + ); + color *= toneMappingExposure / 0.6; + color = ACESInputMat * color; + color = RRTAndODTFit( color ); + color = ACESOutputMat * color; + return saturate( color ); +} +const mat3 LINEAR_REC2020_TO_LINEAR_SRGB = mat3( + vec3( 1.6605, - 0.1246, - 0.0182 ), + vec3( - 0.5876, 1.1329, - 0.1006 ), + vec3( - 0.0728, - 0.0083, 1.1187 ) +); +const mat3 LINEAR_SRGB_TO_LINEAR_REC2020 = mat3( + vec3( 0.6274, 0.0691, 0.0164 ), + vec3( 0.3293, 0.9195, 0.0880 ), + vec3( 0.0433, 0.0113, 0.8956 ) +); +vec3 agxDefaultContrastApprox( vec3 x ) { + vec3 x2 = x * x; + vec3 x4 = x2 * x2; + return + 15.5 * x4 * x2 + - 40.14 * x4 * x + + 31.96 * x4 + - 6.868 * x2 * x + + 0.4298 * x2 + + 0.1191 * x + - 0.00232; +} +vec3 AgXToneMapping( vec3 color ) { + const mat3 AgXInsetMatrix = mat3( + vec3( 0.856627153315983, 0.137318972929847, 0.11189821299995 ), + vec3( 0.0951212405381588, 0.761241990602591, 0.0767994186031903 ), + vec3( 0.0482516061458583, 0.101439036467562, 0.811302368396859 ) + ); + const mat3 AgXOutsetMatrix = mat3( + vec3( 1.1271005818144368, - 0.1413297634984383, - 0.14132976349843826 ), + vec3( - 0.11060664309660323, 1.157823702216272, - 0.11060664309660294 ), + vec3( - 0.016493938717834573, - 0.016493938717834257, 1.2519364065950405 ) + ); + const float AgxMinEv = - 12.47393; const float AgxMaxEv = 4.026069; + color *= toneMappingExposure; + color = LINEAR_SRGB_TO_LINEAR_REC2020 * color; + color = AgXInsetMatrix * color; + color = max( color, 1e-10 ); color = log2( color ); + color = ( color - AgxMinEv ) / ( AgxMaxEv - AgxMinEv ); + color = clamp( color, 0.0, 1.0 ); + color = agxDefaultContrastApprox( color ); + color = AgXOutsetMatrix * color; + color = pow( max( vec3( 0.0 ), color ), vec3( 2.2 ) ); + color = LINEAR_REC2020_TO_LINEAR_SRGB * color; + color = clamp( color, 0.0, 1.0 ); + return color; +} +vec3 NeutralToneMapping( vec3 color ) { + const float StartCompression = 0.8 - 0.04; + const float Desaturation = 0.15; + color *= toneMappingExposure; + float x = min( color.r, min( color.g, color.b ) ); + float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; + color -= offset; + float peak = max( color.r, max( color.g, color.b ) ); + if ( peak < StartCompression ) return color; + float d = 1. - StartCompression; + float newPeak = 1. - d * d / ( peak + d - StartCompression ); + color *= newPeak / peak; + float g = 1. - 1. / ( Desaturation * ( peak - newPeak ) + 1. ); + return mix( color, vec3( newPeak ), g ); +} +vec3 CustomToneMapping( vec3 color ) { return color; }`,K_=`#ifdef USE_TRANSMISSION + material.transmission = transmission; + material.transmissionAlpha = 1.0; + material.thickness = thickness; + material.attenuationDistance = attenuationDistance; + material.attenuationColor = attenuationColor; + #ifdef USE_TRANSMISSIONMAP + material.transmission *= texture2D( transmissionMap, vTransmissionMapUv ).r; + #endif + #ifdef USE_THICKNESSMAP + material.thickness *= texture2D( thicknessMap, vThicknessMapUv ).g; + #endif + vec3 pos = vWorldPosition; + vec3 v = normalize( cameraPosition - pos ); + vec3 n = transformNormalByInverseViewMatrix( normal, viewMatrix ); + vec4 transmitted = getIBLVolumeRefraction( + n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90, + pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness, + material.attenuationColor, material.attenuationDistance ); + material.transmissionAlpha = mix( material.transmissionAlpha, transmitted.a, material.transmission ); + totalDiffuse = mix( totalDiffuse, transmitted.rgb, material.transmission ); +#endif`,q_=`#ifdef USE_TRANSMISSION + uniform float transmission; + uniform float thickness; + uniform float attenuationDistance; + uniform vec3 attenuationColor; + #ifdef USE_TRANSMISSIONMAP + uniform sampler2D transmissionMap; + #endif + #ifdef USE_THICKNESSMAP + uniform sampler2D thicknessMap; + #endif + uniform vec2 transmissionSamplerSize; + uniform sampler2D transmissionSamplerMap; + uniform mat4 modelMatrix; + uniform mat4 projectionMatrix; + varying vec3 vWorldPosition; + float w0( float a ) { + return ( 1.0 / 6.0 ) * ( a * ( a * ( - a + 3.0 ) - 3.0 ) + 1.0 ); + } + float w1( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * ( 3.0 * a - 6.0 ) + 4.0 ); + } + float w2( float a ){ + return ( 1.0 / 6.0 ) * ( a * ( a * ( - 3.0 * a + 3.0 ) + 3.0 ) + 1.0 ); + } + float w3( float a ) { + return ( 1.0 / 6.0 ) * ( a * a * a ); + } + float g0( float a ) { + return w0( a ) + w1( a ); + } + float g1( float a ) { + return w2( a ) + w3( a ); + } + float h0( float a ) { + return - 1.0 + w1( a ) / ( w0( a ) + w1( a ) ); + } + float h1( float a ) { + return 1.0 + w3( a ) / ( w2( a ) + w3( a ) ); + } + vec4 bicubic( sampler2D tex, vec2 uv, vec4 texelSize, float lod ) { + uv = uv * texelSize.zw + 0.5; + vec2 iuv = floor( uv ); + vec2 fuv = fract( uv ); + float g0x = g0( fuv.x ); + float g1x = g1( fuv.x ); + float h0x = h0( fuv.x ); + float h1x = h1( fuv.x ); + float h0y = h0( fuv.y ); + float h1y = h1( fuv.y ); + vec2 p0 = ( vec2( iuv.x + h0x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p1 = ( vec2( iuv.x + h1x, iuv.y + h0y ) - 0.5 ) * texelSize.xy; + vec2 p2 = ( vec2( iuv.x + h0x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + vec2 p3 = ( vec2( iuv.x + h1x, iuv.y + h1y ) - 0.5 ) * texelSize.xy; + return g0( fuv.y ) * ( g0x * textureLod( tex, p0, lod ) + g1x * textureLod( tex, p1, lod ) ) + + g1( fuv.y ) * ( g0x * textureLod( tex, p2, lod ) + g1x * textureLod( tex, p3, lod ) ); + } + vec4 textureBicubic( sampler2D sampler, vec2 uv, float lod ) { + vec2 fLodSize = vec2( textureSize( sampler, int( lod ) ) ); + vec2 cLodSize = vec2( textureSize( sampler, int( lod + 1.0 ) ) ); + vec2 fLodSizeInv = 1.0 / fLodSize; + vec2 cLodSizeInv = 1.0 / cLodSize; + vec4 fSample = bicubic( sampler, uv, vec4( fLodSizeInv, fLodSize ), floor( lod ) ); + vec4 cSample = bicubic( sampler, uv, vec4( cLodSizeInv, cLodSize ), ceil( lod ) ); + return mix( fSample, cSample, fract( lod ) ); + } + vec3 getVolumeTransmissionRay( const in vec3 n, const in vec3 v, const in float thickness, const in float ior, const in mat4 modelMatrix ) { + vec3 refractionVector = refract( - v, normalize( n ), 1.0 / ior ); + vec3 modelScale; + modelScale.x = length( vec3( modelMatrix[ 0 ].xyz ) ); + modelScale.y = length( vec3( modelMatrix[ 1 ].xyz ) ); + modelScale.z = length( vec3( modelMatrix[ 2 ].xyz ) ); + return normalize( refractionVector ) * thickness * modelScale; + } + float applyIorToRoughness( const in float roughness, const in float ior ) { + return roughness * clamp( ior * 2.0 - 2.0, 0.0, 1.0 ); + } + vec4 getTransmissionSample( const in vec2 fragCoord, const in float roughness, const in float ior ) { + float lod = log2( transmissionSamplerSize.x ) * applyIorToRoughness( roughness, ior ); + return textureBicubic( transmissionSamplerMap, fragCoord.xy, lod ); + } + vec3 volumeAttenuation( const in float transmissionDistance, const in vec3 attenuationColor, const in float attenuationDistance ) { + if ( isinf( attenuationDistance ) ) { + return vec3( 1.0 ); + } else { + vec3 attenuationCoefficient = -log( attenuationColor ) / attenuationDistance; + vec3 transmittance = exp( - attenuationCoefficient * transmissionDistance ); return transmittance; + } + } + vec4 getIBLVolumeRefraction( const in vec3 n, const in vec3 v, const in float roughness, const in vec3 diffuseColor, + const in vec3 specularColor, const in float specularF90, const in vec3 position, const in mat4 modelMatrix, + const in mat4 viewMatrix, const in mat4 projMatrix, const in float dispersion, const in float ior, const in float thickness, + const in vec3 attenuationColor, const in float attenuationDistance ) { + vec4 transmittedLight; + vec3 transmittance; + #ifdef USE_DISPERSION + float halfSpread = ( ior - 1.0 ) * 0.025 * dispersion; + vec3 iors = vec3( ior - halfSpread, ior, ior + halfSpread ); + for ( int i = 0; i < 3; i ++ ) { + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, iors[ i ], modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + vec4 transmissionSample = getTransmissionSample( refractionCoords, roughness, iors[ i ] ); + transmittedLight[ i ] = transmissionSample[ i ]; + transmittedLight.a += transmissionSample.a; + transmittance[ i ] = diffuseColor[ i ] * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance )[ i ]; + } + transmittedLight.a /= 3.0; + #else + vec3 transmissionRay = getVolumeTransmissionRay( n, v, thickness, ior, modelMatrix ); + vec3 refractedRayExit = position + transmissionRay; + vec4 ndcPos = projMatrix * viewMatrix * vec4( refractedRayExit, 1.0 ); + vec2 refractionCoords = ndcPos.xy / ndcPos.w; + refractionCoords += 1.0; + refractionCoords /= 2.0; + transmittedLight = getTransmissionSample( refractionCoords, roughness, ior ); + transmittance = diffuseColor * volumeAttenuation( length( transmissionRay ), attenuationColor, attenuationDistance ); + #endif + vec3 attenuatedColor = transmittance * transmittedLight.rgb; + vec3 F = EnvironmentBRDF( n, v, specularColor, specularF90, roughness ); + float transmittanceFactor = ( transmittance.r + transmittance.g + transmittance.b ) / 3.0; + return vec4( ( 1.0 - F ) * attenuatedColor, 1.0 - ( 1.0 - transmittedLight.a ) * transmittanceFactor ); + } +#endif`,Z_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + varying vec2 vNormalMapUv; +#endif +#ifdef USE_EMISSIVEMAP + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_SPECULARMAP + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,$_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + varying vec2 vUv; +#endif +#ifdef USE_MAP + uniform mat3 mapTransform; + varying vec2 vMapUv; +#endif +#ifdef USE_ALPHAMAP + uniform mat3 alphaMapTransform; + varying vec2 vAlphaMapUv; +#endif +#ifdef USE_LIGHTMAP + uniform mat3 lightMapTransform; + varying vec2 vLightMapUv; +#endif +#ifdef USE_AOMAP + uniform mat3 aoMapTransform; + varying vec2 vAoMapUv; +#endif +#ifdef USE_BUMPMAP + uniform mat3 bumpMapTransform; + varying vec2 vBumpMapUv; +#endif +#ifdef USE_NORMALMAP + uniform mat3 normalMapTransform; + varying vec2 vNormalMapUv; +#endif +#ifdef USE_DISPLACEMENTMAP + uniform mat3 displacementMapTransform; + varying vec2 vDisplacementMapUv; +#endif +#ifdef USE_EMISSIVEMAP + uniform mat3 emissiveMapTransform; + varying vec2 vEmissiveMapUv; +#endif +#ifdef USE_METALNESSMAP + uniform mat3 metalnessMapTransform; + varying vec2 vMetalnessMapUv; +#endif +#ifdef USE_ROUGHNESSMAP + uniform mat3 roughnessMapTransform; + varying vec2 vRoughnessMapUv; +#endif +#ifdef USE_ANISOTROPYMAP + uniform mat3 anisotropyMapTransform; + varying vec2 vAnisotropyMapUv; +#endif +#ifdef USE_CLEARCOATMAP + uniform mat3 clearcoatMapTransform; + varying vec2 vClearcoatMapUv; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + uniform mat3 clearcoatNormalMapTransform; + varying vec2 vClearcoatNormalMapUv; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + uniform mat3 clearcoatRoughnessMapTransform; + varying vec2 vClearcoatRoughnessMapUv; +#endif +#ifdef USE_SHEEN_COLORMAP + uniform mat3 sheenColorMapTransform; + varying vec2 vSheenColorMapUv; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + uniform mat3 sheenRoughnessMapTransform; + varying vec2 vSheenRoughnessMapUv; +#endif +#ifdef USE_IRIDESCENCEMAP + uniform mat3 iridescenceMapTransform; + varying vec2 vIridescenceMapUv; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + uniform mat3 iridescenceThicknessMapTransform; + varying vec2 vIridescenceThicknessMapUv; +#endif +#ifdef USE_SPECULARMAP + uniform mat3 specularMapTransform; + varying vec2 vSpecularMapUv; +#endif +#ifdef USE_SPECULAR_COLORMAP + uniform mat3 specularColorMapTransform; + varying vec2 vSpecularColorMapUv; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + uniform mat3 specularIntensityMapTransform; + varying vec2 vSpecularIntensityMapUv; +#endif +#ifdef USE_TRANSMISSIONMAP + uniform mat3 transmissionMapTransform; + varying vec2 vTransmissionMapUv; +#endif +#ifdef USE_THICKNESSMAP + uniform mat3 thicknessMapTransform; + varying vec2 vThicknessMapUv; +#endif`,J_=`#if defined( USE_UV ) || defined( USE_ANISOTROPY ) + vUv = vec3( uv, 1 ).xy; +#endif +#ifdef USE_MAP + vMapUv = ( mapTransform * vec3( MAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ALPHAMAP + vAlphaMapUv = ( alphaMapTransform * vec3( ALPHAMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_LIGHTMAP + vLightMapUv = ( lightMapTransform * vec3( LIGHTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_AOMAP + vAoMapUv = ( aoMapTransform * vec3( AOMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_BUMPMAP + vBumpMapUv = ( bumpMapTransform * vec3( BUMPMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_NORMALMAP + vNormalMapUv = ( normalMapTransform * vec3( NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_DISPLACEMENTMAP + vDisplacementMapUv = ( displacementMapTransform * vec3( DISPLACEMENTMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_EMISSIVEMAP + vEmissiveMapUv = ( emissiveMapTransform * vec3( EMISSIVEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_METALNESSMAP + vMetalnessMapUv = ( metalnessMapTransform * vec3( METALNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ROUGHNESSMAP + vRoughnessMapUv = ( roughnessMapTransform * vec3( ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_ANISOTROPYMAP + vAnisotropyMapUv = ( anisotropyMapTransform * vec3( ANISOTROPYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOATMAP + vClearcoatMapUv = ( clearcoatMapTransform * vec3( CLEARCOATMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_NORMALMAP + vClearcoatNormalMapUv = ( clearcoatNormalMapTransform * vec3( CLEARCOAT_NORMALMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_CLEARCOAT_ROUGHNESSMAP + vClearcoatRoughnessMapUv = ( clearcoatRoughnessMapTransform * vec3( CLEARCOAT_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCEMAP + vIridescenceMapUv = ( iridescenceMapTransform * vec3( IRIDESCENCEMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_IRIDESCENCE_THICKNESSMAP + vIridescenceThicknessMapUv = ( iridescenceThicknessMapTransform * vec3( IRIDESCENCE_THICKNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_COLORMAP + vSheenColorMapUv = ( sheenColorMapTransform * vec3( SHEEN_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SHEEN_ROUGHNESSMAP + vSheenRoughnessMapUv = ( sheenRoughnessMapTransform * vec3( SHEEN_ROUGHNESSMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULARMAP + vSpecularMapUv = ( specularMapTransform * vec3( SPECULARMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_COLORMAP + vSpecularColorMapUv = ( specularColorMapTransform * vec3( SPECULAR_COLORMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_SPECULAR_INTENSITYMAP + vSpecularIntensityMapUv = ( specularIntensityMapTransform * vec3( SPECULAR_INTENSITYMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_TRANSMISSIONMAP + vTransmissionMapUv = ( transmissionMapTransform * vec3( TRANSMISSIONMAP_UV, 1 ) ).xy; +#endif +#ifdef USE_THICKNESSMAP + vThicknessMapUv = ( thicknessMapTransform * vec3( THICKNESSMAP_UV, 1 ) ).xy; +#endif`,j_=`#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; + #endif + #ifdef USE_INSTANCING + worldPosition = instanceMatrix * worldPosition; + #endif + worldPosition = modelMatrix * worldPosition; +#endif`;const Q_=`varying vec2 vUv; +uniform mat3 uvTransform; +void main() { + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + gl_Position = vec4( position.xy, 1.0, 1.0 ); +}`,ex=`uniform sampler2D t2D; +uniform float backgroundIntensity; +varying vec2 vUv; +void main() { + vec4 texColor = texture2D( t2D, vUv ); + #ifdef DECODE_VIDEO_TEXTURE + texColor = vec4( mix( pow( texColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), texColor.rgb * 0.0773993808, vec3( lessThanEqual( texColor.rgb, vec3( 0.04045 ) ) ) ), texColor.w ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,tx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,nx=`#ifdef ENVMAP_TYPE_CUBE + uniform samplerCube envMap; +#elif defined( ENVMAP_TYPE_CUBE_UV ) + uniform sampler2D envMap; +#endif +uniform float backgroundBlurriness; +uniform float backgroundIntensity; +uniform mat3 backgroundRotation; +varying vec3 vWorldDirection; +#include +void main() { + #ifdef ENVMAP_TYPE_CUBE + vec4 texColor = textureCube( envMap, backgroundRotation * vWorldDirection ); + #elif defined( ENVMAP_TYPE_CUBE_UV ) + vec4 texColor = textureCubeUV( envMap, backgroundRotation * vWorldDirection, backgroundBlurriness ); + #else + vec4 texColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + #endif + texColor.rgb *= backgroundIntensity; + gl_FragColor = texColor; + #include + #include +}`,ix=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include + gl_Position.z = gl_Position.w; +}`,sx=`uniform samplerCube tCube; +uniform float tFlip; +uniform float opacity; +varying vec3 vWorldDirection; +void main() { + vec4 texColor = textureCube( tCube, vec3( tFlip * vWorldDirection.x, vWorldDirection.yz ) ); + gl_FragColor = texColor; + gl_FragColor.a *= opacity; + #include + #include +}`,rx=`#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vHighPrecisionZW = gl_Position.zw; +}`,ax=`#if DEPTH_PACKING == 3200 + uniform float opacity; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +varying vec2 vHighPrecisionZW; +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #if DEPTH_PACKING == 3200 + diffuseColor.a = opacity; + #endif + #include + #include + #include + #include + #include + #ifdef USE_REVERSED_DEPTH_BUFFER + float fragCoordZ = vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ]; + #else + float fragCoordZ = 0.5 * vHighPrecisionZW[ 0 ] / vHighPrecisionZW[ 1 ] + 0.5; + #endif + #if DEPTH_PACKING == 3200 + gl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity ); + #elif DEPTH_PACKING == 3201 + gl_FragColor = packDepthToRGBA( fragCoordZ ); + #elif DEPTH_PACKING == 3202 + gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 ); + #elif DEPTH_PACKING == 3203 + gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 ); + #endif +}`,ox=`#define DISTANCE +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #ifdef USE_DISPLACEMENTMAP + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + vWorldPosition = worldPosition.xyz; +}`,lx=`#define DISTANCE +uniform vec3 referencePosition; +uniform float nearDistance; +uniform float farDistance; +varying vec3 vWorldPosition; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 1.0 ); + #include + #include + #include + #include + #include + float dist = length( vWorldPosition - referencePosition ); + dist = ( dist - nearDistance ) / ( farDistance - nearDistance ); + dist = saturate( dist ); + gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 ); +}`,cx=`varying vec3 vWorldDirection; +#include +void main() { + vWorldDirection = transformDirection( position, modelMatrix ); + #include + #include +}`,ux=`uniform sampler2D tEquirect; +varying vec3 vWorldDirection; +#include +void main() { + vec3 direction = normalize( vWorldDirection ); + vec2 sampleUV = equirectUv( direction ); + gl_FragColor = texture2D( tEquirect, sampleUV ); + #include + #include +}`,hx=`uniform float scale; +attribute float lineDistance; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vLineDistance = scale * lineDistance; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,dx=`uniform vec3 diffuse; +uniform float opacity; +uniform float dashSize; +uniform float totalSize; +varying float vLineDistance; +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + if ( mod( vLineDistance, totalSize ) > dashSize ) { + discard; + } + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,fx=`#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #if defined ( USE_ENVMAP ) || defined ( USE_SKINNING ) + #include + #include + #include + #include + #include + #endif + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,px=`uniform vec3 diffuse; +uniform float opacity; +#ifndef FLAT_SHADED + varying vec3 vNormal; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + #ifdef USE_LIGHTMAP + vec4 lightMapTexel = texture2D( lightMap, vLightMapUv ); + reflectedLight.indirectDiffuse += lightMapTexel.rgb * lightMapIntensity * RECIPROCAL_PI; + #else + reflectedLight.indirectDiffuse += vec3( 1.0 ); + #endif + #include + reflectedLight.indirectDiffuse *= diffuseColor.rgb; + vec3 outgoingLight = reflectedLight.indirectDiffuse; + #include + #include + #include + #include + #include + #include + #include +}`,mx=`#define LAMBERT +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,gx=`#define LAMBERT +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,_x=`#define MATCAP +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; +}`,xx=`#define MATCAP +uniform vec3 diffuse; +uniform float opacity; +uniform sampler2D matcap; +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 viewDir = normalize( vViewPosition ); + vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) ); + vec3 y = cross( viewDir, x ); + vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; + #ifdef USE_MATCAP + vec4 matcapColor = texture2D( matcap, uv ); + #else + vec4 matcapColor = vec4( vec3( mix( 0.2, 0.8, uv.y ) ), 1.0 ); + #endif + vec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb; + #include + #include + #include + #include + #include + #include +}`,yx=`#define NORMAL +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + vViewPosition = - mvPosition.xyz; +#endif +}`,vx=`#define NORMAL +uniform float opacity; +#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP_TANGENTSPACE ) + varying vec3 vViewPosition; +#endif +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( 0.0, 0.0, 0.0, opacity ); + #include + #include + #include + #include + gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a ); + #ifdef OPAQUE + gl_FragColor.a = 1.0; + #endif +}`,Sx=`#define PHONG +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include + #include +}`,bx=`#define PHONG +uniform vec3 diffuse; +uniform vec3 emissive; +uniform vec3 specular; +uniform float shininess; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include + #include +}`,Mx=`#define STANDARD +varying vec3 vViewPosition; +#ifdef USE_TRANSMISSION + varying vec3 vWorldPosition; +#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +#ifdef USE_TRANSMISSION + vWorldPosition = worldPosition.xyz; +#endif +}`,Ax=`#define STANDARD +#ifdef PHYSICAL + #define IOR + #define USE_SPECULAR +#endif +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float roughness; +uniform float metalness; +uniform float opacity; +#ifdef IOR + uniform float ior; +#endif +#ifdef USE_SPECULAR + uniform float specularIntensity; + uniform vec3 specularColor; + #ifdef USE_SPECULAR_COLORMAP + uniform sampler2D specularColorMap; + #endif + #ifdef USE_SPECULAR_INTENSITYMAP + uniform sampler2D specularIntensityMap; + #endif +#endif +#ifdef USE_CLEARCOAT + uniform float clearcoat; + uniform float clearcoatRoughness; +#endif +#ifdef USE_DISPERSION + uniform float dispersion; +#endif +#ifdef USE_IRIDESCENCE + uniform float iridescence; + uniform float iridescenceIOR; + uniform float iridescenceThicknessMinimum; + uniform float iridescenceThicknessMaximum; +#endif +#ifdef USE_SHEEN + uniform vec3 sheenColor; + uniform float sheenRoughness; + #ifdef USE_SHEEN_COLORMAP + uniform sampler2D sheenColorMap; + #endif + #ifdef USE_SHEEN_ROUGHNESSMAP + uniform sampler2D sheenRoughnessMap; + #endif +#endif +#ifdef USE_ANISOTROPY + uniform vec2 anisotropyVector; + #ifdef USE_ANISOTROPYMAP + uniform sampler2D anisotropyMap; + #endif +#endif +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse; + vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular; + #include + vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance; + #ifdef USE_SHEEN + + outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect; + + #endif + #ifdef USE_CLEARCOAT + float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) ); + vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc ); + outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat; + #endif + #include + #include + #include + #include + #include + #include +}`,Ex=`#define TOON +varying vec3 vViewPosition; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vViewPosition = - mvPosition.xyz; + #include + #include + #include +}`,Tx=`#define TOON +uniform vec3 diffuse; +uniform vec3 emissive; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) ); + vec3 totalEmissiveRadiance = emissive; + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance; + #include + #include + #include + #include + #include + #include +}`,Cx=`uniform float size; +uniform float scale; +#include +#include +#include +#include +#include +#include +#ifdef USE_POINTS_UV + varying vec2 vUv; + uniform mat3 uvTransform; +#endif +void main() { + #ifdef USE_POINTS_UV + vUv = ( uvTransform * vec3( uv, 1 ) ).xy; + #endif + #include + #include + #include + #include + #include + #include + gl_PointSize = size; + #ifdef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z ); + #endif + #include + #include + #include + #include +}`,wx=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include + #include +}`,Rx=`#include +#include +#include +#include +#include +#include +#include +void main() { + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include +}`,Dx=`uniform vec3 color; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +void main() { + #include + gl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) ); + #include + #include + #include + #include +}`,Lx=`uniform float rotation; +uniform vec2 center; +#include +#include +#include +#include +#include +void main() { + #include + vec4 mvPosition = modelViewMatrix[ 3 ]; + vec2 scale = vec2( length( modelMatrix[ 0 ].xyz ), length( modelMatrix[ 1 ].xyz ) ); + #ifndef USE_SIZEATTENUATION + bool isPerspective = isPerspectiveMatrix( projectionMatrix ); + if ( isPerspective ) scale *= - mvPosition.z; + #endif + vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale; + vec2 rotatedPosition; + rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y; + rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y; + mvPosition.xy += rotatedPosition; + gl_Position = projectionMatrix * mvPosition; + #include + #include + #include +}`,Ix=`uniform vec3 diffuse; +uniform float opacity; +#include +#include +#include +#include +#include +#include +#include +#include +#include +void main() { + vec4 diffuseColor = vec4( diffuse, opacity ); + #include + vec3 outgoingLight = vec3( 0.0 ); + #include + #include + #include + #include + #include + outgoingLight = diffuseColor.rgb; + #include + #include + #include + #include +}`,$e={alphahash_fragment:Qm,alphahash_pars_fragment:eg,alphamap_fragment:tg,alphamap_pars_fragment:ng,alphatest_fragment:ig,alphatest_pars_fragment:sg,aomap_fragment:rg,aomap_pars_fragment:ag,batching_pars_vertex:og,batching_vertex:lg,begin_vertex:cg,beginnormal_vertex:ug,bsdfs:hg,iridescence_fragment:dg,bumpmap_pars_fragment:fg,clipping_planes_fragment:pg,clipping_planes_pars_fragment:mg,clipping_planes_pars_vertex:gg,clipping_planes_vertex:_g,color_fragment:xg,color_pars_fragment:yg,color_pars_vertex:vg,color_vertex:Sg,common:bg,cube_uv_reflection_fragment:Mg,defaultnormal_vertex:Ag,displacementmap_pars_vertex:Eg,displacementmap_vertex:Tg,emissivemap_fragment:Cg,emissivemap_pars_fragment:wg,colorspace_fragment:Rg,colorspace_pars_fragment:Dg,envmap_fragment:Lg,envmap_common_pars_fragment:Ig,envmap_pars_fragment:Pg,envmap_pars_vertex:Ug,envmap_physical_pars_fragment:Xg,envmap_vertex:Og,fog_vertex:Ng,fog_pars_vertex:kg,fog_fragment:Fg,fog_pars_fragment:Bg,gradientmap_pars_fragment:Hg,lightmap_pars_fragment:zg,lights_lambert_fragment:Vg,lights_lambert_pars_fragment:Gg,lights_pars_begin:Wg,lights_toon_fragment:Yg,lights_toon_pars_fragment:Kg,lights_phong_fragment:qg,lights_phong_pars_fragment:Zg,lights_physical_fragment:$g,lights_physical_pars_fragment:Jg,lights_fragment_begin:jg,lights_fragment_maps:Qg,lights_fragment_end:e_,lightprobes_pars_fragment:t_,logdepthbuf_fragment:n_,logdepthbuf_pars_fragment:i_,logdepthbuf_pars_vertex:s_,logdepthbuf_vertex:r_,map_fragment:a_,map_pars_fragment:o_,map_particle_fragment:l_,map_particle_pars_fragment:c_,metalnessmap_fragment:u_,metalnessmap_pars_fragment:h_,morphinstance_vertex:d_,morphcolor_vertex:f_,morphnormal_vertex:p_,morphtarget_pars_vertex:m_,morphtarget_vertex:g_,normal_fragment_begin:__,normal_fragment_maps:x_,normal_pars_fragment:y_,normal_pars_vertex:v_,normal_vertex:S_,normalmap_pars_fragment:b_,clearcoat_normal_fragment_begin:M_,clearcoat_normal_fragment_maps:A_,clearcoat_pars_fragment:E_,iridescence_pars_fragment:T_,opaque_fragment:C_,packing:w_,premultiplied_alpha_fragment:R_,project_vertex:D_,dithering_fragment:L_,dithering_pars_fragment:I_,roughnessmap_fragment:P_,roughnessmap_pars_fragment:U_,shadowmap_pars_fragment:O_,shadowmap_pars_vertex:N_,shadowmap_vertex:k_,shadowmask_pars_fragment:F_,skinbase_vertex:B_,skinning_pars_vertex:H_,skinning_vertex:z_,skinnormal_vertex:V_,specularmap_fragment:G_,specularmap_pars_fragment:W_,tonemapping_fragment:X_,tonemapping_pars_fragment:Y_,transmission_fragment:K_,transmission_pars_fragment:q_,uv_pars_fragment:Z_,uv_pars_vertex:$_,uv_vertex:J_,worldpos_vertex:j_,background_vert:Q_,background_frag:ex,backgroundCube_vert:tx,backgroundCube_frag:nx,cube_vert:ix,cube_frag:sx,depth_vert:rx,depth_frag:ax,distance_vert:ox,distance_frag:lx,equirect_vert:cx,equirect_frag:ux,linedashed_vert:hx,linedashed_frag:dx,meshbasic_vert:fx,meshbasic_frag:px,meshlambert_vert:mx,meshlambert_frag:gx,meshmatcap_vert:_x,meshmatcap_frag:xx,meshnormal_vert:yx,meshnormal_frag:vx,meshphong_vert:Sx,meshphong_frag:bx,meshphysical_vert:Mx,meshphysical_frag:Ax,meshtoon_vert:Ex,meshtoon_frag:Tx,points_vert:Cx,points_frag:wx,shadow_vert:Rx,shadow_frag:Dx,sprite_vert:Lx,sprite_frag:Ix},Ce={common:{diffuse:{value:new Qe(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new qe}},envmap:{envMap:{value:null},envMapRotation:{value:new qe},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new qe}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new qe}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new qe},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new qe},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new qe},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new qe}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new qe}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new qe}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new Qe(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:null},probesMin:{value:new B},probesMax:{value:new B},probesResolution:{value:new B}},points:{diffuse:{value:new Qe(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0},uvTransform:{value:new qe}},sprite:{diffuse:{value:new Qe(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new qe},alphaMap:{value:null},alphaMapTransform:{value:new qe},alphaTest:{value:0}}},Kn={basic:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.fog]),vertexShader:$e.meshbasic_vert,fragmentShader:$e.meshbasic_frag},lambert:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},envMapIntensity:{value:1}}]),vertexShader:$e.meshlambert_vert,fragmentShader:$e.meshlambert_frag},phong:{uniforms:tn([Ce.common,Ce.specularmap,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},specular:{value:new Qe(1118481)},shininess:{value:30},envMapIntensity:{value:1}}]),vertexShader:$e.meshphong_vert,fragmentShader:$e.meshphong_frag},standard:{uniforms:tn([Ce.common,Ce.envmap,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.roughnessmap,Ce.metalnessmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag},toon:{uniforms:tn([Ce.common,Ce.aomap,Ce.lightmap,Ce.emissivemap,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.gradientmap,Ce.fog,Ce.lights,{emissive:{value:new Qe(0)}}]),vertexShader:$e.meshtoon_vert,fragmentShader:$e.meshtoon_frag},matcap:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,Ce.fog,{matcap:{value:null}}]),vertexShader:$e.meshmatcap_vert,fragmentShader:$e.meshmatcap_frag},points:{uniforms:tn([Ce.points,Ce.fog]),vertexShader:$e.points_vert,fragmentShader:$e.points_frag},dashed:{uniforms:tn([Ce.common,Ce.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}]),vertexShader:$e.linedashed_vert,fragmentShader:$e.linedashed_frag},depth:{uniforms:tn([Ce.common,Ce.displacementmap]),vertexShader:$e.depth_vert,fragmentShader:$e.depth_frag},normal:{uniforms:tn([Ce.common,Ce.bumpmap,Ce.normalmap,Ce.displacementmap,{opacity:{value:1}}]),vertexShader:$e.meshnormal_vert,fragmentShader:$e.meshnormal_frag},sprite:{uniforms:tn([Ce.sprite,Ce.fog]),vertexShader:$e.sprite_vert,fragmentShader:$e.sprite_frag},background:{uniforms:{uvTransform:{value:new qe},t2D:{value:null},backgroundIntensity:{value:1}},vertexShader:$e.background_vert,fragmentShader:$e.background_frag},backgroundCube:{uniforms:{envMap:{value:null},backgroundBlurriness:{value:0},backgroundIntensity:{value:1},backgroundRotation:{value:new qe}},vertexShader:$e.backgroundCube_vert,fragmentShader:$e.backgroundCube_frag},cube:{uniforms:{tCube:{value:null},tFlip:{value:-1},opacity:{value:1}},vertexShader:$e.cube_vert,fragmentShader:$e.cube_frag},equirect:{uniforms:{tEquirect:{value:null}},vertexShader:$e.equirect_vert,fragmentShader:$e.equirect_frag},distance:{uniforms:tn([Ce.common,Ce.displacementmap,{referencePosition:{value:new B},nearDistance:{value:1},farDistance:{value:1e3}}]),vertexShader:$e.distance_vert,fragmentShader:$e.distance_frag},shadow:{uniforms:tn([Ce.lights,Ce.fog,{color:{value:new Qe(0)},opacity:{value:1}}]),vertexShader:$e.shadow_vert,fragmentShader:$e.shadow_frag}};Kn.physical={uniforms:tn([Kn.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new qe},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new qe},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new qe},dispersion:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new qe},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new qe},sheen:{value:0},sheenColor:{value:new Qe(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new qe},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new qe},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new qe},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new qe},attenuationDistance:{value:0},attenuationColor:{value:new Qe(0)},specularColor:{value:new Qe(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new qe},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new qe},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new qe}}]),vertexShader:$e.meshphysical_vert,fragmentShader:$e.meshphysical_frag};const ba={r:0,b:0,g:0},Px=new Et,Mf=new qe;Mf.set(-1,0,0,0,1,0,0,0,1);function Ux(n,e,t,i,s,r){const a=new Qe(0);let o=s===!0?0:1,l,c,u=null,d=0,h=null;function f(b){let A=b.isScene===!0?b.background:null;if(A&&A.isTexture){const y=b.backgroundBlurriness>0;A=e.get(A,y)}return A}function p(b){let A=!1;const y=f(b);y===null?m(a,o):y&&y.isColor&&(m(y,1),A=!0);const M=n.xr.getEnvironmentBlendMode();M==="additive"?t.buffers.color.setClear(0,0,0,1,r):M==="alpha-blend"&&t.buffers.color.setClear(0,0,0,0,r),(n.autoClear||A)&&(t.buffers.depth.setTest(!0),t.buffers.depth.setMask(!0),t.buffers.color.setMask(!0),n.clear(n.autoClearColor,n.autoClearDepth,n.autoClearStencil))}function g(b,A){const y=f(A);y&&(y.isCubeTexture||y.mapping===xo)?(c===void 0&&(c=new Vt(new Fr(1,1,1),new On({name:"BackgroundCubeMaterial",uniforms:Zs(Kn.backgroundCube.uniforms),vertexShader:Kn.backgroundCube.vertexShader,fragmentShader:Kn.backgroundCube.fragmentShader,side:cn,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),c.geometry.deleteAttribute("normal"),c.geometry.deleteAttribute("uv"),c.onBeforeRender=function(M,S,E){this.matrixWorld.copyPosition(E.matrixWorld)},Object.defineProperty(c.material,"envMap",{get:function(){return this.uniforms.envMap.value}}),i.update(c)),c.material.uniforms.envMap.value=y,c.material.uniforms.backgroundBlurriness.value=A.backgroundBlurriness,c.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,c.material.uniforms.backgroundRotation.value.setFromMatrix4(Px.makeRotationFromEuler(A.backgroundRotation)).transpose(),y.isCubeTexture&&y.isRenderTargetTexture===!1&&c.material.uniforms.backgroundRotation.value.premultiply(Mf),c.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,(u!==y||d!==y.version||h!==n.toneMapping)&&(c.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),c.layers.enableAll(),b.unshift(c,c.geometry,c.material,0,0,null)):y&&y.isTexture&&(l===void 0&&(l=new Vt(new ts(2,2),new On({name:"BackgroundMaterial",uniforms:Zs(Kn.background.uniforms),vertexShader:Kn.background.vertexShader,fragmentShader:Kn.background.fragmentShader,side:Bi,depthTest:!1,depthWrite:!1,fog:!1,allowOverride:!1})),l.geometry.deleteAttribute("normal"),Object.defineProperty(l.material,"map",{get:function(){return this.uniforms.t2D.value}}),i.update(l)),l.material.uniforms.t2D.value=y,l.material.uniforms.backgroundIntensity.value=A.backgroundIntensity,l.material.toneMapped=it.getTransfer(y.colorSpace)!==ft,y.matrixAutoUpdate===!0&&y.updateMatrix(),l.material.uniforms.uvTransform.value.copy(y.matrix),(u!==y||d!==y.version||h!==n.toneMapping)&&(l.material.needsUpdate=!0,u=y,d=y.version,h=n.toneMapping),l.layers.enableAll(),b.unshift(l,l.geometry,l.material,0,0,null))}function m(b,A){b.getRGB(ba,vf(n)),t.buffers.color.setClear(ba.r,ba.g,ba.b,A,r)}function _(){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 a},setClearColor:function(b,A=1){a.set(b),o=A,m(a,o)},getClearAlpha:function(){return o},setClearAlpha:function(b){o=b,m(a,o)},render:p,addToRenderList:g,dispose:_}}function Ox(n,e){const t=n.getParameter(n.MAX_VERTEX_ATTRIBS),i={},s=h(null);let r=s,a=!1;function o(L,w,U,O,P){let Z=!1;const N=d(L,O,U,w);r!==N&&(r=N,c(r.object)),Z=f(L,O,U,P),Z&&p(L,O,U,P),P!==null&&e.update(P,n.ELEMENT_ARRAY_BUFFER),(Z||a)&&(a=!1,y(L,w,U,O),P!==null&&n.bindBuffer(n.ELEMENT_ARRAY_BUFFER,e.get(P).buffer))}function l(){return n.createVertexArray()}function c(L){return n.bindVertexArray(L)}function u(L){return n.deleteVertexArray(L)}function d(L,w,U,O){const P=O.wireframe===!0;let Z=i[w.id];Z===void 0&&(Z={},i[w.id]=Z);const N=L.isInstancedMesh===!0?L.id:0;let W=Z[N];W===void 0&&(W={},Z[N]=W);let D=W[U.id];D===void 0&&(D={},W[U.id]=D);let re=D[P];return re===void 0&&(re=h(l()),D[P]=re),re}function h(L){const w=[],U=[],O=[];for(let P=0;P=0){const ie=P[D];let oe=Z[D];if(oe===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(oe=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(oe=L.instanceColor)),ie===void 0||ie.attribute!==oe||oe&&ie.data!==oe.data)return!0;N++}return r.attributesNum!==N||r.index!==O}function p(L,w,U,O){const P={},Z=w.attributes;let N=0;const W=U.getAttributes();for(const D in W)if(W[D].location>=0){let ie=Z[D];ie===void 0&&(D==="instanceMatrix"&&L.instanceMatrix&&(ie=L.instanceMatrix),D==="instanceColor"&&L.instanceColor&&(ie=L.instanceColor));const oe={};oe.attribute=ie,ie&&ie.data&&(oe.data=ie.data),P[D]=oe,N++}r.attributes=P,r.attributesNum=N,r.index=O}function g(){const L=r.newAttributes;for(let w=0,U=L.length;w=0){let re=P[W];if(re===void 0&&(W==="instanceMatrix"&&L.instanceMatrix&&(re=L.instanceMatrix),W==="instanceColor"&&L.instanceColor&&(re=L.instanceColor)),re!==void 0){const ie=re.normalized,oe=re.itemSize,_e=e.get(re);if(_e===void 0)continue;const de=_e.buffer,le=_e.type,z=_e.bytesPerElement,ne=le===n.INT||le===n.UNSIGNED_INT||re.gpuType===Pc;if(re.isInterleavedBufferAttribute){const J=re.data,xe=J.stride,Ae=re.offset;if(J.isInstancedInterleavedBuffer){for(let Se=0;Se0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.HIGH_FLOAT).precision>0)return"highp";E="mediump"}return E==="mediump"&&n.getShaderPrecisionFormat(n.VERTEX_SHADER,n.MEDIUM_FLOAT).precision>0&&n.getShaderPrecisionFormat(n.FRAGMENT_SHADER,n.MEDIUM_FLOAT).precision>0?"mediump":"lowp"}let c=t.precision!==void 0?t.precision:"highp";const u=l(c);u!==c&&(Ye("WebGLRenderer:",c,"not supported, using",u,"instead."),c=u);const d=t.logarithmicDepthBuffer===!0,h=t.reversedDepthBuffer===!0&&e.has("EXT_clip_control");t.reversedDepthBuffer===!0&&h===!1&&Ye("WebGLRenderer: Unable to use reversed depth buffer due to missing EXT_clip_control extension. Fallback to default depth buffer.");const f=n.getParameter(n.MAX_TEXTURE_IMAGE_UNITS),p=n.getParameter(n.MAX_VERTEX_TEXTURE_IMAGE_UNITS),g=n.getParameter(n.MAX_TEXTURE_SIZE),m=n.getParameter(n.MAX_CUBE_MAP_TEXTURE_SIZE),_=n.getParameter(n.MAX_VERTEX_ATTRIBS),b=n.getParameter(n.MAX_VERTEX_UNIFORM_VECTORS),A=n.getParameter(n.MAX_VARYING_VECTORS),y=n.getParameter(n.MAX_FRAGMENT_UNIFORM_VECTORS),M=n.getParameter(n.MAX_SAMPLES),S=n.getParameter(n.SAMPLES);return{isWebGL2:!0,getMaxAnisotropy:r,getMaxPrecision:l,textureFormatReadable:a,textureTypeReadable:o,precision:c,logarithmicDepthBuffer:d,reversedDepthBuffer:h,maxTextures:f,maxVertexTextures:p,maxTextureSize:g,maxCubemapSize:m,maxAttributes:_,maxVertexUniforms:b,maxVaryings:A,maxFragmentUniforms:y,maxSamples:M,samples:S}}function Fx(n){const e=this;let t=null,i=0,s=!1,r=!1;const a=new Li,o=new qe,l={value:null,needsUpdate:!1};this.uniform=l,this.numPlanes=0,this.numIntersection=0,this.init=function(d,h){const f=d.length!==0||h||i!==0||s;return s=h,i=d.length,f},this.beginShadows=function(){r=!0,u(null)},this.endShadows=function(){r=!1},this.setGlobalState=function(d,h){t=u(d,h,0)},this.setState=function(d,h,f){const p=d.clippingPlanes,g=d.clipIntersection,m=d.clipShadows,_=n.get(d);if(!s||p===null||p.length===0||r&&!m)r?u(null):c();else{const b=r?0:i,A=b*4;let y=_.clippingState||null;l.value=y,y=u(p,h,A,f);for(let M=0;M!==A;++M)y[M]=t[M];_.clippingState=y,this.numIntersection=g?this.numPlanes:0,this.numPlanes+=b}};function c(){l.value!==t&&(l.value=t,l.needsUpdate=i>0),e.numPlanes=i,e.numIntersection=0}function u(d,h,f,p){const g=d!==null?d.length:0;let m=null;if(g!==0){if(m=l.value,p!==!0||m===null){const _=f+g*4,b=h.matrixWorldInverse;o.getNormalMatrix(b),(m===null||m.length<_)&&(m=new Float32Array(_));for(let A=0,y=f;A!==g;++A,y+=4)a.copy(d[A]).applyMatrix4(b,o),a.normal.toArray(m,y),m[y+3]=a.constant}l.value=m,l.needsUpdate=!0}return e.numPlanes=g,e.numIntersection=0,m}}const Oi=4,sh=[.125,.215,.35,.446,.526,.582],Ji=20,Bx=256,mr=new Yc,rh=new Qe;let il=null,sl=0,rl=0,al=!1;const Hx=new B;class ah{constructor(e){this._renderer=e,this._pingPongRenderTarget=null,this._lodMax=0,this._cubeSize=0,this._sizeLods=[],this._sigmas=[],this._lodMeshes=[],this._backgroundBox=null,this._cubemapMaterial=null,this._equirectMaterial=null,this._blurMaterial=null,this._ggxMaterial=null}fromScene(e,t=0,i=.1,s=100,r={}){const{size:a=256,position:o=Hx}=r;il=this._renderer.getRenderTarget(),sl=this._renderer.getActiveCubeFace(),rl=this._renderer.getActiveMipmapLevel(),al=this._renderer.xr.enabled,this._renderer.xr.enabled=!1,this._setSize(a);const l=this._allocateTargets();return l.depthBuffer=!0,this._sceneToCubeUV(e,i,s,l,o),t>0&&this._blur(l,0,0,t),this._applyPMREM(l),this._cleanup(l),l}fromEquirectangular(e,t=null){return this._fromTexture(e,t)}fromCubemap(e,t=null){return this._fromTexture(e,t)}compileCubemapShader(){this._cubemapMaterial===null&&(this._cubemapMaterial=ch(),this._compileMaterial(this._cubemapMaterial))}compileEquirectangularShader(){this._equirectMaterial===null&&(this._equirectMaterial=lh(),this._compileMaterial(this._equirectMaterial))}dispose(){this._dispose(),this._cubemapMaterial!==null&&this._cubemapMaterial.dispose(),this._equirectMaterial!==null&&this._equirectMaterial.dispose(),this._backgroundBox!==null&&(this._backgroundBox.geometry.dispose(),this._backgroundBox.material.dispose())}_setSize(e){this._lodMax=Math.floor(Math.log2(e)),this._cubeSize=Math.pow(2,this._lodMax)}_dispose(){this._blurMaterial!==null&&this._blurMaterial.dispose(),this._ggxMaterial!==null&&this._ggxMaterial.dispose(),this._pingPongRenderTarget!==null&&this._pingPongRenderTarget.dispose();for(let e=0;e2?M:0,M,M),d.setRenderTarget(s),_&&d.render(g,l),d.render(e,l)}d.toneMapping=f,d.autoClear=h,e.background=b}_textureToCubeUV(e,t){const i=this._renderer,s=e.mapping===ns||e.mapping===Ys;s?(this._cubemapMaterial===null&&(this._cubemapMaterial=ch()),this._cubemapMaterial.uniforms.flipEnvMap.value=e.isRenderTargetTexture===!1?-1:1):this._equirectMaterial===null&&(this._equirectMaterial=lh());const r=s?this._cubemapMaterial:this._equirectMaterial,a=this._lodMeshes[0];a.material=r;const o=r.uniforms;o.envMap.value=e;const l=this._cubeSize;Us(t,0,0,3*l,2*l),i.setRenderTarget(t),i.render(a,mr)}_applyPMREM(e){const t=this._renderer,i=t.autoClear;t.autoClear=!1;const s=this._lodMeshes.length;for(let r=1;rp-Oi?i-p+Oi:0),_=4*(this._cubeSize-g);l.envMap.value=e.texture,l.roughness.value=f,l.mipInt.value=p-t,Us(r,m,_,3*g,2*g),s.setRenderTarget(r),s.render(o,mr),l.envMap.value=r.texture,l.roughness.value=0,l.mipInt.value=p-i,Us(e,m,_,3*g,2*g),s.setRenderTarget(e),s.render(o,mr)}_blur(e,t,i,s,r){const a=this._pingPongRenderTarget;this._halfBlur(e,a,t,i,s,"latitudinal",r),this._halfBlur(a,e,i,i,s,"longitudinal",r)}_halfBlur(e,t,i,s,r,a,o){const l=this._renderer,c=this._blurMaterial;a!=="latitudinal"&&a!=="longitudinal"&&at("blur direction must be either latitudinal or longitudinal!");const u=3,d=this._lodMeshes[s];d.material=c;const h=c.uniforms,f=this._sizeLods[i]-1,p=isFinite(r)?Math.PI/(2*f):2*Math.PI/(2*Ji-1),g=r/p,m=isFinite(r)?1+Math.floor(u*g):Ji;m>Ji&&Ye(`sigmaRadians, ${r}, is too large and will clip, as it requested ${m} samples when the maximum is set to ${Ji}`);const _=[];let b=0;for(let E=0;EA-Oi?s-A+Oi:0),S=4*(this._cubeSize-y);Us(t,M,S,3*y,2*y),l.setRenderTarget(t),l.render(d,mr)}}function zx(n){const e=[],t=[],i=[];let s=n;const r=n-Oi+1+sh.length;for(let a=0;an-Oi?l=sh[a-n+Oi-1]:a===0&&(l=0),t.push(l);const c=1/(o-2),u=-c,d=1+c,h=[u,u,d,u,d,d,u,u,d,d,u,d],f=6,p=6,g=3,m=2,_=1,b=new Float32Array(g*p*f),A=new Float32Array(m*p*f),y=new Float32Array(_*p*f);for(let S=0;S2?0:-1,T=[E,v,0,E+2/3,v,0,E+2/3,v+1,0,E,v,0,E+2/3,v+1,0,E,v+1,0];b.set(T,g*p*S),A.set(h,m*p*S);const I=[S,S,S,S,S,S];y.set(I,_*p*S)}const M=new Ct;M.setAttribute("position",new Un(b,g)),M.setAttribute("uv",new Un(A,m)),M.setAttribute("faceIndex",new Un(y,_)),i.push(new Vt(M,null)),s>Oi&&s--}return{lodMeshes:i,sizeLods:e,sigmas:t}}function oh(n,e,t){const i=new jn(n,e,t);return i.texture.mapping=xo,i.texture.name="PMREM.cubeUv",i.scissorTest=!0,i}function Us(n,e,t,i,s){n.viewport.set(e,t,i,s),n.scissor.set(e,t,i,s)}function Vx(n,e,t){return new On({name:"PMREMGGXConvolution",defines:{GGX_SAMPLES:Bx,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},roughness:{value:0},mipInt:{value:0}},vertexShader:vo(),fragmentShader:` + + precision highp float; + precision highp int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform float roughness; + uniform float mipInt; + + #define ENVMAP_TYPE_CUBE_UV + #include + + #define PI 3.14159265359 + + // Van der Corput radical inverse + float radicalInverse_VdC(uint bits) { + bits = (bits << 16u) | (bits >> 16u); + bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); + bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); + bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); + bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); + return float(bits) * 2.3283064365386963e-10; // / 0x100000000 + } + + // Hammersley sequence + vec2 hammersley(uint i, uint N) { + return vec2(float(i) / float(N), radicalInverse_VdC(i)); + } + + // GGX VNDF importance sampling (Eric Heitz 2018) + // "Sampling the GGX Distribution of Visible Normals" + // https://jcgt.org/published/0007/04/01/ + vec3 importanceSampleGGX_VNDF(vec2 Xi, vec3 V, float roughness) { + float alpha = roughness * roughness; + + // Section 4.1: Orthonormal basis + vec3 T1 = vec3(1.0, 0.0, 0.0); + vec3 T2 = cross(V, T1); + + // Section 4.2: Parameterization of projected area + float r = sqrt(Xi.x); + float phi = 2.0 * PI * Xi.y; + float t1 = r * cos(phi); + float t2 = r * sin(phi); + float s = 0.5 * (1.0 + V.z); + t2 = (1.0 - s) * sqrt(1.0 - t1 * t1) + s * t2; + + // Section 4.3: Reprojection onto hemisphere + vec3 Nh = t1 * T1 + t2 * T2 + sqrt(max(0.0, 1.0 - t1 * t1 - t2 * t2)) * V; + + // Section 3.4: Transform back to ellipsoid configuration + return normalize(vec3(alpha * Nh.x, alpha * Nh.y, max(0.0, Nh.z))); + } + + void main() { + vec3 N = normalize(vOutputDirection); + vec3 V = N; // Assume view direction equals normal for pre-filtering + + vec3 prefilteredColor = vec3(0.0); + float totalWeight = 0.0; + + // For very low roughness, just sample the environment directly + if (roughness < 0.001) { + gl_FragColor = vec4(bilinearCubeUV(envMap, N, mipInt), 1.0); + return; + } + + // Tangent space basis for VNDF sampling + vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); + vec3 tangent = normalize(cross(up, N)); + vec3 bitangent = cross(N, tangent); + + for(uint i = 0u; i < uint(GGX_SAMPLES); i++) { + vec2 Xi = hammersley(i, uint(GGX_SAMPLES)); + + // For PMREM, V = N, so in tangent space V is always (0, 0, 1) + vec3 H_tangent = importanceSampleGGX_VNDF(Xi, vec3(0.0, 0.0, 1.0), roughness); + + // Transform H back to world space + vec3 H = normalize(tangent * H_tangent.x + bitangent * H_tangent.y + N * H_tangent.z); + vec3 L = normalize(2.0 * dot(V, H) * H - V); + + float NdotL = max(dot(N, L), 0.0); + + if(NdotL > 0.0) { + // Sample environment at fixed mip level + // VNDF importance sampling handles the distribution filtering + vec3 sampleColor = bilinearCubeUV(envMap, L, mipInt); + + // Weight by NdotL for the split-sum approximation + // VNDF PDF naturally accounts for the visible microfacet distribution + prefilteredColor += sampleColor * NdotL; + totalWeight += NdotL; + } + } + + if (totalWeight > 0.0) { + prefilteredColor = prefilteredColor / totalWeight; + } + + gl_FragColor = vec4(prefilteredColor, 1.0); + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function Gx(n,e,t){const i=new Float32Array(Ji),s=new B(0,1,0);return new On({name:"SphericalGaussianBlur",defines:{n:Ji,CUBEUV_TEXEL_WIDTH:1/e,CUBEUV_TEXEL_HEIGHT:1/t,CUBEUV_MAX_MIP:`${n}.0`},uniforms:{envMap:{value:null},samples:{value:1},weights:{value:i},latitudinal:{value:!1},dTheta:{value:0},mipInt:{value:0},poleAxis:{value:s}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + uniform int samples; + uniform float weights[ n ]; + uniform bool latitudinal; + uniform float dTheta; + uniform float mipInt; + uniform vec3 poleAxis; + + #define ENVMAP_TYPE_CUBE_UV + #include + + vec3 getSample( float theta, vec3 axis ) { + + float cosTheta = cos( theta ); + // Rodrigues' axis-angle rotation + vec3 sampleDirection = vOutputDirection * cosTheta + + cross( axis, vOutputDirection ) * sin( theta ) + + axis * dot( axis, vOutputDirection ) * ( 1.0 - cosTheta ); + + return bilinearCubeUV( envMap, sampleDirection, mipInt ); + + } + + void main() { + + vec3 axis = latitudinal ? poleAxis : cross( poleAxis, vOutputDirection ); + + if ( all( equal( axis, vec3( 0.0 ) ) ) ) { + + axis = vec3( vOutputDirection.z, 0.0, - vOutputDirection.x ); + + } + + axis = normalize( axis ); + + gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 ); + gl_FragColor.rgb += weights[ 0 ] * getSample( 0.0, axis ); + + for ( int i = 1; i < n; i++ ) { + + if ( i >= samples ) { + + break; + + } + + float theta = dTheta * float( i ); + gl_FragColor.rgb += weights[ i ] * getSample( -1.0 * theta, axis ); + gl_FragColor.rgb += weights[ i ] * getSample( theta, axis ); + + } + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function lh(){return new On({name:"EquirectangularToCubeUV",uniforms:{envMap:{value:null}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + varying vec3 vOutputDirection; + + uniform sampler2D envMap; + + #include + + void main() { + + vec3 outputDirection = normalize( vOutputDirection ); + vec2 uv = equirectUv( outputDirection ); + + gl_FragColor = vec4( texture2D ( envMap, uv ).rgb, 1.0 ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function ch(){return new On({name:"CubemapToCubeUV",uniforms:{envMap:{value:null},flipEnvMap:{value:-1}},vertexShader:vo(),fragmentShader:` + + precision mediump float; + precision mediump int; + + uniform float flipEnvMap; + + varying vec3 vOutputDirection; + + uniform samplerCube envMap; + + void main() { + + gl_FragColor = textureCube( envMap, vec3( flipEnvMap * vOutputDirection.x, vOutputDirection.yz ) ); + + } + `,blending:fi,depthTest:!1,depthWrite:!1})}function vo(){return` + + precision mediump float; + precision mediump int; + + attribute float faceIndex; + + varying vec3 vOutputDirection; + + // RH coordinate system; PMREM face-indexing convention + vec3 getDirection( vec2 uv, float face ) { + + uv = 2.0 * uv - 1.0; + + vec3 direction = vec3( uv, 1.0 ); + + if ( face == 0.0 ) { + + direction = direction.zyx; // ( 1, v, u ) pos x + + } else if ( face == 1.0 ) { + + direction = direction.xzy; + direction.xz *= -1.0; // ( -u, 1, -v ) pos y + + } else if ( face == 2.0 ) { + + direction.x *= -1.0; // ( -u, v, 1 ) pos z + + } else if ( face == 3.0 ) { + + direction = direction.zyx; + direction.xz *= -1.0; // ( -1, v, -u ) neg x + + } else if ( face == 4.0 ) { + + direction = direction.xzy; + direction.xy *= -1.0; // ( -u, -1, v ) neg y + + } else if ( face == 5.0 ) { + + direction.z *= -1.0; // ( u, v, -1 ) neg z + + } + + return direction; + + } + + void main() { + + vOutputDirection = getDirection( uv, faceIndex ); + gl_Position = vec4( position, 1.0 ); + + } + `}class Af extends jn{constructor(e=1,t={}){super(e,e,t),this.isWebGLCubeRenderTarget=!0;const i={width:e,height:e,depth:1},s=[i,i,i,i,i,i];this.texture=new cf(s),this._setTextureOptions(t),this.texture.isRenderTargetTexture=!0}fromEquirectangularTexture(e,t){this.texture.type=t.type,this.texture.colorSpace=t.colorSpace,this.texture.generateMipmaps=t.generateMipmaps,this.texture.minFilter=t.minFilter,this.texture.magFilter=t.magFilter;const i={uniforms:{tEquirect:{value:null}},vertexShader:` + + varying vec3 vWorldDirection; + + vec3 transformDirection( in vec3 dir, in mat4 matrix ) { + + return normalize( ( matrix * vec4( dir, 0.0 ) ).xyz ); + + } + + void main() { + + vWorldDirection = transformDirection( position, modelMatrix ); + + #include + #include + + } + `,fragmentShader:` + + uniform sampler2D tEquirect; + + varying vec3 vWorldDirection; + + #include + + void main() { + + vec3 direction = normalize( vWorldDirection ); + + vec2 sampleUV = equirectUv( direction ); + + gl_FragColor = texture2D( tEquirect, sampleUV ); + + } + `},s=new Fr(5,5,5),r=new On({name:"CubemapFromEquirect",uniforms:Zs(i.uniforms),vertexShader:i.vertexShader,fragmentShader:i.fragmentShader,side:cn,blending:fi});r.uniforms.tEquirect.value=t;const a=new Vt(s,r),o=t.minFilter;return t.minFilter===Ui&&(t.minFilter=Xt),new qm(1,10,this).update(e,a),t.minFilter=o,a.geometry.dispose(),a.material.dispose(),this}clear(e,t=!0,i=!0,s=!0){const r=e.getRenderTarget();for(let a=0;a<6;a++)e.setRenderTarget(this,a),e.clear(t,i,s);e.setRenderTarget(r)}}function Wx(n){let e=new WeakMap,t=new WeakMap,i=null;function s(h,f=!1){return h==null?null:f?a(h):r(h)}function r(h){if(h&&h.isTexture){const f=h.mapping;if(f===To||f===Co)if(e.has(h)){const p=e.get(h).texture;return o(p,h.mapping)}else{const p=h.image;if(p&&p.height>0){const g=new Af(p.height);return g.fromEquirectangularTexture(n,h),e.set(h,g),h.addEventListener("dispose",c),o(g.texture,h.mapping)}else return null}}return h}function a(h){if(h&&h.isTexture){const f=h.mapping,p=f===To||f===Co,g=f===ns||f===Ys;if(p||g){let m=t.get(h);const _=m!==void 0?m.texture.pmremVersion:0;if(h.isRenderTargetTexture&&h.pmremVersion!==_)return i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h,m):i.fromCubemap(h,m),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),m.texture;if(m!==void 0)return m.texture;{const b=h.image;return p&&b&&b.height>0||g&&b&&l(b)?(i===null&&(i=new ah(n)),m=p?i.fromEquirectangular(h):i.fromCubemap(h),m.texture.pmremVersion=h.pmremVersion,t.set(h,m),h.addEventListener("dispose",u),m.texture):null}}}return h}function o(h,f){return f===To?h.mapping=ns:f===Co&&(h.mapping=Ys),h}function l(h){let f=0;const p=6;for(let g=0;g=65535?sf:nf)(h,1);m.version=g;const _=r.get(d);_&&e.remove(_),r.set(d,m)}function u(d){const h=r.get(d);if(h){const f=d.index;f!==null&&h.versione.maxTextureSize&&(S=Math.ceil(M/e.maxTextureSize),M=e.maxTextureSize);const E=new Float32Array(M*S*4*d),v=new Qd(E,M,S,d);v.type=Pn,v.needsUpdate=!0;const T=y*4;for(let L=0;L + #include + + void main() { + gl_FragColor = texture2D( tDiffuse, vUv ); + + #ifdef LINEAR_TONE_MAPPING + gl_FragColor.rgb = LinearToneMapping( gl_FragColor.rgb ); + #elif defined( REINHARD_TONE_MAPPING ) + gl_FragColor.rgb = ReinhardToneMapping( gl_FragColor.rgb ); + #elif defined( CINEON_TONE_MAPPING ) + gl_FragColor.rgb = CineonToneMapping( gl_FragColor.rgb ); + #elif defined( ACES_FILMIC_TONE_MAPPING ) + gl_FragColor.rgb = ACESFilmicToneMapping( gl_FragColor.rgb ); + #elif defined( AGX_TONE_MAPPING ) + gl_FragColor.rgb = AgXToneMapping( gl_FragColor.rgb ); + #elif defined( NEUTRAL_TONE_MAPPING ) + gl_FragColor.rgb = NeutralToneMapping( gl_FragColor.rgb ); + #elif defined( CUSTOM_TONE_MAPPING ) + gl_FragColor.rgb = CustomToneMapping( gl_FragColor.rgb ); + #endif + + #ifdef SRGB_TRANSFER + gl_FragColor = sRGBTransferOETF( gl_FragColor ); + #endif + }`,depthTest:!1,depthWrite:!1}),u=new Vt(l,c),d=new Yc(-1,1,1,-1,0,1);let h=null,f=null,p=!1,g,m=null,_=[],b=!1;this.setSize=function(A,y){a.setSize(A,y),o.setSize(A,y);for(let M=0;M<_.length;M++){const S=_[M];S.setSize&&S.setSize(A,y)}},this.setEffects=function(A){_=A,b=_.length>0&&_[0].isRenderPass===!0;const y=a.width,M=a.height;for(let S=0;S<_.length;S++){const E=_[S];E.setSize&&E.setSize(y,M)}},this.begin=function(A,y){if(p||A.toneMapping===Jn&&_.length===0)return!1;if(m=y,y!==null){const M=y.width,S=y.height;(a.width!==M||a.height!==S)&&this.setSize(M,S)}return b===!1&&A.setRenderTarget(a),g=A.toneMapping,A.toneMapping=Jn,!0},this.hasRenderPass=function(){return b},this.end=function(A,y){A.toneMapping=g,p=!0;let M=a,S=o;for(let E=0;E<_.length;E++){const v=_[E];if(v.enabled!==!1&&(v.render(A,S,M,y),v.needsSwap!==!1)){const T=M;M=S,S=T}}if(h!==A.outputColorSpace||f!==A.toneMapping){h=A.outputColorSpace,f=A.toneMapping,c.defines={},it.getTransfer(h)===ft&&(c.defines.SRGB_TRANSFER="");const E=Jx[f];E&&(c.defines[E]=""),c.needsUpdate=!0}c.uniforms.tDiffuse.value=M.texture,A.setRenderTarget(m),A.render(u,d),m=null,p=!1},this.isCompositing=function(){return p},this.dispose=function(){a.depthTexture&&a.depthTexture.dispose(),a.dispose(),o.dispose(),l.dispose(),c.dispose()}}const Ef=new Jt,yc=new Ks(1,1),Tf=new Qd,Cf=new G0,wf=new cf,uh=[],hh=[],dh=new Float32Array(16),fh=new Float32Array(9),ph=new Float32Array(4);function ir(n,e,t){const i=n[0];if(i<=0||i>0)return n;const s=e*t;let r=uh[s];if(r===void 0&&(r=new Float32Array(s),uh[s]=r),e!==0){i.toArray(r,0);for(let a=1,o=0;a!==e;++a)o+=t,n[a].toArray(r,o)}return r}function kt(n,e){if(n.length!==e.length)return!1;for(let t=0,i=n.length;t0&&(this.seq=s.concat(r))}setValue(e,t,i,s){const r=this.map[t];r!==void 0&&r.setValue(e,i,s)}setOptional(e,t,i){const s=t[i];s!==void 0&&this.setValue(e,i,s)}static upload(e,t,i,s){for(let r=0,a=t.length;r!==a;++r){const o=t[r],l=i[o.id];l.needsUpdate!==!1&&o.setValue(e,l.value,s)}}static seqWithValue(e,t){const i=[];for(let s=0,r=e.length;s!==r;++s){const a=e[s];a.id in t&&i.push(a)}return i}}function gh(n,e,t){const i=n.createShader(e);return n.shaderSource(i,t),n.compileShader(i),i}const G1=37297;let W1=0;function X1(n,e){const t=n.split(` +`),i=[],s=Math.max(e-6,0),r=Math.min(e+6,t.length);for(let a=s;a":" "} ${o}: ${t[a]}`)}return i.join(` +`)}const _h=new qe;function Y1(n){it._getMatrix(_h,it.workingColorSpace,n);const e=`mat3( ${_h.elements.map(t=>t.toFixed(4))} )`;switch(it.getTransfer(n)){case $a:return[e,"LinearTransferOETF"];case ft:return[e,"sRGBTransferOETF"];default:return Ye("WebGLProgram: Unsupported color space: ",n),[e,"LinearTransferOETF"]}}function xh(n,e,t){const i=n.getShaderParameter(e,n.COMPILE_STATUS),r=(n.getShaderInfoLog(e)||"").trim();if(i&&r==="")return"";const a=/ERROR: 0:(\d+)/.exec(r);if(a){const o=parseInt(a[1]);return t.toUpperCase()+` + +`+r+` + +`+X1(n.getShaderSource(e),o)}else return r}function K1(n,e){const t=Y1(e);return[`vec4 ${n}( vec4 value ) {`,` return ${t[1]}( vec4( value.rgb * ${t[0]}, value.a ) );`,"}"].join(` +`)}const q1={[kd]:"Linear",[Fd]:"Reinhard",[Bd]:"Cineon",[Hd]:"ACESFilmic",[Vd]:"AgX",[Gd]:"Neutral",[zd]:"Custom"};function Z1(n,e){const t=q1[e];return t===void 0?(Ye("WebGLProgram: Unsupported toneMapping:",e),"vec3 "+n+"( vec3 color ) { return LinearToneMapping( color ); }"):"vec3 "+n+"( vec3 color ) { return "+t+"ToneMapping( color ); }"}const Ma=new B;function $1(){it.getLuminanceCoefficients(Ma);const n=Ma.x.toFixed(4),e=Ma.y.toFixed(4),t=Ma.z.toFixed(4);return["float luminance( const in vec3 rgb ) {",` const vec3 weights = vec3( ${n}, ${e}, ${t} );`," return dot( weights, rgb );","}"].join(` +`)}function J1(n){return[n.extensionClipCullDistance?"#extension GL_ANGLE_clip_cull_distance : require":"",n.extensionMultiDraw?"#extension GL_ANGLE_multi_draw : require":""].filter(br).join(` +`)}function j1(n){const e=[];for(const t in n){const i=n[t];i!==!1&&e.push("#define "+t+" "+i)}return e.join(` +`)}function Q1(n,e){const t={},i=n.getProgramParameter(e,n.ACTIVE_ATTRIBUTES);for(let s=0;s/gm;function vc(n){return n.replace(ey,ny)}const ty=new Map;function ny(n,e){let t=$e[e];if(t===void 0){const i=ty.get(e);if(i!==void 0)t=$e[i],Ye('WebGLRenderer: Shader chunk "%s" has been deprecated. Use "%s" instead.',e,i);else throw new Error("THREE.WebGLProgram: Can not resolve #include <"+e+">")}return vc(t)}const iy=/#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 Sh(n){return n.replace(iy,sy)}function sy(n,e,t,i){let s="";for(let r=parseInt(e);r0&&(m+=` +`),_=["#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p].filter(br).join(` +`),_.length>0&&(_+=` +`)):(m=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.extensionClipCullDistance?"#define USE_CLIP_DISTANCE":"",t.batching?"#define USE_BATCHING":"",t.batchingColor?"#define USE_BATCHING_COLOR":"",t.instancing?"#define USE_INSTANCING":"",t.instancingColor?"#define USE_INSTANCING_COLOR":"",t.instancingMorph?"#define USE_INSTANCING_MORPH":"",t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.map?"#define USE_MAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+u:"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.displacementMap?"#define USE_DISPLACEMENTMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.mapUv?"#define MAP_UV "+t.mapUv:"",t.alphaMapUv?"#define ALPHAMAP_UV "+t.alphaMapUv:"",t.lightMapUv?"#define LIGHTMAP_UV "+t.lightMapUv:"",t.aoMapUv?"#define AOMAP_UV "+t.aoMapUv:"",t.emissiveMapUv?"#define EMISSIVEMAP_UV "+t.emissiveMapUv:"",t.bumpMapUv?"#define BUMPMAP_UV "+t.bumpMapUv:"",t.normalMapUv?"#define NORMALMAP_UV "+t.normalMapUv:"",t.displacementMapUv?"#define DISPLACEMENTMAP_UV "+t.displacementMapUv:"",t.metalnessMapUv?"#define METALNESSMAP_UV "+t.metalnessMapUv:"",t.roughnessMapUv?"#define ROUGHNESSMAP_UV "+t.roughnessMapUv:"",t.anisotropyMapUv?"#define ANISOTROPYMAP_UV "+t.anisotropyMapUv:"",t.clearcoatMapUv?"#define CLEARCOATMAP_UV "+t.clearcoatMapUv:"",t.clearcoatNormalMapUv?"#define CLEARCOAT_NORMALMAP_UV "+t.clearcoatNormalMapUv:"",t.clearcoatRoughnessMapUv?"#define CLEARCOAT_ROUGHNESSMAP_UV "+t.clearcoatRoughnessMapUv:"",t.iridescenceMapUv?"#define IRIDESCENCEMAP_UV "+t.iridescenceMapUv:"",t.iridescenceThicknessMapUv?"#define IRIDESCENCE_THICKNESSMAP_UV "+t.iridescenceThicknessMapUv:"",t.sheenColorMapUv?"#define SHEEN_COLORMAP_UV "+t.sheenColorMapUv:"",t.sheenRoughnessMapUv?"#define SHEEN_ROUGHNESSMAP_UV "+t.sheenRoughnessMapUv:"",t.specularMapUv?"#define SPECULARMAP_UV "+t.specularMapUv:"",t.specularColorMapUv?"#define SPECULAR_COLORMAP_UV "+t.specularColorMapUv:"",t.specularIntensityMapUv?"#define SPECULAR_INTENSITYMAP_UV "+t.specularIntensityMapUv:"",t.transmissionMapUv?"#define TRANSMISSIONMAP_UV "+t.transmissionMapUv:"",t.thicknessMapUv?"#define THICKNESSMAP_UV "+t.thicknessMapUv:"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexNormals?"#define HAS_NORMAL":"",t.vertexColors?"#define USE_COLOR":"",t.vertexAlphas?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.flatShading?"#define FLAT_SHADED":"",t.skinning?"#define USE_SKINNING":"",t.morphTargets?"#define USE_MORPHTARGETS":"",t.morphNormals&&t.flatShading===!1?"#define USE_MORPHNORMALS":"",t.morphColors?"#define USE_MORPHCOLORS":"",t.morphTargetsCount>0?"#define MORPHTARGETS_TEXTURE_STRIDE "+t.morphTextureStride:"",t.morphTargetsCount>0?"#define MORPHTARGETS_COUNT "+t.morphTargetsCount:"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.sizeAttenuation?"#define USE_SIZEATTENUATION":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;","uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;","#ifdef USE_INSTANCING"," attribute mat4 instanceMatrix;","#endif","#ifdef USE_INSTANCING_COLOR"," attribute vec3 instanceColor;","#endif","#ifdef USE_INSTANCING_MORPH"," uniform sampler2D morphTexture;","#endif","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_UV1"," attribute vec2 uv1;","#endif","#ifdef USE_UV2"," attribute vec2 uv2;","#endif","#ifdef USE_UV3"," attribute vec2 uv3;","#endif","#ifdef USE_TANGENT"," attribute vec4 tangent;","#endif","#if defined( USE_COLOR_ALPHA )"," attribute vec4 color;","#elif defined( USE_COLOR )"," attribute vec3 color;","#endif","#ifdef USE_SKINNING"," attribute vec4 skinIndex;"," attribute vec4 skinWeight;","#endif",` +`].filter(br).join(` +`),_=[bh(t),"#define SHADER_TYPE "+t.shaderType,"#define SHADER_NAME "+t.shaderName,p,t.useFog&&t.fog?"#define USE_FOG":"",t.useFog&&t.fogExp2?"#define FOG_EXP2":"",t.alphaToCoverage?"#define ALPHA_TO_COVERAGE":"",t.map?"#define USE_MAP":"",t.matcap?"#define USE_MATCAP":"",t.envMap?"#define USE_ENVMAP":"",t.envMap?"#define "+c:"",t.envMap?"#define "+u:"",t.envMap?"#define "+d:"",h?"#define CUBEUV_TEXEL_WIDTH "+h.texelWidth:"",h?"#define CUBEUV_TEXEL_HEIGHT "+h.texelHeight:"",h?"#define CUBEUV_MAX_MIP "+h.maxMip+".0":"",t.lightMap?"#define USE_LIGHTMAP":"",t.aoMap?"#define USE_AOMAP":"",t.bumpMap?"#define USE_BUMPMAP":"",t.normalMap?"#define USE_NORMALMAP":"",t.normalMapObjectSpace?"#define USE_NORMALMAP_OBJECTSPACE":"",t.normalMapTangentSpace?"#define USE_NORMALMAP_TANGENTSPACE":"",t.packedNormalMap?"#define USE_PACKED_NORMALMAP":"",t.emissiveMap?"#define USE_EMISSIVEMAP":"",t.anisotropy?"#define USE_ANISOTROPY":"",t.anisotropyMap?"#define USE_ANISOTROPYMAP":"",t.clearcoat?"#define USE_CLEARCOAT":"",t.clearcoatMap?"#define USE_CLEARCOATMAP":"",t.clearcoatRoughnessMap?"#define USE_CLEARCOAT_ROUGHNESSMAP":"",t.clearcoatNormalMap?"#define USE_CLEARCOAT_NORMALMAP":"",t.dispersion?"#define USE_DISPERSION":"",t.iridescence?"#define USE_IRIDESCENCE":"",t.iridescenceMap?"#define USE_IRIDESCENCEMAP":"",t.iridescenceThicknessMap?"#define USE_IRIDESCENCE_THICKNESSMAP":"",t.specularMap?"#define USE_SPECULARMAP":"",t.specularColorMap?"#define USE_SPECULAR_COLORMAP":"",t.specularIntensityMap?"#define USE_SPECULAR_INTENSITYMAP":"",t.roughnessMap?"#define USE_ROUGHNESSMAP":"",t.metalnessMap?"#define USE_METALNESSMAP":"",t.alphaMap?"#define USE_ALPHAMAP":"",t.alphaTest?"#define USE_ALPHATEST":"",t.alphaHash?"#define USE_ALPHAHASH":"",t.sheen?"#define USE_SHEEN":"",t.sheenColorMap?"#define USE_SHEEN_COLORMAP":"",t.sheenRoughnessMap?"#define USE_SHEEN_ROUGHNESSMAP":"",t.transmission?"#define USE_TRANSMISSION":"",t.transmissionMap?"#define USE_TRANSMISSIONMAP":"",t.thicknessMap?"#define USE_THICKNESSMAP":"",t.vertexTangents&&t.flatShading===!1?"#define USE_TANGENT":"",t.vertexColors||t.instancingColor?"#define USE_COLOR":"",t.vertexAlphas||t.batchingColor?"#define USE_COLOR_ALPHA":"",t.vertexUv1s?"#define USE_UV1":"",t.vertexUv2s?"#define USE_UV2":"",t.vertexUv3s?"#define USE_UV3":"",t.pointsUvs?"#define USE_POINTS_UV":"",t.gradientMap?"#define USE_GRADIENTMAP":"",t.flatShading?"#define FLAT_SHADED":"",t.doubleSided?"#define DOUBLE_SIDED":"",t.flipSided?"#define FLIP_SIDED":"",t.shadowMapEnabled?"#define USE_SHADOWMAP":"",t.shadowMapEnabled?"#define "+l:"",t.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",t.numLightProbes>0?"#define USE_LIGHT_PROBES":"",t.numLightProbeGrids>0?"#define USE_LIGHT_PROBES_GRID":"",t.decodeVideoTexture?"#define DECODE_VIDEO_TEXTURE":"",t.decodeVideoTextureEmissive?"#define DECODE_VIDEO_TEXTURE_EMISSIVE":"",t.logarithmicDepthBuffer?"#define USE_LOGARITHMIC_DEPTH_BUFFER":"",t.reversedDepthBuffer?"#define USE_REVERSED_DEPTH_BUFFER":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;","uniform bool isOrthographic;",t.toneMapping!==Jn?"#define TONE_MAPPING":"",t.toneMapping!==Jn?$e.tonemapping_pars_fragment:"",t.toneMapping!==Jn?Z1("toneMapping",t.toneMapping):"",t.dithering?"#define DITHERING":"",t.opaque?"#define OPAQUE":"",$e.colorspace_pars_fragment,K1("linearToOutputTexel",t.outputColorSpace),$1(),t.useDepthPacking?"#define DEPTH_PACKING "+t.depthPacking:"",` +`].filter(br).join(` +`)),a=vc(a),a=yh(a,t),a=vh(a,t),o=vc(o),o=yh(o,t),o=vh(o,t),a=Sh(a),o=Sh(o),t.isRawShaderMaterial!==!0&&(b=`#version 300 es +`,m=[f,"#define attribute in","#define varying out","#define texture2D texture"].join(` +`)+` +`+m,_=["#define varying in",t.glslVersion===pc?"":"layout(location = 0) out highp vec4 pc_fragColor;",t.glslVersion===pc?"":"#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(` +`)+` +`+_);const A=b+m+a,y=b+_+o,M=gh(s,s.VERTEX_SHADER,A),S=gh(s,s.FRAGMENT_SHADER,y);s.attachShader(g,M),s.attachShader(g,S),t.index0AttributeName!==void 0?s.bindAttribLocation(g,0,t.index0AttributeName):t.hasPositionAttribute===!0&&s.bindAttribLocation(g,0,"position"),s.linkProgram(g);function E(L){if(n.debug.checkShaderErrors){const w=s.getProgramInfoLog(g)||"",U=s.getShaderInfoLog(M)||"",O=s.getShaderInfoLog(S)||"",P=w.trim(),Z=U.trim(),N=O.trim();let W=!0,D=!0;if(s.getProgramParameter(g,s.LINK_STATUS)===!1)if(W=!1,typeof n.debug.onShaderError=="function")n.debug.onShaderError(s,g,M,S);else{const re=xh(s,M,"vertex"),ie=xh(s,S,"fragment");at("WebGLProgram: Shader Error "+s.getError()+" - VALIDATE_STATUS "+s.getProgramParameter(g,s.VALIDATE_STATUS)+` + +Material Name: `+L.name+` +Material Type: `+L.type+` + +Program Info Log: `+P+` +`+re+` +`+ie)}else P!==""?Ye("WebGLProgram: Program Info Log:",P):(Z===""||N==="")&&(D=!1);D&&(L.diagnostics={runnable:W,programLog:P,vertexShader:{log:Z,prefix:m},fragmentShader:{log:N,prefix:_}})}s.deleteShader(M),s.deleteShader(S),v=new Va(s,g),T=Q1(s,g)}let v;this.getUniforms=function(){return v===void 0&&E(this),v};let T;this.getAttributes=function(){return T===void 0&&E(this),T};let I=t.rendererExtensionParallelShaderCompile===!1;return this.isReady=function(){return I===!1&&(I=s.getProgramParameter(g,G1)),I},this.destroy=function(){i.releaseStatesOfProgram(this),s.deleteProgram(g),this.program=void 0},this.type=t.shaderType,this.name=t.shaderName,this.id=W1++,this.cacheKey=e,this.usedTimes=1,this.program=g,this.vertexShader=M,this.fragmentShader=S,this}let my=0;class gy{constructor(){this.shaderCache=new Map,this.materialCache=new Map}update(e,t,i){const s=this._getShaderCacheForMaterial(e);return s.has(t)===!1&&(s.add(t),t.usedTimes++),s.has(i)===!1&&(s.add(i),i.usedTimes++),this}remove(e){const t=this.materialCache.get(e);for(const i of t)i.usedTimes--,i.usedTimes===0&&this.shaderCache.delete(i.code);return this.materialCache.delete(e),this}getVertexShaderStage(e){return this._getShaderStage(e.vertexShader)}getFragmentShaderStage(e){return this._getShaderStage(e.fragmentShader)}dispose(){this.shaderCache.clear(),this.materialCache.clear()}_getShaderCacheForMaterial(e){const t=this.materialCache;let i=t.get(e);return i===void 0&&(i=new Set,t.set(e,i)),i}_getShaderStage(e){const t=this.shaderCache;let i=t.get(e);return i===void 0&&(i=new _y(e),t.set(e,i)),i}}class _y{constructor(e){this.id=my++,this.code=e,this.usedTimes=0}}function xy(n){return n===is||n===Ka||n===qa}function yy(n,e,t,i,s,r){const a=new ef,o=new gy,l=new Set,c=[],u=new Map,d=i.logarithmicDepthBuffer;let h=i.precision;const f={MeshDepthMaterial:"depth",MeshDistanceMaterial:"distance",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshToonMaterial:"toon",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",MeshMatcapMaterial:"matcap",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points",ShadowMaterial:"shadow",SpriteMaterial:"sprite"};function p(v){return l.add(v),v===0?"uv":`uv${v}`}function g(v,T,I,L,w,U){const O=L.fog,P=w.geometry,Z=v.isMeshStandardMaterial||v.isMeshLambertMaterial||v.isMeshPhongMaterial?L.environment:null,N=v.isMeshStandardMaterial||v.isMeshLambertMaterial&&!v.envMap||v.isMeshPhongMaterial&&!v.envMap,W=e.get(v.envMap||Z,N),D=W&&W.mapping===xo?W.image.height:null,re=f[v.type];v.precision!==null&&(h=i.getMaxPrecision(v.precision),h!==v.precision&&Ye("WebGLProgram.getParameters:",v.precision,"not supported, using",h,"instead."));const ie=P.morphAttributes.position||P.morphAttributes.normal||P.morphAttributes.color,oe=ie!==void 0?ie.length:0;let _e=0;P.morphAttributes.position!==void 0&&(_e=1),P.morphAttributes.normal!==void 0&&(_e=2),P.morphAttributes.color!==void 0&&(_e=3);let de,le,z,ne;if(re){const Ne=Kn[re];de=Ne.vertexShader,le=Ne.fragmentShader}else{de=v.vertexShader,le=v.fragmentShader;const Ne=o.getVertexShaderStage(v),Mt=o.getFragmentShaderStage(v);o.update(v,Ne,Mt),z=Ne.id,ne=Mt.id}const J=n.getRenderTarget(),xe=n.state.buffers.depth.getReversed(),Ae=w.isInstancedMesh===!0,Se=w.isBatchedMesh===!0,Be=!!v.map,ze=!!v.matcap,Ue=!!W,Oe=!!v.aoMap,Xe=!!v.lightMap,tt=!!v.bumpMap&&v.wireframe===!1,rt=!!v.normalMap,mt=!!v.displacementMap,yt=!!v.emissiveMap,ct=!!v.metalnessMap,ut=!!v.roughnessMap,V=v.anisotropy>0,et=v.clearcoat>0,se=v.dispersion>0,R=v.iridescence>0,x=v.sheen>0,G=v.transmission>0,H=V&&!!v.anisotropyMap,$=et&&!!v.clearcoatMap,fe=et&&!!v.clearcoatNormalMap,X=et&&!!v.clearcoatRoughnessMap,F=R&&!!v.iridescenceMap,Y=R&&!!v.iridescenceThicknessMap,ae=x&&!!v.sheenColorMap,ce=x&&!!v.sheenRoughnessMap,he=!!v.specularMap,ee=!!v.specularColorMap,ge=!!v.specularIntensityMap,we=G&&!!v.transmissionMap,Ge=G&&!!v.thicknessMap,k=!!v.gradientMap,ye=!!v.alphaMap,ue=v.alphaTest>0,ve=!!v.alphaHash,Me=!!v.extensions;let pe=Jn;v.toneMapped&&(J===null||J.isXRRenderTarget===!0)&&(pe=n.toneMapping);const Fe={shaderID:re,shaderType:v.type,shaderName:v.name,vertexShader:de,fragmentShader:le,defines:v.defines,customVertexShaderID:z,customFragmentShaderID:ne,isRawShaderMaterial:v.isRawShaderMaterial===!0,glslVersion:v.glslVersion,precision:h,batching:Se,batchingColor:Se&&w._colorsTexture!==null,instancing:Ae,instancingColor:Ae&&w.instanceColor!==null,instancingMorph:Ae&&w.morphTexture!==null,outputColorSpace:J===null?n.outputColorSpace:J.isXRRenderTarget===!0?J.texture.colorSpace:it.workingColorSpace,alphaToCoverage:!!v.alphaToCoverage,map:Be,matcap:ze,envMap:Ue,envMapMode:Ue&&W.mapping,envMapCubeUVHeight:D,aoMap:Oe,lightMap:Xe,bumpMap:tt,normalMap:rt,displacementMap:mt,emissiveMap:yt,normalMapObjectSpace:rt&&v.normalMapType===E0,normalMapTangentSpace:rt&&v.normalMapType===vu,packedNormalMap:rt&&v.normalMapType===vu&&xy(v.normalMap.format),metalnessMap:ct,roughnessMap:ut,anisotropy:V,anisotropyMap:H,clearcoat:et,clearcoatMap:$,clearcoatNormalMap:fe,clearcoatRoughnessMap:X,dispersion:se,iridescence:R,iridescenceMap:F,iridescenceThicknessMap:Y,sheen:x,sheenColorMap:ae,sheenRoughnessMap:ce,specularMap:he,specularColorMap:ee,specularIntensityMap:ge,transmission:G,transmissionMap:we,thicknessMap:Ge,gradientMap:k,opaque:v.transparent===!1&&v.blending===zs&&v.alphaToCoverage===!1,alphaMap:ye,alphaTest:ue,alphaHash:ve,combine:v.combine,mapUv:Be&&p(v.map.channel),aoMapUv:Oe&&p(v.aoMap.channel),lightMapUv:Xe&&p(v.lightMap.channel),bumpMapUv:tt&&p(v.bumpMap.channel),normalMapUv:rt&&p(v.normalMap.channel),displacementMapUv:mt&&p(v.displacementMap.channel),emissiveMapUv:yt&&p(v.emissiveMap.channel),metalnessMapUv:ct&&p(v.metalnessMap.channel),roughnessMapUv:ut&&p(v.roughnessMap.channel),anisotropyMapUv:H&&p(v.anisotropyMap.channel),clearcoatMapUv:$&&p(v.clearcoatMap.channel),clearcoatNormalMapUv:fe&&p(v.clearcoatNormalMap.channel),clearcoatRoughnessMapUv:X&&p(v.clearcoatRoughnessMap.channel),iridescenceMapUv:F&&p(v.iridescenceMap.channel),iridescenceThicknessMapUv:Y&&p(v.iridescenceThicknessMap.channel),sheenColorMapUv:ae&&p(v.sheenColorMap.channel),sheenRoughnessMapUv:ce&&p(v.sheenRoughnessMap.channel),specularMapUv:he&&p(v.specularMap.channel),specularColorMapUv:ee&&p(v.specularColorMap.channel),specularIntensityMapUv:ge&&p(v.specularIntensityMap.channel),transmissionMapUv:we&&p(v.transmissionMap.channel),thicknessMapUv:Ge&&p(v.thicknessMap.channel),alphaMapUv:ye&&p(v.alphaMap.channel),vertexTangents:!!P.attributes.tangent&&(rt||V),vertexNormals:!!P.attributes.normal,vertexColors:v.vertexColors,vertexAlphas:v.vertexColors===!0&&!!P.attributes.color&&P.attributes.color.itemSize===4,pointsUvs:w.isPoints===!0&&!!P.attributes.uv&&(Be||ye),fog:!!O,useFog:v.fog===!0,fogExp2:!!O&&O.isFogExp2,flatShading:v.wireframe===!1&&(v.flatShading===!0||P.attributes.normal===void 0&&rt===!1&&(v.isMeshLambertMaterial||v.isMeshPhongMaterial||v.isMeshStandardMaterial||v.isMeshPhysicalMaterial)),sizeAttenuation:v.sizeAttenuation===!0,logarithmicDepthBuffer:d,reversedDepthBuffer:xe,skinning:w.isSkinnedMesh===!0,hasPositionAttribute:P.attributes.position!==void 0,morphTargets:P.morphAttributes.position!==void 0,morphNormals:P.morphAttributes.normal!==void 0,morphColors:P.morphAttributes.color!==void 0,morphTargetsCount:oe,morphTextureStride:_e,numDirLights:T.directional.length,numPointLights:T.point.length,numSpotLights:T.spot.length,numSpotLightMaps:T.spotLightMap.length,numRectAreaLights:T.rectArea.length,numHemiLights:T.hemi.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:v.dithering,shadowMapEnabled:n.shadowMap.enabled&&I.length>0,shadowMapType:n.shadowMap.type,toneMapping:pe,decodeVideoTexture:Be&&v.map.isVideoTexture===!0&&it.getTransfer(v.map.colorSpace)===ft,decodeVideoTextureEmissive:yt&&v.emissiveMap.isVideoTexture===!0&&it.getTransfer(v.emissiveMap.colorSpace)===ft,premultipliedAlpha:v.premultipliedAlpha,doubleSided:v.side===zt,flipSided:v.side===cn,useDepthPacking:v.depthPacking>=0,depthPacking:v.depthPacking||0,index0AttributeName:v.index0AttributeName,extensionClipCullDistance:Me&&v.extensions.clipCullDistance===!0&&t.has("WEBGL_clip_cull_distance"),extensionMultiDraw:(Me&&v.extensions.multiDraw===!0||Se)&&t.has("WEBGL_multi_draw"),rendererExtensionParallelShaderCompile:t.has("KHR_parallel_shader_compile"),customProgramCacheKey:v.customProgramCacheKey()};return Fe.vertexUv1s=l.has(1),Fe.vertexUv2s=l.has(2),Fe.vertexUv3s=l.has(3),l.clear(),Fe}function m(v){const T=[];if(v.shaderID?T.push(v.shaderID):(T.push(v.customVertexShaderID),T.push(v.customFragmentShaderID)),v.defines!==void 0)for(const I in v.defines)T.push(I),T.push(v.defines[I]);return v.isRawShaderMaterial===!1&&(_(T,v),b(T,v),T.push(n.outputColorSpace)),T.push(v.customProgramCacheKey),T.join()}function _(v,T){v.push(T.precision),v.push(T.outputColorSpace),v.push(T.envMapMode),v.push(T.envMapCubeUVHeight),v.push(T.mapUv),v.push(T.alphaMapUv),v.push(T.lightMapUv),v.push(T.aoMapUv),v.push(T.bumpMapUv),v.push(T.normalMapUv),v.push(T.displacementMapUv),v.push(T.emissiveMapUv),v.push(T.metalnessMapUv),v.push(T.roughnessMapUv),v.push(T.anisotropyMapUv),v.push(T.clearcoatMapUv),v.push(T.clearcoatNormalMapUv),v.push(T.clearcoatRoughnessMapUv),v.push(T.iridescenceMapUv),v.push(T.iridescenceThicknessMapUv),v.push(T.sheenColorMapUv),v.push(T.sheenRoughnessMapUv),v.push(T.specularMapUv),v.push(T.specularColorMapUv),v.push(T.specularIntensityMapUv),v.push(T.transmissionMapUv),v.push(T.thicknessMapUv),v.push(T.combine),v.push(T.fogExp2),v.push(T.sizeAttenuation),v.push(T.morphTargetsCount),v.push(T.morphAttributeCount),v.push(T.numDirLights),v.push(T.numPointLights),v.push(T.numSpotLights),v.push(T.numSpotLightMaps),v.push(T.numHemiLights),v.push(T.numRectAreaLights),v.push(T.numDirLightShadows),v.push(T.numPointLightShadows),v.push(T.numSpotLightShadows),v.push(T.numSpotLightShadowsWithMaps),v.push(T.numLightProbes),v.push(T.shadowMapType),v.push(T.toneMapping),v.push(T.numClippingPlanes),v.push(T.numClipIntersection),v.push(T.depthPacking)}function b(v,T){a.disableAll(),T.instancing&&a.enable(0),T.instancingColor&&a.enable(1),T.instancingMorph&&a.enable(2),T.matcap&&a.enable(3),T.envMap&&a.enable(4),T.normalMapObjectSpace&&a.enable(5),T.normalMapTangentSpace&&a.enable(6),T.clearcoat&&a.enable(7),T.iridescence&&a.enable(8),T.alphaTest&&a.enable(9),T.vertexColors&&a.enable(10),T.vertexAlphas&&a.enable(11),T.vertexUv1s&&a.enable(12),T.vertexUv2s&&a.enable(13),T.vertexUv3s&&a.enable(14),T.vertexTangents&&a.enable(15),T.anisotropy&&a.enable(16),T.alphaHash&&a.enable(17),T.batching&&a.enable(18),T.dispersion&&a.enable(19),T.batchingColor&&a.enable(20),T.gradientMap&&a.enable(21),T.packedNormalMap&&a.enable(22),T.vertexNormals&&a.enable(23),v.push(a.mask),a.disableAll(),T.fog&&a.enable(0),T.useFog&&a.enable(1),T.flatShading&&a.enable(2),T.logarithmicDepthBuffer&&a.enable(3),T.reversedDepthBuffer&&a.enable(4),T.skinning&&a.enable(5),T.morphTargets&&a.enable(6),T.morphNormals&&a.enable(7),T.morphColors&&a.enable(8),T.premultipliedAlpha&&a.enable(9),T.shadowMapEnabled&&a.enable(10),T.doubleSided&&a.enable(11),T.flipSided&&a.enable(12),T.useDepthPacking&&a.enable(13),T.dithering&&a.enable(14),T.transmission&&a.enable(15),T.sheen&&a.enable(16),T.opaque&&a.enable(17),T.pointsUvs&&a.enable(18),T.decodeVideoTexture&&a.enable(19),T.decodeVideoTextureEmissive&&a.enable(20),T.alphaToCoverage&&a.enable(21),T.numLightProbeGrids>0&&a.enable(22),T.hasPositionAttribute&&a.enable(23),v.push(a.mask)}function A(v){const T=f[v.type];let I;if(T){const L=Kn[T];I=zm.clone(L.uniforms)}else I=v.uniforms;return I}function y(v,T){let I=u.get(T);return I!==void 0?++I.usedTimes:(I=new py(n,T,v,s),c.push(I),u.set(T,I)),I}function M(v){if(--v.usedTimes===0){const T=c.indexOf(v);c[T]=c[c.length-1],c.pop(),u.delete(v.cacheKey),v.destroy()}}function S(v){o.remove(v)}function E(){o.dispose()}return{getParameters:g,getProgramCacheKey:m,getUniforms:A,acquireProgram:y,releaseProgram:M,releaseShaderCache:S,programs:c,dispose:E}}function vy(){let n=new WeakMap;function e(a){return n.has(a)}function t(a){let o=n.get(a);return o===void 0&&(o={},n.set(a,o)),o}function i(a){n.delete(a)}function s(a,o,l){n.get(a)[o]=l}function r(){n=new WeakMap}return{has:e,get:t,remove:i,update:s,dispose:r}}function Sy(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.material.id!==e.material.id?n.material.id-e.material.id:n.materialVariant!==e.materialVariant?n.materialVariant-e.materialVariant:n.z!==e.z?n.z-e.z:n.id-e.id}function Mh(n,e){return n.groupOrder!==e.groupOrder?n.groupOrder-e.groupOrder:n.renderOrder!==e.renderOrder?n.renderOrder-e.renderOrder:n.z!==e.z?e.z-n.z:n.id-e.id}function Ah(){const n=[];let e=0;const t=[],i=[],s=[];function r(){e=0,t.length=0,i.length=0,s.length=0}function a(h){let f=0;return h.isInstancedMesh&&(f+=2),h.isSkinnedMesh&&(f+=1),f}function o(h,f,p,g,m,_){let b=n[e];return b===void 0?(b={id:h.id,object:h,geometry:f,material:p,materialVariant:a(h),groupOrder:g,renderOrder:h.renderOrder,z:m,group:_},n[e]=b):(b.id=h.id,b.object=h,b.geometry=f,b.material=p,b.materialVariant=a(h),b.groupOrder=g,b.renderOrder=h.renderOrder,b.z=m,b.group=_),e++,b}function l(h,f,p,g,m,_){const b=o(h,f,p,g,m,_);p.transmission>0?i.push(b):p.transparent===!0?s.push(b):t.push(b)}function c(h,f,p,g,m,_){const b=o(h,f,p,g,m,_);p.transmission>0?i.unshift(b):p.transparent===!0?s.unshift(b):t.unshift(b)}function u(h,f,p){t.length>1&&t.sort(h||Sy),i.length>1&&i.sort(f||Mh),s.length>1&&s.sort(f||Mh),p&&(t.reverse(),i.reverse(),s.reverse())}function d(){for(let h=e,f=n.length;h=r.length?(a=new Ah,r.push(a)):a=r[s],a}function t(){n=new WeakMap}return{get:e,dispose:t}}function My(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={direction:new B,color:new Qe};break;case"SpotLight":t={position:new B,direction:new B,color:new Qe,distance:0,coneCos:0,penumbraCos:0,decay:0};break;case"PointLight":t={position:new B,color:new Qe,distance:0,decay:0};break;case"HemisphereLight":t={direction:new B,skyColor:new Qe,groundColor:new Qe};break;case"RectAreaLight":t={color:new Qe,position:new B,halfWidth:new B,halfHeight:new B};break}return n[e.id]=t,t}}}function Ay(){const n={};return{get:function(e){if(n[e.id]!==void 0)return n[e.id];let t;switch(e.type){case"DirectionalLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"SpotLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee};break;case"PointLight":t={shadowIntensity:1,shadowBias:0,shadowNormalBias:0,shadowRadius:1,shadowMapSize:new Ee,shadowCameraNear:1,shadowCameraFar:1e3};break}return n[e.id]=t,t}}}let Ey=0;function Ty(n,e){return(e.castShadow?2:0)-(n.castShadow?2:0)+(e.map?1:0)-(n.map?1:0)}function Cy(n){const e=new My,t=Ay(),i={version:0,hash:{directionalLength:-1,pointLength:-1,spotLength:-1,rectAreaLength:-1,hemiLength:-1,numDirectionalShadows:-1,numPointShadows:-1,numSpotShadows:-1,numSpotMaps:-1,numLightProbes:-1},ambient:[0,0,0],probe:[],directional:[],directionalShadow:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotLightMap:[],spotShadow:[],spotShadowMap:[],spotLightMatrix:[],rectArea:[],rectAreaLTC1:null,rectAreaLTC2:null,point:[],pointShadow:[],pointShadowMap:[],pointShadowMatrix:[],hemi:[],numSpotLightShadowsWithMaps:0,numLightProbes:0};for(let c=0;c<9;c++)i.probe.push(new B);const s=new B,r=new Et,a=new Et;function o(c){let u=0,d=0,h=0;for(let T=0;T<9;T++)i.probe[T].set(0,0,0);let f=0,p=0,g=0,m=0,_=0,b=0,A=0,y=0,M=0,S=0,E=0;c.sort(Ty);for(let T=0,I=c.length;T0&&(n.has("OES_texture_float_linear")===!0?(i.rectAreaLTC1=Ce.LTC_FLOAT_1,i.rectAreaLTC2=Ce.LTC_FLOAT_2):(i.rectAreaLTC1=Ce.LTC_HALF_1,i.rectAreaLTC2=Ce.LTC_HALF_2)),i.ambient[0]=u,i.ambient[1]=d,i.ambient[2]=h;const v=i.hash;(v.directionalLength!==f||v.pointLength!==p||v.spotLength!==g||v.rectAreaLength!==m||v.hemiLength!==_||v.numDirectionalShadows!==b||v.numPointShadows!==A||v.numSpotShadows!==y||v.numSpotMaps!==M||v.numLightProbes!==E)&&(i.directional.length=f,i.spot.length=g,i.rectArea.length=m,i.point.length=p,i.hemi.length=_,i.directionalShadow.length=b,i.directionalShadowMap.length=b,i.pointShadow.length=A,i.pointShadowMap.length=A,i.spotShadow.length=y,i.spotShadowMap.length=y,i.directionalShadowMatrix.length=b,i.pointShadowMatrix.length=A,i.spotLightMatrix.length=y+M-S,i.spotLightMap.length=M,i.numSpotLightShadowsWithMaps=S,i.numLightProbes=E,v.directionalLength=f,v.pointLength=p,v.spotLength=g,v.rectAreaLength=m,v.hemiLength=_,v.numDirectionalShadows=b,v.numPointShadows=A,v.numSpotShadows=y,v.numSpotMaps=M,v.numLightProbes=E,i.version=Ey++)}function l(c,u){let d=0,h=0,f=0,p=0,g=0;const m=u.matrixWorldInverse;for(let _=0,b=c.length;_=a.length?(o=new Eh(n),a.push(o)):o=a[r],o}function i(){e=new WeakMap}return{get:t,dispose:i}}const Ry=`void main() { + gl_Position = vec4( position, 1.0 ); +}`,Dy=`uniform sampler2D shadow_pass; +uniform vec2 resolution; +uniform float radius; +void main() { + const float samples = float( VSM_SAMPLES ); + float mean = 0.0; + float squared_mean = 0.0; + float uvStride = samples <= 1.0 ? 0.0 : 2.0 / ( samples - 1.0 ); + float uvStart = samples <= 1.0 ? 0.0 : - 1.0; + for ( float i = 0.0; i < samples; i ++ ) { + float uvOffset = uvStart + i * uvStride; + #ifdef HORIZONTAL_PASS + vec2 distribution = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( uvOffset, 0.0 ) * radius ) / resolution ).rg; + mean += distribution.x; + squared_mean += distribution.y * distribution.y + distribution.x * distribution.x; + #else + float depth = texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, uvOffset ) * radius ) / resolution ).r; + mean += depth; + squared_mean += depth * depth; + #endif + } + mean = mean / samples; + 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 ); +}`,Ly=[new B(1,0,0),new B(-1,0,0),new B(0,1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1)],Iy=[new B(0,-1,0),new B(0,-1,0),new B(0,0,1),new B(0,0,-1),new B(0,-1,0),new B(0,-1,0)],Th=new Et,gr=new B,ll=new B;function Py(n,e,t){let i=new of;const s=new Ee,r=new Ee,a=new wt,o=new Xm,l=new Ym,c={},u=t.maxTextureSize,d={[Bi]:cn,[cn]:Bi,[zt]:zt},h=new On({defines:{VSM_SAMPLES:8},uniforms:{shadow_pass:{value:null},resolution:{value:new Ee},radius:{value:4}},vertexShader:Ry,fragmentShader:Dy}),f=h.clone();f.defines.HORIZONTAL_PASS=1;const p=new Ct;p.setAttribute("position",new Un(new Float32Array([-1,-1,.5,3,-1,.5,-1,3,.5]),3));const g=new Vt(p,h),m=this;this.enabled=!1,this.autoUpdate=!0,this.needsUpdate=!1,this.type=Na;let _=this.type;this.render=function(S,E,v){if(m.enabled===!1||m.autoUpdate===!1&&m.needsUpdate===!1||S.length===0)return;this.type===n0&&(Ye("WebGLShadowMap: PCFSoftShadowMap has been deprecated. Using PCFShadowMap instead."),this.type=Na);const T=n.getRenderTarget(),I=n.getActiveCubeFace(),L=n.getActiveMipmapLevel(),w=n.state;w.setBlending(fi),w.buffers.depth.getReversed()===!0?w.buffers.color.setClear(0,0,0,0):w.buffers.color.setClear(1,1,1,1),w.buffers.depth.setTest(!0),w.setScissorTest(!1);const U=_!==this.type;U&&E.traverse(function(O){O.material&&(Array.isArray(O.material)?O.material.forEach(P=>P.needsUpdate=!0):O.material.needsUpdate=!0)});for(let O=0,P=S.length;Ou||s.y>u)&&(s.x>u&&(r.x=Math.floor(u/W.x),s.x=r.x*W.x,N.mapSize.x=r.x),s.y>u&&(r.y=Math.floor(u/W.y),s.y=r.y*W.y,N.mapSize.y=r.y));const D=n.state.buffers.depth.getReversed();if(N.camera._reversedDepth=D,N.map===null||U===!0){if(N.map!==null&&(N.map.depthTexture!==null&&(N.map.depthTexture.dispose(),N.map.depthTexture=null),N.map.dispose()),this.type===yr){if(Z.isPointLight){Ye("WebGLShadowMap: VSM shadow maps are not supported for PointLights. Use PCF or BasicShadowMap instead.");continue}N.map=new jn(s.x,s.y,{format:is,type:_i,minFilter:Xt,magFilter:Xt,generateMipmaps:!1}),N.map.texture.name=Z.name+".shadowMap",N.map.depthTexture=new Ks(s.x,s.y,Pn),N.map.depthTexture.name=Z.name+".shadowMapDepth",N.map.depthTexture.format=xi,N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt}else Z.isPointLight?(N.map=new Af(s.x),N.map.depthTexture=new om(s.x,ei)):(N.map=new jn(s.x,s.y),N.map.depthTexture=new Ks(s.x,s.y,ei)),N.map.depthTexture.name=Z.name+".shadowMap",N.map.depthTexture.format=xi,this.type===Na?(N.map.depthTexture.compareFunction=D?Hc:Bc,N.map.depthTexture.minFilter=Xt,N.map.depthTexture.magFilter=Xt):(N.map.depthTexture.compareFunction=null,N.map.depthTexture.minFilter=Nt,N.map.depthTexture.magFilter=Nt);N.camera.updateProjectionMatrix()}const re=N.map.isWebGLCubeRenderTarget?6:1;for(let ie=0;ie0||E.map&&E.alphaTest>0||E.alphaToCoverage===!0){const w=I.uuid,U=E.uuid;let O=c[w];O===void 0&&(O={},c[w]=O);let P=O[U];P===void 0&&(P=I.clone(),O[U]=P,E.addEventListener("dispose",M)),I=P}if(I.visible=E.visible,I.wireframe=E.wireframe,T===yr?I.side=E.shadowSide!==null?E.shadowSide:E.side:I.side=E.shadowSide!==null?E.shadowSide:d[E.side],I.alphaMap=E.alphaMap,I.alphaTest=E.alphaToCoverage===!0?.5:E.alphaTest,I.map=E.map,I.clipShadows=E.clipShadows,I.clippingPlanes=E.clippingPlanes,I.clipIntersection=E.clipIntersection,I.displacementMap=E.displacementMap,I.displacementScale=E.displacementScale,I.displacementBias=E.displacementBias,I.wireframeLinewidth=E.wireframeLinewidth,I.linewidth=E.linewidth,v.isPointLight===!0&&I.isMeshDistanceMaterial===!0){const w=n.properties.get(I);w.light=v}return I}function y(S,E,v,T,I){if(S.visible===!1)return;if(S.layers.test(E.layers)&&(S.isMesh||S.isLine||S.isPoints)&&(S.castShadow||S.receiveShadow&&I===yr)&&(!S.frustumCulled||i.intersectsObject(S))){S.modelViewMatrix.multiplyMatrices(v.matrixWorldInverse,S.matrixWorld);const U=e.update(S),O=S.material;if(Array.isArray(O)){const P=U.groups;for(let Z=0,N=P.length;Z=1):D.indexOf("OpenGL ES")!==-1&&(W=parseFloat(/^OpenGL ES (\d)/.exec(D)[1]),N=W>=2);let re=null,ie={};const oe=n.getParameter(n.SCISSOR_BOX),_e=n.getParameter(n.VIEWPORT),de=new wt().fromArray(oe),le=new wt().fromArray(_e);function z(k,ye,ue,ve){const Me=new Uint8Array(4),pe=n.createTexture();n.bindTexture(k,pe),n.texParameteri(k,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(k,n.TEXTURE_MAG_FILTER,n.NEAREST);for(let Fe=0;Fe"u"?!1:/OculusBrowser/g.test(navigator.userAgent),c=new Ee,u=new WeakMap,d=new Set;let h;const f=new WeakMap;let p=!1;try{p=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")!==null}catch{}function g(R,x){return p?new OffscreenCanvas(R,x):ja("canvas")}function m(R,x,G){let H=1;const $=se(R);if(($.width>G||$.height>G)&&(H=G/Math.max($.width,$.height)),H<1)if(typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&R instanceof HTMLCanvasElement||typeof ImageBitmap<"u"&&R instanceof ImageBitmap||typeof VideoFrame<"u"&&R instanceof VideoFrame){const fe=Math.floor(H*$.width),X=Math.floor(H*$.height);h===void 0&&(h=g(fe,X));const F=x?g(fe,X):h;return F.width=fe,F.height=X,F.getContext("2d").drawImage(R,0,0,fe,X),Ye("WebGLRenderer: Texture has been resized from ("+$.width+"x"+$.height+") to ("+fe+"x"+X+")."),F}else return"data"in R&&Ye("WebGLRenderer: Image in DataTexture is too big ("+$.width+"x"+$.height+")."),R;return R}function _(R){return R.generateMipmaps}function b(R){n.generateMipmap(R)}function A(R){return R.isWebGLCubeRenderTarget?n.TEXTURE_CUBE_MAP:R.isWebGL3DRenderTarget?n.TEXTURE_3D:R.isWebGLArrayRenderTarget||R.isCompressedArrayTexture?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D}function y(R,x,G,H,$,fe=!1){if(R!==null){if(n[R]!==void 0)return n[R];Ye("WebGLRenderer: Attempt to use non-existing WebGL internal format '"+R+"'")}let X;H&&(X=e.get("EXT_texture_norm16"),X||Ye("WebGLRenderer: Unable to use normalized textures without EXT_texture_norm16 extension"));let F=x;if(x===n.RED&&(G===n.FLOAT&&(F=n.R32F),G===n.HALF_FLOAT&&(F=n.R16F),G===n.UNSIGNED_BYTE&&(F=n.R8),G===n.UNSIGNED_SHORT&&X&&(F=X.R16_EXT),G===n.SHORT&&X&&(F=X.R16_SNORM_EXT)),x===n.RED_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.R8UI),G===n.UNSIGNED_SHORT&&(F=n.R16UI),G===n.UNSIGNED_INT&&(F=n.R32UI),G===n.BYTE&&(F=n.R8I),G===n.SHORT&&(F=n.R16I),G===n.INT&&(F=n.R32I)),x===n.RG&&(G===n.FLOAT&&(F=n.RG32F),G===n.HALF_FLOAT&&(F=n.RG16F),G===n.UNSIGNED_BYTE&&(F=n.RG8),G===n.UNSIGNED_SHORT&&X&&(F=X.RG16_EXT),G===n.SHORT&&X&&(F=X.RG16_SNORM_EXT)),x===n.RG_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RG8UI),G===n.UNSIGNED_SHORT&&(F=n.RG16UI),G===n.UNSIGNED_INT&&(F=n.RG32UI),G===n.BYTE&&(F=n.RG8I),G===n.SHORT&&(F=n.RG16I),G===n.INT&&(F=n.RG32I)),x===n.RGB_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGB8UI),G===n.UNSIGNED_SHORT&&(F=n.RGB16UI),G===n.UNSIGNED_INT&&(F=n.RGB32UI),G===n.BYTE&&(F=n.RGB8I),G===n.SHORT&&(F=n.RGB16I),G===n.INT&&(F=n.RGB32I)),x===n.RGBA_INTEGER&&(G===n.UNSIGNED_BYTE&&(F=n.RGBA8UI),G===n.UNSIGNED_SHORT&&(F=n.RGBA16UI),G===n.UNSIGNED_INT&&(F=n.RGBA32UI),G===n.BYTE&&(F=n.RGBA8I),G===n.SHORT&&(F=n.RGBA16I),G===n.INT&&(F=n.RGBA32I)),x===n.RGB&&(G===n.UNSIGNED_SHORT&&X&&(F=X.RGB16_EXT),G===n.SHORT&&X&&(F=X.RGB16_SNORM_EXT),G===n.UNSIGNED_INT_5_9_9_9_REV&&(F=n.RGB9_E5),G===n.UNSIGNED_INT_10F_11F_11F_REV&&(F=n.R11F_G11F_B10F)),x===n.RGBA){const Y=fe?$a:it.getTransfer($);G===n.FLOAT&&(F=n.RGBA32F),G===n.HALF_FLOAT&&(F=n.RGBA16F),G===n.UNSIGNED_BYTE&&(F=Y===ft?n.SRGB8_ALPHA8:n.RGBA8),G===n.UNSIGNED_SHORT&&X&&(F=X.RGBA16_EXT),G===n.SHORT&&X&&(F=X.RGBA16_SNORM_EXT),G===n.UNSIGNED_SHORT_4_4_4_4&&(F=n.RGBA4),G===n.UNSIGNED_SHORT_5_5_5_1&&(F=n.RGB5_A1)}return(F===n.R16F||F===n.R32F||F===n.RG16F||F===n.RG32F||F===n.RGBA16F||F===n.RGBA32F)&&e.get("EXT_color_buffer_float"),F}function M(R,x){let G;return R?x===null||x===ei||x===Rr?G=n.DEPTH24_STENCIL8:x===Pn?G=n.DEPTH32F_STENCIL8:x===wr&&(G=n.DEPTH24_STENCIL8,Ye("DepthTexture: 16 bit depth attachment is not supported with stencil. Using 24-bit attachment.")):x===null||x===ei||x===Rr?G=n.DEPTH_COMPONENT24:x===Pn?G=n.DEPTH_COMPONENT32F:x===wr&&(G=n.DEPTH_COMPONENT16),G}function S(R,x){return _(R)===!0||R.isFramebufferTexture&&R.minFilter!==Nt&&R.minFilter!==Xt?Math.log2(Math.max(x.width,x.height))+1:R.mipmaps!==void 0&&R.mipmaps.length>0?R.mipmaps.length:R.isCompressedTexture&&Array.isArray(R.image)?x.mipmaps.length:1}function E(R){const x=R.target;x.removeEventListener("dispose",E),T(x),x.isVideoTexture&&u.delete(x),x.isHTMLTexture&&d.delete(x)}function v(R){const x=R.target;x.removeEventListener("dispose",v),L(x)}function T(R){const x=i.get(R);if(x.__webglInit===void 0)return;const G=R.source,H=f.get(G);if(H){const $=H[x.__cacheKey];$.usedTimes--,$.usedTimes===0&&I(R),Object.keys(H).length===0&&f.delete(G)}i.remove(R)}function I(R){const x=i.get(R);n.deleteTexture(x.__webglTexture);const G=R.source,H=f.get(G);delete H[x.__cacheKey],a.memory.textures--}function L(R){const x=i.get(R);if(R.depthTexture&&(R.depthTexture.dispose(),i.remove(R.depthTexture)),R.isWebGLCubeRenderTarget)for(let H=0;H<6;H++){if(Array.isArray(x.__webglFramebuffer[H]))for(let $=0;$=s.maxTextures&&Ye("WebGLTextures: Trying to use "+R+" texture units while this GPU supports only "+s.maxTextures),w+=1,R}function N(R){const x=[];return x.push(R.wrapS),x.push(R.wrapT),x.push(R.wrapR||0),x.push(R.magFilter),x.push(R.minFilter),x.push(R.anisotropy),x.push(R.internalFormat),x.push(R.format),x.push(R.type),x.push(R.generateMipmaps),x.push(R.premultiplyAlpha),x.push(R.flipY),x.push(R.unpackAlignment),x.push(R.colorSpace),x.join()}function W(R,x){const G=i.get(R);if(R.isVideoTexture&&V(R),R.isRenderTargetTexture===!1&&R.isExternalTexture!==!0&&R.version>0&&G.__version!==R.version){const H=R.image;if(H===null)Ye("WebGLRenderer: Texture marked for update but no image data found.");else if(H.complete===!1)Ye("WebGLRenderer: Texture marked for update but image is incomplete");else{xe(G,R,x);return}}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D,G.__webglTexture,n.TEXTURE0+x)}function D(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}else R.isExternalTexture&&(G.__webglTexture=R.sourceTexture?R.sourceTexture:null);t.bindTexture(n.TEXTURE_2D_ARRAY,G.__webglTexture,n.TEXTURE0+x)}function re(R,x){const G=i.get(R);if(R.isRenderTargetTexture===!1&&R.version>0&&G.__version!==R.version){xe(G,R,x);return}t.bindTexture(n.TEXTURE_3D,G.__webglTexture,n.TEXTURE0+x)}function ie(R,x){const G=i.get(R);if(R.isCubeDepthTexture!==!0&&R.version>0&&G.__version!==R.version){Ae(G,R,x);return}t.bindTexture(n.TEXTURE_CUBE_MAP,G.__webglTexture,n.TEXTURE0+x)}const oe={[Ol]:n.REPEAT,[ui]:n.CLAMP_TO_EDGE,[Nl]:n.MIRRORED_REPEAT},_e={[Nt]:n.NEAREST,[M0]:n.NEAREST_MIPMAP_NEAREST,[Kr]:n.NEAREST_MIPMAP_LINEAR,[Xt]:n.LINEAR,[wo]:n.LINEAR_MIPMAP_NEAREST,[Ui]:n.LINEAR_MIPMAP_LINEAR},de={[T0]:n.NEVER,[L0]:n.ALWAYS,[C0]:n.LESS,[Bc]:n.LEQUAL,[w0]:n.EQUAL,[Hc]:n.GEQUAL,[R0]:n.GREATER,[D0]:n.NOTEQUAL};function le(R,x){if(x.type===Pn&&e.has("OES_texture_float_linear")===!1&&(x.magFilter===Xt||x.magFilter===wo||x.magFilter===Kr||x.magFilter===Ui||x.minFilter===Xt||x.minFilter===wo||x.minFilter===Kr||x.minFilter===Ui)&&Ye("WebGLRenderer: Unable to use linear filtering with floating point textures. OES_texture_float_linear not supported on this device."),n.texParameteri(R,n.TEXTURE_WRAP_S,oe[x.wrapS]),n.texParameteri(R,n.TEXTURE_WRAP_T,oe[x.wrapT]),(R===n.TEXTURE_3D||R===n.TEXTURE_2D_ARRAY)&&n.texParameteri(R,n.TEXTURE_WRAP_R,oe[x.wrapR]),n.texParameteri(R,n.TEXTURE_MAG_FILTER,_e[x.magFilter]),n.texParameteri(R,n.TEXTURE_MIN_FILTER,_e[x.minFilter]),x.compareFunction&&(n.texParameteri(R,n.TEXTURE_COMPARE_MODE,n.COMPARE_REF_TO_TEXTURE),n.texParameteri(R,n.TEXTURE_COMPARE_FUNC,de[x.compareFunction])),e.has("EXT_texture_filter_anisotropic")===!0){if(x.magFilter===Nt||x.minFilter!==Kr&&x.minFilter!==Ui||x.type===Pn&&e.has("OES_texture_float_linear")===!1)return;if(x.anisotropy>1||i.get(x).__currentAnisotropy){const G=e.get("EXT_texture_filter_anisotropic");n.texParameterf(R,G.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(x.anisotropy,s.getMaxAnisotropy())),i.get(x).__currentAnisotropy=x.anisotropy}}}function z(R,x){let G=!1;R.__webglInit===void 0&&(R.__webglInit=!0,x.addEventListener("dispose",E));const H=x.source;let $=f.get(H);$===void 0&&($={},f.set(H,$));const fe=N(x);if(fe!==R.__cacheKey){$[fe]===void 0&&($[fe]={texture:n.createTexture(),usedTimes:0},a.memory.textures++,G=!0),$[fe].usedTimes++;const X=$[R.__cacheKey];X!==void 0&&($[R.__cacheKey].usedTimes--,X.usedTimes===0&&I(x)),R.__cacheKey=fe,R.__webglTexture=$[fe].texture}return G}function ne(R,x,G){return Math.floor(Math.floor(R/G)/x)}function J(R,x,G,H){const fe=R.updateRanges;if(fe.length===0)t.texSubImage2D(n.TEXTURE_2D,0,0,0,x.width,x.height,G,H,x.data);else{fe.sort((ce,he)=>ce.start-he.start);let X=0;for(let ce=1;ce0){we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const Me=ih(ee.width,ee.height,x.format,x.type);for(const pe of x.layerUpdates){const Fe=ee.data.subarray(pe*Me/ee.data.BYTES_PER_ELEMENT,(pe+1)*Me/ee.data.BYTES_PER_ELEMENT);t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,pe,ee.width,ee.height,1,ae,Fe)}x.clearLayerUpdates()}else t.compressedTexSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,ae,ee.data)}else t.compressedTexImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ee.data,0,0);else Ye("WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()");else we?k&&t.texSubImage3D(n.TEXTURE_2D_ARRAY,ue,0,0,0,ee.width,ee.height,Y.depth,ae,ce,ee.data):t.texImage3D(n.TEXTURE_2D_ARRAY,ue,he,ee.width,ee.height,Y.depth,0,ae,ce,ee.data)}else{we&&Ge&&t.texStorage2D(n.TEXTURE_2D,ye,he,ge[0].width,ge[0].height);for(let ue=0,ve=ge.length;ue0){const ue=ih(Y.width,Y.height,x.format,x.type);for(const ve of x.layerUpdates){const Me=Y.data.subarray(ve*ue/Y.data.BYTES_PER_ELEMENT,(ve+1)*ue/Y.data.BYTES_PER_ELEMENT);t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,ve,Y.width,Y.height,1,ae,ce,Me)}x.clearLayerUpdates()}else t.texSubImage3D(n.TEXTURE_2D_ARRAY,0,0,0,0,Y.width,Y.height,Y.depth,ae,ce,Y.data)}else t.texImage3D(n.TEXTURE_2D_ARRAY,0,he,Y.width,Y.height,Y.depth,0,ae,ce,Y.data);else if(x.isData3DTexture)we?(Ge&&t.texStorage3D(n.TEXTURE_3D,ye,he,Y.width,Y.height,Y.depth),k&&t.texSubImage3D(n.TEXTURE_3D,0,0,0,0,Y.width,Y.height,Y.depth,ae,ce,Y.data)):t.texImage3D(n.TEXTURE_3D,0,he,Y.width,Y.height,Y.depth,0,ae,ce,Y.data);else if(x.isFramebufferTexture){if(Ge)if(we)t.texStorage2D(n.TEXTURE_2D,ye,he,Y.width,Y.height);else{let ue=Y.width,ve=Y.height;for(let Me=0;Me>=1,ve>>=1}}else if(x.isHTMLTexture){if("texElementImage2D"in n){const ue=n.canvas;if(ue.hasAttribute("layoutsubtree")||ue.setAttribute("layoutsubtree","true"),Y.parentNode!==ue){ue.appendChild(Y),d.add(x),ue.onpaint=ve=>{const Me=ve.changedElements;for(const pe of d)Me.includes(pe.image)&&(pe.needsUpdate=!0)},ue.requestPaint();return}if(n.texElementImage2D.length===3)n.texElementImage2D(n.TEXTURE_2D,n.RGBA8,Y);else{const Me=n.RGBA,pe=n.RGBA,Fe=n.UNSIGNED_BYTE;n.texElementImage2D(n.TEXTURE_2D,0,Me,pe,Fe,Y)}n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE)}}else if(ge.length>0){if(we&&Ge){const ue=se(ge[0]);t.texStorage2D(n.TEXTURE_2D,ye,he,ue.width,ue.height)}for(let ue=0,ve=ge.length;ue0&&ve++;const pe=se(he[0]);t.texStorage2D(n.TEXTURE_CUBE_MAP,ve,Ge,pe.width,pe.height)}for(let pe=0;pe<6;pe++)if(ce){k?ue&&t.texSubImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,0,0,he[pe].width,he[pe].height,ge,we,he[pe].data):t.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+pe,0,Ge,he[pe].width,he[pe].height,0,ge,we,he[pe].data);for(let Fe=0;Fe>fe),ee=Math.max(1,x.height>>fe);$===n.TEXTURE_3D||$===n.TEXTURE_2D_ARRAY?t.texImage3D($,fe,Y,he,ee,x.depth,0,X,F,null):t.texImage2D($,fe,Y,he,ee,0,X,F,null)}t.bindFramebuffer(n.FRAMEBUFFER,R),ut(x)?o.framebufferTexture2DMultisampleEXT(n.FRAMEBUFFER,H,$,ce.__webglTexture,0,ct(x)):($===n.TEXTURE_2D||$>=n.TEXTURE_CUBE_MAP_POSITIVE_X&&$<=n.TEXTURE_CUBE_MAP_NEGATIVE_Z)&&n.framebufferTexture2D(n.FRAMEBUFFER,H,$,ce.__webglTexture,fe),t.bindFramebuffer(n.FRAMEBUFFER,null)}function Be(R,x,G){if(n.bindRenderbuffer(n.RENDERBUFFER,R),x.depthBuffer){const H=x.depthTexture,$=H&&H.isDepthTexture?H.type:null,fe=M(x.stencilBuffer,$),X=x.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT;ut(x)?o.renderbufferStorageMultisampleEXT(n.RENDERBUFFER,ct(x),fe,x.width,x.height):G?n.renderbufferStorageMultisample(n.RENDERBUFFER,ct(x),fe,x.width,x.height):n.renderbufferStorage(n.RENDERBUFFER,fe,x.width,x.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,X,n.RENDERBUFFER,R)}else{const H=x.textures;for(let $=0;${delete x.__boundDepthTexture,delete x.__depthDisposeCallback,H.removeEventListener("dispose",$)};H.addEventListener("dispose",$),x.__depthDisposeCallback=$}x.__boundDepthTexture=H}if(R.depthTexture&&!x.__autoAllocateDepthBuffer)if(G)for(let H=0;H<6;H++)ze(x.__webglFramebuffer[H],R,H);else{const H=R.texture.mipmaps;H&&H.length>0?ze(x.__webglFramebuffer[0],R,0):ze(x.__webglFramebuffer,R,0)}else if(G){x.__webglDepthbuffer=[];for(let H=0;H<6;H++)if(t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[H]),x.__webglDepthbuffer[H]===void 0)x.__webglDepthbuffer[H]=n.createRenderbuffer(),Be(x.__webglDepthbuffer[H],R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer[H];n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}else{const H=R.texture.mipmaps;if(H&&H.length>0?t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer[0]):t.bindFramebuffer(n.FRAMEBUFFER,x.__webglFramebuffer),x.__webglDepthbuffer===void 0)x.__webglDepthbuffer=n.createRenderbuffer(),Be(x.__webglDepthbuffer,R,!1);else{const $=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,fe=x.__webglDepthbuffer;n.bindRenderbuffer(n.RENDERBUFFER,fe),n.framebufferRenderbuffer(n.FRAMEBUFFER,$,n.RENDERBUFFER,fe)}}t.bindFramebuffer(n.FRAMEBUFFER,null)}function Oe(R,x,G){const H=i.get(R);x!==void 0&&Se(H.__webglFramebuffer,R,R.texture,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,0),G!==void 0&&Ue(R)}function Xe(R){const x=R.texture,G=i.get(R),H=i.get(x);R.addEventListener("dispose",v);const $=R.textures,fe=R.isWebGLCubeRenderTarget===!0,X=$.length>1;if(X||(H.__webglTexture===void 0&&(H.__webglTexture=n.createTexture()),H.__version=x.version,a.memory.textures++),fe){G.__webglFramebuffer=[];for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0){G.__webglFramebuffer[F]=[];for(let Y=0;Y0){G.__webglFramebuffer=[];for(let F=0;F0&&ut(R)===!1){G.__webglMultisampledFramebuffer=n.createFramebuffer(),G.__webglColorRenderbuffer=[],t.bindFramebuffer(n.FRAMEBUFFER,G.__webglMultisampledFramebuffer);for(let F=0;F<$.length;F++){const Y=$[F];G.__webglColorRenderbuffer[F]=n.createRenderbuffer(),n.bindRenderbuffer(n.RENDERBUFFER,G.__webglColorRenderbuffer[F]);const ae=r.convert(Y.format,Y.colorSpace),ce=r.convert(Y.type),he=y(Y.internalFormat,ae,ce,Y.normalized,Y.colorSpace,R.isXRRenderTarget===!0),ee=ct(R);n.renderbufferStorageMultisample(n.RENDERBUFFER,ee,he,R.width,R.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0+F,n.RENDERBUFFER,G.__webglColorRenderbuffer[F])}n.bindRenderbuffer(n.RENDERBUFFER,null),R.depthBuffer&&(G.__webglDepthRenderbuffer=n.createRenderbuffer(),Be(G.__webglDepthRenderbuffer,R,!0)),t.bindFramebuffer(n.FRAMEBUFFER,null)}}if(fe){t.bindTexture(n.TEXTURE_CUBE_MAP,H.__webglTexture),le(n.TEXTURE_CUBE_MAP,x);for(let F=0;F<6;F++)if(x.mipmaps&&x.mipmaps.length>0)for(let Y=0;Y0)for(let Y=0;Y0){if(ut(R)===!1){const x=R.textures,G=R.width,H=R.height;let $=n.COLOR_BUFFER_BIT;const fe=R.stencilBuffer?n.DEPTH_STENCIL_ATTACHMENT:n.DEPTH_ATTACHMENT,X=i.get(R),F=x.length>1;if(F)for(let ae=0;ae0?t.bindFramebuffer(n.DRAW_FRAMEBUFFER,X.__webglFramebuffer[0]):t.bindFramebuffer(n.DRAW_FRAMEBUFFER,X.__webglFramebuffer);for(let ae=0;ae0&&e.has("WEBGL_multisampled_render_to_texture")===!0&&x.__useRenderToTexture!==!1}function V(R){const x=a.render.frame;u.get(R)!==x&&(u.set(R,x),R.update())}function et(R,x){const G=R.colorSpace,H=R.format,$=R.type;return R.isCompressedTexture===!0||R.isVideoTexture===!0||G!==Za&&G!==ci&&(it.getTransfer(G)===ft?(H!==bn||$!==vn)&&Ye("WebGLTextures: sRGB encoded textures have to use RGBAFormat and UnsignedByteType."):at("WebGLTextures: Unsupported texture color space:",G)),x}function se(R){return typeof HTMLImageElement<"u"&&R instanceof HTMLImageElement?(c.width=R.naturalWidth||R.width,c.height=R.naturalHeight||R.height):typeof VideoFrame<"u"&&R instanceof VideoFrame?(c.width=R.displayWidth,c.height=R.displayHeight):(c.width=R.width,c.height=R.height),c}this.allocateTextureUnit=Z,this.resetTextureUnits=U,this.getTextureUnits=O,this.setTextureUnits=P,this.setTexture2D=W,this.setTexture2DArray=D,this.setTexture3D=re,this.setTextureCube=ie,this.rebindTextures=Oe,this.setupRenderTarget=Xe,this.updateRenderTargetMipmap=tt,this.updateMultisampleRenderTarget=yt,this.setupDepthRenderbuffer=Ue,this.setupFrameBufferTexture=Se,this.useMultisampledRTT=ut,this.isReversedDepthBuffer=function(){return t.buffers.depth.getReversed()}}function Ny(n,e){function t(i,s=ci){let r;const a=it.getTransfer(s);if(i===vn)return n.UNSIGNED_BYTE;if(i===Uc)return n.UNSIGNED_SHORT_4_4_4_4;if(i===Oc)return n.UNSIGNED_SHORT_5_5_5_1;if(i===Kd)return n.UNSIGNED_INT_5_9_9_9_REV;if(i===qd)return n.UNSIGNED_INT_10F_11F_11F_REV;if(i===Xd)return n.BYTE;if(i===Yd)return n.SHORT;if(i===wr)return n.UNSIGNED_SHORT;if(i===Pc)return n.INT;if(i===ei)return n.UNSIGNED_INT;if(i===Pn)return n.FLOAT;if(i===_i)return n.HALF_FLOAT;if(i===Zd)return n.ALPHA;if(i===$d)return n.RGB;if(i===bn)return n.RGBA;if(i===xi)return n.DEPTH_COMPONENT;if(i===es)return n.DEPTH_STENCIL;if(i===Jd)return n.RED;if(i===Nc)return n.RED_INTEGER;if(i===is)return n.RG;if(i===kc)return n.RG_INTEGER;if(i===Fc)return n.RGBA_INTEGER;if(i===ka||i===Fa||i===Ba||i===Ha)if(a===ft)if(r=e.get("WEBGL_compressed_texture_s3tc_srgb"),r!==null){if(i===ka)return r.COMPRESSED_SRGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT}else return null;else if(r=e.get("WEBGL_compressed_texture_s3tc"),r!==null){if(i===ka)return r.COMPRESSED_RGB_S3TC_DXT1_EXT;if(i===Fa)return r.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(i===Ba)return r.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(i===Ha)return r.COMPRESSED_RGBA_S3TC_DXT5_EXT}else return null;if(i===kl||i===Fl||i===Bl||i===Hl)if(r=e.get("WEBGL_compressed_texture_pvrtc"),r!==null){if(i===kl)return r.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(i===Fl)return r.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(i===Bl)return r.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(i===Hl)return r.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}else return null;if(i===zl||i===Vl||i===Gl||i===Wl||i===Xl||i===Ka||i===Yl)if(r=e.get("WEBGL_compressed_texture_etc"),r!==null){if(i===zl||i===Vl)return a===ft?r.COMPRESSED_SRGB8_ETC2:r.COMPRESSED_RGB8_ETC2;if(i===Gl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:r.COMPRESSED_RGBA8_ETC2_EAC;if(i===Wl)return r.COMPRESSED_R11_EAC;if(i===Xl)return r.COMPRESSED_SIGNED_R11_EAC;if(i===Ka)return r.COMPRESSED_RG11_EAC;if(i===Yl)return r.COMPRESSED_SIGNED_RG11_EAC}else return null;if(i===Kl||i===ql||i===Zl||i===$l||i===Jl||i===jl||i===Ql||i===ec||i===tc||i===nc||i===ic||i===sc||i===rc||i===ac)if(r=e.get("WEBGL_compressed_texture_astc"),r!==null){if(i===Kl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR:r.COMPRESSED_RGBA_ASTC_4x4_KHR;if(i===ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR:r.COMPRESSED_RGBA_ASTC_5x4_KHR;if(i===Zl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR:r.COMPRESSED_RGBA_ASTC_5x5_KHR;if(i===$l)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR:r.COMPRESSED_RGBA_ASTC_6x5_KHR;if(i===Jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR:r.COMPRESSED_RGBA_ASTC_6x6_KHR;if(i===jl)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR:r.COMPRESSED_RGBA_ASTC_8x5_KHR;if(i===Ql)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR:r.COMPRESSED_RGBA_ASTC_8x6_KHR;if(i===ec)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR:r.COMPRESSED_RGBA_ASTC_8x8_KHR;if(i===tc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR:r.COMPRESSED_RGBA_ASTC_10x5_KHR;if(i===nc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR:r.COMPRESSED_RGBA_ASTC_10x6_KHR;if(i===ic)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR:r.COMPRESSED_RGBA_ASTC_10x8_KHR;if(i===sc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR:r.COMPRESSED_RGBA_ASTC_10x10_KHR;if(i===rc)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR:r.COMPRESSED_RGBA_ASTC_12x10_KHR;if(i===ac)return a===ft?r.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR:r.COMPRESSED_RGBA_ASTC_12x12_KHR}else return null;if(i===oc||i===lc||i===cc)if(r=e.get("EXT_texture_compression_bptc"),r!==null){if(i===oc)return a===ft?r.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT:r.COMPRESSED_RGBA_BPTC_UNORM_EXT;if(i===lc)return r.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;if(i===cc)return r.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT}else return null;if(i===uc||i===hc||i===qa||i===dc)if(r=e.get("EXT_texture_compression_rgtc"),r!==null){if(i===uc)return r.COMPRESSED_RED_RGTC1_EXT;if(i===hc)return r.COMPRESSED_SIGNED_RED_RGTC1_EXT;if(i===qa)return r.COMPRESSED_RED_GREEN_RGTC2_EXT;if(i===dc)return r.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT}else return null;return i===Rr?n.UNSIGNED_INT_24_8:n[i]!==void 0?n[i]:null}return{convert:t}}const ky=` +void main() { + + gl_Position = vec4( position, 1.0 ); + +}`,Fy=` +uniform sampler2DArray depthColor; +uniform float depthWidth; +uniform float depthHeight; + +void main() { + + vec2 coord = vec2( gl_FragCoord.x / depthWidth, gl_FragCoord.y / depthHeight ); + + if ( coord.x >= 1.0 ) { + + gl_FragDepth = texture( depthColor, vec3( coord.x - 1.0, coord.y, 1 ) ).r; + + } else { + + gl_FragDepth = texture( depthColor, vec3( coord.x, coord.y, 0 ) ).r; + + } + +}`;class By{constructor(){this.texture=null,this.mesh=null,this.depthNear=0,this.depthFar=0}init(e,t){if(this.texture===null){const i=new uf(e.texture);(e.depthNear!==t.depthNear||e.depthFar!==t.depthFar)&&(this.depthNear=e.depthNear,this.depthFar=e.depthFar),this.texture=i}}getMesh(e){if(this.texture!==null&&this.mesh===null){const t=e.cameras[0].viewport,i=new On({vertexShader:ky,fragmentShader:Fy,uniforms:{depthColor:{value:this.texture},depthWidth:{value:t.z},depthHeight:{value:t.w}}});this.mesh=new Vt(new ts(20,20),i)}return this.mesh}reset(){this.texture=null,this.mesh=null}getDepthTexture(){return this.texture}}class Hy extends Gi{constructor(e,t){super();const i=this;let s=null,r=1,a=null,o="local-floor",l=1,c=null,u=null,d=null,h=null,f=null,p=null;const g=typeof XRWebGLBinding<"u",m=new By,_={},b=t.getContextAttributes();let A=null,y=null;const M=[],S=[],E=new Ee;let v=null;const T=new In;T.viewport=new wt;const I=new In;I.viewport=new wt;const L=[T,I],w=new Zm;let U=null,O=null;this.cameraAutoUpdate=!0,this.enabled=!1,this.isPresenting=!1,this.getController=function(z){let ne=M[z];return ne===void 0&&(ne=new Oo,M[z]=ne),ne.getTargetRaySpace()},this.getControllerGrip=function(z){let ne=M[z];return ne===void 0&&(ne=new Oo,M[z]=ne),ne.getGripSpace()},this.getHand=function(z){let ne=M[z];return ne===void 0&&(ne=new Oo,M[z]=ne),ne.getHandSpace()};function P(z){const ne=S.indexOf(z.inputSource);if(ne===-1)return;const J=M[ne];J!==void 0&&(J.update(z.inputSource,z.frame,c||a),J.dispatchEvent({type:z.type,data:z.inputSource}))}function Z(){s.removeEventListener("select",P),s.removeEventListener("selectstart",P),s.removeEventListener("selectend",P),s.removeEventListener("squeeze",P),s.removeEventListener("squeezestart",P),s.removeEventListener("squeezeend",P),s.removeEventListener("end",Z),s.removeEventListener("inputsourceschange",N);for(let z=0;z=0&&(S[xe]=null,M[xe].disconnect(J))}for(let ne=0;ne=S.length){S.push(J),xe=Se;break}else if(S[Se]===null){S[Se]=J,xe=Se;break}if(xe===-1)break}const Ae=M[xe];Ae&&Ae.connect(J)}}const W=new B,D=new B;function re(z,ne,J){W.setFromMatrixPosition(ne.matrixWorld),D.setFromMatrixPosition(J.matrixWorld);const xe=W.distanceTo(D),Ae=ne.projectionMatrix.elements,Se=J.projectionMatrix.elements,Be=Ae[14]/(Ae[10]-1),ze=Ae[14]/(Ae[10]+1),Ue=(Ae[9]+1)/Ae[5],Oe=(Ae[9]-1)/Ae[5],Xe=(Ae[8]-1)/Ae[0],tt=(Se[8]+1)/Se[0],rt=Be*Xe,mt=Be*tt,yt=xe/(-Xe+tt),ct=yt*-Xe;if(ne.matrixWorld.decompose(z.position,z.quaternion,z.scale),z.translateX(ct),z.translateZ(yt),z.matrixWorld.compose(z.position,z.quaternion,z.scale),z.matrixWorldInverse.copy(z.matrixWorld).invert(),Ae[10]===-1)z.projectionMatrix.copy(ne.projectionMatrix),z.projectionMatrixInverse.copy(ne.projectionMatrixInverse);else{const ut=Be+yt,V=ze+yt,et=rt-ct,se=mt+(xe-ct),R=Ue*ze/V*ut,x=Oe*ze/V*ut;z.projectionMatrix.makePerspective(et,se,R,x,ut,V),z.projectionMatrixInverse.copy(z.projectionMatrix).invert()}}function ie(z,ne){ne===null?z.matrixWorld.copy(z.matrix):z.matrixWorld.multiplyMatrices(ne.matrixWorld,z.matrix),z.matrixWorldInverse.copy(z.matrixWorld).invert()}this.updateCamera=function(z){if(s===null)return;let ne=z.near,J=z.far;m.texture!==null&&(m.depthNear>0&&(ne=m.depthNear),m.depthFar>0&&(J=m.depthFar)),w.near=I.near=T.near=ne,w.far=I.far=T.far=J,(U!==w.near||O!==w.far)&&(s.updateRenderState({depthNear:w.near,depthFar:w.far}),U=w.near,O=w.far),w.layers.mask=z.layers.mask|6,T.layers.mask=w.layers.mask&-5,I.layers.mask=w.layers.mask&-3;const xe=z.parent,Ae=w.cameras;ie(w,xe);for(let Se=0;Se0&&(m.alphaTest.value=_.alphaTest);const b=e.get(_),A=b.envMap,y=b.envMapRotation;A&&(m.envMap.value=A,m.envMapRotation.value.setFromMatrix4(zy.makeRotationFromEuler(y)).transpose(),A.isCubeTexture&&A.isRenderTargetTexture===!1&&m.envMapRotation.value.premultiply(Rf),m.reflectivity.value=_.reflectivity,m.ior.value=_.ior,m.refractionRatio.value=_.refractionRatio),_.lightMap&&(m.lightMap.value=_.lightMap,m.lightMapIntensity.value=_.lightMapIntensity,t(_.lightMap,m.lightMapTransform)),_.aoMap&&(m.aoMap.value=_.aoMap,m.aoMapIntensity.value=_.aoMapIntensity,t(_.aoMap,m.aoMapTransform))}function a(m,_){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,_.map&&(m.map.value=_.map,t(_.map,m.mapTransform))}function o(m,_){m.dashSize.value=_.dashSize,m.totalSize.value=_.dashSize+_.gapSize,m.scale.value=_.scale}function l(m,_,b,A){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,m.size.value=_.size*b,m.scale.value=A*.5,_.map&&(m.map.value=_.map,t(_.map,m.uvTransform)),_.alphaMap&&(m.alphaMap.value=_.alphaMap,t(_.alphaMap,m.alphaMapTransform)),_.alphaTest>0&&(m.alphaTest.value=_.alphaTest)}function c(m,_){m.diffuse.value.copy(_.color),m.opacity.value=_.opacity,m.rotation.value=_.rotation,_.map&&(m.map.value=_.map,t(_.map,m.mapTransform)),_.alphaMap&&(m.alphaMap.value=_.alphaMap,t(_.alphaMap,m.alphaMapTransform)),_.alphaTest>0&&(m.alphaTest.value=_.alphaTest)}function u(m,_){m.specular.value.copy(_.specular),m.shininess.value=Math.max(_.shininess,1e-4)}function d(m,_){_.gradientMap&&(m.gradientMap.value=_.gradientMap)}function h(m,_){m.metalness.value=_.metalness,_.metalnessMap&&(m.metalnessMap.value=_.metalnessMap,t(_.metalnessMap,m.metalnessMapTransform)),m.roughness.value=_.roughness,_.roughnessMap&&(m.roughnessMap.value=_.roughnessMap,t(_.roughnessMap,m.roughnessMapTransform)),_.envMap&&(m.envMapIntensity.value=_.envMapIntensity)}function f(m,_,b){m.ior.value=_.ior,_.sheen>0&&(m.sheenColor.value.copy(_.sheenColor).multiplyScalar(_.sheen),m.sheenRoughness.value=_.sheenRoughness,_.sheenColorMap&&(m.sheenColorMap.value=_.sheenColorMap,t(_.sheenColorMap,m.sheenColorMapTransform)),_.sheenRoughnessMap&&(m.sheenRoughnessMap.value=_.sheenRoughnessMap,t(_.sheenRoughnessMap,m.sheenRoughnessMapTransform))),_.clearcoat>0&&(m.clearcoat.value=_.clearcoat,m.clearcoatRoughness.value=_.clearcoatRoughness,_.clearcoatMap&&(m.clearcoatMap.value=_.clearcoatMap,t(_.clearcoatMap,m.clearcoatMapTransform)),_.clearcoatRoughnessMap&&(m.clearcoatRoughnessMap.value=_.clearcoatRoughnessMap,t(_.clearcoatRoughnessMap,m.clearcoatRoughnessMapTransform)),_.clearcoatNormalMap&&(m.clearcoatNormalMap.value=_.clearcoatNormalMap,t(_.clearcoatNormalMap,m.clearcoatNormalMapTransform),m.clearcoatNormalScale.value.copy(_.clearcoatNormalScale),_.side===cn&&m.clearcoatNormalScale.value.negate())),_.dispersion>0&&(m.dispersion.value=_.dispersion),_.iridescence>0&&(m.iridescence.value=_.iridescence,m.iridescenceIOR.value=_.iridescenceIOR,m.iridescenceThicknessMinimum.value=_.iridescenceThicknessRange[0],m.iridescenceThicknessMaximum.value=_.iridescenceThicknessRange[1],_.iridescenceMap&&(m.iridescenceMap.value=_.iridescenceMap,t(_.iridescenceMap,m.iridescenceMapTransform)),_.iridescenceThicknessMap&&(m.iridescenceThicknessMap.value=_.iridescenceThicknessMap,t(_.iridescenceThicknessMap,m.iridescenceThicknessMapTransform))),_.transmission>0&&(m.transmission.value=_.transmission,m.transmissionSamplerMap.value=b.texture,m.transmissionSamplerSize.value.set(b.width,b.height),_.transmissionMap&&(m.transmissionMap.value=_.transmissionMap,t(_.transmissionMap,m.transmissionMapTransform)),m.thickness.value=_.thickness,_.thicknessMap&&(m.thicknessMap.value=_.thicknessMap,t(_.thicknessMap,m.thicknessMapTransform)),m.attenuationDistance.value=_.attenuationDistance,m.attenuationColor.value.copy(_.attenuationColor)),_.anisotropy>0&&(m.anisotropyVector.value.set(_.anisotropy*Math.cos(_.anisotropyRotation),_.anisotropy*Math.sin(_.anisotropyRotation)),_.anisotropyMap&&(m.anisotropyMap.value=_.anisotropyMap,t(_.anisotropyMap,m.anisotropyMapTransform))),m.specularIntensity.value=_.specularIntensity,m.specularColor.value.copy(_.specularColor),_.specularColorMap&&(m.specularColorMap.value=_.specularColorMap,t(_.specularColorMap,m.specularColorMapTransform)),_.specularIntensityMap&&(m.specularIntensityMap.value=_.specularIntensityMap,t(_.specularIntensityMap,m.specularIntensityMapTransform))}function p(m,_){_.matcap&&(m.matcap.value=_.matcap)}function g(m,_){const b=e.get(_).light;m.referencePosition.value.setFromMatrixPosition(b.matrixWorld),m.nearDistance.value=b.shadow.camera.near,m.farDistance.value=b.shadow.camera.far}return{refreshFogUniforms:i,refreshMaterialUniforms:s}}function Gy(n,e,t,i){let s={},r={},a=[];const o=n.getParameter(n.MAX_UNIFORM_BUFFER_BINDINGS);function l(y,M){const S=M.program;i.uniformBlockBinding(y,S)}function c(y,M){let S=s[y.id];S===void 0&&(m(y),S=u(y),s[y.id]=S,y.addEventListener("dispose",b));const E=M.program;i.updateUBOMapping(y,E);const v=e.render.frame;r[y.id]!==v&&(h(y),r[y.id]=v)}function u(y){const M=d();y.__bindingPointIndex=M;const S=n.createBuffer(),E=y.__size,v=y.usage;return n.bindBuffer(n.UNIFORM_BUFFER,S),n.bufferData(n.UNIFORM_BUFFER,E,v),n.bindBuffer(n.UNIFORM_BUFFER,null),n.bindBufferBase(n.UNIFORM_BUFFER,M,S),S}function d(){for(let y=0;y0&&(S+=E-v),y.__size=S,y.__cache={},this}function _(y){const M={boundary:0,storage:0};return typeof y=="number"||typeof y=="boolean"?(M.boundary=4,M.storage=4):y.isVector2?(M.boundary=8,M.storage=8):y.isVector3||y.isColor?(M.boundary=16,M.storage=12):y.isVector4?(M.boundary=16,M.storage=16):y.isMatrix3?(M.boundary=48,M.storage=48):y.isMatrix4?(M.boundary=64,M.storage=64):y.isTexture?Ye("WebGLRenderer: Texture samplers can not be part of an uniforms group."):ArrayBuffer.isView(y)?(M.boundary=16,M.storage=y.byteLength):Ye("WebGLRenderer: Unsupported uniform value type.",y),M}function b(y){const M=y.target;M.removeEventListener("dispose",b);const S=a.indexOf(M.__bindingPointIndex);a.splice(S,1),n.deleteBuffer(s[M.id]),delete s[M.id],delete r[M.id]}function A(){for(const y in s)n.deleteBuffer(s[y]);a=[],s={},r={}}return{bind:l,update:c,dispose:A}}const Wy=new Uint16Array([12469,15057,12620,14925,13266,14620,13807,14376,14323,13990,14545,13625,14713,13328,14840,12882,14931,12528,14996,12233,15039,11829,15066,11525,15080,11295,15085,10976,15082,10705,15073,10495,13880,14564,13898,14542,13977,14430,14158,14124,14393,13732,14556,13410,14702,12996,14814,12596,14891,12291,14937,11834,14957,11489,14958,11194,14943,10803,14921,10506,14893,10278,14858,9960,14484,14039,14487,14025,14499,13941,14524,13740,14574,13468,14654,13106,14743,12678,14818,12344,14867,11893,14889,11509,14893,11180,14881,10751,14852,10428,14812,10128,14765,9754,14712,9466,14764,13480,14764,13475,14766,13440,14766,13347,14769,13070,14786,12713,14816,12387,14844,11957,14860,11549,14868,11215,14855,10751,14825,10403,14782,10044,14729,9651,14666,9352,14599,9029,14967,12835,14966,12831,14963,12804,14954,12723,14936,12564,14917,12347,14900,11958,14886,11569,14878,11247,14859,10765,14828,10401,14784,10011,14727,9600,14660,9289,14586,8893,14508,8533,15111,12234,15110,12234,15104,12216,15092,12156,15067,12010,15028,11776,14981,11500,14942,11205,14902,10752,14861,10393,14812,9991,14752,9570,14682,9252,14603,8808,14519,8445,14431,8145,15209,11449,15208,11451,15202,11451,15190,11438,15163,11384,15117,11274,15055,10979,14994,10648,14932,10343,14871,9936,14803,9532,14729,9218,14645,8742,14556,8381,14461,8020,14365,7603,15273,10603,15272,10607,15267,10619,15256,10631,15231,10614,15182,10535,15118,10389,15042,10167,14963,9787,14883,9447,14800,9115,14710,8665,14615,8318,14514,7911,14411,7507,14279,7198,15314,9675,15313,9683,15309,9712,15298,9759,15277,9797,15229,9773,15166,9668,15084,9487,14995,9274,14898,8910,14800,8539,14697,8234,14590,7790,14479,7409,14367,7067,14178,6621,15337,8619,15337,8631,15333,8677,15325,8769,15305,8871,15264,8940,15202,8909,15119,8775,15022,8565,14916,8328,14804,8009,14688,7614,14569,7287,14448,6888,14321,6483,14088,6171,15350,7402,15350,7419,15347,7480,15340,7613,15322,7804,15287,7973,15229,8057,15148,8012,15046,7846,14933,7611,14810,7357,14682,7069,14552,6656,14421,6316,14251,5948,14007,5528,15356,5942,15356,5977,15353,6119,15348,6294,15332,6551,15302,6824,15249,7044,15171,7122,15070,7050,14949,6861,14818,6611,14679,6349,14538,6067,14398,5651,14189,5311,13935,4958,15359,4123,15359,4153,15356,4296,15353,4646,15338,5160,15311,5508,15263,5829,15188,6042,15088,6094,14966,6001,14826,5796,14678,5543,14527,5287,14377,4985,14133,4586,13869,4257,15360,1563,15360,1642,15358,2076,15354,2636,15341,3350,15317,4019,15273,4429,15203,4732,15105,4911,14981,4932,14836,4818,14679,4621,14517,4386,14359,4156,14083,3795,13808,3437,15360,122,15360,137,15358,285,15355,636,15344,1274,15322,2177,15281,2765,15215,3223,15120,3451,14995,3569,14846,3567,14681,3466,14511,3305,14344,3121,14037,2800,13753,2467,15360,0,15360,1,15359,21,15355,89,15346,253,15325,479,15287,796,15225,1148,15133,1492,15008,1749,14856,1882,14685,1886,14506,1783,14324,1608,13996,1398,13702,1183]);let zn=null;function Xy(){return zn===null&&(zn=new af(Wy,16,16,is,_i),zn.name="DFG_LUT",zn.minFilter=Xt,zn.magFilter=Xt,zn.wrapS=ui,zn.wrapT=ui,zn.generateMipmaps=!1,zn.needsUpdate=!0),zn}class Yy{constructor(e={}){const{canvas:t=P0(),context:i=null,depth:s=!0,stencil:r=!1,alpha:a=!1,antialias:o=!1,premultipliedAlpha:l=!0,preserveDrawingBuffer:c=!1,powerPreference:u="default",failIfMajorPerformanceCaveat:d=!1,reversedDepthBuffer:h=!1,outputBufferType:f=vn}=e;this.isWebGLRenderer=!0;let p;if(i!==null){if(typeof WebGLRenderingContext<"u"&&i instanceof WebGLRenderingContext)throw new Error("THREE.WebGLRenderer: WebGL 1 is not supported since r163.");p=i.getContextAttributes().alpha}else p=a;const g=f,m=new Set([Fc,kc,Nc]),_=new Set([vn,ei,wr,Rr,Uc,Oc]),b=new Uint32Array(4),A=new Int32Array(4),y=new B;let M=null,S=null;const E=[],v=[];let T=null;this.domElement=t,this.debug={checkShaderErrors:!0,onShaderError:null},this.autoClear=!0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearStencil=!0,this.sortObjects=!0,this.clippingPlanes=[],this.localClippingEnabled=!1,this.toneMapping=Jn,this.toneMappingExposure=1,this.transmissionResolutionScale=1;const I=this;let L=!1,w=null,U=null,O=null,P=null;this._outputColorSpace=pn;let Z=0,N=0,W=null,D=-1,re=null;const ie=new wt,oe=new wt;let _e=null;const de=new Qe(0);let le=0,z=t.width,ne=t.height,J=1,xe=null,Ae=null;const Se=new wt(0,0,z,ne),Be=new wt(0,0,z,ne);let ze=!1;const Ue=new of;let Oe=!1,Xe=!1;const tt=new Et,rt=new B,mt=new wt,yt={background:null,fog:null,environment:null,overrideMaterial:null,isScene:!0};let ct=!1;function ut(){return W===null?J:1}let V=i;function et(C,K){return t.getContext(C,K)}try{const C={alpha:!0,depth:s,stencil:r,antialias:o,premultipliedAlpha:l,preserveDrawingBuffer:c,powerPreference:u,failIfMajorPerformanceCaveat:d};if("setAttribute"in t&&t.setAttribute("data-engine",`three.js r${Ic}`),t.addEventListener("webglcontextlost",Mt,!1),t.addEventListener("webglcontextrestored",ht,!1),t.addEventListener("webglcontextcreationerror",Dt,!1),V===null){const K="webgl2";if(V=et(K,C),V===null)throw et(K)?new Error("THREE.WebGLRenderer: Error creating WebGL context with your selected attributes."):new Error("THREE.WebGLRenderer: Error creating WebGL context.")}}catch(C){throw at("WebGLRenderer: "+C.message),C}let se,R,x,G,H,$,fe,X,F,Y,ae,ce,he,ee,ge,we,Ge,k,ye,ue,ve,Me,pe;function Fe(){se=new Xx(V),se.init(),ve=new Ny(V,se),R=new kx(V,se,e,ve),x=new Uy(V,se),R.reversedDepthBuffer&&h&&x.buffers.depth.setReversed(!0),U=V.createFramebuffer(),O=V.createFramebuffer(),P=V.createFramebuffer(),G=new qx(V),H=new vy,$=new Oy(V,se,x,H,R,ve,G),fe=new Wx(I),X=new jm(V),Me=new Ox(V,X),F=new Yx(V,X,G,Me),Y=new $x(V,F,X,Me,G),k=new Zx(V,R,$),ge=new Fx(H),ae=new yy(I,fe,se,R,Me,ge),ce=new Vy(I,H),he=new by,ee=new wy(se),Ge=new Ux(I,fe,x,Y,p,l),we=new Py(I,Y,R),pe=new Gy(V,G,R,x),ye=new Nx(V,se,G),ue=new Kx(V,se,G),G.programs=ae.programs,I.capabilities=R,I.extensions=se,I.properties=H,I.renderLists=he,I.shadowMap=we,I.state=x,I.info=G}Fe(),g!==vn&&(T=new jx(g,t.width,t.height,o,s,r));const Ne=new Hy(I,V);this.xr=Ne,this.getContext=function(){return V},this.getContextAttributes=function(){return V.getContextAttributes()},this.forceContextLoss=function(){const C=se.get("WEBGL_lose_context");C&&C.loseContext()},this.forceContextRestore=function(){const C=se.get("WEBGL_lose_context");C&&C.restoreContext()},this.getPixelRatio=function(){return J},this.setPixelRatio=function(C){C!==void 0&&(J=C,this.setSize(z,ne,!1))},this.getSize=function(C){return C.set(z,ne)},this.setSize=function(C,K,te=!0){if(Ne.isPresenting){Ye("WebGLRenderer: Can't change size while VR device is presenting.");return}z=C,ne=K,t.width=Math.floor(C*J),t.height=Math.floor(K*J),te===!0&&(t.style.width=C+"px",t.style.height=K+"px"),T!==null&&T.setSize(t.width,t.height),this.setViewport(0,0,C,K)},this.getDrawingBufferSize=function(C){return C.set(z*J,ne*J).floor()},this.setDrawingBufferSize=function(C,K,te){z=C,ne=K,J=te,t.width=Math.floor(C*te),t.height=Math.floor(K*te),this.setViewport(0,0,C,K)},this.setEffects=function(C){if(g===vn){at("WebGLRenderer: setEffects() requires outputBufferType set to HalfFloatType or FloatType.");return}if(C){for(let K=0;K{function De(){if(j.forEach(function(Ie){H.get(Ie).currentProgram.isReady()&&j.delete(Ie)}),j.size===0){Q(C);return}setTimeout(De,10)}se.get("KHR_parallel_shader_compile")!==null?De():setTimeout(De,10)})};let hs=null;function Yr(C){hs&&hs(C)}function ni(){_n.stop()}function rr(){_n.start()}const _n=new bf;_n.setAnimationLoop(Yr),typeof self<"u"&&_n.setContext(self),this.setAnimationLoop=function(C){hs=C,Ne.setAnimationLoop(C),C===null?_n.stop():_n.start()},Ne.addEventListener("sessionstart",ni),Ne.addEventListener("sessionend",rr),this.render=function(C,K){if(K!==void 0&&K.isCamera!==!0){at("WebGLRenderer.render: camera is not an instance of THREE.Camera.");return}if(L===!0)return;w!==null&&w.renderStart(C,K);const te=Ne.enabled===!0&&Ne.isPresenting===!0,j=T!==null&&(W===null||te)&&T.begin(I,W);if(C.matrixWorldAutoUpdate===!0&&C.updateMatrixWorld(),K.parent===null&&K.matrixWorldAutoUpdate===!0&&K.updateMatrixWorld(),Ne.enabled===!0&&Ne.isPresenting===!0&&(T===null||T.isCompositing()===!1)&&(Ne.cameraAutoUpdate===!0&&Ne.updateCamera(K),K=Ne.getCamera()),C.isScene===!0&&C.onBeforeRender(I,C,K,W),S=ee.get(C,v.length),S.init(K),S.state.textureUnits=$.getTextureUnits(),v.push(S),tt.multiplyMatrices(K.projectionMatrix,K.matrixWorldInverse),Ue.setFromProjectionMatrix(tt,Zn,K.reversedDepth),Xe=this.localClippingEnabled,Oe=ge.init(this.clippingPlanes,Xe),M=he.get(C,E.length),M.init(),E.push(M),Ne.enabled===!0&&Ne.isPresenting===!0){const Ie=I.xr.getDepthSensingMesh();Ie!==null&&ds(Ie,K,-1/0,I.sortObjects)}ds(C,K,0,I.sortObjects),M.finish(),I.sortObjects===!0&&M.sort(xe,Ae,K.reversedDepth),ct=Ne.enabled===!1||Ne.isPresenting===!1||Ne.hasDepthSensing()===!1,ct&&Ge.addToRenderList(M,C),this.info.render.frame++,this.info.autoReset===!0&&this.info.reset(),Oe===!0&&ge.beginShadows();const Q=S.state.shadowsArray;if(we.render(Q,C,K),Oe===!0&&ge.endShadows(),(j&&T.hasRenderPass())===!1){const Ie=M.opaque,Re=M.transmissive;if(S.setupLights(),K.isArrayCamera){const He=K.cameras;if(Re.length>0)for(let Ve=0,Ze=He.length;Ve0&&En(Ie,Re,C,K),ct&&Ge.render(C),ar(M,C,K)}W!==null&&N===0&&($.updateMultisampleRenderTarget(W),$.updateRenderTargetMipmap(W)),j&&T.end(I),C.isScene===!0&&C.onAfterRender(I,C,K),Me.resetDefaultState(),D=-1,re=null,v.pop(),v.length>0?(S=v[v.length-1],$.setTextureUnits(S.state.textureUnits),Oe===!0&&ge.setGlobalState(I.clippingPlanes,S.state.camera)):S=null,E.pop(),E.length>0?M=E[E.length-1]:M=null,w!==null&&w.renderEnd()};function ds(C,K,te,j){if(C.visible===!1)return;if(C.layers.test(K.layers)){if(C.isGroup)te=C.renderOrder;else if(C.isLOD)C.autoUpdate===!0&&C.update(K);else if(C.isLightProbeGrid)S.pushLightProbeGrid(C);else if(C.isLight)S.pushLight(C),C.castShadow&&S.pushShadow(C);else if(C.isSprite){if(!C.frustumCulled||Ue.intersectsSprite(C)){j&&mt.setFromMatrixPosition(C.matrixWorld).applyMatrix4(tt);const Ie=Y.update(C),Re=C.material;Re.visible&&M.push(C,Ie,Re,te,mt.z,null)}}else if((C.isMesh||C.isLine||C.isPoints)&&(!C.frustumCulled||Ue.intersectsObject(C))){const Ie=Y.update(C),Re=C.material;if(j&&(C.boundingSphere!==void 0?(C.boundingSphere===null&&C.computeBoundingSphere(),mt.copy(C.boundingSphere.center)):(Ie.boundingSphere===null&&Ie.computeBoundingSphere(),mt.copy(Ie.boundingSphere.center)),mt.applyMatrix4(C.matrixWorld).applyMatrix4(tt)),Array.isArray(Re)){const He=Ie.groups;for(let Ve=0,Ze=He.length;Ve0&&un(Q,K,te),De.length>0&&un(De,K,te),Ie.length>0&&un(Ie,K,te),x.buffers.depth.setTest(!0),x.buffers.depth.setMask(!0),x.buffers.color.setMask(!0),x.setPolygonOffset(!1)}function En(C,K,te,j){if((te.isScene===!0?te.overrideMaterial:null)!==null)return;if(S.state.transmissionRenderTarget[j.id]===void 0){const We=se.has("EXT_color_buffer_half_float")||se.has("EXT_color_buffer_float");S.state.transmissionRenderTarget[j.id]=new jn(1,1,{generateMipmaps:!0,type:We?_i:vn,minFilter:Ui,samples:Math.max(4,R.samples),stencilBuffer:r,resolveDepthBuffer:!1,resolveStencilBuffer:!1,colorSpace:it.workingColorSpace})}const De=S.state.transmissionRenderTarget[j.id],Ie=j.viewport||ie;De.setSize(Ie.z*I.transmissionResolutionScale,Ie.w*I.transmissionResolutionScale);const Re=I.getRenderTarget(),He=I.getActiveCubeFace(),Ve=I.getActiveMipmapLevel();I.setRenderTarget(De),I.getClearColor(de),le=I.getClearAlpha(),le<1&&I.setClearColor(16777215,.5),I.clear(),ct&&Ge.render(te);const Ze=I.toneMapping;I.toneMapping=Jn;const Je=j.viewport;if(j.viewport!==void 0&&(j.viewport=void 0),S.setupLightsView(j),Oe===!0&&ge.setGlobalState(I.clippingPlanes,j),un(C,te,j),$.updateMultisampleRenderTarget(De),$.updateRenderTargetMipmap(De),se.has("WEBGL_multisampled_render_to_texture")===!1){let We=!1;for(let gt=0,Lt=K.length;gt0,j.currentProgram=Je,j.uniformsList=null,Je}function fs(C){if(C.uniformsList===null){const K=C.currentProgram.getUniforms();C.uniformsList=Va.seqWithValue(K.seq,C.uniforms)}return C.uniformsList}function ps(C,K){const te=H.get(C);te.outputColorSpace=K.outputColorSpace,te.batching=K.batching,te.batchingColor=K.batchingColor,te.instancing=K.instancing,te.instancingColor=K.instancingColor,te.instancingMorph=K.instancingMorph,te.skinning=K.skinning,te.morphTargets=K.morphTargets,te.morphNormals=K.morphNormals,te.morphColors=K.morphColors,te.morphTargetsCount=K.morphTargetsCount,te.numClippingPlanes=K.numClippingPlanes,te.numIntersection=K.numClipIntersection,te.vertexAlphas=K.vertexAlphas,te.vertexTangents=K.vertexTangents,te.toneMapping=K.toneMapping}function Tn(C,K){if(C.length===0)return null;if(C.length===1)return C[0].texture!==null?C[0]:null;y.setFromMatrixPosition(K.matrixWorld);for(let te=0,j=C.length;te0),We=!!te.morphAttributes.position,gt=!!te.morphAttributes.normal,Lt=!!te.morphAttributes.color;let Tt=Jn;j.toneMapped&&(W===null||W.isXRRenderTarget===!0)&&(Tt=I.toneMapping);const vt=te.morphAttributes.position||te.morphAttributes.normal||te.morphAttributes.color,Kt=vt!==void 0?vt.length:0,Le=H.get(j),hn=S.state.lights;if(Oe===!0&&(Xe===!0||C!==re)){const bt=C===re&&j.id===D;ge.setState(j,C,bt)}let ot=!1;j.version===Le.__version?(Le.needsLights&&Le.lightsStateVersion!==hn.state.version||Le.outputColorSpace!==Re||Q.isBatchedMesh&&Le.batching===!1||!Q.isBatchedMesh&&Le.batching===!0||Q.isBatchedMesh&&Le.batchingColor===!0&&Q.colorTexture===null||Q.isBatchedMesh&&Le.batchingColor===!1&&Q.colorTexture!==null||Q.isInstancedMesh&&Le.instancing===!1||!Q.isInstancedMesh&&Le.instancing===!0||Q.isSkinnedMesh&&Le.skinning===!1||!Q.isSkinnedMesh&&Le.skinning===!0||Q.isInstancedMesh&&Le.instancingColor===!0&&Q.instanceColor===null||Q.isInstancedMesh&&Le.instancingColor===!1&&Q.instanceColor!==null||Q.isInstancedMesh&&Le.instancingMorph===!0&&Q.morphTexture===null||Q.isInstancedMesh&&Le.instancingMorph===!1&&Q.morphTexture!==null||Le.envMap!==Ve||j.fog===!0&&Le.fog!==De||Le.numClippingPlanes!==void 0&&(Le.numClippingPlanes!==ge.numPlanes||Le.numIntersection!==ge.numIntersection)||Le.vertexAlphas!==Ze||Le.vertexTangents!==Je||Le.morphTargets!==We||Le.morphNormals!==gt||Le.morphColors!==Lt||Le.toneMapping!==Tt||Le.morphTargetsCount!==Kt||!!Le.lightProbeGrid!=S.state.lightProbeGridArray.length>0)&&(ot=!0):(ot=!0,Le.__version=j.version);let xn=Le.currentProgram;ot===!0&&(xn=yi(j,K,Q),w&&j.isNodeMaterial&&w.onUpdateProgram(j,xn,Le));let Bn=!1,vi=!1,ms=!1;const St=xn.getUniforms(),It=Le.uniforms;if(x.useProgram(xn.program)&&(Bn=!0,vi=!0,ms=!0),j.id!==D&&(D=j.id,vi=!0),Le.needsLights){const bt=Tn(S.state.lightProbeGridArray,Q);Le.lightProbeGrid!==bt&&(Le.lightProbeGrid=bt,vi=!0)}if(Bn||re!==C){x.buffers.depth.getReversed()&&C.reversedDepth!==!0&&(C._reversedDepth=!0,C.updateProjectionMatrix()),St.setValue(V,"projectionMatrix",C.projectionMatrix),St.setValue(V,"viewMatrix",C.matrixWorldInverse);const bi=St.map.cameraPosition;bi!==void 0&&bi.setValue(V,rt.setFromMatrixPosition(C.matrixWorld)),R.logarithmicDepthBuffer&&St.setValue(V,"logDepthBufFC",2/(Math.log(C.far+1)/Math.LN2)),(j.isMeshPhongMaterial||j.isMeshToonMaterial||j.isMeshLambertMaterial||j.isMeshBasicMaterial||j.isMeshStandardMaterial||j.isShaderMaterial)&&St.setValue(V,"isOrthographic",C.isOrthographicCamera===!0),re!==C&&(re=C,vi=!0,ms=!0)}if(Le.needsLights&&(hn.state.directionalShadowMap.length>0&&St.setValue(V,"directionalShadowMap",hn.state.directionalShadowMap,$),hn.state.spotShadowMap.length>0&&St.setValue(V,"spotShadowMap",hn.state.spotShadowMap,$),hn.state.pointShadowMap.length>0&&St.setValue(V,"pointShadowMap",hn.state.pointShadowMap,$)),Q.isSkinnedMesh){St.setOptional(V,Q,"bindMatrix"),St.setOptional(V,Q,"bindMatrixInverse");const bt=Q.skeleton;bt&&(bt.boneTexture===null&&bt.computeBoneTexture(),St.setValue(V,"boneTexture",bt.boneTexture,$))}Q.isBatchedMesh&&(St.setOptional(V,Q,"batchingTexture"),St.setValue(V,"batchingTexture",Q._matricesTexture,$),St.setOptional(V,Q,"batchingIdTexture"),St.setValue(V,"batchingIdTexture",Q._indirectTexture,$),St.setOptional(V,Q,"batchingColorTexture"),Q._colorsTexture!==null&&St.setValue(V,"batchingColorTexture",Q._colorsTexture,$));const Si=te.morphAttributes;if((Si.position!==void 0||Si.normal!==void 0||Si.color!==void 0)&&k.update(Q,te,xn),(vi||Le.receiveShadow!==Q.receiveShadow)&&(Le.receiveShadow=Q.receiveShadow,St.setValue(V,"receiveShadow",Q.receiveShadow)),(j.isMeshStandardMaterial||j.isMeshLambertMaterial||j.isMeshPhongMaterial)&&j.envMap===null&&K.environment!==null&&(It.envMapIntensity.value=K.environmentIntensity),It.dfgLUT!==void 0&&(It.dfgLUT.value=Xy()),vi){if(St.setValue(V,"toneMappingExposure",I.toneMappingExposure),Le.needsLights&&Cn(It,ms),De&&j.fog===!0&&ce.refreshFogUniforms(It,De),ce.refreshMaterialUniforms(It,j,J,ne,S.state.transmissionRenderTarget[C.id]),Le.needsLights&&Le.lightProbeGrid){const bt=Le.lightProbeGrid;It.probesSH.value=bt.texture,It.probesMin.value.copy(bt.boundingBox.min),It.probesMax.value.copy(bt.boundingBox.max),It.probesResolution.value.copy(bt.resolution)}Va.upload(V,fs(Le),It,$)}if(j.isShaderMaterial&&j.uniformsNeedUpdate===!0&&(Va.upload(V,fs(Le),It,$),j.uniformsNeedUpdate=!1),j.isSpriteMaterial&&St.setValue(V,"center",Q.center),St.setValue(V,"modelViewMatrix",Q.modelViewMatrix),St.setValue(V,"normalMatrix",Q.normalMatrix),St.setValue(V,"modelMatrix",Q.matrixWorld),j.uniformsGroups!==void 0){const bt=j.uniformsGroups;for(let bi=0,gs=bt.length;bi0&&$.useMultisampledRTT(C)===!1?j=H.get(C).__webglMultisampledFramebuffer:Array.isArray(Ve)?j=Ve[te]:j=Ve,ie.copy(C.viewport),oe.copy(C.scissor),_e=C.scissorTest}else ie.copy(Se).multiplyScalar(J).floor(),oe.copy(Be).multiplyScalar(J).floor(),_e=ze;if(te!==0&&(j=U),x.bindFramebuffer(V.FRAMEBUFFER,j)&&x.drawBuffers(C,j),x.viewport(ie),x.scissor(oe),x.setScissorTest(_e),Q){const Re=H.get(C.texture);V.framebufferTexture2D(V.FRAMEBUFFER,V.COLOR_ATTACHMENT0,V.TEXTURE_CUBE_MAP_POSITIVE_X+K,Re.__webglTexture,te)}else if(De){const Re=K;for(let He=0;He1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.");return}if(!R.textureTypeReadable(Je)){at("WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.");return}K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q&&V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),De)}finally{const Ve=W!==null?H.get(W).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,Ve)}}},this.readRenderTargetPixelsAsync=async function(C,K,te,j,Q,De,Ie,Re=0){if(!(C&&C.isWebGLRenderTarget))throw new Error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");let He=H.get(C).__webglFramebuffer;if(C.isWebGLCubeRenderTarget&&Ie!==void 0&&(He=He[Ie]),He)if(K>=0&&K<=C.width-j&&te>=0&&te<=C.height-Q){x.bindFramebuffer(V.FRAMEBUFFER,He);const Ve=C.textures[Re],Ze=Ve.format,Je=Ve.type;if(C.textures.length>1&&V.readBuffer(V.COLOR_ATTACHMENT0+Re),!R.textureFormatReadable(Ze))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in RGBA or implementation defined format.");if(!R.textureTypeReadable(Je))throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: renderTarget is not in UnsignedByteType or implementation defined type.");const We=V.createBuffer();V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.bufferData(V.PIXEL_PACK_BUFFER,De.byteLength,V.STREAM_READ),V.readPixels(K,te,j,Q,ve.convert(Ze),ve.convert(Je),0);const gt=W!==null?H.get(W).__webglFramebuffer:null;x.bindFramebuffer(V.FRAMEBUFFER,gt);const Lt=V.fenceSync(V.SYNC_GPU_COMMANDS_COMPLETE,0);return V.flush(),await U0(V,Lt,4),V.bindBuffer(V.PIXEL_PACK_BUFFER,We),V.getBufferSubData(V.PIXEL_PACK_BUFFER,0,De),V.deleteBuffer(We),V.deleteSync(Lt),De}else throw new Error("THREE.WebGLRenderer.readRenderTargetPixelsAsync: requested read bounds are out of range.")},this.copyFramebufferToTexture=function(C,K=null,te=0){const j=Math.pow(2,-te),Q=Math.floor(C.image.width*j),De=Math.floor(C.image.height*j),Ie=K!==null?K.x:0,Re=K!==null?K.y:0;$.setTexture2D(C,0),V.copyTexSubImage2D(V.TEXTURE_2D,te,0,0,Ie,Re,Q,De),x.unbindTexture()},this.copyTextureToTexture=function(C,K,te=null,j=null,Q=0,De=0){let Ie,Re,He,Ve,Ze,Je,We,gt,Lt;const Tt=C.isCompressedTexture?C.mipmaps[De]:C.image;if(te!==null)Ie=te.max.x-te.min.x,Re=te.max.y-te.min.y,He=te.isBox3?te.max.z-te.min.z:1,Ve=te.min.x,Ze=te.min.y,Je=te.isBox3?te.min.z:0;else{const It=Math.pow(2,-Q);Ie=Math.floor(Tt.width*It),Re=Math.floor(Tt.height*It),C.isDataArrayTexture?He=Tt.depth:C.isData3DTexture?He=Math.floor(Tt.depth*It):He=1,Ve=0,Ze=0,Je=0}j!==null?(We=j.x,gt=j.y,Lt=j.z):(We=0,gt=0,Lt=0);const vt=ve.convert(K.format),Kt=ve.convert(K.type);let Le;K.isData3DTexture?($.setTexture3D(K,0),Le=V.TEXTURE_3D):K.isDataArrayTexture||K.isCompressedArrayTexture?($.setTexture2DArray(K,0),Le=V.TEXTURE_2D_ARRAY):($.setTexture2D(K,0),Le=V.TEXTURE_2D),x.activeTexture(V.TEXTURE0),x.pixelStorei(V.UNPACK_FLIP_Y_WEBGL,K.flipY),x.pixelStorei(V.UNPACK_PREMULTIPLY_ALPHA_WEBGL,K.premultiplyAlpha),x.pixelStorei(V.UNPACK_ALIGNMENT,K.unpackAlignment);const hn=x.getParameter(V.UNPACK_ROW_LENGTH),ot=x.getParameter(V.UNPACK_IMAGE_HEIGHT),xn=x.getParameter(V.UNPACK_SKIP_PIXELS),Bn=x.getParameter(V.UNPACK_SKIP_ROWS),vi=x.getParameter(V.UNPACK_SKIP_IMAGES);x.pixelStorei(V.UNPACK_ROW_LENGTH,Tt.width),x.pixelStorei(V.UNPACK_IMAGE_HEIGHT,Tt.height),x.pixelStorei(V.UNPACK_SKIP_PIXELS,Ve),x.pixelStorei(V.UNPACK_SKIP_ROWS,Ze),x.pixelStorei(V.UNPACK_SKIP_IMAGES,Je);const ms=C.isDataArrayTexture||C.isData3DTexture,St=K.isDataArrayTexture||K.isData3DTexture;if(C.isDepthTexture){const It=H.get(C),Si=H.get(K),bt=H.get(It.__renderTarget),bi=H.get(Si.__renderTarget);x.bindFramebuffer(V.READ_FRAMEBUFFER,bt.__webglFramebuffer),x.bindFramebuffer(V.DRAW_FRAMEBUFFER,bi.__webglFramebuffer);for(let gs=0;gsMath.PI&&(i-=on),s<-Math.PI?s+=on:s>Math.PI&&(s-=on),i<=s?this._spherical.theta=Math.max(i,Math.min(s,this._spherical.theta)):this._spherical.theta=this._spherical.theta>(i+s)/2?Math.max(i,this._spherical.theta):Math.min(s,this._spherical.theta)),this._spherical.phi=Math.max(this.minPolarAngle,Math.min(this.maxPolarAngle,this._spherical.phi)),this._spherical.makeSafe(),this.enableDamping===!0?this.target.addScaledVector(this._panOffset,this.dampingFactor):this.target.add(this._panOffset),this.target.sub(this.cursor),this.target.clampLength(this.minTargetRadius,this.maxTargetRadius),this.target.add(this.cursor);let r=!1;if(this.zoomToCursor&&this._performCursorZoom||this.object.isOrthographicCamera)this._spherical.radius=this._clampDistance(this._spherical.radius);else{const a=this._spherical.radius;this._spherical.radius=this._clampDistance(this._spherical.radius*this._scale),r=a!=this._spherical.radius}if(Ot.setFromSpherical(this._spherical),Ot.applyQuaternion(this._quatInverse),t.copy(this.target).add(Ot),this.object.lookAt(this.target),this.enableDamping===!0?(this._sphericalDelta.theta*=1-this.dampingFactor,this._sphericalDelta.phi*=1-this.dampingFactor,this._panOffset.multiplyScalar(1-this.dampingFactor)):(this._sphericalDelta.set(0,0,0),this._panOffset.set(0,0,0)),this.zoomToCursor&&this._performCursorZoom){let a=null;if(this.object.isPerspectiveCamera){const o=Ot.length();a=this._clampDistance(o*this._scale);const l=o-a;this.object.position.addScaledVector(this._dollyDirection,l),this.object.updateMatrixWorld(),r=!!l}else if(this.object.isOrthographicCamera){const o=new B(this._mouse.x,this._mouse.y,0);o.unproject(this.object);const l=this.object.zoom;this.object.zoom=Math.max(this.minZoom,Math.min(this.maxZoom,this.object.zoom/this._scale)),this.object.updateProjectionMatrix(),r=l!==this.object.zoom;const c=new B(this._mouse.x,this._mouse.y,0);c.unproject(this.object),this.object.position.sub(c).add(o),this.object.updateMatrixWorld(),a=Ot.length()}else console.warn("WARNING: OrbitControls.js encountered an unknown camera type - zoom to cursor disabled."),this.zoomToCursor=!1;a!==null&&(this.screenSpacePanning?this.target.set(0,0,-1).transformDirection(this.object.matrix).multiplyScalar(a).add(this.object.position):(Aa.origin.copy(this.object.position),Aa.direction.set(0,0,-1).transformDirection(this.object.matrix),Math.abs(this.object.up.dot(Aa.direction))cl||8*(1-this._lastQuaternion.dot(this.object.quaternion))>cl||this._lastTargetPosition.distanceToSquared(this.target)>cl?(this.dispatchEvent(Ch),this._lastPosition.copy(this.object.position),this._lastQuaternion.copy(this.object.quaternion),this._lastTargetPosition.copy(this.target),!0):!1}_getAutoRotationAngle(e){return e!==null?on/60*this.autoRotateSpeed*e:on/60/60*this.autoRotateSpeed}_getZoomScale(e){const t=Math.abs(e*.01);return Math.pow(.95,this.zoomSpeed*t)}_rotateLeft(e){this._sphericalDelta.theta-=e}_rotateUp(e){this._sphericalDelta.phi-=e}_panLeft(e,t){Ot.setFromMatrixColumn(t,0),Ot.multiplyScalar(-e),this._panOffset.add(Ot)}_panUp(e,t){this.screenSpacePanning===!0?Ot.setFromMatrixColumn(t,1):(Ot.setFromMatrixColumn(t,0),Ot.crossVectors(this.object.up,Ot)),Ot.multiplyScalar(e),this._panOffset.add(Ot)}_pan(e,t){const i=this.domElement;if(this.object.isPerspectiveCamera){const s=this.object.position;Ot.copy(s).sub(this.target);let r=Ot.length();r*=Math.tan(this.object.fov/2*Math.PI/180),this._panLeft(2*e*r/i.clientHeight,this.object.matrix),this._panUp(2*t*r/i.clientHeight,this.object.matrix)}else this.object.isOrthographicCamera?(this._panLeft(e*(this.object.right-this.object.left)/this.object.zoom/i.clientWidth,this.object.matrix),this._panUp(t*(this.object.top-this.object.bottom)/this.object.zoom/i.clientHeight,this.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),this.enablePan=!1)}_dollyOut(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale/=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_dollyIn(e){this.object.isPerspectiveCamera||this.object.isOrthographicCamera?this._scale*=e:(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),this.enableZoom=!1)}_updateZoomParameters(e,t){if(!this.zoomToCursor)return;this._performCursorZoom=!0;const i=this.domElement.getBoundingClientRect(),s=e-i.left,r=t-i.top,a=i.width,o=i.height;this._mouse.x=s/a*2-1,this._mouse.y=-(r/o)*2+1,this._dollyDirection.set(this._mouse.x,this._mouse.y,1).unproject(this.object).sub(this.object.position).normalize()}_clampDistance(e){return Math.max(this.minDistance,Math.min(this.maxDistance,e))}_handleMouseDownRotate(e){this._rotateStart.set(e.clientX,e.clientY)}_handleMouseDownDolly(e){this._updateZoomParameters(e.clientX,e.clientX),this._dollyStart.set(e.clientX,e.clientY)}_handleMouseDownPan(e){this._panStart.set(e.clientX,e.clientY)}_handleMouseMoveRotate(e){this._rotateEnd.set(e.clientX,e.clientY),this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd),this.update()}_handleMouseMoveDolly(e){this._dollyEnd.set(e.clientX,e.clientY),this._dollyDelta.subVectors(this._dollyEnd,this._dollyStart),this._dollyDelta.y>0?this._dollyOut(this._getZoomScale(this._dollyDelta.y)):this._dollyDelta.y<0&&this._dollyIn(this._getZoomScale(this._dollyDelta.y)),this._dollyStart.copy(this._dollyEnd),this.update()}_handleMouseMovePan(e){this._panEnd.set(e.clientX,e.clientY),this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd),this.update()}_handleMouseWheel(e){this._updateZoomParameters(e.clientX,e.clientY),e.deltaY<0?this._dollyIn(this._getZoomScale(e.deltaY)):e.deltaY>0&&this._dollyOut(this._getZoomScale(e.deltaY)),this.update()}_handleKeyDown(e){let t=!1;switch(e.code){case this.keys.UP:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,this.keyPanSpeed),t=!0;break;case this.keys.BOTTOM:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateUp(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(0,-this.keyPanSpeed),t=!0;break;case this.keys.LEFT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(this.keyPanSpeed,0),t=!0;break;case this.keys.RIGHT:e.ctrlKey||e.metaKey||e.shiftKey?this.enableRotate&&this._rotateLeft(-on*this.keyRotateSpeed/this.domElement.clientHeight):this.enablePan&&this._pan(-this.keyPanSpeed,0),t=!0;break}t&&(e.preventDefault(),this.update())}_handleTouchStartRotate(e){if(this._pointers.length===1)this._rotateStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._rotateStart.set(i,s)}}_handleTouchStartPan(e){if(this._pointers.length===1)this._panStart.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panStart.set(i,s)}}_handleTouchStartDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyStart.set(0,r)}_handleTouchStartDollyPan(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enablePan&&this._handleTouchStartPan(e)}_handleTouchStartDollyRotate(e){this.enableZoom&&this._handleTouchStartDolly(e),this.enableRotate&&this._handleTouchStartRotate(e)}_handleTouchMoveRotate(e){if(this._pointers.length==1)this._rotateEnd.set(e.pageX,e.pageY);else{const i=this._getSecondPointerPosition(e),s=.5*(e.pageX+i.x),r=.5*(e.pageY+i.y);this._rotateEnd.set(s,r)}this._rotateDelta.subVectors(this._rotateEnd,this._rotateStart).multiplyScalar(this.rotateSpeed);const t=this.domElement;this._rotateLeft(on*this._rotateDelta.x/t.clientHeight),this._rotateUp(on*this._rotateDelta.y/t.clientHeight),this._rotateStart.copy(this._rotateEnd)}_handleTouchMovePan(e){if(this._pointers.length===1)this._panEnd.set(e.pageX,e.pageY);else{const t=this._getSecondPointerPosition(e),i=.5*(e.pageX+t.x),s=.5*(e.pageY+t.y);this._panEnd.set(i,s)}this._panDelta.subVectors(this._panEnd,this._panStart).multiplyScalar(this.panSpeed),this._pan(this._panDelta.x,this._panDelta.y),this._panStart.copy(this._panEnd)}_handleTouchMoveDolly(e){const t=this._getSecondPointerPosition(e),i=e.pageX-t.x,s=e.pageY-t.y,r=Math.sqrt(i*i+s*s);this._dollyEnd.set(0,r),this._dollyDelta.set(0,Math.pow(this._dollyEnd.y/this._dollyStart.y,this.zoomSpeed)),this._dollyOut(this._dollyDelta.y),this._dollyStart.copy(this._dollyEnd);const a=(e.pageX+t.x)*.5,o=(e.pageY+t.y)*.5;this._updateZoomParameters(a,o)}_handleTouchMoveDollyPan(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enablePan&&this._handleTouchMovePan(e)}_handleTouchMoveDollyRotate(e){this.enableZoom&&this._handleTouchMoveDolly(e),this.enableRotate&&this._handleTouchMoveRotate(e)}_addPointer(e){this._pointers.push(e.pointerId)}_removePointer(e){delete this._pointerPositions[e.pointerId];for(let t=0;t=250&&n<=255){const e=Math.round(40+(n-250)*43);return e*65536+e*256+e}if(n>=10&&n<=249){const e=n-10,[t,i]=cv[e%10];return ov(Math.floor(e/10)*15,t,i)}return 13226457}function qc(n){if(n==null)return null;if(typeof n=="object"&&n!==null&&"value"in n){const e=n.value;if(typeof e=="number"&&Number.isFinite(e))return e.toString(16);if(typeof e=="string"&&e.length){const t=Number(e);return Number.isFinite(t)?t.toString(16):e.toLowerCase()}return null}if(typeof n=="number"&&Number.isFinite(n))return n.toString(16);if(typeof n=="string"&&n.length){const e=Number(n);return Number.isFinite(e)?e.toString(16):n.toLowerCase()}return null}function Lf(n){return qc(n.ownerHandle)}function uv(n){const e=n.toLowerCase().replace(/\*/g,"").trim();return e?e==="model_space"||e==="ms"||e.startsWith("model")?"model":e==="paper_space"||e==="ps"||e.startsWith("paper")?"paper":null:null}function hv(n,e,t){return n==="model"?"Model":n==="paper"?t<=1?"Layout":`Layout (${e.replace(/^\*/,"")})`:e}function Hs(n){var a;const e=((a=n==null?void 0:n.tables)==null?void 0:a.blocks)??[],t=(n==null?void 0:n.entities)??[],i=new Map;for(const o of t){const l=Lf(o);l&&i.set(l,(i.get(l)||0)+1)}const s=[];let r=0;for(const o of e){const l=uv(o.name??"");if(!l)continue;const c=qc(o.handle);if(!c)continue;l==="paper"&&(r+=1);const u=typeof o.handle=="number"?o.handle:typeof o.handle=="object"&&o.handle&&"value"in o.handle?Number(o.handle.value):null;s.push({id:c,label:hv(l,o.name??"",r),name:o.name??"",handle:Number.isFinite(u)?u:null,handleHex:c,kind:l,entityCount:i.get(c)||0})}return s.sort((o,l)=>{if(o.kind!==l.kind){if(o.kind==="model")return-1;if(l.kind==="model")return 1}return 0}),s}function dv(n){if(!n.length)return null;const e=n.find(i=>i.kind==="paper"&&i.entityCount>0);if(e)return e;const t=n.find(i=>i.kind==="model");return t||(n[0]??null)}function ul(n,e,t=3){const i=new Set([e]);for(let s=0;s>>=1,e}function Yn(n,e,t){if(!e)return t;for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>16-e;return n.tag>>>=e,n.bitcount-=e,i+t}function Sc(n,e){for(;n.bitcount<24;)n.tag|=n.source[n.sourceIndex++]<>>=1,++s,t+=e.table[s],i-=e.table[s];while(i>=0);return n.tag=r,n.bitcount-=s,e.trans[t+i]}function _v(n,e,t){var i,s,r,a,o,l;for(i=Yn(n,5,257),s=Yn(n,5,1),r=Yn(n,4,4),a=0;a<19;++a)Vn[a]=0;for(a=0;a8;)n.sourceIndex--,n.bitcount-=8;if(e=n.source[n.sourceIndex+1],e=256*e+n.source[n.sourceIndex],t=n.source[n.sourceIndex+3],t=256*t+n.source[n.sourceIndex+2],e!==(~t&65535))return If;for(n.sourceIndex+=4,i=e;i;--i)n.dest[n.destLen++]=n.source[n.sourceIndex++];return n.bitcount=0,Zc}function Ff(n,e){var t=new fv(n,e),i,s,r;do{switch(i=gv(t),s=Yn(t,2,0),s){case 0:r=xv(t);break;case 1:r=Lh(t,Pf,Uf);break;case 2:_v(t,t.ltree,t.dtree),r=Lh(t,t.ltree,t.dtree);break;default:r=If}if(r!==Zc)throw new Error("Data error")}while(!i);return t.destLenthis.x2&&(this.x2=n)),typeof e=="number"&&((isNaN(this.y1)||isNaN(this.y2))&&(this.y1=e,this.y2=e),ethis.y2&&(this.y2=e))};ls.prototype.addX=function(n){this.addPoint(n,null)};ls.prototype.addY=function(n){this.addPoint(null,n)};ls.prototype.addBezier=function(n,e,t,i,s,r,a,o){const l=[n,e],c=[t,i],u=[s,r],d=[a,o];this.addPoint(n,e),this.addPoint(a,o);for(let h=0;h<=1;h++){const f=6*l[h]-12*c[h]+6*u[h],p=-3*l[h]+9*c[h]-9*u[h]+3*d[h],g=3*c[h]-3*l[h];if(p===0){if(f===0)continue;const A=-g/f;01||Math.abs(a.y-i)>1||r.pop():a.type==="L"&&c&&c.x===a.x&&c.y===a.y?r.pop():a.type==="Z"&&(o&&l&&c&&o.type==="M"&&l.type==="L"&&c.type==="L"&&c.x===o.x&&c.y===o.y&&(r.shift(),r[0].type="M"),s+1g.length).map(g=>{let m=parseFloat(g);return(e.decimalPlaces||e.decimalPlaces===0)&&(m=Hf(m,e.decimalPlaces)),m})}function u(p){if(!this.commands.length)return p;const g=this.commands[this.commands.length-1];for(let m=0;m-1)o[o.length-1]+=g;else if(r.indexOf(g)>-1)if(!a.type&&!this.commands.length&&(a.type="L"),g==="-")!a.type||m.indexOf("-")>0?l=!0:m.length?o.push("-"):o[o.length-1]=g;else if(!a.type||m.length>0)l=!0;else continue;else if(i.indexOf(g)>-1)a.type?(d.apply(this),a={type:g}):a.type=g;else{if(s.indexOf(g)>-1)throw new Error("Unsupported path command: "+g+". Currently supported commands are "+i.split("").join(", ")+".");` , +\r\f\v`.indexOf(g)>-1?o.push(""):g==="."?!a.type||m.indexOf(g)>-1?l=!0:o[o.length-1]+=g:l=!0}if(l)throw new Error("Unexpected character: "+g+" at offset "+p)}d.apply(this),e.optimize&&(this.commands=zf(this.commands));const h=e.flipY;let f=e.flipYBase;if(h===!0&&e.flipYBase===void 0){const p=this.getBoundingBox();f=p.y1+p.y2}for(const p in this.commands){const g=this.commands[p];for(const m in g)["x","x1","x2"].includes(m)?this.commands[p][m]=e.x+g[m]*e.scale:["y","y1","y2"].includes(m)&&(this.commands[p][m]=e.y+(h?f-g[m]:g[m])*e.scale)}return this};Bt.fromSVG=function(n,e){return new Bt().fromSVG(n,e)};Bt.prototype.moveTo=function(n,e){this.commands.push({type:"M",x:n,y:e})};Bt.prototype.lineTo=function(n,e){this.commands.push({type:"L",x:n,y:e})};Bt.prototype.curveTo=Bt.prototype.bezierCurveTo=function(n,e,t,i,s,r){this.commands.push({type:"C",x1:n,y1:e,x2:t,y2:i,x:s,y:r})};Bt.prototype.quadTo=Bt.prototype.quadraticCurveTo=function(n,e,t,i){this.commands.push({type:"Q",x1:n,y1:e,x:t,y:i})};Bt.prototype.close=Bt.prototype.closePath=function(){this.commands.push({type:"Z"})};Bt.prototype.extend=function(n){if(n.commands)n=n.commands;else if(n instanceof Bf){const e=n;this.moveTo(e.x1,e.y1),this.lineTo(e.x2,e.y1),this.lineTo(e.x2,e.y2),this.lineTo(e.x1,e.y2),this.close();return}Array.prototype.push.apply(this.commands,n)};Bt.prototype.getBoundingBox=function(){const n=new Bf;let e=0,t=0,i=0,s=0;for(let r=0;r=0&&l>0&&(o+=" "),o+=e(c)}return o}let i=this.commands;n.optimize&&(i=JSON.parse(JSON.stringify(this.commands)),i=zf(i));const s=n.flipY;let r=n.flipYBase;if(s===!0&&r===void 0){const o=new Bt;o.extend(i);const l=o.getBoundingBox();r=l.y1+l.y2}let a="";for(let o=0;o=0&&n<=255,"Byte value should be between 0 and 255."),[n]};Ke.BYTE=Fn(1);be.CHAR=function(n){return[n.charCodeAt(0)]};Ke.CHAR=Fn(1);be.CHARARRAY=function(n){(n===null||typeof n>"u")&&(n="",console.warn("CHARARRAY with undefined or null value encountered and treated as an empty string. This is probably caused by a missing glyph name."));const e=[];for(let t=0;t"u"?0:n.length};be.USHORT=function(n){return[n>>8&255,n&255]};Ke.USHORT=Fn(2);be.SHORT=function(n){return n>=Ph&&(n=-(2*Ph-n)),[n>>8&255,n&255]};Ke.SHORT=Fn(2);be.UINT24=function(n){return[n>>16&255,n>>8&255,n&255]};Ke.UINT24=Fn(3);be.ULONG=function(n){return[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.ULONG=Fn(4);be.LONG=function(n){return n>=Uh&&(n=-(2*Uh-n)),[n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONG=Fn(4);be.FLOAT=function(n){if(n>bv||n>24&255,n>>16&255,n>>8&255,n&255]};Ke.LONGDATETIME=Fn(8);be.TAG=function(n){return ke.argument(n.length===4,"Tag should be exactly 4 ASCII characters."),[n.charCodeAt(0),n.charCodeAt(1),n.charCodeAt(2),n.charCodeAt(3)]};Ke.TAG=Fn(4);be.Card8=be.BYTE;Ke.Card8=Ke.BYTE;be.Card16=be.USHORT;Ke.Card16=Ke.USHORT;be.OffSize=be.BYTE;Ke.OffSize=Ke.BYTE;be.SID=be.USHORT;Ke.SID=Ke.USHORT;be.NUMBER=function(n){return n>=-107&&n<=107?[n+139]:n>=108&&n<=1131?(n=n-108,[(n>>8)+247,n&255]):n>=-1131&&n<=-108?(n=-n-108,[(n>>8)+251,n&255]):n>=-32768&&n<=32767?be.NUMBER16(n):be.NUMBER32(n)};Ke.NUMBER=function(n){return be.NUMBER(n).length};be.NUMBER16=function(n){return[28,n>>8&255,n&255]};Ke.NUMBER16=Fn(3);be.NUMBER32=function(n){return[29,n>>24&255,n>>16&255,n>>8&255,n&255]};Ke.NUMBER32=Fn(5);be.REAL=function(n){let e=n.toString();const t=/\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(e);if(t){const r=parseFloat("1e"+((t[2]?+t[2]:0)+t[1].length));e=(Math.round(n*r)/r).toString()}let i="";for(let r=0,a=e.length;r>8&255,e[e.length]=i&255}return e};Ke.UTF16=function(n){return n.length*2};var io={"x-mac-croatian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®Š™´¨≠ŽØ∞±≤≥∆µ∂∑∏š∫ªºΩžø¿¡¬√ƒ≈ƫȅ ÀÃÕŒœĐ—“”‘’÷◊©⁄€‹›Æ»–·‚„‰ÂćÁčÈÍÎÏÌÓÔđÒÚÛÙıˆ˜¯πË˚¸Êæˇ","x-mac-cyrillic":"АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ†°Ґ£§•¶І®©™Ђђ≠Ѓѓ∞±≤≥іµґЈЄєЇїЉљЊњјЅ¬√ƒ≈∆«»… ЋћЌќѕ–—“”‘’÷„ЎўЏџ№Ёёяабвгдежзийклмнопрстуфхцчшщъыьэю","x-mac-gaelic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØḂ±≤≥ḃĊċḊḋḞḟĠġṀæøṁṖṗɼƒſṠ«»… ÀÃÕŒœ–—“”‘’ṡẛÿŸṪ€‹›Ŷŷṫ·Ỳỳ⁊ÂÊÁËÈÍÎÏÌÓÔ♣ÒÚÛÙıÝýŴŵẄẅẀẁẂẃ","x-mac-greek":"Ĺ²É³ÖÜ΅àâä΄¨çéèê룙î‰ôö¦€ùûü†ΓΔΘΛΞΠß®©ΣΪ§≠°·Α±≤≥¥ΒΕΖΗΙΚΜΦΫΨΩάΝ¬ΟΡ≈Τ«»… ΥΧΆΈœ–―“”‘’÷ΉΊΌΎέήίόΏύαβψδεφγηιξκλμνοπώρστθωςχυζϊϋΐΰ­","x-mac-icelandic":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûüݰ¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€ÐðÞþý·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-inuit":"ᐃᐄᐅᐆᐊᐋᐱᐲᐳᐴᐸᐹᑉᑎᑏᑐᑑᑕᑖᑦᑭᑮᑯᑰᑲᑳᒃᒋᒌᒍᒎᒐᒑ°ᒡᒥᒦ•¶ᒧ®©™ᒨᒪᒫᒻᓂᓃᓄᓅᓇᓈᓐᓯᓰᓱᓲᓴᓵᔅᓕᓖᓗᓘᓚᓛᓪᔨᔩᔪᔫᔭ… ᔮᔾᕕᕖᕗ–—“”‘’ᕘᕙᕚᕝᕆᕇᕈᕉᕋᕌᕐᕿᖀᖁᖂᖃᖄᖅᖏᖐᖑᖒᖓᖔᖕᙱᙲᙳᙴᙵᙶᖖᖠᖡᖢᖣᖤᖥᖦᕼŁł","x-mac-ce":"ÄĀāÉĄÖÜáąČäčĆć鏟ĎíďĒēĖóėôöõúĚěü†°Ę£§•¶ß®©™ę¨≠ģĮįĪ≤≥īĶ∂∑łĻļĽľĹĺŅņѬ√ńŇ∆«»… ňŐÕőŌ–—“”‘’÷◊ōŔŕŘ‹›řŖŗŠ‚„šŚśÁŤťÍŽžŪÓÔūŮÚůŰűŲųÝýķŻŁżĢˇ",macintosh:"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›fifl‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-romanian":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ĂȘ∞±≤≥¥µ∂∑∏π∫ªºΩăș¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸ⁄€‹›Țț‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙıˆ˜¯˘˙˚¸˝˛ˇ","x-mac-turkish":"ÄÅÇÉÑÖÜáàâäãåçéèêëíìîïñóòôöõúùûü†°¢£§•¶ß®©™´¨≠ÆØ∞±≤≥¥µ∂∑∏π∫ªºΩæø¿¡¬√ƒ≈∆«»… ÀÃÕŒœ–—“”‘’÷◊ÿŸĞğİıŞş‡·‚„‰ÂÊÁËÈÍÎÏÌÓÔÒÚÛÙˆ˜¯˘˙˚¸˝˛ˇ"};Js.MACSTRING=function(n,e,t,i){const s=io[i];if(s===void 0)return;let r="";for(let a=0;a=128&&(r=t[r],r===void 0))return;i[s]=r}return i};Ke.MACSTRING=function(n,e){const t=be.MACSTRING(n,e);return t!==void 0?t.length:0};function bc(n){return n>=-128&&n<=127}function Av(n,e,t){let i=0;const s=n.length;for(;e>8&255,o+256&255)}return r}be.VARDELTAS=function(n){let e=0;const t=[];for(;e=-128&&i<=127?e=Ev(n,e,t):e=Tv(n,e,t)}return t};be.INDEX=function(n){let e=1;const t=[e],i=[];for(let o=0;o>8,e[a+1]=o&255;for(let l=0;l0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parsePointer32=function(n){const e=this.parseOffset32();if(e>0)return new q(this.data,this.offset+e).parseStruct(n)};q.prototype.parseListOfLists=function(n){const e=this.parseOffset16List(),t=e.length,i=this.relativeOffset,s=new Array(t);for(let r=0;r>4)+1;for(let a=0;a>s,c=o&(1<[]),s=e&$t.LONG_WORDS,r=e&$t.WORD_DELTA_COUNT_MASK;if(r>t)throw Error("wordCount must be less than or equal to regionIndexCount");const a=(s?this.parseLong:this.parseShort).bind(this),o=(s?this.parseShort:this.parseChar).bind(this);for(let l=0;l{let y,M;const S=()=>{let E=0;if(t==="gvar"){if(E=g.privatePoints.length||d.length,!E){const v=i.get(s);v.path,E=v.points.length,E+=4}}else t==="cvar"&&(E=i.length);this.offset=m,this.relativeOffset=_,y=this.parsePackedDeltas(E),t==="gvar"&&(M=this.parsePackedDeltas(E))};return{configurable:!0,get:function(){return y===void 0&&S(),A==="deltasY"?M:y},set:function(E){y===void 0&&S(),A==="deltasY"?M=E:y=E}}};Object.defineProperty(g,"deltas",b.call(this,"deltas")),t==="gvar"&&Object.defineProperty(g,"deltasY",b.call(this,"deltasY")),h+=g.variationDataSize,delete g.variationDataSize}this.relativeOffset=r;const f={headers:u};return f.sharedPoints=d,f};q.prototype.parseTupleVariationHeader=function(n,e){const t=this.parseUShort(),i=this.parseUShort(),s=!!(i&$t.EMBEDDED_PEAK_TUPLE),r=!!(i&$t.INTERMEDIATE_REGION),a=!!(i&$t.PRIVATE_POINT_NUMBERS),o=s?void 0:i&$t.TUPLE_INDEX_MASK,l=s?this.parseTupleRecords(1,n)[0]:void 0,c=r?this.parseTupleRecords(1,n)[0]:void 0,u=r?this.parseTupleRecords(1,n)[0]:void 0,d={variationDataSize:t,peakTuple:l,intermediateStartTuple:c,intermediateEndTuple:u,flags:{embeddedPeakTuple:s,intermediateRegion:r,privatePointNumbers:a}};return e==="gvar"&&(d.sharedTupleRecordsIndex=o),d};q.prototype.parsePackedPointNumbers=function(){const n=this.parseByte(),e=[];let t=n;if(n>=128){const s=this.parseByte();t=(n&$t.POINT_RUN_COUNT_MASK)<<8|s}let i=0;for(;e.length>1,e.skip("uShort",3),n.glyphIndexMap={};const a=new Te.Parser(t,i+s+14),o=new Te.Parser(t,i+s+16+r*2),l=new Te.Parser(t,i+s+16+r*4),c=new Te.Parser(t,i+s+16+r*6);let u=i+s+16+r*8;for(let d=0;d=0;d-=1)if(a=Te.getUShort(n,e+4+d*8),o=Te.getUShort(n,e+4+d*8+2),a===3&&c.includes(o)||a===0&&l.includes(o)||a===1&&o===0){if(r>0)continue;if(r=Te.getULong(n,e+4+d*8+4),i)break}else if(a===0&&o===5){if(s=Te.getULong(n,e+4+d*8+4),i=new Te.Parser(n,e+s),i.parseUShort()!==14)s=-1,i=null;else if(r>0)break}if(r===-1)throw new Error("No valid cmap sub-tables found.");const u=new Te.Parser(n,e+r);if(t.format=u.parseUShort(),t.format===0)Vv(t,u,a,o);else if(t.format===12||t.format===13)Gv(t,u,t.format);else if(t.format===4)Wv(t,u,n,e,r);else throw new Error("Only format 0 (platformId 1, encodingId 0), 4, 12 and 14 cmap tables are supported (found format "+t.format+", platformId "+a+", encodingId "+o+").");return i&&Xv(t,i),t}function Kv(n,e,t){n.segments.push({end:e,start:e,delta:-(e-t),offset:0,glyphIndex:t})}function qv(n){n.segments.push({end:65535,start:65535,delta:1,offset:0})}function Zv(n){if(n.length===0)return n;const e=[n[0]];for(let t=1;t0;t-=1)if(n.get(t).unicode>65535){e=!1;break}let i=[{name:"version",type:"USHORT",value:0},{name:"numTables",type:"USHORT",value:e?1:2},{name:"platformID",type:"USHORT",value:3},{name:"encodingID",type:"USHORT",value:1},{name:"offset",type:"ULONG",value:e?12:20}];e||i.push({name:"cmap12PlatformID",type:"USHORT",value:3},{name:"cmap12EncodingID",type:"USHORT",value:10},{name:"cmap12Offset",type:"ULONG",value:0}),i.push({name:"format",type:"USHORT",value:4},{name:"cmap4Length",type:"USHORT",value:0},{name:"language",type:"USHORT",value:0},{name:"segCountX2",type:"USHORT",value:0},{name:"searchRange",type:"USHORT",value:0},{name:"entrySelector",type:"USHORT",value:0},{name:"rangeShift",type:"USHORT",value:0});const s=new me.Table("cmap",i);for(s.segments=[],t=0;t1&&ke.argument(e,"Can't infer numPaletteEntries on multiple colorRecordIndices"),new me.Table("CPAL",[{name:"version",type:"USHORT",value:n},{name:"numPaletteEntries",type:"USHORT",value:e||t.length},{name:"numPalettes",type:"USHORT",value:i.length},{name:"numColorRecords",type:"USHORT",value:t.length},{name:"colorRecordsArrayOffset",type:"ULONG",value:12+2*i.length},...i.map((s,r)=>({name:"colorRecordIndices_"+r,type:"USHORT",value:s})),...t.map((s,r)=>({name:"colorRecords_"+r,type:"ULONG",value:s}))])}function Qf(n){var e=(n&4278190080)>>24,t=(n&16711680)>>16,i=(n&65280)>>8,s=n&255;return e=e+256&255,t=t+256&255,i=i+256&255,s=(s+256&255)/255,{b:e,g:t,r:i,a:s}}function tu(n,e,t=0,i="hexa"){if(e==65535)return"currentColor";const s=n&&n.tables&&n.tables.cpal;if(!s)return"currentColor";if(t>s.colorRecordIndices.length-1)throw new Error(`Palette index out of range (colorRecordIndices.length: ${s.colorRecordIndices.length}, index: ${e})`);if(e>s.numPaletteEntries)throw new Error(`Color index out of range (numPaletteEntries: ${s.numPaletteEntries}, index: ${e})`);const r=s.colorRecordIndices[t]+e;if(r>s.colorRecords)throw new Error(`Color index out of range (colorRecords.length: ${s.colorRecords.length}, lookupIndex: ${r})`);const a=Qf(s.colorRecords[r]);return i==="bgra"?a:er(a,i)}function Ln(n){return("0"+parseInt(n).toString(16)).slice(-2)}function oS(n){const e=n.r/255,t=n.g/255,i=n.b/255,s=Math.max(e,t,i),r=Math.min(e,t,i);let a,o,l=(s+r)/2;if(s===r)a=o=0;else{const c=s-r;switch(o=l>.5?c/(2-s-r):c/(s+r),s){case e:a=(t-i)/c+(ttypeof o<"u");n={r:Math.round(parseFloat(a[1])/(a[2]?100/255:1)),g:Math.round(parseFloat(a[3])/(a[4]?100/255:1)),b:Math.round(parseFloat(a[5])/(a[6]?100/255:1)),a:a[7]?parseFloat(a[7])/(a[8]?100:1):1}}else{const a=/hsla?\(\s*(?:(\d*\.\d+|\d+)(deg|turn|))\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:,|\s*)\s*(?:(\d*\.\d+)%?|(\d+)%?)\s*(?:(?:,|\s|\/)\s*(?:(0*(?:\.\d+)?()|0*1(?:\.0+)?())|(?:\.\d+)|(\d+)(%)|(\d*\.\d+)(%)))?\s*\)/;if(a.test(n)){const o=n.match(a).filter(l=>typeof l<"u");n=lS({h:parseFloat(o[1])*(o[2]==="turn"?360:1),s:parseFloat(o[3]),l:parseFloat(o[4]),a:o[5]?parseFloat(o[5])/(o[6]?100:1):1})}else s=!1}}if(!s)throw new Error(`Invalid color format: ${n}`);return er(n,e)}function er(n,e="hexa"){if(n==="currentColor")return n;if(Number.isInteger(n)){if(e=="raw"||e=="cpal")return n;n=Qf(n)}else typeof n!="object"&&(n=fo(n,"bgra"));let t=["hsl","hsla"].includes(e)?oS(n):null;switch(e){case"rgba":return`rgba(${n.r}, ${n.g}, ${n.b}, ${parseFloat(n.a.toFixed(3))})`;case"rgb":return`rgb(${n.r}, ${n.g}, ${n.b})`;case"hex":case"hex6":case"hex-6":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}`;case"hexa":case"hex8":case"hex-8":return`#${Ln(n.r)}${Ln(n.g)}${Ln(n.b)}${Ln(n.a*255)}`;case"hsl":return`hsl(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%)`;case"hsla":return`hsla(${t.h.toFixed(2)}, ${t.s.toFixed(2)}%, ${t.l.toFixed(2)}%, ${parseFloat(n.a.toFixed(3))})`;case"bgra":return n;case"raw":case"cpal":return ep(n);default:throw new Error("Unknown color format: "+e)}}var tp={parse:rS,make:aS,getPaletteColor:tu,parseColor:fo,formatColor:er};function cS(n,e){let t=e||new $s;return{configurable:!0,get:function(){return typeof t=="function"&&(t=t()),t},set:function(i){t=i}}}function jt(n){this.bindConstructorValues(n)}jt.prototype.bindConstructorValues=function(n){if(this.index=n.index||0,n.name===".notdef"?n.unicode=void 0:n.name===".null"&&(n.unicode=0),n.unicode===0&&n.name!==".null")throw new Error('The unicode value "0" is reserved for the glyph name ".null" and cannot be used by any other glyph.');this.name=n.name||null,this.unicode=n.unicode,this.unicodes=n.unicodes||(n.unicode!==void 0?[n.unicode]:[]),"xMin"in n&&(this.xMin=n.xMin),"yMin"in n&&(this.yMin=n.yMin),"xMax"in n&&(this.xMax=n.xMax),"yMax"in n&&(this.yMax=n.yMax),"advanceWidth"in n&&(this.advanceWidth=n.advanceWidth),"leftSideBearing"in n&&(this.leftSideBearing=n.leftSideBearing),"points"in n&&(this.points=n.points),Object.defineProperty(this,"path",cS(this,n.path))};jt.prototype.addUnicode=function(n){this.unicodes.length===0&&(this.unicode=n),this.unicodes.push(n)};jt.prototype.getBoundingBox=function(){return this.path.getBoundingBox()};jt.prototype.getPath=function(n,e,t,i,s){n=n!==void 0?n:0,e=e!==void 0?e:0,t=t!==void 0?t:72,i=Object.assign({},s&&s.defaultRenderOptions,i);let r,a,o=i.xScale,l=i.yScale;const c=1/(this.path.unitsPerEm||1e3)*t;let u=this;s&&s.variation&&(u=s.variation.getTransform(this,i.variation),r=u.path.commands),i.hinting&&s&&s.hinting&&(a=u.path&&s.hinting.exec(u,t,i)),a?(r=s.hinting.getCommands(a),n=Math.round(n),e=Math.round(e),o=l=1):(r=u.path.commands,o===void 0&&(o=c),l===void 0&&(l=c));const d=new $s;if(i.drawSVG){const h=this.getSvgImage(s);if(h){const f=new $s;return f._image={image:h.image,x:n+h.leftSideBearing*c,y:e-h.baseline*c,width:h.image.width*c,height:h.image.height*c},d._layers=[f],d}}if(i.drawLayers){const h=this.getLayers(s);if(h&&h.length){d._layers=[];for(let f=0;f"u"&&n.path,n[t]},set:function(i){n[t]=i},enumerable:!0,configurable:!0})}function bo(n,e){if(this.font=n,this.glyphs={},Array.isArray(e))for(let t=0;t=this.length-1;return{value:this.get(n),done:e}}).bind(this)}});bo.prototype.get=function(n){if(this.font._push&&this.glyphs[n]===void 0){this.font._push(n),typeof this.glyphs[n]=="function"&&(this.glyphs[n]=this.glyphs[n]());let e=this.glyphs[n],t=this.font._IndexToUnicodeMap[n];if(t)for(let i=0;i1?Te.getULong(n,e):Te.getCard16(n,e),o=i>1?4:2;let l,c;if(a!==0){const u=Te.getByte(n,e+o);l=e+(a+1)*u+o;let d=e+o+1;for(let h=0;h1?Te.getULong(n,e):Te.getCard16(n,e),r=t>1?4:2;let a,o;if(s!==0){const l=Te.getByte(n,e+r);a=e+(s+1)*l+r;let c=e+r+1;for(let u=0;u1?Te.getULong(t,i):Te.getCard16(t,i),o=r>1?4:2;let l=0;if(a!==0){const u=Te.getByte(t,i+o);l=i+(a+1)*u+o}return Te.getBytes(t,l+e[n],l+e[n+1])}function mS(n){let e="";const i=["0","1","2","3","4","5","6","7","8","9",".","E","E-",null,"-"];for(;;){const s=n.parseByte(),r=s>>4,a=s&15;if(r===15||(e+=i[r],a===15))break;e+=i[a]}return parseFloat(e)}function gS(n,e){let t,i,s,r;if(e===28)return t=n.parseByte(),i=n.parseByte(),t<<8|i;if(e===29)return t=n.parseByte(),i=n.parseByte(),s=n.parseByte(),r=n.parseByte(),t<<24|i<<16|s<<8|r;if(e===30)return mS(n);if(e>=32&&e<=246)return e-139;if(e>=247&&e<=250)return t=n.parseByte(),(e-247)*256+t+108;if(e>=251&&e<=254)return t=n.parseByte(),-(e-251)*256-t-108;throw new Error("Invalid b0 "+e)}function _S(n){const e={};for(let t=0;t1&&l===23){CS(a);continue}r.push([l,a]),a=[]}else a.push(gS(s,l))}return _S(r)}function Tr(n,e){return e<=390?e=Ga[e]:n?e=n[e-391]:e=void 0,e}function iu(n,e,t){const i={};let s;for(let r=0;r2)throw new Error(`Unsupported CFF table version ${t.formatMajor}.${t.formatMinor}`);return t.size=Te.getCard8(n,e+2),t.formatMajor<2?(t.offsetSize=Te.getCard8(n,e+3),t.startOffset=e,t.endOffset=e+4):(t.topDictLength=Te.getCard16(n,e+3),t.endOffset=e+8),t}var ip=[{name:"version",op:0,type:"SID"},{name:"notice",op:1,type:"SID"},{name:"copyright",op:1200,type:"SID"},{name:"fullName",op:2,type:"SID"},{name:"familyName",op:3,type:"SID"},{name:"weight",op:4,type:"SID"},{name:"isFixedPitch",op:1201,type:"number",value:0},{name:"italicAngle",op:1202,type:"number",value:0},{name:"underlinePosition",op:1203,type:"number",value:-100},{name:"underlineThickness",op:1204,type:"number",value:50},{name:"paintType",op:1205,type:"number",value:0},{name:"charstringType",op:1206,type:"number",value:2},{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"uniqueId",op:13,type:"number"},{name:"fontBBox",op:5,type:["number","number","number","number"],value:[0,0,0,0]},{name:"strokeWidth",op:1208,type:"number",value:0},{name:"xuid",op:14,type:[],value:null},{name:"charset",op:15,type:"offset",value:0},{name:"encoding",op:16,type:"offset",value:0},{name:"charStrings",op:17,type:"offset",value:0},{name:"private",op:18,type:["number","offset"],value:[0,0]},{name:"ros",op:1230,type:["SID","SID","number"]},{name:"cidFontVersion",op:1231,type:"number",value:0},{name:"cidFontRevision",op:1232,type:"number",value:0},{name:"cidFontType",op:1233,type:"number",value:0},{name:"cidCount",op:1234,type:"number",value:8720},{name:"uidBase",op:1235,type:"number"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"fontName",op:1238,type:"SID"}],yS=[{name:"fontMatrix",op:1207,type:["real","real","real","real","real","real"],value:[.001,0,0,.001,0,0]},{name:"charStrings",op:17,type:"offset"},{name:"fdArray",op:1236,type:"offset"},{name:"fdSelect",op:1237,type:"offset"},{name:"vstore",op:24,type:"offset"}],sp=[{name:"subrs",op:19,type:"offset",value:0},{name:"defaultWidthX",op:20,type:"number",value:0},{name:"nominalWidthX",op:21,type:"number",value:0}],vS=[{name:"blueValues",op:6,type:"delta"},{name:"otherBlues",op:7,type:"delta"},{name:"familyBlues",op:7,type:"delta"},{name:"familyBlues",op:8,type:"delta"},{name:"familyOtherBlues",op:9,type:"delta"},{name:"blueScale",op:1209,type:"number",value:.039625},{name:"blueShift",op:1210,type:"number",value:7},{name:"blueFuzz",op:1211,type:"number",value:1},{name:"stdHW",op:10,type:"number"},{name:"stdVW",op:11,type:"number"},{name:"stemSnapH",op:1212,type:"number"},{name:"stemSnapV",op:1213,type:"number"},{name:"languageGroup",op:1217,type:"number",value:0},{name:"expansionFactor",op:1218,type:"number",value:.06},{name:"vsindex",op:22,type:"number",value:0},{name:"subrs",op:19,type:"offset"}],SS=[{name:"private",op:18,type:["number","offset"],value:[0,0]}];function bS(n,e,t,i){const s=nu(n,e,n.byteLength,i);return iu(s,i>1?yS:ip,t)}function su(n,e,t,i,s){const r=nu(n,e,t,s);return iu(r,s>1?vS:sp,i)}function MS(n,e,t){const i=nu(n,e,void 0,t);return iu(i,SS)}function AS(n,e,t){const i=[];for(let s=0;se;)n.pop()}function rp(n,e){const t=n.tables.cff&&n.tables.cff.topDict&&n.tables.cff.topDict.paintType||0;return t===2&&(e.fill=null,e.stroke="black",e.strokeWidth=n.tables.cff.topDict.strokeWidth||0),t}function Tc(n,e,t,i,s){let r,a,o,l;const c=new $s,u=[];let d=0,h=!1,f=!1,p=0,g=0,m,_,b,A,y=0,M=[],S,E=0;const v=n.tables.cff2||n.tables.cff;if(b=v.topDict._defaultWidthX,A=v.topDict._nominalWidthX,s=s||n.variation&&n.variation.get(),e.getBlendPath||(e.getBlendPath=function(O){return Tc(n,e,t,i,O)}),n.isCIDFont||i>1){const O=v.topDict._fdSelect?v.topDict._fdSelect[e.index]:0,P=v.topDict._fdArray[O];m=P._subrs,_=P._subrsBias,i>1?(M=v.topDict._vstore.itemVariationStore,y=P._privateDict.vsindex):(b=P._defaultWidthX,A=P._nominalWidthX)}else m=v.topDict._subrs,_=v.topDict._subrsBias;const T=rp(n,c);let I=b;function L(O,P){f&&T!==2&&c.closePath(),c.moveTo(O,P),f=!0}function w(){let O;O=(u.length&1)!==0,O&&!h&&(I=u.shift()+A),d+=u.length>>1,u.length=0,h=!0}function U(O){let P,Z,N,W,D,re,ie,oe,_e,de,le,z,ne=0;for(;ne1&&!h&&(I=u.shift()+A,h=!0),g+=u.pop(),L(p,g);break;case 5:for(;u.length>0;)p+=u.shift(),g+=u.shift(),c.lineTo(p,g);break;case 6:for(;u.length>0&&(p+=u.shift(),c.lineTo(p,g),u.length!==0);)g+=u.shift(),c.lineTo(p,g);break;case 7:for(;u.length>0&&(g+=u.shift(),c.lineTo(p,g),u.length!==0);)p+=u.shift(),c.lineTo(p,g);break;case 8:for(;u.length>0;)r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 10:if(D=u.pop()+_,re=m[D],re){if(E>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callsubr");break}E++,U(re),E--}break;case 11:if(i>1){console.error("CFF CharString operator return (11) is not supported in CFF2");break}return;case 12:switch(Ue=O[ne],ne+=1,Ue){case 35:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),g=z+u.shift(),u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 34:r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=g,p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 36:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l,_e=ie+u.shift(),de=l,le=_e+u.shift(),z=de+u.shift(),p=le+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;case 37:r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),ie=o+u.shift(),oe=l+u.shift(),_e=ie+u.shift(),de=oe+u.shift(),le=_e+u.shift(),z=de+u.shift(),Math.abs(le-p)>Math.abs(z-g)?p=le+u.shift():g=z+u.shift(),c.curveTo(r,a,o,l,ie,oe),c.curveTo(_e,de,le,z,p,g);break;default:console.log("Glyph "+e.index+": unknown operator 1200"+Ue),u.length=0}break;case 14:if(i>1){console.error("CFF CharString operator endchar (14) is not supported in CFF2");break}if(u.length>=4){const Oe=Ec[u.pop()],Xe=Ec[u.pop()],tt=u.pop(),rt=u.pop();if(Oe&&Xe){e.isComposite=!0,e.components=[];const mt=n.cffEncoding.charset.indexOf(Oe),yt=n.cffEncoding.charset.indexOf(Xe);e.components.push({glyphIndex:yt,dx:0,dy:0}),e.components.push({glyphIndex:mt,dx:rt,dy:tt}),c.extend(n.glyphs.get(yt).path);const ct=n.glyphs.get(mt),ut=JSON.parse(JSON.stringify(ct.path.commands));for(let V=0;V0&&!h&&(I=u.shift()+A,h=!0);f&&T!==2&&(c.closePath(),f=!1);break;case 15:if(i<2){console.error("CFF2 CharString operator vsindex (15) is not supported in CFF");break}y=u.pop();break;case 16:if(i<2){console.error("CFF2 CharString operator blend (16) is not supported in CFF");break}S||(S=n.variation&&s&&n.variation.process.getBlendVector(M,y,s));var J=u.pop(),xe=S?S.length:M.itemVariationSubtables[y].regionIndexes.length,Ae=J*xe,Se=u.length-Ae,Be=Se-J;if(S)for(let Oe=0;Oe>3;break;case 21:u.length>2&&!h&&(I=u.shift()+A,h=!0),g+=u.pop(),p+=u.pop(),L(p,g);break;case 22:u.length>1&&!h&&(I=u.shift()+A,h=!0),p+=u.pop(),L(p,g);break;case 23:w();break;case 24:for(;u.length>2;)r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);p+=u.shift(),g+=u.shift(),c.lineTo(p,g);break;case 25:for(;u.length>6;)p+=u.shift(),g+=u.shift(),c.lineTo(p,g);r=p+u.shift(),a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 26:for(u.length&1&&(p+=u.shift());u.length>0;)r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o,g=l+u.shift(),c.curveTo(r,a,o,l,p,g);break;case 27:for(u.length&1&&(g+=u.shift());u.length>0;)r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l,c.curveTo(r,a,o,l,p,g);break;case 28:P=O[ne],Z=O[ne+1],u.push((P<<24|Z<<16)>>16),ne+=2;break;case 29:if(D=u.pop()+n.gsubrsBias,re=n.gsubrs[D],re){if(E>=Bh){console.warn("CFF charstring subroutine call depth exceeded, skipping callgsubr");break}E++,U(re),E--}break;case 30:for(;u.length>0&&(r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g),u.length!==0);)r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),g=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g);break;case 31:for(;u.length>0&&(r=p+u.shift(),a=g,o=r+u.shift(),l=a+u.shift(),g=l+u.shift(),p=o+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g),u.length!==0);)r=p,a=g+u.shift(),o=r+u.shift(),l=a+u.shift(),p=o+u.shift(),g=l+(u.length===1?u.shift():0),c.curveTo(r,a,o,l,p,g);break;default:Ue<32?console.log("Glyph "+e.index+": unknown operator "+Ue):Ue<247?u.push(Ue-139):Ue<251?(P=O[ne],ne+=1,u.push((Ue-247)*256+P+108)):Ue<255?(P=O[ne],ne+=1,u.push(-(Ue-251)*256-P-108)):(P=O[ne],Z=O[ne+1],N=O[ne+2],W=O[ne+3],ne+=4,u.push((P<<24|Z<<16|N<<8|W)/65536))}}}return U(t),n.variation&&s&&(c.commands=c.commands.map(O=>{const P=Object.keys(O);for(let Z=0;Z=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");r.push(a)}else if(l===3||s>1&&l===4){const c=l===4?o.parseULong():o.parseCard16();let u=l===4?o.parseULong():o.parseCard16();if(u!==0)throw new Error(`CFF Table CID Font FDSelect format ${l} range has bad initial GID ${u}`);let d;for(let h=0;h=i)throw new Error("CFF table CID Font FDSelect has bad FD index value "+a+" (FD count "+i+")");if(d>t)throw new Error(`CFF Table CID Font FDSelect format ${s} range has bad GID ${d}`);for(;u1?null:Xn(n,r.endOffset,Te.bytesToString),o=r.formatMajor>1?null:Xn(n,a.endOffset),l=r.formatMajor>1?null:Xn(n,o.endOffset,Te.bytesToString),c=Xn(n,r.formatMajor>1?e+r.size+r.topDictLength:l.endOffset,void 0,r.formatMajor);t.gsubrs=c.objects,t.gsubrsBias=po(t.gsubrs);let u;if(r.formatMajor>1){const h=e+r.size,f=Te.getBytes(n,h,h+r.topDictLength);u=dl(n,0,[f],void 0,r.formatMajor)[0]}else{const h=dl(n,e,o.objects,l.objects,r.formatMajor);if(h.length!==1)throw new Error("CFF table has too many fonts in 'FontSet' - count of fonts NameIndex.length = "+h.length);u=h[0]}if(s.topDict=u,u._privateDict&&(t.defaultWidthX=u._privateDict.defaultWidthX,t.nominalWidthX=u._privateDict.nominalWidthX),r.formatMajor<2&&u.ros[0]!==void 0&&u.ros[1]!==void 0&&(t.isCIDFont=!0),r.formatMajor>1){let h=u.fdArray,f=u.fdSelect;if(!h)throw new Error("This is a CFF2 font, but FDArray information is missing");const p=Xn(n,e+h,null,r.formatMajor),g=AS(n,e,p.objects);u._fdArray=g,f&&(u._fdSelect=Hh(n,e+f,t.numGlyphs,g.length,r.formatMajor))}else if(t.isCIDFont){let h=u.fdArray,f=u.fdSelect;if(h===0||f===0)throw new Error("Font is marked as a CID font, but FDArray and/or FDSelect information is missing");h+=e;const p=Xn(n,h),g=dl(n,e,p.objects,l.objects,r.formatMajor);u._fdArray=g,f+=e,u._fdSelect=Hh(n,f,t.numGlyphs,g.length,r.formatMajor)}if(r.formatMajor<2){const h=e+u.private[1],f=su(n,h,u.private[0],l.objects,r.formatMajor);if(t.defaultWidthX=f.defaultWidthX,t.nominalWidthX=f.nominalWidthX,f.subrs!==0){const p=h+f.subrs,g=Xn(n,p);t.subrs=g.objects,t.subrsBias=po(t.subrs)}else t.subrs=[],t.subrsBias=0}let d;if(i.lowMemory?(d=fS(n,e+u.charStrings,r.formatMajor),t.nGlyphs=d.offsets.length-(r.formatMajor>1?1:0)):(d=Xn(n,e+u.charStrings,null,r.formatMajor),t.nGlyphs=d.objects.length),r.formatMajor>1&&t.tables.maxp&&t.nGlyphs!==t.tables.maxp.numGlyphs&&console.error(`Glyph count in the CFF2 table (${t.nGlyphs}) must correspond to the glyph count in the maxp table (${t.tables.maxp.numGlyphs})`),r.formatMajor<2){let h=[],f=[];u.charset===0?h=Jv:u.charset===1?h=jv:u.charset===2?h=Qv:h=ES(n,e+u.charset,t.nGlyphs,l.objects,t.isCIDFont),u.encoding===0?f=Ec:u.encoding===1?f=eS:f=TS(n,e+u.encoding),t.cffEncoding=new jf(f,h),t.encoding=t.encoding||t.cffEncoding}if(t.glyphs=new Qn.GlyphSet(t),i.lowMemory)t._push=function(h){const f=pS(h,d.offsets,n,e+u.charStrings,void 0,r.formatMajor);t.glyphs.push(h,Qn.cffGlyphLoader(t,h,Tc,f,r.formatMajor))};else for(let h=0;h=0&&(t=i),i=e.indexOf(n),i>=0?t=i+Ga.length:(t=Ga.length+e.length,e.push(n)),t}function RS(){return new me.Record("Header",[{name:"major",type:"Card8",value:1},{name:"minor",type:"Card8",value:0},{name:"hdrSize",type:"Card8",value:4},{name:"major",type:"Card8",value:1}])}function DS(n){const e=new me.Record("Name INDEX",[{name:"names",type:"INDEX",value:[]}]);e.names=[];for(let t=0;t=t.begin&&n=1&&(t.ulCodePageRange1=i.parseULong(),t.ulCodePageRange2=i.parseULong()),t.version>=2&&(t.sxHeight=i.parseShort(),t.sCapHeight=i.parseShort(),t.usDefaultChar=i.parseUShort(),t.usBreakChar=i.parseUShort(),t.usMaxContent=i.parseUShort()),t}function jS(n){return new me.Table("OS/2",[{name:"version",type:"USHORT",value:3},{name:"xAvgCharWidth",type:"SHORT",value:0},{name:"usWeightClass",type:"USHORT",value:0},{name:"usWidthClass",type:"USHORT",value:0},{name:"fsType",type:"USHORT",value:0},{name:"ySubscriptXSize",type:"SHORT",value:650},{name:"ySubscriptYSize",type:"SHORT",value:699},{name:"ySubscriptXOffset",type:"SHORT",value:0},{name:"ySubscriptYOffset",type:"SHORT",value:140},{name:"ySuperscriptXSize",type:"SHORT",value:650},{name:"ySuperscriptYSize",type:"SHORT",value:699},{name:"ySuperscriptXOffset",type:"SHORT",value:0},{name:"ySuperscriptYOffset",type:"SHORT",value:479},{name:"yStrikeoutSize",type:"SHORT",value:49},{name:"yStrikeoutPosition",type:"SHORT",value:258},{name:"sFamilyClass",type:"SHORT",value:0},{name:"bFamilyType",type:"BYTE",value:0},{name:"bSerifStyle",type:"BYTE",value:0},{name:"bWeight",type:"BYTE",value:0},{name:"bProportion",type:"BYTE",value:0},{name:"bContrast",type:"BYTE",value:0},{name:"bStrokeVariation",type:"BYTE",value:0},{name:"bArmStyle",type:"BYTE",value:0},{name:"bLetterform",type:"BYTE",value:0},{name:"bMidline",type:"BYTE",value:0},{name:"bXHeight",type:"BYTE",value:0},{name:"ulUnicodeRange1",type:"ULONG",value:0},{name:"ulUnicodeRange2",type:"ULONG",value:0},{name:"ulUnicodeRange3",type:"ULONG",value:0},{name:"ulUnicodeRange4",type:"ULONG",value:0},{name:"achVendID",type:"CHARARRAY",value:"XXXX"},{name:"fsSelection",type:"USHORT",value:0},{name:"usFirstCharIndex",type:"USHORT",value:0},{name:"usLastCharIndex",type:"USHORT",value:0},{name:"sTypoAscender",type:"SHORT",value:0},{name:"sTypoDescender",type:"SHORT",value:0},{name:"sTypoLineGap",type:"SHORT",value:0},{name:"usWinAscent",type:"USHORT",value:0},{name:"usWinDescent",type:"USHORT",value:0},{name:"ulCodePageRange1",type:"ULONG",value:0},{name:"ulCodePageRange2",type:"ULONG",value:0},{name:"sxHeight",type:"SHORT",value:0},{name:"sCapHeight",type:"SHORT",value:0},{name:"usDefaultChar",type:"USHORT",value:0},{name:"usBreakChar",type:"USHORT",value:0},{name:"usMaxContext",type:"USHORT",value:0}],n)}var Rc={parse:JS,make:jS,unicodeRanges:wc,getUnicodeRange:$S};function QS(n,e){const t={},i=new Te.Parser(n,e);switch(t.version=i.parseVersion(),t.italicAngle=i.parseFixed(),t.underlinePosition=i.parseShort(),t.underlineThickness=i.parseShort(),t.isFixedPitch=i.parseULong(),t.minMemType42=i.parseULong(),t.maxMemType42=i.parseULong(),t.minMemType1=i.parseULong(),t.maxMemType1=i.parseULong(),t.version){case 1:t.names=ji.slice();break;case 2:t.numberOfGlyphs=i.parseUShort(),t.glyphNameIndex=new Array(t.numberOfGlyphs);for(let s=0;s=ji.length){const r=i.parseChar();t.names.push(i.parseString(r))}break;case 2.5:t.numberOfGlyphs=i.parseUShort(),t.offset=new Array(t.numberOfGlyphs);for(let s=0;s[{name:"glyphID_"+a,type:"USHORT",value:r.glyphID},{name:"firstLayerIndex_"+a,type:"USHORT",value:r.firstLayerIndex},{name:"numLayers_"+a,type:"USHORT",value:r.numLayers}]).flat(),...t.map((r,a)=>[{name:"LayerGlyphID_"+a,type:"USHORT",value:r.glyphID},{name:"paletteIndex_"+a,type:"USHORT",value:r.paletteIndex}]).flat()])}var gp={parse:rb,make:ab};function ob(n,e){return[{name:"tag_"+n,type:"TAG",value:e.tag},{name:"minValue_"+n,type:"FIXED",value:e.minValue<<16},{name:"defaultValue_"+n,type:"FIXED",value:e.defaultValue<<16},{name:"maxValue_"+n,type:"FIXED",value:e.maxValue<<16},{name:"flags_"+n,type:"USHORT",value:0},{name:"nameID_"+n,type:"USHORT",value:e.axisNameID}]}function lb(n,e,t){const i={},s=new Te.Parser(n,e);i.tag=s.parseTag(),i.minValue=s.parseFixed(),i.defaultValue=s.parseFixed(),i.maxValue=s.parseFixed(),s.skip("uShort",1);const r=s.parseUShort();return i.axisNameID=r,i.name=ho(t,r),i}function cb(n,e,t,i={}){const s=[{name:"nameID_"+n,type:"USHORT",value:e.subfamilyNameID},{name:"flags_"+n,type:"USHORT",value:0}];for(let r=0;r1||r>0?i.parseUShort():void 0;t!==void 0&&ke.argument(l>=t.axes.length,"STAT axis count must be greater than or equal to fvar axis count"),u>0&&ke.argument(l>=0,"STAT axis count must be greater than 0 if STAT axis value count is greater than 0");const f=[];for(let m=0;mo.value.tag?1:-1}),e.fields=e.fields.concat(i),e.fields=e.fields.concat(s),e}function Xh(n,e,t){for(let i=0;i0)return n.glyphs.get(s).getMetrics()}return t}function Lb(n){let e=0;for(let t=0;tAe||l===void 0)&&Ae>0&&(l=Ae),c 123 are reserved for internal usage");if(xe.name===".notdef")continue;const Be=xe.getMetrics();e.push(Be.xMin),t.push(Be.yMin),i.push(Be.xMax),s.push(Be.yMax),a.push(Be.leftSideBearing),o.push(Be.rightSideBearing),r.push(xe.advanceWidth)}const p={xMin:Math.min.apply(null,e),yMin:Math.min.apply(null,t),xMax:Math.max.apply(null,i),yMax:Math.max.apply(null,s),advanceWidthMax:Math.max.apply(null,r),advanceWidthAvg:Lb(r),minLeftSideBearing:Math.min.apply(null,a),maxLeftSideBearing:Math.max.apply(null,a),minRightSideBearing:Math.min.apply(null,o)};p.ascender=n.ascender,p.descender=n.descender;let g=0;n.weightClass>=600&&(g|=n.macStyleValues.BOLD),n.italicAngle<0&&(g|=n.macStyleValues.ITALIC);const m=lp.make({flags:3,unitsPerEm:n.unitsPerEm,xMin:p.xMin,yMin:p.yMin,xMax:p.xMax,yMax:p.yMax,lowestRecPPEM:3,macStyle:g,createdTimestamp:n.createdTimestamp}),_=cp.make({ascender:p.ascender,descender:p.descender,advanceWidthMax:p.advanceWidthMax,minLeftSideBearing:p.minLeftSideBearing,minRightSideBearing:p.minRightSideBearing,xMaxExtent:p.maxLeftSideBearing+(p.xMax-p.xMin),numberOfHMetrics:n.glyphs.length}),b=dp.make(n.glyphs.length),A=Rc.make(Object.assign({xAvgCharWidth:Math.round(p.advanceWidthAvg),usFirstCharIndex:l,usLastCharIndex:c,ulUnicodeRange1:u,ulUnicodeRange2:d,ulUnicodeRange3:h,ulUnicodeRange4:f,sTypoAscender:p.ascender,sTypoDescender:p.descender,sTypoLineGap:0,usWinAscent:p.yMax,usWinDescent:Math.abs(p.yMin),ulCodePageRange1:1,sxHeight:Xh(n,"xyvw",{yMax:Math.round(p.ascender/2)}).yMax,sCapHeight:Xh(n,"HIKLEFJMNTZBDPRAGOQSUVWXY",p).yMax,usDefaultChar:n.hasChar(" ")?32:0,usBreakChar:n.hasChar(" ")?32:0},n.tables.os2)),y=up.make(n.glyphs),M=Zf.make(n.glyphs),S=n.getEnglishName("fontFamily"),E=n.getEnglishName("fontSubfamily"),v=S+" "+E;let T=n.getEnglishName("postScriptName");T||(T=S.replace(/\s/g,"")+"-"+E);const I={};for(let J in n.names)I[J]=n.names[J];I.unicode=I.unicode||{},I.macintosh=I.macintosh||{},I.windows=I.windows||{};const L=n.names.unicode||{},w=n.names.macintosh||{},U=n.names.windows||{};for(const J in I){if(I[J]=I[J]||{},!I[J].uniqueID){const xe=n.getEnglishName("manufacturer")||"";I[J].uniqueID={en:`${xe}: ${v}`}}I[J].postScriptName||(I[J].postScriptName={en:T})}I.unicode.preferredFamily||(I.unicode.preferredFamily=L.fontFamily||w.fontFamily||U.fontFamily),I.macintosh.preferredFamily||(I.macintosh.preferredFamily=w.fontFamily||L.fontFamily||U.fontFamily),I.windows.preferredFamily||(I.windows.preferredFamily=U.fontFamily||L.fontFamily||w.fontFamily),I.unicode.preferredSubfamily||(I.unicode.preferredSubfamily=L.fontSubfamily||w.fontSubfamily||U.fontSubfamily),I.macintosh.preferredSubfamily||(I.macintosh.preferredSubfamily=w.fontSubfamily||L.fontSubfamily||U.fontSubfamily),I.windows.preferredSubfamily||(I.windows.preferredSubfamily=U.fontSubfamily||L.fontSubfamily||w.fontSubfamily);const O=[],P=qf.make(I,O),Z=O.length>0?hp.make(O):void 0,N=fp.make(n),W=Cc.make(n.glyphs,{version:n.getEnglishName("version"),fullName:v,familyName:S,weightName:E,postScriptName:T,unitsPerEm:n.unitsPerEm,fontBBox:[0,p.yMin,p.ascender,p.advanceWidthMax],topDict:n.tables.cff&&n.tables.cff.topDict||{}}),D=n.metas&&Object.keys(n.metas).length>0?mp.make(n.metas):void 0,re=[m,_,b,A,P,M,N,W,y];Z&&re.push(Z);const ie={gsub:pp,cpal:tp,colr:gp,stat:xp,avar:yp,cvar:vp,fvar:_p,gvar:Sp,gasp:bp,svg:Mp},oe={avar:[n.tables.fvar],fvar:[n.names]};for(let J in ie){const xe=n.tables[J];if(xe){const Ae=ie[J].make.call(n,xe,...oe[J]||[]);Ae&&re.push(Ae)}}D&&re.push(D);const _e=Ap(re),de=_e.encode(),le=ru(de),z=_e.fields;let ne=!1;for(let J=0;J>>1,r=n[s].tag;if(r===e)return s;r>>1,r=n[s];if(r===e)return s;r>>1;t=n[r];const a=t.start;if(a===e)return t;a0)return t=n[i-1],e>t.end?0:t}function Ep(n,e){this.font=n,this.tableName=e}Ep.prototype={searchTag:fl,binSearch:Yh,getTable:function(n){let e=this.font.tables[this.tableName];return!e&&n&&(e=this.font.tables[this.tableName]=this.createDefaultTable()),e},getScriptNames:function(){let n=this.getTable();return n?n.scripts.map(function(e){return e.tag}):[]},getDefaultScriptName:function(){let n=this.getTable();if(!n)return;let e=!1;for(let t=0;t=0)return i[s].script;if(e){const r={tag:n,script:{defaultLangSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]},langSysRecords:[]}};return i.splice(-1-s,0,r),r.script}}},getLangSysTable:function(n,e,t){const i=this.getScriptTable(n,t);if(i){if(!e||e==="dflt"||e==="DFLT")return i.defaultLangSys;const s=fl(i.langSysRecords,e);if(s>=0)return i.langSysRecords[s].langSys;if(t){const r={tag:e,langSys:{reserved:0,reqFeatureIndex:65535,featureIndexes:[]}};return i.langSysRecords.splice(-1-s,0,r),r.langSys}}},getFeatureTable:function(n,e,t,i){const s=this.getLangSysTable(n,e,i);if(s){let r;const a=s.featureIndexes,o=this.font.tables[this.tableName].features;for(let l=0;l=o[l-1].tag,"Features must be added in alphabetical order."),r={tag:t,feature:{params:0,lookupListIndexes:[]}},o.push(r),a.push(l),r.feature}}},getLookupTables:function(n,e,t,i,s){const r=this.getFeatureTable(n,e,t,s),a=[];if(r){let o;const l=r.lookupListIndexes,c=this.font.tables[this.tableName].lookups;for(let u=0;u=0?t:-1}case 2:{const t=Kh(n.ranges,e);return t?t.index+e-t.start:-1}}},expandCoverage:function(n){if(n.format===1)return n.glyphs;{const e=[],t=n.ranges;for(let i=0;it)s=a-1;else{r=o;break}}return r}function kb(n,e,t){let i=0,s=n.length-1;for(;i<=s;){const r=Math.floor((i+s)/2),a=n[r];if(a[e]t)s=r-1;else return r}return-1}function Fb(n,e,t){let i=0,s=n.length;const r=(a,o)=>a[e]-o[e];for(;i>>1;r(n[a],t)<0?i=a+1:s=a}return n.splice(i,0,t),i}function Tp(n){return n[0]===31&&n[1]===139&&n[2]===8}function Bb(n){const e=new DataView(n.buffer,n.byteOffset,n.byteLength);let t=10;const i=n.byteLength-8,s=e.getInt8(3);if(s&4&&(t+=2+e.getUint16(t,!0)),s&8)for(;t=i)throw new Error("Can't find compressed blocks");const r=e.getUint32(e.byteLength-4,!0);return Ff(n.subarray(t,i),new Uint8Array(r))}function qh(n){return{x:n.x,y:n.y,onCurve:n.onCurve,lastPointOfContour:n.lastPointOfContour}}function Hb(n){return{glyphIndex:n.glyphIndex,xScale:n.xScale,scale01:n.scale01,scale10:n.scale10,yScale:n.yScale,dx:n.dx,dy:n.dy}}function mn(n){Mo.call(this,n,"gsub")}function au(n,e,t){const i=n.subtables;for(let s=0;s1,'Multiple: "by" must be an array of two or more ids');const s=this.getLookupTables(t,i,n,2,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},sequences:[]});ke.assert(r.coverage.format===1,"Multiple: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.sequences.splice(o,0,0)),r.sequences[o]=e.by};mn.prototype.addAlternate=function(n,e,t,i){const s=this.getLookupTables(t,i,n,3,!0)[0],r=au(s,1,{substFormat:1,coverage:{format:1,glyphs:[]},alternateSets:[]});ke.assert(r.coverage.format===1,"Alternate: unable to modify coverage table format "+r.coverage.format);const a=e.sub;let o=this.binSearch(r.coverage.glyphs,a);o<0&&(o=-1-o,r.coverage.glyphs.splice(o,0,a),r.alternateSets.splice(o,0,0)),r.alternateSets[o]=e.by};mn.prototype.addLigature=function(n,e,t,i){const s=this.getLookupTables(t,i,n,4,!0)[0];let r=s.subtables[0];r||(r={substFormat:1,coverage:{format:1,glyphs:[]},ligatureSets:[]},s.subtables[0]=r),ke.assert(r.coverage.format===1,"Ligature: unable to modify coverage table format "+r.coverage.format);const a=e.sub[0],o=e.sub.slice(1),l={ligGlyph:e.by,components:o};let c=this.binSearch(r.coverage.glyphs,a);if(c>=0){const u=r.ligatureSets[c];for(let d=0;dfo(e,"raw")):fo(n,"raw")}fillPalette(n,e=[],t=this.cpal().numPaletteEntries){return n=Number.isInteger(n)?this.get(n,"raw"):n,Object.assign(Array(t).fill(this.defaultValue),this.toCPALcolor(n).concat(this.toCPALcolor(e)))}extend(n){if(this.ensureCPAL(Array(n).fill(this.defaultValue)))return;const e=this.cpal(),t=e.numPaletteEntries+n,i=this.getAll().map(s=>this.fillPalette(s,[],t));e.numPaletteEntries=t,e.colorRecords=this.toCPALcolor(i.flat()),this.updateIndices()}get(n,e="hexa"){return this.getAll(e)[n]||null}getColor(n,e=0,t="hexa"){return tu(this.font,n,e,t)}setColor(n,e,t=0){n=parseInt(n),t=parseInt(t);let i=this.getAll("raw"),s=i[t];if(!s)throw Error(`paletteIndex ${t} out of range`);const r=this.cpal(),a=r.numPaletteEntries;Array.isArray(e)||(e=[e]),e.length+n>a&&(this.extend(e.length+n-a),i=this.getAll("raw"),s=i[t]);for(let o=0;ot?this.extend(n.length-t):n.lengtht.numPaletteEntries-1)throw Error(`Replacement index out of range: numPaletteEntries after deletion: ${t.numPaletteEntries-1}, replacementIndex: ${e})`);for(let o=0;od!==n);s.push(c)}const r=this.font.tables.colr;if(r){const o=r.layerRecords;for(let l=0;ln)o[l].paletteIndex-=1;else if(c===n){let u=0;for(let d=0;dn&&e<=n+i[d].length){u++;break}o[l].paletteIndex=e-u}}this.font.tables.colr={...r,layerRecords:o}}const a=s.flat();for(let o=0;oi.length?t=i.length:t<0&&(t=i.length+1+t%(i.length+1),t>=i.length+1&&(t-=i.length+1));const s=[];for(let r=0;r({glyphID:s.glyph.index,paletteIndex:r===e?t:s.paletteIndex})),this.updateColrTable(n,i)):console.error("Invalid layer index")}remove(n,e,t=e){let i=this.get(n);i=i.map(s=>({glyphID:s.glyph.index,paletteIndex:s.paletteIndex})),i.splice(e,t-e+1),this.updateColrTable(n,i)}updateColrTable(n,e){this.ensureCOLR();const i=this.font.tables.colr;let s=kb(i.baseGlyphRecords,"glyphID",n);if(s===-1){const u={glyphID:n,firstLayerIndex:i.layerRecords.length,numLayers:0};s=Fb(i.baseGlyphRecords,"glyphID",u)}const a=i.baseGlyphRecords[s],o=a.numLayers,l=e.length,c=l-o;if(c>0){const u=e.slice(o).map(d=>({glyphID:d.glyphID,paletteIndex:d.paletteIndex}));i.layerRecords.splice(a.firstLayerIndex+o,0,...u)}else c<0&&i.layerRecords.splice(a.firstLayerIndex+l,-c);for(let u=0;u{if(s.image=r,typeof this.font.onGlyphUpdated=="function")try{this.font.onGlyphUpdated(n)}catch(a){console.error("font.onGlyphUpdated",n,a)}}),i.images.set(n,s)),s}};function Wb(n){return{template:Yb(n).then(Zb),images:new Map}}function Xb(n,e,t){return{promise:e.then(i=>{let s;typeof i=="string"?s=i:(i[4]=t,s=i.join(""));const r=$b(s,n.unitsPerEm);return r.image.decode().then(()=>r)}),image:void 0}}var Yb=typeof DecompressionStream=="function"?qb:Kb;function Kb(n){try{return Promise.resolve(new TextDecoder().decode(Tp(n)?Bb(n):n))}catch(e){return Promise.reject(e)}}function qb(n){if(Tp(n))return new Response(new Response(n).body.pipeThrough(new DecompressionStream("gzip"))).text();try{return Promise.resolve(new TextDecoder().decode(n))}catch(e){return Promise.reject(e)}}function Zb(n){const e=n.indexOf("",e+4)+1;if(/ id=['"]glyph\d+['"]/.test(n.substring(e,t)))return n;const i=n.lastIndexOf("");return[n.substring(0,t),"",n.substring(t,i),'',n.substring(i)]}function $b(n,e){const i=new DOMParser().parseFromString(n,"image/svg+xml").documentElement,s=i.viewBox.baseVal,r=i.width.baseVal,a=i.height.baseVal;let o=1,l=1;s.width>0&&s.height>0&&(r.unitType===1?(o=r.valueInSpecifiedUnits/s.width,l=a.unitType===1?a.valueInSpecifiedUnits/s.height:o):a.unitType===1?(l=a.valueInSpecifiedUnits/s.height,o=l):e&&(o=e/s.width,l=e/s.height));const c=document.createElement("div");c.style.position="fixed",c.style.visibility="hidden",c.appendChild(i),document.body.appendChild(c);const u=i.getBBox();document.body.removeChild(c);const d=(u.x-s.x)*o,h=(s.y-u.y)*l,f=u.width*o,p=u.height*l;i.setAttribute("viewBox",[u.x,u.y,u.width,u.height].join(" ")),o!==1&&i.setAttribute("width",f),l!==1&&i.setAttribute("height",p);const g=new Image(f,p);return g.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i.outerHTML),{leftSideBearing:d,baseline:h,image:g}}var pl=new WeakMap;function Zh(n,e,t,i,s){let r;return(e&i)>0?(r=n.parseByte(),e&s||(r=-r),r=t+r):(e&s)>0?r=t:r=t+n.parseShort(),r}function wp(n,e,t){const i=new Te.Parser(e,t);n._numberOfContours=i.parseShort(),n._xMin=i.parseShort(),n._yMin=i.parseShort(),n._xMax=i.parseShort(),n._yMax=i.parseShort();let s,r;if(n._numberOfContours>0){const a=n.endPointIndices=[];for(let l=0;l0){const c=i.parseByte();for(let u=0;u0){const l=[];let c;if(o>0){for(let h=0;h=0,l.push(c);let u=0;for(let h=0;h0?(s&2)>0?(o.dx=i.parseShort(),o.dy=i.parseShort()):o.matchedPoints=[i.parseUShort(),i.parseUShort()]:(s&2)>0?(o.dx=i.parseChar(),o.dy=i.parseChar()):o.matchedPoints=[i.parseByte(),i.parseByte()],(s&8)>0?o.xScale=o.yScale=i.parseF2Dot14():(s&64)>0?(o.xScale=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()):(s&128)>0&&(o.xScale=i.parseF2Dot14(),o.scale01=i.parseF2Dot14(),o.scale10=i.parseF2Dot14(),o.yScale=i.parseF2Dot14()),n.components.push(o),a=!!(s&32)}if(s&256){n.instructionLength=i.parseUShort(),n.instructions=[];for(let o=0;oe.points.length-1||s.matchedPoints[1]>r.points.length-1)throw Error("Matched points out of range in "+e.name);const o=e.points[s.matchedPoints[0]];let l=r.points[s.matchedPoints[1]];const c={xScale:s.xScale,scale01:s.scale01,scale10:s.scale10,yScale:s.yScale,dx:0,dy:0};l=Wa([l],c)[0],c.dx=o.x-l.x,c.dy=o.y-l.y,a=Wa(r.points,c)}e.points=e.points.concat(a)}}}finally{t.delete(e.index)}}return ou(e.points)}function jb(n,e,t,i){const s=new Qn.GlyphSet(i);for(let r=0;r=1&&e[t]r)continue;let o=i,l=i;for(i++;i<=r;)t[i]&&(this.deltaInterpolate(l+1,i-1,l,i,e,n),l=i),i++;l===o?this.deltaShift(s,r,l,e,n):(this.deltaInterpolate(l+1,r,l,o,e,n),o>0&&this.deltaInterpolate(s,o-1,l,o,e,n)),i=r+1}}deltaInterpolate(n,e,t,i,s,r){if(n>e)return;let a=["x","y"];for(let l=0;ls[i][c]){var o=t;t=i,i=o}let u=s[t][c],d=s[i][c],h=r[t][c],f=r[i][c];if(u!==d||h===f){let p=u===d?0:(f-h)/(d-u);for(let g=n;g<=e;g++){let m=s[g][c];m<=u?m+=h-u:m>=d?m+=f-d:m=h+(m-u)*p,r[g][c]=m}}}}deltaShift(n,e,t,i,s){let r=s[t].x-i[t].x,a=s[t].y-i[t].y;if(!(r===0&&a===0))for(let o=n;o<=e;o++)o!==t&&(s[o].x+=r,s[o].y+=a)}transformComponents(n,e,t,i,s,r){let a=0;for(let o=0;o-1&&(u.dx+=Math.round(s.deltas[d]*r),u.dy+=Math.round(s.deltasY[d]*r));const h=Wa(this.getTransform(c,t).points,u);e.splice(a,h.length,...h),a+=c.points.length}}applyTupleVariationStore(n,e,t,i="gvar",s={}){t||(t=this.font.variation.get());const r=this.getNormalizedCoords(t),{headers:a,sharedPoints:o}=n,l=this.fvar().axes.length;let c;i==="gvar"?c=e.map(qh):i==="cvar"&&(c=[...e]);for(let u=0;ud.intermediateEndTuple[p]){h=0;break}else r[p]Math.max(0,g[p])){h=0;break}h=(h*r[p]+Number.EPSILON)/(g[p]+Number.EPSILON)}}}if(h===0)continue;const f=d.privatePoints.length?d.privatePoints:o;if(i==="gvar"&&s.glyph&&s.glyph.isComposite)this.transformComponents(s.glyph,c,t,f,d,h);else if(f.length===0)for(let p=0;p=o&&(l=o-1),{outerIndex:s,innerIndex:r}=a[t].map[l]}else s=0,r=n;return this.getDelta(a.itemVariationStore,s,r,i)}getDelta(n,e,t,i){if(e>=n.itemVariationSubtables.length)return 0;let s=n.itemVariationSubtables[e];if(t>=s.deltaSets.length)return 0;let r=s.deltaSets[t],a=this.getBlendVector(n,e,i),o=0;for(let l=0;ld.peakCoord||d.peakCoord>d.endCoord||d.startCoord<0&&d.endCoord>0&&d.peakCoord!==0||d.peakCoord===0?h=1:s[u]d.endCoord?h=0:s[u]===d.peakCoord?h=1:s[u]-1?this.set(n):this.set(this.getDefaultCoordinates())}getDefaultCoordinates(){return this.fvar().axes.reduce((n,e)=>(n[e.tag]=e.defaultValue,n),{})}getDefaultInstanceIndex(){const n=this.getDefaultCoordinates();let e=this.getInstanceIndex(n);return e<0&&(e=this.fvar().instances.findIndex(t=>t.name&&t.name.en==="Regular")),e}getInstanceIndex(n){return this.fvar().instances.findIndex(e=>Object.keys(n).every(t=>e.coordinates[t]===n[t]))}getInstance(n){return this.fvar().instances&&this.fvar().instances[n]}set(n){let e;if(Number.isInteger(n)){const t=this.getInstance(n);if(!t)throw Error(`Invalid instance index ${n}`);e={...t.coordinates}}else e=n,this.process.normalizeCoordTags(e);e=Object.assign({},this.font.defaultRenderOptions.variation,e),this.font.defaultRenderOptions=Object.assign({},this.font.defaultRenderOptions,{variation:e})}get(){return Object.assign({},this.font.defaultRenderOptions.variation)}avar(){return this.font.tables.avar}cvar(){return this.font.tables.cvar}fvar(){return this.font.tables.fvar}gvar(){return this.font.tables.gvar}hvar(){return this.font.tables.hvar}},$h=1e6,mo=64,go=1e4,Lp,as,Ip,Dc;function Pp(n){this.font=n,this.getCommands=function(e){return Dp.getPath(e).commands},this._fpgmState=this._prepState=void 0,this._errorState=0}function i2(n){return n}function Up(n){return Math.sign(n)*Math.round(Math.abs(n))}function s2(n){return Math.sign(n)*Math.round(Math.abs(n*2))/2}function r2(n){return Math.sign(n)*(Math.round(Math.abs(n)+.5)-.5)}function a2(n){return Math.sign(n)*Math.ceil(Math.abs(n))}function o2(n){return Math.sign(n)*Math.floor(Math.abs(n))}var Op=function(n){const e=this.srPeriod;let t=this.srPhase;const i=this.srThreshold;let s=1;return n<0&&(n=-n,s=-1),n+=i-t,n=Math.trunc(n/e)*e,n+=t,n<0?t*s:n*s},$n={x:1,y:0,axis:"x",distance:function(n,e,t,i){return(t?n.xo:n.x)-(i?e.xo:e.x)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.xo-e.xo,r=n.xo-t.xo,l=e.x-e.xo,c=t.x-t.xo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.x=n.xo+(l+c)/2;return}n.x=n.xo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){$n.setRelative(n,n,(l+c)/2,i,!0);return}$n.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:Number.NEGATIVE_INFINITY,setRelative:function(n,e,t,i,s){if(!i||i===this){n.x=(s?e.xo:e.x)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.x=o+(n.y-l)/i.normalSlope},slope:0,touch:function(n){n.xTouched=!0},touched:function(n){return n.xTouched},untouch:function(n){n.xTouched=!1}},hi={x:0,y:1,axis:"y",distance:function(n,e,t,i){return(t?n.yo:n.y)-(i?e.yo:e.y)},interpolate:function(n,e,t,i){let s,r,a,o,l,c,u;if(!i||i===this){if(s=n.yo-e.yo,r=n.yo-t.yo,l=e.y-e.yo,c=t.y-t.yo,a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){n.y=n.yo+(l+c)/2;return}n.y=n.yo+(l*o+c*a)/u;return}if(s=i.distance(n,e,!0,!0),r=i.distance(n,t,!0,!0),l=i.distance(e,e,!1,!0),c=i.distance(t,t,!1,!0),a=Math.abs(s),o=Math.abs(r),u=a+o,u===0){hi.setRelative(n,n,(l+c)/2,i,!0);return}hi.setRelative(n,n,(l*o+c*a)/u,i,!0)},normalSlope:0,setRelative:function(n,e,t,i,s){if(!i||i===this){n.y=(s?e.yo:e.y)+t;return}const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y;n.y=l+i.normalSlope*(n.x-o)},slope:Number.POSITIVE_INFINITY,touch:function(n){n.yTouched=!0},touched:function(n){return n.yTouched},untouch:function(n){n.yTouched=!1}};Object.freeze($n);Object.freeze(hi);function Vr(n,e){this.x=n,this.y=e,this.axis=void 0,this.slope=e/n,this.normalSlope=-n/e,Object.freeze(this)}Vr.prototype.distance=function(n,e,t,i){return this.x*$n.distance(n,e,t,i)+this.y*hi.distance(n,e,t,i)};Vr.prototype.interpolate=function(n,e,t,i){let s,r,a,o,l,c,u;if(a=i.distance(n,e,!0,!0),o=i.distance(n,t,!0,!0),s=i.distance(e,e,!1,!0),r=i.distance(t,t,!1,!0),l=Math.abs(a),c=Math.abs(o),u=l+c,u===0){this.setRelative(n,n,(s+r)/2,i,!0);return}this.setRelative(n,n,(s*c+r*l)/u,i,!0)};Vr.prototype.setRelative=function(n,e,t,i,s){i=i||this;const r=s?e.xo:e.x,a=s?e.yo:e.y,o=r+t*i.x,l=a+t*i.y,c=i.normalSlope,u=this.slope,d=n.x,h=n.y;n.x=(u*d-c*o+l-h)/(u-c),n.y=u*(n.x-d)+h};Vr.prototype.touch=function(n){n.xTouched=!0,n.yTouched=!0};function Gr(n,e){const t=Math.sqrt(n*n+e*e);return n/=t,e/=t,n===1&&e===0?$n:n===0&&e===1?hi:new Vr(n,e)}function gi(n,e,t,i){this.x=this.xo=Math.round(n*64)/64,this.y=this.yo=Math.round(e*64)/64,this.lastPointOfContour=t,this.onCurve=i,this.prevPointOnContour=void 0,this.nextPointOnContour=void 0,this.xTouched=!1,this.yTouched=!1,Object.preventExtensions(this)}gi.prototype.nextTouched=function(n){let e=this.nextPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.nextPointOnContour;return e};gi.prototype.prevTouched=function(n){let e=this.prevPointOnContour;for(;!n.touched(e)&&e!==this;)e=e.prevPointOnContour;return e};var Or=Object.freeze(new gi(0,0)),l2={cvCutIn:17/16,deltaBase:9,deltaShift:.125,loop:1,minDis:1,autoFlip:!0};function Ni(n,e){switch(this.env=n,this.stack=[],this.prog=e,n){case"glyf":this.zp0=this.zp1=this.zp2=1,this.rp0=this.rp1=this.rp2=0;case"prep":this.fv=this.pv=this.dpv=$n,this.round=Up}}Pp.prototype.exec=function(n,e){if(typeof e!="number")throw new Error("Point size is not a number!");if(this._errorState>2)return;const t=this.font;let i=this._prepState;if(!i||i.ppem!==e){let s=this._fpgmState;if(!s){Ni.prototype=l2,s=this._fpgmState=new Ni("fpgm",t.tables.fpgm),s.funcs=[],s.font=t,s.instructionCount=0,s.callDepth=0;try{as(s)}catch(a){console.log("Hinting error in FPGM:"+a),this._errorState=3;return}}Ni.prototype=s,i=this._prepState=new Ni("prep",t.tables.prep),i.ppem=e,i.instructionCount=0,i.callDepth=0;const r=t.variation&&t.variation.process.getCvarTransform()||t.tables.cvt;if(r){const a=i.cvt=new Array(r.length),o=e/t.unitsPerEm;for(let l=0;l1))try{return Ip(n,i)}catch(s){this._errorState<1&&(console.log("Hinting error:"+s),console.log("Note: further hinting errors are silenced")),this._errorState=1;return}};Ip=function(n,e){const t=e.ppem/e.font.unitsPerEm,i=t;let s=n.components,r,a,o;if(Ni.prototype=e,!s)o=new Ni("glyf",n.instructions),o.instructionCount=0,o.callDepth=0,Dc(n,o,t,i),a=o.gZone;else{const l=e.font;a=[],r=[];for(let c=0;c$h)throw new Error("Hinting instructions exceeded maximum of "+$h);if(i=Lp[e[n.ip]],!i)throw new Error("unknown instruction: 0x"+Number(e[n.ip]).toString(16));i(n)}};function Ao(n){const e=n.tZone=new Array(n.gZone.length);for(let t=0;t=176&&r<=183)i+=r-176+1;else if(r>=184&&r<=191)i+=(r-184+1)*2;else if(e&&s===1&&r===27)break;while(s>0);n.ip=i}function Jh(n,e){e.fv=e.pv=e.dpv=n}function jh(n,e){e.pv=e.dpv=n}function Qh(n,e){e.fv=n}function ed(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.pv=e.dpv=Gr(o,l)}function td(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.fv=Gr(o,l)}function c2(n){const e=n.stack,t=e.pop(),i=e.pop();n.pv=n.dpv=Gr(i,t)}function u2(n){const e=n.stack,t=e.pop(),i=e.pop();n.fv=Gr(i,t)}function h2(n){const e=n.stack,t=n.pv;e.push(t.x*16384),e.push(t.y*16384)}function d2(n){const e=n.stack,t=n.fv;e.push(t.x*16384),e.push(t.y*16384)}function f2(n){n.fv=n.pv}function p2(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop(),r=e.pop(),a=e.pop(),o=n.z0,l=n.z1,c=o[t],u=o[i],d=l[s],h=l[r],f=n.z2[a],p=c.x,g=c.y,m=u.x,_=u.y,b=d.x,A=d.y,y=h.x,M=h.y,S=(p-m)*(A-M)-(g-_)*(b-y),E=p*_-g*m,v=b*M-A*y;f.x=(E*(b-y)-v*(p-m))/S,f.y=(E*(A-M)-v*(g-_))/S}function m2(n){n.rp0=n.stack.pop()}function g2(n){n.rp1=n.stack.pop()}function _2(n){n.rp2=n.stack.pop()}function x2(n){const e=n.stack.pop();switch(n.zp0=e,e){case 0:n.tZone||Ao(n),n.z0=n.tZone;break;case 1:n.z0=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function y2(n){const e=n.stack.pop();switch(n.zp1=e,e){case 0:n.tZone||Ao(n),n.z1=n.tZone;break;case 1:n.z1=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function v2(n){const e=n.stack.pop();switch(n.zp2=e,e){case 0:n.tZone||Ao(n),n.z2=n.tZone;break;case 1:n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function S2(n){const e=n.stack.pop();switch(n.zp0=n.zp1=n.zp2=e,e){case 0:n.tZone||Ao(n),n.z0=n.z1=n.z2=n.tZone;break;case 1:n.z0=n.z1=n.z2=n.gZone;break;default:throw new Error("Invalid zone pointer")}}function b2(n){n.loop=n.stack.pop(),n.loop>go&&(n.loop=go)}function M2(n){n.round=Up}function A2(n){n.round=r2}function E2(n){const e=n.stack.pop();n.minDis=e/64}function T2(n){Np(n,!1)}function C2(n){const e=n.stack.pop();n.ip+=e-1}function w2(n){const e=n.stack.pop();n.cvCutIn=e/64}function R2(n){const e=n.stack;e.push(e[e.length-1])}function ml(n){n.stack.pop()}function D2(n){n.stack.length=0}function L2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t),e.push(i)}function I2(n){const e=n.stack;e.push(e.length)}function P2(n){const e=n.stack,t=e.pop();let i=e.pop();if(i>go&&(i=go),++n.callDepth>mo)throw new Error("Hinting call depth exceeded maximum of "+mo);const s=n.ip,r=n.prog;n.prog=n.funcs[t];for(let a=0;amo)throw new Error("Hinting call depth exceeded maximum of "+mo);const t=n.ip,i=n.prog;n.prog=n.funcs[e],as(n),n.ip=t,n.prog=i,n.callDepth--}function O2(n){const e=n.stack,t=e.pop();e.push(e[e.length-t])}function N2(n){const e=n.stack,t=e.pop();e.push(e.splice(e.length-t,1)[0])}function k2(n){if(n.env!=="fpgm")throw new Error("FDEF not allowed here");const e=n.stack,t=n.prog;let i=n.ip;const s=e.pop(),r=i;for(;t[++i]!==45;);n.ip=i,n.funcs[s]=t.slice(r+1,i)}function nd(n,e){const t=e.stack.pop(),i=e.z0[t],s=e.fv,r=e.pv;let a=r.distance(i,Or);n&&(a=e.round(a)),s.setRelative(i,Or,a,r),s.touch(i),e.rp0=e.rp1=t}function id(n,e){const t=e.z2,i=t.length-2;let s,r,a;for(let o=0;ot?1:0)}function Q2(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i>=t?1:0)}function eM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t===i?1:0)}function tM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t!==i?1:0)}function nM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?1:0)}function iM(n){const e=n.stack,t=e.pop();e.push(Math.trunc(t)&1?0:1)}function sM(n){n.stack.pop()||Np(n,!0)}function rM(n){}function aM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t&&i?1:0)}function oM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(t||i?1:0)}function lM(n){const e=n.stack,t=e.pop();e.push(t?0:1)}function gl(n,e){const t=e.stack,i=t.pop(),s=e.fv,r=e.pv,a=e.ppem,o=e.deltaBase+(n-1)*16,l=e.deltaShift,c=e.z0;for(let u=0;u>4)!==a)continue;let p=(h&15)-8;p>=0&&p++;const g=c[d];s.setRelative(g,g,p*l,r)}}function cM(n){const t=n.stack.pop();n.deltaBase=t}function uM(n){const t=n.stack.pop();n.deltaShift=Math.pow(.5,t)}function hM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i+t)}function dM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i-t)}function fM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*64/t)}function pM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(i*t/64)}function mM(n){const e=n.stack,t=e.pop();e.push(Math.abs(t))}function gM(n){const e=n.stack;let t=e.pop();e.push(-t)}function _M(n){const e=n.stack,t=e.pop();e.push(Math.floor(t/64)*64)}function xM(n){const e=n.stack,t=e.pop();e.push(Math.ceil(t/64)*64)}function Da(n,e){const t=e.stack,i=t.pop();t.push(e.round(i/64)*64)}function yM(n){const e=n.stack,t=e.pop(),i=e.pop();n.cvt[i]=t*n.ppem/n.font.unitsPerEm}function _l(n,e){const t=e.stack,i=t.pop(),s=e.ppem,r=e.deltaBase+(n-1)*16,a=e.deltaShift;for(let o=0;o>4)!==s)continue;let d=(c&15)-8;d>=0&&d++;const h=d*a;e.cvt[l]+=h}}function vM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=.5;break;case 64:t=1;break;case 128:t=2;break;default:throw new Error("invalid SROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid SROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function SM(n){let e=n.stack.pop();n.round=Op;let t;switch(e&192){case 0:t=Math.sqrt(2)/2;break;case 64:t=Math.sqrt(2);break;case 128:t=2*Math.sqrt(2);break;default:throw new Error("invalid S45ROUND value")}switch(n.srPeriod=t,e&48){case 0:n.srPhase=0;break;case 16:n.srPhase=.25*t;break;case 32:n.srPhase=.5*t;break;case 48:n.srPhase=.75*t;break;default:throw new Error("invalid S45ROUND value")}e&=15,e===0?n.srThreshold=0:n.srThreshold=(e/8-.5)*t}function bM(n){n.round=i2}function MM(n){n.round=a2}function AM(n){n.round=o2}function EM(n){n.stack.pop()}function hd(n,e){const t=e.stack,i=t.pop(),s=t.pop(),r=e.z2[i],a=e.z1[s];let o,l;n?(o=r.y-a.y,l=a.x-r.x):(o=a.x-r.x,l=a.y-r.y),e.dpv=Gr(o,l)}function TM(n){const e=n.stack,t=e.pop();let i=0;t&1&&(i=35),t&32&&(i|=4096),e.push(i)}function CM(n){const e=n.stack,t=e.pop(),i=e.pop(),s=e.pop();e.push(i),e.push(t),e.push(s)}function wM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.max(i,t))}function RM(n){const e=n.stack,t=e.pop(),i=e.pop();e.push(Math.min(i,t))}function DM(n){n.stack.pop()}function LM(n){const e=n.stack.pop();let t=n.stack.pop();switch(e){case 1:n.inhibitGridFit=!!t;return;case 2:n.ignoreCvt=!!t;return;default:throw new Error("invalid INSTCTRL[] selector")}}function Ri(n,e){const t=e.stack,i=e.prog;let s=e.ip;for(let r=0;r=0?1:-1,g=Math.abs(g),n&&(_=r.cvt[o],i&&Math.abs(g-_)=0&&nthis[s[0]].apply(this,s.slice(1).concat(!0))),i=s=>typeof s=="object"&&Object.prototype.hasOwnProperty.call(s,"FAIL");if(t.every(i))return{FAIL:"composeRUD: one or more operations hasn't completed successfully",report:t.filter(i)};this.dispatch("composeRUD",[t.filter(s=>!i(s))])};Rt.prototype.replaceRange=function(n,e,t,i){e=e!==null?e:this.tokens.length;const s=t.every(r=>r instanceof sr);if(!isNaN(n)&&this.inboundIndex(n)&&s){const r=this.tokens.splice.apply(this.tokens,[n,e].concat(t));return i||this.dispatch("replaceToken",[n,e,t]),[r,t]}else return{FAIL:"replaceRange: invalid tokens or startIndex."}};Rt.prototype.replaceToken=function(n,e,t){if(!isNaN(n)&&this.inboundIndex(n)&&e instanceof sr){const i=this.tokens.splice(n,1,e);return t||this.dispatch("replaceToken",[n,e]),[i[0],e]}else return{FAIL:"replaceToken: invalid token or index."}};Rt.prototype.removeRange=function(n,e,t){e=isNaN(e)?this.tokens.length:e;const i=this.tokens.splice(n,e);return t||this.dispatch("removeRange",[i,n,e]),i};Rt.prototype.removeToken=function(n,e){if(!isNaN(n)&&this.inboundIndex(n)){const t=this.tokens.splice(n,1);return e||this.dispatch("removeToken",[t,n]),t}else return{FAIL:"removeToken: invalid token index."}};Rt.prototype.insertToken=function(n,e,t){return n.every(s=>s instanceof sr)?(this.tokens.splice.apply(this.tokens,[e,0].concat(n)),t||this.dispatch("insertToken",[n,e]),n):{FAIL:"insertToken: invalid token(s)."}};Rt.prototype.registerModifier=function(n,e,t){this.events.newToken.subscribe(function(i,s){const r=[i,s],a=e===null||e.apply(this,r)===!0,o=[i,s];if(a){let l=t.apply(this,o);i.setState(n,l)}}),this.registeredModifiers.push(n)};Eo.prototype.subscribe=function(n){return typeof n=="function"?this.subscribers.push(n)-1:{FAIL:`invalid '${this.eventId}' event handler`}};Eo.prototype.unsubscribe=function(n){this.subscribers.splice(n,1)};rn.prototype.setCurrentIndex=function(n){this.index=n,this.current=this.context[n],this.backtrack=this.context.slice(0,n),this.lookahead=this.context.slice(n+1)};rn.prototype.get=function(n){switch(!0){case n===0:return this.current;case(n<0&&Math.abs(n)<=this.backtrack.length):return this.backtrack.slice(n)[0];case(n>0&&n<=this.lookahead.length):return this.lookahead[n-1];default:return null}};Rt.prototype.rangeToText=function(n){if(n instanceof lu)return this.getRangeTokens(n).map(e=>e.char).join("")};Rt.prototype.getText=function(){return this.tokens.map(n=>n.char).join("")};Rt.prototype.getContext=function(n){let e=this.registeredContexts[n];return e||null};Rt.prototype.on=function(n,e){const t=this.events[n];return t?t.subscribe(e):null};Rt.prototype.dispatch=function(n,e){const t=this.events[n];if(t instanceof Eo)for(let i=0;ie.char);for(let e=0;e=s.start&&n<=s.end){let r=n-s.start;return s.index+r}}break}default:return-1}return-1}function kM(n,e){return Vi(n,e.coverage)===-1?null:n+e.deltaGlyphId}function FM(n,e){let t=Vi(n,e.coverage);return t===-1?null:e.substitute[t]}function xl(n,e){let t=[];for(let i=0;i{const{lookupListIndex:d,sequenceIndex:h}=u,{subtables:f}=this.getLookupByIndex(d);for(const p of f)Vi(c[h],p.coverage)!==-1&&(c[h]=p.deltaGlyphId)};for(let c=0;ci.features[s]),this.features[n]=e,this.mapTagsToFeatures(e,n),e};gn.prototype.getSubstitutionType=function(n,e){const t=n.lookupType.toString(),i=e.substFormat.toString();return t+i};gn.prototype.getLookupMethod=function(n,e){let t=this.getSubstitutionType(n,e);switch(t){case"11":return i=>kM.apply(this,[i,e]);case"12":return i=>FM.apply(this,[i,e]);case"63":return i=>BM.apply(this,[i,e]);case"41":return i=>HM.apply(this,[i,e]);case"21":return i=>GM.apply(this,[i,e]);case"51":return i=>zM.apply(this,[i,e]);case"53":return i=>VM.apply(this,[i,e]);default:throw new Error(`substitutionType : ${t} lookupType: ${n.lookupType} - substFormat: ${e.substFormat} is not yet supported`)}};gn.prototype.lookupFeature=function(n){let e=n.contextParams,t=e.index;const i=this.getFeature({tag:n.tag,script:n.script});if(!i)return new Error(`font '${(this.font.names.unicode||this.font.names.windows||this.font.names.macintosh).fullName.en}' doesn't support feature '${n.tag}' for script '${n.script}'.`);const s=this.getFeatureLookups(i),r=[].concat(e.context);for(let a=0;ai.tag===n.tag);return e&&t};gn.prototype.getLookupSubtables=function(n){return n.subtables||null};gn.prototype.getLookupByIndex=function(n){return this.font.tables.gsub.lookups[n]||null};gn.prototype.getFeatureLookups=function(n){return n.lookupListIndexes.map(this.getLookupByIndex.bind(this))};gn.prototype.getFeature=function(e){if(!this.font)return{FAIL:"No font was found"};Object.prototype.hasOwnProperty.call(this.features,e.script)||this.getScriptFeatures(e.script);const t=this.features[e.script];return t?t.tags[e.tag]?this.features[e.script].tags[e.tag]:null:{FAIL:`No feature for script ${e.script}`}};var WM=gn;function XM(n){const e=n.current,t=n.get(-1);return t===null&&Fi(e)||!Fi(t)&&Fi(e)}function YM(n){const e=n.get(1);return e===null||!Fi(e)}var KM={startCheck:XM,endCheck:YM};function qM(n){const e=n.current,t=n.get(-1);return(Fi(e)||zi(e))&&!Fi(t)}function ZM(n){const e=n.get(1);switch(!0){case e===null:return!0;case(!Fi(e)&&!zi(e)):{const t=NM(e);if(!t)return!0;if(t){let i=!1;if(i=n.lookahead.some(s=>Fi(s)||zi(s)),!i)return!0}break}default:return!1}}var $M={startCheck:qM,endCheck:ZM};function JM(n,e,t){e[t].setState(n.tag,n.substitution)}function jM(n,e,t){e[t].setState(n.tag,n.substitution)}function yl(n,e,t){for(let i=0;i=0;t--){const i=e[t],s=kp(i),r=zi(i);if(!s&&!r)return!0;if(s)return!1}return!1}function n3(n){if(kp(n.current))return!1;for(let e=0;ea.getState("glyphIndex")),0);const r=new rn(i.map(a=>a.char),0);for(let a=0;ai.activeState.value);return new rn(t,0)}function r3(n){const e="arab";let t=this.tokenizer.getRangeTokens(n),i=fd(t);for(let s=0;s1}function l3(n){return n.index===n.context.length-1}var c3={startCheck:o3,endCheck:l3};function pd(n,e){const t=n.map(i=>i.activeState.value);return new rn(t,0)}function u3(n){const e="delf",t="ccmp";let i=this.tokenizer.getRangeTokens(n),s=pd(i);for(let r=0;ri.activeState.value);return new rn(t,0)}function m3(n){const e="latn";let t=this.tokenizer.getRangeTokens(n),i=md(t);for(let s=0;si.activeState.value);return new rn(t,e||0)}function v3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=gd(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function b3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=_d(t,0);for(let s=0;si.activeState.value);return new rn(t,e||0)}function A3(n){const e="thai";let t=this.tokenizer.getRangeTokens(n),i=xd(t,0);for(let s=0;s=6155&&e<=6157||e>=65024&&e<=65039||e>=917760&&e<=917999}function T3(n){const e=n.current,t=n.get(1);return t===null&&Lc(e)||Lc(t)}function C3(n){const e=n.get(1);return e===null||!Lc(e)}var w3={startCheck:T3,endCheck:C3};function R3(n){const e=this.query.font,t=this.tokenizer.getRangeTokens(n);if(t[1].setState("deleted",!0),e.tables.cmap&&e.tables.cmap.varSelectorList){const i=t[0].char.codePointAt(0),s=t[1].char.codePointAt(0),r=e.tables.cmap.varSelectorList[s];if(r!==void 0&&r.nonDefaultUVS){const a=r.nonDefaultUVS.uvsMappings;if(a[i]){const o=a[i].glyphID;e.glyphs.glyphs[o]!==void 0&&t[0].setState("glyphIndex",o)}}}}var D3=R3;function Mn(n){this.baseDir=n||"ltr",this.tokenizer=new OM,this.featuresTags={}}Mn.prototype.setText=function(n){this.text=n};Mn.prototype.contextChecks={ccmpReplacementCheck:c3,latinWordCheck:p3,arabicWordCheck:KM,arabicSentenceCheck:$M,thaiWordCheck:y3,unicodeVariationSequenceCheck:w3};function ks(n){const e=this.contextChecks[`${n}Check`];return this.tokenizer.registerContextChecker(n,e.startCheck,e.endCheck)}function L3(){return ks.call(this,"ccmpReplacement"),ks.call(this,"latinWord"),ks.call(this,"arabicWord"),ks.call(this,"arabicSentence"),ks.call(this,"thaiWord"),ks.call(this,"unicodeVariationSequence"),this.tokenizer.tokenize(this.text)}function I3(){const n=this.tokenizer.getContextRanges("arabicSentence");for(let e=0;ethis.query.supports({script:n,tag:i}));Object.prototype.hasOwnProperty.call(this.featuresTags,n)?this.featuresTags[n]=this.featuresTags[n].concat(t):this.featuresTags[n]=t};Mn.prototype.applyFeatures=function(n,e){if(!n)throw new Error("No valid font was provided to apply features");this.query||(this.query=new WM(n));for(let t=0;t0)throw new Error("When creating a new Font object, negative descender value is required.");this.names={},this.names.unicode=vl(n),this.names.macintosh=vl(n),this.names.windows=vl(n),this.unitsPerEm=n.unitsPerEm||1e3,this.ascender=n.ascender,this.descender=n.descender,this.createdTimestamp=n.createdTimestamp,this.italicAngle=n.italicAngle||0,this.weightClass=n.weightClass||0;let e=0;n.fsSelection?e=n.fsSelection:(this.italicAngle<0?e|=this.fsSelectionValues.ITALIC:this.italicAngle>0&&(e|=this.fsSelectionValues.OBLIQUE),this.weightClass>=600&&(e|=this.fsSelectionValues.BOLD),e===0&&(e=this.fsSelectionValues.REGULAR)),(!n.panose||!Array.isArray(n.panose))&&(n.panose=[0,0,0,0,0,0,0,0,0]),this.tables=Object.assign(n.tables,{os2:Object.assign({usWeightClass:n.weightClass||this.usWeightClasses.MEDIUM,usWidthClass:n.widthClass||this.usWidthClasses.MEDIUM,bFamilyType:n.panose[0]||0,bSerifStyle:n.panose[1]||0,bWeight:n.panose[2]||0,bProportion:n.panose[3]||0,bContrast:n.panose[4]||0,bStrokeVariation:n.panose[5]||0,bArmStyle:n.panose[6]||0,bLetterform:n.panose[7]||0,bMidline:n.panose[8]||0,bXHeight:n.panose[9]||0,fsSelection:e},n.tables.os2)})}this.supported=!0,this.glyphs=new Qn.GlyphSet(this,n.glyphs||[]),this.encoding=new $f(this),this.position=new Ub(this),this.substitution=new zb(this),this.tables=this.tables||{},this.tables=new Proxy(this.tables,{set:(e,t,i)=>(e[t]=i,e.fvar&&(e.gvar||e.cff2)&&!this.variation&&(this.variation=new n2(this)),!0)}),this.palettes=new Cp(this),this.layers=new Vb(this),this.svgImages=new Gb(this),this._push=null,this._hmtxTableData={},Object.defineProperty(this,"hinting",{get:function(){return this._hinting?this._hinting:this.outlinesFormat==="truetype"?this._hinting=new IM(this):null}})}pt.prototype.hasChar=function(n){return this.encoding.charToGlyphIndex(n)>0};pt.prototype.charToGlyphIndex=function(n){return this.encoding.charToGlyphIndex(n)};pt.prototype.charToGlyph=function(n){const e=this.charToGlyphIndex(n);let t=this.glyphs.get(e);return t||(t=this.glyphs.get(0)),t};pt.prototype.updateFeatures=function(n){return this.defaultRenderOptions.features.map(e=>e.script==="latn"?{script:"latn",tags:e.tags.filter(t=>n[t])}:e)};pt.prototype.stringToGlyphIndexes=function(n,e){const t=new B3,i=r=>this.charToGlyphIndex(r.char);t.registerModifier("glyphIndex",null,i);let s=e?this.updateFeatures(e.features):this.defaultRenderOptions.features;return t.applyFeatures(this,s),t.getTextGlyphs(n)};pt.prototype.stringToGlyphs=function(n,e){const t=this.stringToGlyphIndexes(n,e);let i=t.length;const s=new Array(i),r=this.glyphs.get(0);for(let a=0;a{const u=a.getPath(o,l,c,s,this);if(s.drawSVG||s.drawLayers){const d=u._layers;if(d&&d.length){for(let h=0;h0,"No English "+s+" specified.")}if(i("fontFamily"),i("weightName"),i("manufacturer"),i("copyright"),i("version"),t(this.unitsPerEm>0,"No unitsPerEm specified."),this.tables.colr){const s=this.tables.colr.baseGlyphRecords;let r=-1;for(let a=0;as[a].glyphID)break;r=o}}return n};pt.prototype.toTables=function(){return Pb.fontToTable(this)};pt.prototype.toBuffer=function(){return console.warn("Font.toBuffer is deprecated. Use Font.toArrayBuffer instead."),this.toArrayBuffer()};pt.prototype.toArrayBuffer=function(){const e=this.toTables().encode(),t=new ArrayBuffer(e.length),i=new Uint8Array(t);for(let s=0;s=1.2&&(s.markGlyphSets=t.parsePointer(q3)),s}var $3={parse:Z3},kn=new Array(10);kn[1]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();if(t===1)return{posFormat:1,coverage:this.parsePointer(q.coverage),value:this.parseValueRecord()};if(t===2)return{posFormat:2,coverage:this.parsePointer(q.coverage),values:this.parseValueRecordList()};ke.assert(!1,"0x"+e.toString(16)+": GPOS lookup type 1 format must be 1 or 2.")};kn[2]=function(){const e=this.offset+this.relativeOffset,t=this.parseUShort();ke.assert(t===1||t===2,"0x"+e.toString(16)+": GPOS lookup type 2 format must be 1 or 2.");const i=this.parsePointer(q.coverage),s=this.parseUShort(),r=this.parseUShort();if(t===1)return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,pairSets:this.parseList(q.pointer(q.list(function(){return{secondGlyph:this.parseUShort(),value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}})))};if(t===2){const a=this.parsePointer(q.classDef),o=this.parsePointer(q.classDef),l=this.parseUShort(),c=this.parseUShort();return{posFormat:t,coverage:i,valueFormat1:s,valueFormat2:r,classDef1:a,classDef2:o,class1Count:l,class2Count:c,classRecords:this.parseList(l,q.list(c,function(){return{value1:this.parseValueRecord(s),value2:this.parseValueRecord(r)}}))}}};kn[3]=function(){return{error:"GPOS Lookup 3 not supported"}};kn[4]=function(){return{error:"GPOS Lookup 4 not supported"}};kn[5]=function(){return{error:"GPOS Lookup 5 not supported"}};kn[6]=function(){return{error:"GPOS Lookup 6 not supported"}};kn[7]=function(){return{error:"GPOS Lookup 7 not supported"}};kn[8]=function(){return{error:"GPOS Lookup 8 not supported"}};kn[9]=function(){return{error:"GPOS Lookup 9 not supported"}};function J3(n,e){e=e||0;const t=new q(n,e),i=t.parseVersion(1);return ke.argument(i===1||i===1.1,"Unsupported GPOS table version "+i),i===1?{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn)}:{version:i,scripts:t.parseScriptList(),features:t.parseFeatureList(),lookups:t.parseLookupList(kn),variations:t.parseFeatureVariationsList()}}var j3=new Array(10);function Q3(n){return new me.Table("GPOS",[{name:"version",type:"ULONG",value:65536},{name:"scripts",type:"TABLE",value:new me.ScriptList(n.scripts)},{name:"features",type:"TABLE",value:new me.FeatureList(n.features)},{name:"lookups",type:"TABLE",value:new me.LookupList(n.lookups,j3)}])}var eA={parse:J3,make:Q3};function tA(n){const e={};n.skip("uShort");const t=n.parseUShort();ke.argument(t===0,"Unsupported kern sub-table version."),n.skip("uShort",2);const i=n.parseUShort();n.skip("uShort",3);for(let s=0;s1&&console.warn("Only the first kern subtable is supported."),n.skip("uLong");const s=n.parseUShort()&255;if(n.skip("uShort"),s===0){const r=n.parseUShort();n.skip("uShort",3);for(let a=0;a{const t=await(await fetch(e)).arrayBuffer();return new Cr(lA(t))})(),this._shared.catch(()=>{Cr._shared=null})),this._shared}measureEm(e){let t=0;for(const i of e)t+=this.ensureGlyph(i.codePointAt(0)).advance;return t}ensureGlyph(e){let t=this.glyphs.get(e);if(t)return t;const i=this.font.charToGlyph(String.fromCodePoint(e)),s=(i.advanceWidth??this.upem*.5)/this.upem,r=i.getPath(0,0,1),a=[];let o=0,l=0,c=0,u=0;for(const w of r.commands)switch(w.type){case"M":c=o=w.x,u=l=-w.y;break;case"L":a.push(vd(c,u,w.x,-w.y)),c=w.x,u=-w.y;break;case"Q":a.push({x0:c,y0:u,cx:w.x1,cy:-w.y1,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break;case"C":{const U=(w.x1+w.x2)/2,O=(-w.y1+-w.y2)/2;a.push({x0:c,y0:u,cx:U,cy:O,x1:w.x,y1:-w.y}),c=w.x,u=-w.y;break}case"Z":(c!==o||u!==l)&&a.push(vd(c,u,o,l)),c=o,u=l;break}if(!a.length)return t={base:-1,advance:s},this.glyphs.set(e,t),t;let d=1/0,h=1/0,f=-1/0,p=-1/0;for(const w of a)d=Math.min(d,w.x0,w.cx,w.x1),f=Math.max(f,w.x0,w.cx,w.x1),h=Math.min(h,w.y0,w.cy,w.y1),p=Math.max(p,w.y0,w.cy,w.y1);const g=Math.max(f-d,1e-6),m=Math.max(p-h,1e-6),_=Array.from({length:ln},()=>[]),b=Array.from({length:ln},()=>[]);a.forEach((w,U)=>{const O=Math.min(w.y0,w.cy,w.y1),P=Math.max(w.y0,w.cy,w.y1),Z=Math.min(w.x0,w.cx,w.x1),N=Math.max(w.x0,w.cx,w.x1),W=Ia((O-h)/m),D=Ia((P-h)/m);for(let oe=W;oe<=D;oe++)_[oe].push(U);const re=Ia((Z-d)/g),ie=Ia((N-d)/g);for(let oe=re;oe<=ie;oe++)b[oe].push(U)});const A=w=>Math.ceil(w.length/4),y=_.reduce((w,U)=>w+A(U),0)+b.reduce((w,U)=>w+A(U),0),M=2+ln*2+y+a.length*2,S=this.alloc(M),E=this.data,v=(w,U,O,P,Z)=>{E[w*4]=U,E[w*4+1]=O,E[w*4+2]=P,E[w*4+3]=Z},T=S+2+ln*2+y;v(S,d,h,f,p),v(S+1,S+2,S+2+ln,0,0);let I=S+2+ln*2;const L=(w,U)=>{for(let O=0;O{v(T+U*2,w.x0,w.y0,w.cx,w.cy),v(T+U*2+1,w.x1,w.y1,0,0)}),t={base:S,advance:s},this.glyphs.set(e,t),t}bboxOf(e){const t=e.base*4;return[this.data[t],this.data[t+1],this.data[t+2],this.data[t+3]]}alloc(e){const t=(this.used+e)*4;if(t>this.data.length){let s=this.data.length;for(;s= count) break; + vec4 idx4 = T(int(band.x) + (j >> 2)); + int cb = int(j % 4 == 0 ? idx4.x : j % 4 == 1 ? idx4.y : j % 4 == 2 ? idx4.z : idx4.w); + vec4 A = T(cb); + vec2 e = T(cb + 1).xy; + // Swap the CURVE points before subtracting: p is already in swapped + // coordinates for the vertical ray ((A.xy - p).yx would be wrong). + vec2 p1 = (swap ? A.yx : A.xy) - p; + vec2 p2 = (swap ? A.wz : A.zw) - p; + vec2 p3 = (swap ? e.yx : e.xy) - p; + + uint code = (0x2E74u >> ((p1.y > 0.0 ? 2u : 0u) + (p2.y > 0.0 ? 4u : 0u) + (p3.y > 0.0 ? 8u : 0u))) & 3u; + if (code != 0u) { + vec2 a = p1 - p2 * 2.0 + p3; + vec2 b = p1 - p2; + float t1, t2; + if (abs(a.y) < 1e-6) { + float t = p1.y / (2.0 * b.y); + t1 = t; t2 = t; + } else { + float d = sqrt(max(b.y * b.y - a.y * p1.y, 0.0)); + t1 = (b.y - d) / a.y; + t2 = (b.y + d) / a.y; + } + if ((code & 1u) != 0u) { + float x = (a.x * t1 - b.x * 2.0) * t1 + p1.x; + cov += clamp(x * ppem + 0.5, 0.0, 1.0); + } + if (code > 1u) { + float x = (a.x * t2 - b.x * 2.0) * t2 + p1.x; + cov -= clamp(x * ppem + 0.5, 0.0, 1.0); + } + } + } + return cov; + } + + void main() { + vec4 bbox = T(vBase); + vec4 bases = T(vBase + 1); + vec2 fw = fwidth(vEm); + + vec2 span = max(bbox.zw - bbox.xy, vec2(1e-6)); + int hb = clamp(int((vEm.y - bbox.y) / span.y * float(${ln})), 0, ${ln-1}); + int vb = clamp(int((vEm.x - bbox.x) / span.x * float(${ln})), 0, ${ln-1}); + + float covH = rayCoverage(vEm, 1.0 / max(fw.x, 1e-9), int(bases.x) + hb, false); + float covV = -rayCoverage(vEm.yx, 1.0 / max(fw.y, 1e-9), int(bases.y) + vb, true); + float alpha = clamp((covH + covV) * 0.5, 0.0, 1.0); + if (alpha < 0.004) discard; + fragOut = vec4(vColor, alpha); + } +`;class dA{constructor(e){Gt(this,"pos",[]);Gt(this,"emuv",[]);Gt(this,"gbase",[]);Gt(this,"color",[]);Gt(this,"index",[]);this.engine=e}add(e,t,i,s,r,a,o){const l=this.engine,c=String(e).split(` +`),u=i,d=i*5/3,h=(c.length-1)*d+i;a===4&&(o=2);let f;o===3?f=-i:o===2?f=h/2-i:f=(c.length-1)*d;const p=Math.cos(s),g=Math.sin(s),m=(r>>16&255)/255,_=(r>>8&255)/255,b=(r&255)/255;for(let A=0;A=0){const[L,w,U,O]=this.engine.bboxOf(I),P=L-La,Z=w-La,N=U+La,W=O+La,D=this.pos.length/3;for(const[re,ie]of[[P,Z],[N,Z],[N,W],[P,W]]){const oe=S+(v+re)*u,_e=E+ie*u;this.pos.push(t.x+oe*p-_e*g,t.y+oe*g+_e*p,1),this.emuv.push(re,ie),this.gbase.push(I.base),this.color.push(m,_,b)}this.index.push(D,D+1,D+2,D,D+2,D+3)}v+=I.advance}}}build(){if(!this.index.length)return null;const e=new Ct;e.setAttribute("position",new dt(this.pos,3)),e.setAttribute("emuv",new dt(this.emuv,2)),e.setAttribute("gbase",new dt(this.gbase,1)),e.setAttribute("tcolor",new dt(this.color,3)),e.setIndex(this.index);const t=new On({glslVersion:pc,vertexShader:uA,fragmentShader:hA,uniforms:{dataTex:{value:this.engine.texture()}},transparent:!0,depthTest:!1,depthWrite:!1,side:zt}),i=new Vt(e,t);return i.frustumCulled=!0,i}}const fA=`; IntelliCAD Linetypes\r +;\r +; icad.lin\r +; Release 1.0 \r +; \r +; .............................................................................\r +;\r +; Copyright (c) 1998 by Visio Corporation. All rights reserved.\r +;\r +; The Software is subject to the license agreement that accompanies \r +; or is included with the Software, which specifies the permitted \r +; and prohibited uses of the Software. Any unauthorized duplication \r +; or use of Visio Corporation Software, in whole or in part, in print, \r +; or in any other storage and retrieval system is prohibited.\r +; \r +; To the maximum extent permitted by applicable law, Visio Corporation\r +; and its suppliers disclaim any and all warranties and conditions,\r +; either express or implied, including, without limitation, implied\r +; warranties of merchantability, fitness for a particular purpose,\r +; title, and non-infringement, and those arising out of usage of trade\r +; or course of dealing, concerning these materials. These materials\r +; are provided "as is" without warranty of any kind.\r +; .............................................................................\r +\r +\r +\r +*BORDER,__ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . __ __ . \r +A,0.50,-0.250,0.50,-0.250,0,-0.250\r +*BORDER2,__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__.__ \r +A,0.25,-0.125,0.25,-0.125,0,-0.125\r +*BORDERX2,____ ____ . ____ ____ . ____ ____ . ____ ____ . \r +A,1.0,-0.5,1.0,-0.5,0,-0.5\r +\r +*CENTER,____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _ ____ _\r +A,1.250,-0.25,0.25,-0.25\r +*CENTER2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.1250,0.1250,-0.125\r +*CENTERX2,________ __ ________ __ ________ __ ________ __ ____\r +A,2.5,-0.50,0.50,-0.50\r +\r +*DASHDOT,__ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . __ . _\r +A,0.50,-0.250,0,-0.250\r +*DASHDOT2,_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._.\r +A,0.25,-0.125,0,-0.125\r +*DASHDOTX2,____ . ____ . ____ . ____ . ____ . ____ . ____ \r +A,1.0,-0.5,0,-0.5\r +\r +*DASHED,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.50,-0.250\r +*DASHED2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.250,-0.1250\r +*DASHEDX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,1.0,-0.5\r +\r +*DIVIDE,____ . . ____ . . ____ . . ____ . . ____ . . ____ . . ____ . .\r +A,0.50,-0.25,0,-0.25,0,-0.25\r +*DIVIDE2,__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..__..\r +A,0.25,-0.125,0,-0.125,0,-0.125\r +*DIVIDEX2,________ . . ________ . . ________ . . ________ . .\r +A,1.0,-0.5,0,-0.5,0,-0.50\r +\r +*DOT,. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-0.25\r +*DOT2,................................................................\r +A,0,-0.125\r +*DOTX2,. . . . . . . . . . . . . . . . . . . . . \r +A,0,-0.5\r +\r +*HIDDEN,__ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ __ \r +A,0.250,-0.1250\r +*HIDDEN2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.06250\r +*HIDDENX2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.5,-0.25\r +\r +*PHANTOM,______ __ __ ______ __ __ ______ __ __ ______ __ __\r +A,1.25,-0.25,0.250,-0.25,0.25,-0.25\r +*PHANTOM2,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.625,-0.125,0.1250,-0.125,0.125,-0.1250\r +*PHANTOMX2,____________ ____ ____ ____________ ____ ____ \r +A,2.5,-0.5,0.5,-0.5,0.50,-0.5\r +\r +*PHANTOM4,___ _ _ ___ _ _ (1/2 of Phantom2)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.3125,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +\r +*PHANTOM8,___ _ _ ___ _ _ (1/2 of Phantom4)__ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,0.15625,-0.03125,0.03125,-0.03125,0.03125,-0.03125\r +\r +*BORDER4,__.__.__.__.__.__._ (1/2 of Border2) _.__.__.__.__.__.__.__.__ \r +A,0.125,-0.0625,0.125,-0.0625,0,-0.0625\r +\r +*CENTER4,___ _ ___ _ ___ _ __ (1/2 of Center2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.0625,0.0625,-0.0625\r +*CENTER8,___ _ ___ _ ___ _ __ (1/2 of Center4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.03125,0.03125,-0.03125\r +\r +*CENTERF,_____ _ _____ (Finer short dashes than Center) _____\r +A,1.25,-0.125,0.125,-0.125\r +*CENTERF2,___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ _\r +A,0.75,-0.0625,0.0625,-0.0625\r +;; Auto-Arch additions for finer linetypes.\r +*CENTERF4,___ _ ___ _ ___ _ __ (1/2 of CenterF2)__ _ ___ _ ___ _ ___ _ _\r +A,0.375,-0.03125,0.03125,-0.03125\r +*CENTERF8,___ _ ___ _ ___ _ __ (1/2 of CenterF4)__ _ ___ _ ___ _ ___ _ _\r +A,0.1875,-0.0015625,0.0015625,-0.0015625\r +\r +*DASHED4,_ _ _ _ _ _ _ _ (1/2 of Dashed2)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.125,-0.0625\r +*DASHED8,_ _ _ _ _ _ _ _ (1/2 of Dashed4)_ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +\r +*DEMOx2,____ ____ ____ ____ ____\r +A,0.250,-0.5\r +*DEMO,__ __ __ __ __ __ __ __ __ __ __\r +A,0.125,-0.25\r +*DEMO2,_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO4,_ _ _ _ _ _ (1/2 of Demo2) _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.125\r +*DEMO8,_ _ _ _ _ _ (1/2 of Demo4) _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.0625\r +\r +*INVISIBLE,. (Dot at endpoints only) .\r +A,0,-1000\r +\r +*DOT4,...................(1/2 of Dot2)................................\r +A,0,-0.06125\r +*DOT8,...................(1/2 of Dot4)................................\r +A,0,-0.03125\r +*DOT16,..................(1/2 of Dot8)................................\r +A,0,-0.0015625\r +\r +*HIDDEN4,_ _ _ _ _ _ _ _ (1/2 of Hidden2)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.0625,-0.03125\r +*HIDDEN8,_ _ _ _ _ _ _ _ (1/2 of Hidden4)_ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.03125,-0.015\r +\r +*JIS_02_0.7, Hot Water Supply __ __ __ __ __ __ __\r +A,0.8,-0.5\r +*JIS_02_1.0, HIDDEN 0.8 - - - - - - - - - -\r +A,0.8,-0.8\r +*JIS_02_1.2, HIDDEN01.25 - - - - - - - - - -\r +A,1.26,-1.26\r +*JIS_02_2.0, HIDDEN02 __ __ __ __ __ __ __ __ __ __ __ \r +A,1.99,-0.99\r +*JIS_02_4.0, HIDDEN04 ____ ____ ____ ____ ____ ____ ____ \r +A,3.999,-0.999\r +*JIS_08_11, ___ _ ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,10.9999,-0.499,0.499,-0.499\r +*JIS_08_15, ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,14.999,-0.499,0.499,-0.499\r +*JIS_08_25, ________ __ ________ __ ________ __\r +A,24.999,-1,0.8,-1\r +*JIS_08_37, _____________ __ _____________ __ _____________ __ \r +A,36.999,-1.0,0.8,-1\r +*JIS_08_50, , ___________________ __ ___________________ __ \r +A,49.999,-1.0,0.8,-1\r +*JIS_09_08, _____ _ _ _____ _ _ _____ _ _ _____ _ _ _____ _ _ \r +A,7.999,-0.5,0.5,-0.5,0.5,-0.5\r +*JIS_09_15, _________ _ _ _________ _ _ _________ _ _ _________ _ _ \r +A,14.999,-0.999,0.499,-0.999,0.499,-0.999\r +*JIS_09_29, _____________ _ _ _____________ _ _ _____________ _ _ \r +A,28.999,-1.499,0.999,-1.499,0.999,-1.499\r +*JIS_09_50, _______________________ __ __ _______________________\r +A,49.999,-1.499,0.999,-1.499,0.999,-1.499\r +\r +\r +\r +*CONTOUR,______ ______ ______ ______ ______ ______ ______ ______\r +A,0.375,-0.09375\r +*CONTOUR2,____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ \r +A,0.25,-0.0625\r +*COLDWR,___ _ ____ _ _____ _ _____ _ _____ _ ____\r +A,0.25,-0.075,0.075,-0.075\r +*HOTWR,___ _ _ ___ _ _ ___ _ _ ___ _ _ ___ _ _ ___\r +A,0.25,-0.075,0.075,-0.075,0.075,-0.075\r +*HCW,_____ _ _ _ _____ _ _ _ _____ _ _ _ _____\r +A,1,-0.125,0.125,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY,___________ __ __ ___________ __ __ ______ \r +A,1.75,-0.125,0.125,-0.125,0.125,-0.125\r +*BOUNDARY2,______ _ _ ______ _ _ ______ _ _ ______ _ _ ______\r +A,1,-0.0625,0.0625,-0.0625,0.0625,-0.0625\r +*STREAM,_________ . . ___________ . . ___________\r +A,1,-0.125,0,-0.125,0,-0.125 \r +*PNEUM,__ ___ ___ ___ ___ ___ ___ ___ ___ ___ __\r +A,0.2,-0.1,0.2,-0.1\r +*WASTE,__ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,0.25,-0.125\r +*2DASHES,____ _ _ _____ _ _ ____ _ _ ____ _ _ ____\r +A,0.75,-0.25,0.1,-0.25,0.1,-0.25\r +*EWIREUP,__ . __ . __ . __ . __ . __ . __ . __ .__\r +A,0.25,-.075,0,-.075\r +*EWCELL,___ ___ . ___ ___ . __ __ . __ __ . __ __\r +A,0.25,-0.075,0.25,-.075,0,-.075\r +\r +*EVENDASH,-- -- -- -- -- -- -- -- -- -- --\r +A,0.125,-0.125\r +\r +;; Additional Plumbing linetypes\r +*DCW,Domestic Cold Water ___ _ ______________ _ ____\r +A,1.25,-0.06,0.08,-0.06\r +*DCW2,Domestic Cold Water __ _ ______ _ _____ _ ____\r +A,0.625,-0.03,0.04,-0.03\r +*DCWX2,Domestic Cold Water ________ ___ __________\r +A,2.5,-0.12,0.16,-0.12\r +*DHW,Domestic Hot Water ___ _ _ ___________ _ _ ____\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06\r +*DHW2,Domestic Hot Water __ _ _ _____ _ _ ____ _ _ __\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWX2,Domestic Hot Water _____ ___ ___ ___ _____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12\r +*DHWR,Domestic Hot Wtr Return _____ __ __ __ ________\r +A,1.25,-0.06,0.08,-0.06,0.08,-0.06,0.08,-0.06\r +*DHWR2,Domestic Hot Wtr Return ___ _ _ _ ____________\r +A,0.625,-0.03,0.04,-0.03,0.04,-0.03,0.04,-0.03\r +*DHWRX2,Domestic Hot Wtr Return ____ ___ ____ ____ ____\r +A,2.5,-0.12,0.16,-0.12,0.16,-0.12,0.16,-0.12\r +*VENT,Sanitary Vent Pipe __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*VENT2,Sanitary Vent Pipe _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*VENTX2,Sanitary Vent Pipe ____ ____ ____ ___\r +A,0.32,-0.16\r +*COND,Steam Condensate __ __ __ __ __ __ __ __ __ __ __\r +A,0.16,-0.08\r +*COND2,Steam Condensate _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\r +A,0.08,-0.04\r +*CONDX2,Steam Condensate ____ ____ ____ ____\r +A,0.32,-0.16\r +\r +;;; ISO LINTYPES\r +*DaL013,02b013 Dashed line 0.13mm\r +A,1.56,-0.39\r +*DaSpL013,03b013 Dashed space line 0.13mm\r +A,1.56,-2.34\r +*LDaDoL013,04b013 Long dashed dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39\r +*LDaDbDoL,05b013 Long dash double dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39\r +*LDaTrDoL,06b013 Long dashed triplicate dotted line 0.13mm \r +A,3.12,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*DoL013,07b013 Dotted line\r +A,0.065,-0.39\r +*LDaShDaL013,08b013 Long dashed short dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39\r +*09b013,Long dashed double-short-dashed line 0.13mm \r +A,3.12,-0.39,0.78,-0.39,0.78,-0.39\r +*10b013,Dashed dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39\r +*11b013,Double-dashed dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39\r +*12b013,Dashed double-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*13b013,Double-dashed double-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39\r +*14b013,Dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*15b013,Double-dashed triplicate-dotted line 0.13mm \r +A,1.56,-0.39,1.56,-0.39,0.065,-0.39,0.065,-0.39,0.065,-0.39\r +*02b018,Dashed line 0.18mm \r +A,2.16,-0.54\r +*03b018,Dashed space line 0.18mm \r +A,2.16,-3.24\r +*04b018,Long dashed dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54\r +*05b018,Long dash double dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54\r +*06b018,Long dashed triplicate dotted line 0.18mm \r +A,4.32,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*07b018,Lotted line\r +A,0.09,-0.54\r +*08b018,Long dashed short dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54\r +*09b018,Long dashed double-short-dashed line 0.18mm \r +A,4.32,-0.54,1.08,-0.54,1.08,-0.54\r +*10b018,Dashed dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54\r +*11b018,Double-dashed dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,.09,-0.54\r +*12b018,Dashed double-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*13b018,Double-dashed double-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54\r +*14b018,Dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*15b018,Double-dashed triplicate-dotted line 0.18mm \r +A,2.16,-0.54,2.16,-0.54,0.09,-0.54,0.09,-0.54,0.09,-0.54\r +*02b025,Dashed Line 0.25mm \r +A,3,-0.75\r +*03b025,Dashed space line 0.25mm \r +A,3,-4.5\r +*04b025,Long dashed dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75\r +*05b025,Long dash double dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75\r +*06b025,Long dashed triplicate dotted line 0.25mm \r +A,6,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*07b025,Dotted line 0.25 mm \r +A,0.125,-0.75\r +*08b025,Long dashed short dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75\r +*09b025,Long dashed double-short-dashed line 0.25mm \r +A,6,-0.75,1.5,-0.75,1.5,-0.75\r +*10b025,Dashed dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75\r +*11b025,Double-dashed dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75\r +*12b025,Dashed double-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75\r +*13b025,Double-dashed double-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75\r +*14b025,Dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*15b025,Double-dashed triplicate-dotted line 0.25mm \r +A,3,-0.75,3,-0.75,0.125,-0.75,0.125,-0.75,0.125,-0.75\r +*02b035,Dashed line 0.35mm \r +A,4.2,-1.05\r +*03b035,Dashed space line 0.35mm \r +A,4.2,-6.3\r +*04b035,Long dashed dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05\r +*05b035,Long dash double dotted line 0.35mm \r +A,8.4,-1.05,0.175,-1.05,0.175,-1.05\r +*06b035,Long dashed triplicate dotted line 0.35mm \r +A,8.4,-1.05,.175,-1.05,.175,-1.05,0.175,-1.05\r +*07b035,Dotted line 0.35mm \r +A,.175,-1.05\r +*08b035,Long dashed short dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05\r +*09b035,Long dashed double-short-dashed line 0.35mm \r +A,8.4,-1.05,2.1,-1.05,2.1,-1.05\r +*10b035,Lashed dotted line 0.35mm \r +A,4.2,-1.05,0.175,-1.05\r +*11b035,Double-dashed dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05\r +*12b035,Dashed double-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05\r +*13b035,Double-dashed double-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05\r +*14b035,Dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*15b035,Double-dashed triplicate-dotted line 0.35mm \r +A,4.2,-1.05,4.2,-1.05,.175,-1.05,.175,-1.05,.175,-1.05\r +*02b05,Dashed line 0.5mm \r +A,6,-1.5\r +*03b05,Dashed space line 0.5mm \r +A,6,-9\r +*04b05,Long dashed dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5\r +*05b05,Long dash double dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,0.25,-1.5\r +*06b05,Long dashed triplicate dotted line 0.5mm \r +A,12,-1.5,0.25,-1.5,.25,-1.5,0.25,-1.5\r +*07b05,Dotted line 0.5mm \r +A,0.25,-1.5\r +*08b05,Long dashed short dashed line 0.5mm \r +A,12,-1.5,3,-1.5\r +*09b05,Long dashed double-short-dashed line 0.5mm \r +A,12,-1.5,3,-1.5,3,-1.5\r +*10b05,Dashed dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5\r +*11b05,Double-dashed dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5\r +*12b05,Dashed double-dotted line 0.5mm \r +A,6,-1.5,.25,-1.5,0.25,-1.5\r +*13b05,Double-dashed double-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5\r +*14b05,Dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*15b05,Double-dashed triplicate-dotted line 0.5mm \r +A,6,-1.5,6,-1.5,0.25,-1.5,0.25,-1.5,0.25,-1.5\r +*02b07,Dashed Line 0.7mm \r +A,8.4,-2.1\r +*03b07,Dashed space line 0.7mm \r +A,8.4,-12.6\r +*04b07,Long dashed dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1\r +*05b07,Long dash double dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1\r +*06b07,Long dashed triplicate dotted line 0.7mm \r +A,16.8,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*07b07,Dotted line 0.7mm \r +A,0.35,-2.1\r +*08b07,Long dashed short dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1\r +*09b07,Long dashed double-short-dashed line 0.7mm \r +A,16.8,-2.1,4.2,-2.1,4.2,-2.1\r +*10b07,Dashed dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1\r +*11b07,Double-dashed dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1\r +*12b07,Dashed double-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*13b07,Double-dashed double-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1\r +*14b07,Dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*15b07,Double-dashed triplicate-dotted line 0.7mm \r +A,8.4,-2.1,8.4,-2.1,0.35,-2.1,0.35,-2.1,0.35,-2.1\r +*02b1,Dashed Line 1mm \r +A,12,-3\r +*03b1,Dashed space line 1mm \r +A,12,-18\r +*04b1,Long dashed dotted line 1mm \r +A,24,-3,.5,-3\r +*05b1,Long dash double dotted line 1mm \r +A,24,-3,.5,-3,.5,-3\r +*06b1,Long dashed triplicate dotted line 1mm \r +A,24,-3,.5,-3,.5,-3,.5,-3\r +*07b1,Dotted line\r +A,.5,-3\r +*08b1,Long dashed short dashed line 1mm \r +A,24,-3,6,-3\r +*09b1,Long dashed double-short-dashed line 1mm \r +A,24,-3,6,-3,6,-3\r +*10b1,Dashed dotted line 1mm \r +A,12,-3,.5,-3\r +*11b1,Double-dashed dotted line 1mm \r +A,12,-3,12,-3,0.5,-3\r +*12b1,Dashed double-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3\r +*13b1,Double-dashed double-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,0.5,-3\r +*14b1,Dashed triplicate-dotted line 1mm \r +A,12,-3,0.5,-3,0.5,-3,0.5,-3\r +*15b1,Double-dashed triplicate-dotted line 1mm \r +A,12,-3,12,-3,0.5,-3,.5,-3,0.5,-3\r +*02b14,Dashed Line 1.4mm \r +A,16.8,-4.2\r +*03b14,Dashed space line 1.4mm \r +A,16.8,25.2\r +*04b14,Long dashed dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2\r +*05b14,Long dash double dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2\r +*06b14,Long dashed triplicate dotted line 1.4mm \r +A,33.6,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*07b14,Dotted line 1.4mm \r +A,.7,-4.2\r +*08b14,Long dashed short dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2\r +*09b14,Long dashed double-short-dashed line 1.4mm \r +A,33.6,-4.2,8.4,-4.2,8.4,-4.2\r +*10b14,Dashed dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2\r +*11b14,Double-dashed dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2\r +*12b14,Dashed double-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2\r +*13b14,Double-dashed double-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2\r +*14b14,Dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*15b14,Double-dashed triplicate-dotted line 1.4mm \r +A,16.8,-4.2,16.8,-4.2,.7,-4.2,.7,-4.2,.7,-4.2\r +*02b2,Dashed Line 2mm \r +A,24,-6\r +*03b2,Dashed space line 2mm \r +A,24,-36\r +*04b2,Long dashed dotted line 2mm \r +A,48,-6,1,-6\r +*05b2,Long dash double dotted line 2mm \r +A,48,-6,1,-6,1,-6\r +*06b2,Long dashed triplicate dotted line 2mm \r +A,48,-6,1,-6,1,-6,1,-6\r +*07b2,Dotted line 2mm \r +A,1,-6\r +*08b2,Long dashed short dashed line 2mm \r +A,48,-6,12,-6\r +*09b2,Long dashed double-short-dashed line 2mm \r +A,48,-6,12,-6,12,-6\r +*10b2,Dashed dotted line 2mm \r +A,24,-6,1,-6\r +*11b2,Double-dashed dotted line 2mm \r +A,24,-6,24,-6,1,-6\r +*12b2,Dashed double-dotted line 2mm \r +A,24,-6,1,-6,1,-6\r +*13b2,Double-dashed double-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6\r +*14b2,Dashed triplicate-dotted line 2mm \r +A,24,-6,1,-6,1,-6,1,-6\r +*15b2,Double-dashed triplicate-dotted line 2mm \r +A,24,-6,24,-6,1,-6,1,-6,1,-6\r +;; Complex linetypes using standard style\r +*FENCELINE1,Fenceline_circle ----0-----0----0-----0----0-----0--\r +A,.25,-.1,[CIRC1,ltypeshp.shx,x=-.1,s=.1],-.1,.1\r +*FENCELINE2,Fenceline square ----[]-----[]----[]-----[]----[]---\r +A,.25,-.1,[BOX,ltypeshp.shx,x=-.1,s=.1],-.1,1\r +*TRACKS,Tracks -|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-|-\r +A,.15,[TRACK1,ltypeshp.shx,s=.25],.15\r +*MAP,Map line ----MAP----MAP----MAP----MAP----MAP---- \r +A,.5,-.2,["MAP",STANDARD,S=.1,R=0.0,X=-0.1,Y=-.05],-.25\r +*BATTING,Batting SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS\r +A,.0001,-.1,[BAT,ltypeshp.shx,x=-.1,s=.1],-.2,[BAT,ltypeshp.shx,r=180,x=.1,s=.1],-.1\r +*ZIGZAG,Zig zag /\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\\/\r +A,.0001,-.2,[ZIG,ltypeshp.shx,x=-.2,s=.2],-.4,[ZIG,ltypeshp.shx,r=180,x=.2,s=.2],-.2\r +*HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----\r +A,12.7,-5.08,["HW",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +*GAS_LINE,Gas line ----GAS----GAS----GAS----GAS----GAS----GAS--\r +A,.5,-.2,["GAS",STANDARD,S=.1,U=0.0,X=-0.1,Y=-.05],-.25\r +*SMILEYS,Smiley line ---- :^) ---- 8) ---- :^) ----\r +A,12.7,-5.08,[":^)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08,12.7,-5.08,["8)",STANDARD,S=2.54,R=0.0,X=-2.54,Y=-1.27],-5.08\r +\r +;------------Slope--------------\r +*SLOPE,1B 1S |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE-D, 1B 1S Double |-|-|-|-|-|-|-|-|-|-|-|-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2, 1B 2S ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE2-D, 1B 2S Double ||-||-||-||-||-||-||-||-||-||-||-||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3, 1B 3S |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE3-D, 1B 3S Double |||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-|||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4, 1B 4S ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE4-D, 1B 4S Double ||||-||||-||||-||||-||||-||||-||||-||||-||||-||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5, 1B 5S |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=0.52,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +*SLOPE5-D, 1B 5S Double |||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-|||||-\r +A,0.13,[TRACK1,ltypeshp.shx,S=1.04,R=0.0,X=0,Y=1.04],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.52],0.26,[TRACK1,ltypeshp.shx,S=0.26,R=0.0,X=0,Y=0.26],0.13\r +\r +;------------Alphabets--------------\r +*Letter A, ---- A ---- A ---- A ---- A ---- A ----\r +A,1.0,-0.5,["A",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter B, ---- B ---- B ---- B ---- B ---- B ----\r +A,1.0,-0.5,["B",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter C,---- C ---- C ---- C ---- C ---- C ----\r +A,1.0,-0.5,["C",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter D, ---- D ---- D ---- D ---- D ---- D ----\r +A,1.0,-0.5,["D",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter E, ---- E ---- E ---- E ---- E ---- E ----\r +A,1.0,-0.5,["E",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter F, ---- F ---- F ---- F ---- F ---- F ----\r +A,1.0,-0.5,["F",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter G, ---- G ---- G ---- G ---- G ---- G ----\r +A,1.0,-0.5,["G",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter H, ---- H ---- H ---- H ---- H ---- H ----\r +A,1.0,-0.5,["H",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter I, ---- I ---- I ---- I ---- I ---- I ----\r +A,1.0,-0.5,["I",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter J, ---- J ---- J ---- J ---- J ---- J ----\r +A,1.0,-0.5,["J",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter K, ---- K ---- K ---- K ---- K ---- K ----\r +A,1.0,-0.5,["K",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter L, ---- L ---- L ---- L ---- L ---- L ----\r +A,1.0,-0.5,["L",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter M, ---- M ---- M ---- M ---- M ---- M ----\r +A,1.0,-0.5,["M",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter N, ---- N ---- N ---- N ---- N ---- N ----\r +A,1.0,-0.5,["N",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter O, ---- O ---- O ---- O ---- O ---- O ----\r +A,1.0,-0.5,["O",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter P, ---- P ---- P ---- P ---- P ---- P ----\r +A,1.0,-0.5,["P",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Q, ---- Q ---- Q ---- Q ---- Q ---- Q ----\r +A,1.0,-0.5,["Q",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter R, ---- R ---- R ---- R ---- R ---- R ----\r +A,1.0,-0.5,["R",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter S, ---- S ---- S ---- S ---- S ---- S ----\r +A,1.0,-0.5,["S",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter T, ---- T ---- T ---- T ---- T ---- T ----\r +A,1.0,-0.5,["T",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter U, ---- U ---- U ---- U ---- U ---- U ----\r +A,1.0,-0.5,["U",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter V, ---- V ---- V ---- V ---- V ---- V ----\r +A,1.0,-0.5,["V",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter W, ---- W ---- W ---- W ---- W ---- W ----\r +A,1.0,-0.5,["W",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter X, ---- X ---- X ---- X ---- X ---- X ----\r +A,1.0,-0.5,["X",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Y, ---- Y ---- Y ---- Y ---- Y ---- Y ----\r +A,1.0,-0.5,["Y",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Letter Z, ---- Z ---- Z ---- Z ---- Z ---- Z ----\r +A,1.0,-0.5,["Z",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +;------------Numericals--------------\r +*Numbers 0, ---- 0 ---- 0 ---- 0 ---- 0 ---- 0 ----\r +A,1.0,-0.5,["0",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 1, ---- 1 ---- 1 ---- 1 ---- 1 ---- 1 ----\r +A,1.0,-0.5,["1",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 2, ---- 2 ---- 2 ---- 2 ---- 2 ---- 2 ----\r +A,1.0,-0.5,["2",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 3, ---- 3 ---- 3 ---- 3 ---- 3 ---- 3 ----\r +A,1.0,-0.5,["3",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 4, ---- 4 ---- 4 ---- 4 ---- 4 ---- 4 ----\r +A,1.0,-0.5,["4",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 5, ---- 5 ---- 5 ---- 5 ---- 5 ---- 5 ----\r +A,1.0,-0.5,["5",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 6, ---- 6 ---- 6 ---- 6 ---- 6 ---- 6 ----\r +A,1.0,-0.5,["6",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 7, ---- 7 ---- 7 ---- 7 ---- 7 ---- 7 ----\r +A,1.0,-0.5,["7",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 8, ---- 8 ---- 8 ---- 8 ---- 8 ---- 8 ----\r +A,1.0,-0.5,["8",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +*Numbers 9, ---- 9 ---- 9 ---- 9 ---- 9 ---- 9 ----\r +A,1.0,-0.5,["9",standard,S=1,R=0,X=0,Y=-0.5],-1.5\r +\r +\r +`,pA=`;; ------------------------------------�� �� �� ��------------------------------------\r +;; �� �� ���� ���� ����(KOSDIC.lin)�� �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ���� �� ��Ͽ� ���ǵ� �� ������\r +;; AutoCAD ����ڿ��� �����ϱ� ���� ���۵Ǿ����ϴ�.\r +;; \r +;; ǥ�ع��� : �Ǽ�CALS/EC ���ڵ��� �ۼ�ǥ�� V1.1(2006.12)\r +;; ������� : �Ǽ�CALS/EC ������ �ѱ��Ǽ����������\r +;;\r +;; �����Ģ : 1/1 ��ô�� ����ũ�� 2.0mm�� ��� ������ ũ�⸦ ������\r +;; LIB ��Ģ : AutoCAD�� ANSI����(���� ��������� ����)�� ����Ű ���� 1/10�� ������\r +;; (��) ���� �� ���� ������ 2mm�̸� 0.2unit�� ����\r +;; ����Ģ : �ǹ����鿡 ����� ��� �������� ��Ģ�� ���յǷ��� ��������ô�� 10�踦 ������\r +;; (��) LTSCALE=10 (���� 8~10��), ������ô�� 1/5 �̸� LTSCALE=5x10��=50\r +;;\r +;; ISO���� �԰� 15��\r +// ���� AutoCAD ISO�� 25.4����� ������ �� ����\r +*A-ISONS01,ISO �����԰� 01 Continuous ________________________________\r +A,1,1\r +*A-ISONS02,ISO �����԰� 02 dash __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.47244,-.118111\r +*A-ISONS03,ISO �����԰� 03 dash space __ __ __ __ __ __\r +A,.47244,-.7086614\r +*A-ISONS04,ISO �����԰� 04 long-dash dot ____ . ____ . ____ . ____ . _\r +A,.94488,-.11811,0,-.11811\r +*A-ISONS05,ISO �����԰� 05 long-dash double-dot ____ .. ____ .. ____ . \r +A,.94488,-.11811,0,-.11811,0,-.11811\r +*A-ISONS06,ISO �����԰� 06 long-dash triple-dot ____ ... ____ ... ____\r +A,.94488,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS07,ISO �����԰� 07 dot . . . . . . . . . . . . . . . . . . . . \r +A,0,-.11811\r +*A-ISONS08,ISO �����԰� 08 long-dash short-dash ____ __ ____ __ ____ _\r +A,.94488,-.11811,.94488,-.11811\r +*A-ISONS09,ISO �����԰� 09 long-dash double-short-dash ____ __ __ ____\r +A,.94488,-.11811,.94488,-.11811,.94488,-.11811\r +*A-ISONS10,ISO �����԰� 10 dash dot __ . __ . __ . __ . __ . __ . __ . \r +A,.47244,-.11811,0,-.11811\r +*A-ISONS11,ISO �����԰� 11 double-dash dot __ __ . __ __ . __ __ . __ _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811\r +*A-ISONS12,ISO �����԰� 12 dash double-dot __ . . __ . . __ . . __ . . \r +A,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS13,ISO �����԰� 13 double-dash double-dot __ __ . . __ __ . . _\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811\r +*A-ISONS14,ISO �����԰� 14 dash triple-dot __ . . . __ . . . __ . . . _\r +A,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +*A-ISONS15,ISO �����԰� 15 double-dash triple-dot __ __ . . . __ __ . .\r +A,.47244,-.11811,.47244,-.11811,0,-.11811,0,-.11811,0,-.11811\r +\r +;; ���CAD ����\r +*A-BORDR01,�ܰ���(�Ϲ�) Border __ __ . __ __ . __ __ . __ __ . __ __ .\r +A,.5,-.25,.5,-.25,0,-.25\r +*A-BORDR01H,�ܰ���(�ݹ��) Border (.5x) __.__.__.__.__.__.__.__.__.__.__.\r +A,.25,-.125,.25,-.125,0,-.125\r +*A-BORDR01X,�ܰ���(���) Border (2x) ____ ____ . ____ ____ . ___\r +A,1.0,-.5,1.0,-.5,0,-.5\r +*A-CENTR01,�߽ɼ�(�Ϲ�) Center ____ _ ____ _ ____ _ ____ _ ____ _ ____\r +A,1.25,-.25,.25,-.25\r +*A-CENTR01H,�߽ɼ�(�ݹ��) Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___\r +A,.75,-.125,.125,-.125\r +*A-CENTR01X,�߽ɼ�(���) Center (2x) ________ __ ________ __ _____\r +A,2.5,-.5,.5,-.5\r +*A-DASDT01,�Ĵ�����(�Ϲ�) Dash dot __ . __ . __ . __ . __ . __ . __ . __\r +A,.5,-.25,0,-.25\r +*A-DASDT01H,�Ĵ�����(�ݹ��) Dash dot (.5x) _._._._._._._._._._._._._._._.\r +A,.25,-.125,0,-.125\r +*A-DASDT01X,�Ĵ�����(���) Dash dot (2x) ____ . ____ . ____ . ___\r +A,1.0,-.5,0,-.5\r +*A-DASHD01,�ļ�(�Ϲ�) Dashed __ __ __ __ __ __ __ __ __ __ __ __ __ _\r +A,.5,-.25\r +*A-DASHD01H,�ļ�(�ݹ��) Dashed (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.25,-.125\r +*A-DASHD01X,�ļ�(���) Dashed (2x) ____ ____ ____ ____ ____ ___\r +A,1.0,-.5\r +*A-DIVID01,���Ҽ�(�Ϲ�) Divide ____ . . ____ . . ____ . . ____ . . ____\r +A,.5,-.25,0,-.25,0,-.25\r +*A-DIVID01H,���Ҽ�(�ݹ��) Divide (.5x) __..__..__..__..__..__..__..__.._\r +A,.25,-.125,0,-.125,0,-.125\r +*A-DIVID01X,���Ҽ�(���) Divide (2x) ________ . . ________ . . _\r +A,1.0,-.5,0,-.5,0,-.5\r +*A-DOTLN01,����(�Ϲ�) Dot . . . . . . . . . . . . . . . . . . . . . . . .\r +A,0,-.25\r +*A-DOTLN01H,����(�ݹ��) Dot (.5x) ........................................\r +A,0,-.125\r +*A-DOTLN01X,����(���) Dot (2x) . . . . . . . . . . . . . .\r +A,0,-.5\r +*A-HIDDN01,������(�Ϲ�) Hidden __ __ __ __ __ __ __ __ __ __ __ __ __ __\r +A,.25,-.125\r +*A-HIDDN01H,������(�ݹ��) Hidden (.5x) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \r +A,.125,-.0625\r +*A-HIDDN01X,������(���) Hidden (2x) ____ ____ ____ ____ ____ ____ ____ \r +A,.5,-.25\r +*A-PHATM01,����(�Ϲ�) Phantom ______ __ __ ______ __ __ ______ \r +A,1.25,-.25,.25,-.25,.25,-.25\r +*A-PHATM01H,����(�ݹ��) Phantom (.5x) ___ _ _ ___ _ _ ___ _ _ ___ _ _\r +A,.625,-.125,.125,-.125,.125,-.125\r +*A-PHATM01X,����(���) Phantom (2x) ____________ ____ ____ _\r +A,2.5,-.5,.5,-.5,.5,-.5\r +\r +;; �潺�ü�\r +*E-FENCE01,�潺(X �ļ�)\r +A,.85,-.15,[KSC11,kosdic.shx,s=.1],-.15,.85\r +*E-FENCE02,�潺(X �Ǽ�)\r +A,1.0,[KSC11,kosdic.shx,s=.1],1.0\r +*E-FENCE03,�潺(/\\ �ļ�)\r +A,.875,-.05,[KSC12,kosdic.shx,s=.1],-.2,.875\r +*E-FENCE04,�潺(+ �ļ�)\r +A,.85,-.15,[KSC15,kosdic.shx,s=.1],-.15,.85\r +\r +;; �������\r +*E-UTIL01,����(| �Ǽ�)\r +A,1.0,[KSC01,kosdic.shx,s=.1],1.0\r +*E-UTIL02,����(|| �ļ�)\r +A,.05,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],1.85\r +*E-UTIL03,����(|| �Ǽ�)\r +A,.95,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.95\r +*E-UTIL04,����(||| �ļ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],-.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL05,����(||| �Ǽ�)\r +A,.9,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.1,[KSC01,kosdic.shx,s=.1],.9\r +*E-UTIL06,����(/ �ļ�)\r +A,.9,-.1,[KSC02,kosdic.shx,s=.1],-.1,.9\r +*E-UTIL07,����(/ �Ǽ�)\r +A,1.0,[KSC02,kosdic.shx,s=.1],1.0\r +*E-UTIL08,����(// �ļ�)\r +A,.85,-.15,[KSC05,kosdic.shx,s=.1],-.15,.85\r +*E-UTIL09,����(// �Ǽ�)\r +A,1.0,[KSC05,kosdic.shx,s=.1],1.0\r +*E-UTIL10,����(/// �ļ�)\r +A,.8,-.2,[KSC06,kosdic.shx,s=.1],-.2,.8\r +*E-UTIL11,����(/// �Ǽ�)\r +A,1.0,[KSC06,kosdic.shx,s=.1],1.0\r +\r +;; �ü�����\r +*E-FACLN01,�ü�(- ���༱)\r +A,.25,[KSC01,kosdic.shx,y=-.05,s=.1,r=270],.25\r +*E-FACLN02,�ü�(= ���༱)\r +A,.25,[KSC04,kosdic.shx,y=-.05,s=.1],.25\r +*E-FACLN03,�ü�(O �ļ�)\r +A,.85,[KSC31,kosdic.shx,x=.075,s=.075],-.15,1.0\r +*E-FACLN04,�ü�(O �Ǽ�)\r +A,1.0,[KSC31,kosdic.shx,s=.075],1.0\r +*E-FACLN05,�ü�(��,����Ʈ)\r +A,1.0,[KSC32,kosdic.shx,s=.075],1.0\r +\r +;; ��������\r +*E-TOPOG01,����(�� �ļ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.25\r +*E-TOPOG02,����(�� �Ǽ�)\r +A,.000002,[KSC16,kosdic.shx,s=.1],-.2\r +*E-TOPOG03,����(| �Ǽ�)\r +A,0,-.1,[KSC15,kosdic.shx,s=.1],-.1\r +*E-TOPOG04,����(| ����)\r +A,0,[KSC00,kosdic.shx,y=.1,s=.1],.2,[KSC00,kosdic.shx,s=.1],.2\r +*E-TOPOG05,����(~. ����)\r +A,.000005,[KSC1C,kosdic.shx,s=.1],-.45,[KSC30,kosdic.shx,s=.1],-.05\r +\r +;; ������� ����\r +*B-ZIGZG01,�������(��)\r +A,.000002,[KSC13,kosdic.shx,s=.1],-.2\r +*B-ZIGZG02,�������(ȣ)\r +A,.000002,[KSC1B,kosdic.shx,s=.1],-.2\r +*C-ZIGZG01,�������(�Ǽ�,��)\r +A,.1,[KSC13,kosdic.shx,s=.1],.1\r +*C-ZIGZG02,�������(�Ǽ�,ȣ)\r +A,.1,[KSC1B,kosdic.shx,s=.1],.1\r +\r +;; ���� �� ����\r +*D-SWALL01,����(�ű�)\r +A,0,[KSC61,kosdic.shx,y=-.1,s=.1],-.2\r +*X-SWALL01,����(����)\r +A,0,[KSC71,kosdic.shx,s=.1],-.4\r +*D-BWALL01,���ϴ�(����)\r +A,0,[KSC18,kosdic.shx,s=.1],-.25\r +*D-BWALL02,���ϴ�(�ű�)\r +A,.000005,[KSC3A,kosdic.shx,s=.05],-.1,[KSC3A,kosdic.shx,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.1,[KSC04,kosdic.shx,y=-.025,s=.05],-.05\r +\r +;; ��/�����迭\r +*E-DOTLN01,���ҹ迭\r +A,0,[KSC30,kosdic.shx,s=.3],-.15\r +*E-DOTLN02,���ҹ迭(��)\r +A,.075,[KSC30,kosdic.shx,s=.3],.075\r +*E-CIRCL01,�����������Ϲ迭\r +A,0,[KSC31,kosdic.shx,s=.1],-.2\r +*E-CIRCL02,ä��������Ϲ迭\r +A,0,[KSC32,kosdic.shx,s=.1],-.2\r +*D-RROAD01,ö��(����)\r +A,0,[KSC3A,kosdic.shx,s=.1],-.2,[KSC04,kosdic.shx,y=-.05,s=.1],-.2\r +\r +;; ������\r +*E-DIGLN01,������\r +A,.9,-.2,[KSC19,kosdic.shx,s=.1,r=180],.9\r +*E-DIGLN01H,������(�ݹ��)\r +A,.45,-.1,[KSC19,kosdic.shx,s=.05,r=180],.45\r +*E-DIGLN01X,������(���)\r +A,1.8,-.4,[KSC19,kosdic.shx,s=.2,r=180],1.8\r +\r +;; ���\r +*B-GREEN01,����/�����\r +A,.000002,[KSC08,kosdic.shx,s=.1],-.2\r +*B-GREEN02,�����\r +A,0,[KSC21,kosdic.shx,s=.1],-.45\r +*E-BOUND01,�������\r +A,.875,[KSC60,kosdic.shx,s=.1],-.25,.875\r +\r +;; ��Ÿ\r +*B-RANDM01,�ұ�Ģ��\r +A,0,[KSC1A,kosdic.shx,s=.1],-.2\r +*E-DEMOL01,ö�Ŵ��\r +A,.075,[KSC01,kosdic.shx,s=.1,r=30],.075\r +*X-EARTH01,���ݼ�\r +A,0,[KSC20,kosdic.shx,s=.1,x=.25,r=180],.25\r +\r +;; ���ܼ�\r +*E-CUTLN01,���ܼ�(��)\r +A,.95,[KSC14,kosdic.shx,s=.1],-.1,.95\r +*E-CUTLN02,���ܼ�(ȣ)\r +A,.95,[KSC22,kosdic.shx,s=.1],-.1,.95\r +\r +;; ���帧 ����\r +*E-WFLOW01,���帧(��, �ļ�)\r +A,.6,[KSC36,kosdic.shx,s=.1],-.65\r +*E-WFLOW02,���帧(��, �Ǽ�)\r +A,1.5,[KSC36,kosdic.shx,s=.1],0\r +*E-WFLOW03,���帧(ȭ��, �ļ�)\r +A,.6,[KSC35,kosdic.shx,s=.1],-.65\r +*E-WFLOW04,���帧(ȭ��, �Ǽ�)\r +A,1.5,[KSC35,kosdic.shx,s=.1],0\r +\r +;; ���������\r +*G-WATER01,���������(W ����)\r +A,2.933333,["W",Standard,y=.05,s=.2],.066667\r +*G-WATER02,���������(W �ļ�)\r +A,2.75,-.05,["W",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; �¼�����\r +*G-HWATR01,�¼�����(HWL ����)\r +A,2.783629,["HWL",Standard,y=.05,s=.2],.216371\r +*G-HWATR02,�¼�����(HWL �ļ�)\r +A,2.35,-.05,["HWL",Standard,y=-.1,s=.2],-.6\r +\r +;; �ü�����\r +*G-CWATR01,�ü�����(CWL ����)\r +A,2.783629,["CWL",Standard,y=.05,s=.2],.216371\r +*G-CWATR02,�ü�����(CWL �ļ�)\r +A,2.35,-.05,["CWL",Standard,y=-.1,s=.2],-.6\r +\r +;; ��������\r +*E-SEWER01,��������(����)\r +A,.95,-.1,[KSC09,kosdic.shx,s=.1,r=180],.95\r +*E-SEWER01H,��������(����,�ݹ��)\r +A,.475,-.05,[KSC09,kosdic.shx,s=.05,r=180],.475\r +*E-SEWER01X,��������(����,���)\r +A,1.9,-.2,[KSC09,kosdic.shx,s=.2,r=180],1.9\r +*G-SEWER01,��������(S ����)\r +A,2.933333,["S",Standard,y=.05,s=.2],.066667\r +*G-SEWER02,��������(S �ļ�)\r +A,2.75,-.05,["S",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��ż���\r +*G-TELCM01,��ż���(T ����)\r +A,2.933333,["T",Standard,y=.05,s=.2],.066667\r +*G-TELCM02,��ż���(T �ļ�)\r +A,2.75,-.05,["T",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ���⼱��\r +*G-ELECT01,���⼱��(E ����)\r +A,2.933333,["E",Standard,y=.05,s=.2],.066667\r +*G-ELECT02,���⼱��(E �ļ�)\r +A,2.75,-.05,["E",Standard,y=-.1,s=.2,r=360],-.2\r +\r +;; ��������\r +*G-GASLN01,��������(G ����)\r +A,2.933333,["G",Standard,y=.05,s=.2],.066667\r +*G-GASLN02,��������(G �ļ�)\r +A,2.75,-.05,["G",Standard,y=-.1,s=.2,r=360],-.2\r +*G-GASLN03,��������(GAS ����)\r +A,2.783629,["GAS",Standard,y=.05,s=.2],.216371\r +*G-GASLN04,��������(GAS �ļ�)\r +A,2.35,-.05,["GAS",Standard,y=-.1,s=.2],-.6\r +\r +;; �Ϲ�������\r +;; *CAL421,PIPE\r +;; A,2.733333,["PIPE",Standard,y=.05,s=.2],.266667\r +*G-PIPEL01,�Ϲ� ������(PIPE �ļ�)\r +A,3.25,-.05,["PIPE",Standard,y=-.1,s=.2],-.7\r +\r +;; �������\r +*H-DICHT00,�������\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["T",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHT00R,�������(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["T",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; L������\r +*H-DICHL00,L������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["L",Standard,y=-.1,s=.2],-.216667\r +*H-DICHL00R,L������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["L",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL01,L������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHL01R,L������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["L1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL02,L������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL02R,L������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL03,L������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL03R,L������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL04,L������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL04R,L������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL05,L������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL05R,L������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL06,L������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL06R,L������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL07,L������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL07R,L������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL08,L������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["L8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHL08R,L������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["L8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL09,L������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L9",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHL09R,L������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["L9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHL10,L������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["L10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-DICHL10R,L������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["L10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHL11,L������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["L11",Standard,y=-.1,s=.2],-.55\r +*H-DICHL11R,L������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["L11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHL12,L������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL12R,L������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL13,L������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["L13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHL13R,L������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL14,L������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL14R,L������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["L14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHL15,L������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["L15",Standard,y=-.1,s=.2],-.583333\r +*H-DICHL15R,L������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["L15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; U������\r +*H-DICHU00,U������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["U",Standard,y=-.1,s=.2],-.216667\r +*H-DICHU00R,U������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["U",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU01,U������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["U1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHU01R,U������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["U1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU02,U������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU02R,U������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU03,U������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["U3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHU03R,U������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU04,U������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU04R,U������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU05,U������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU05R,U������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU06,U������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U6",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU06R,U������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU07,U������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U7",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU07R,U������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU08,U������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U8",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU08R,U������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU09,U������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["U9",Standard,y=-.1,s=.2],-.416667\r +*H-DICHU09R,U������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["U9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHU10,U������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.383333,["U10",Standard,y=-.1,s=.2],-.566667\r +*H-DICHU10R,U������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["U10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-DICHU11,U������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.4,["U11",Standard,y=-.1,s=.2],-.55\r +*H-DICHU11R,U������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.8,["U11",Standard,y=.1,s=.2,r=180],-.15\r +*H-DICHU12,U������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U12",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU12R,U������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U12",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU13,U������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U13",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU13R,U������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U13",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU14,U������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["U14",Standard,y=-.1,s=.2],-.583333\r +*H-DICHU14R,U������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.833333,["U14",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHU15,U������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["U15",Standard,y=-.1,s=.2,r=360],-.583333\r +*H-DICHU15R,U������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["U15",Standard,y=.1,s=.2,r=180],-.116667\r +\r +;; V������\r +*H-DICHV00,V������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V",Standard,y=-.1,s=.2,r=360],-.25\r +*H-DICHV00R,V������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.5,["V",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV01,V������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V1",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHV01R,V������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["V1",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV02,V������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.3,["V2",Standard,y=-.1,s=.2],-.45\r +*H-DICHV02R,V������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V2",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV03,V������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V3",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV03R,V������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V3",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV04,V������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V4",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV04R,V������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V4",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV05,V������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V5",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV05R,V������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V5",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV06,V������ ����06\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V6",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV06R,V������ ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.25,0,-.45,["V6",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV07,V������ ����07\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V7",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV07R,V������ ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V7",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV08,V������ ����08\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V8",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV08R,V������ ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.7,["V8",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV09,V������ ����09\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.3,["V9",Standard,y=-.1,s=.2,r=360],-.45\r +*H-DICHV09R,V������ ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.7,["V9",Standard,y=.1,s=.2,r=180],-.05\r +*H-DICHV10,V������ ����10\r +A,.7,[KSC35,kosdic.shx,s=.1],-.35,["V10",Standard,y=-.1,s=.2],-.6\r +*H-DICHV10R,V������ ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.85,["V10",Standard,y=.1,s=.2,r=180],-.1\r +*H-DICHV11,V������ ����11\r +A,.7,[KSC35,kosdic.shx,s=.1],-.366667,["V11",Standard,y=-.1,s=.2],-.583333\r +*H-DICHV11R,V������ ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.833333,["V11",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHV12,V������ ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["V12",Standard,y=-.1,s=.2,r=360],-.616667\r +*H-DICHV12R,V������ ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V12",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV13,V������ ����13\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V13",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV13R,V������ ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V13",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV14,V������ ����14\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V14",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV14R,V������ ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V14",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHV15,V������ ����15\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["V15",Standard,y=-.1,s=.2],-.616667\r +*H-DICHV15R,V������ ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["V15",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; ����ũ\r +*H-DICHD00,����ũ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-DICHD00R,����ũ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["D",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD01,����ũ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["D1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHD01R,����ũ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.633333,["D1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHD02,����ũ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["D2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHD02R,����ũ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD03,����ũ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD03R,����ũ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD04,����ũ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD04R,����ũ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["D4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHD05,����ũ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["D5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHD05R,����ũ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["D5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �긶�� ����\r +*H-DICHB00,�긶������ ����00\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B",Standard,y=-.1,s=.2],-.216667\r +*H-DICHB00R,�긶������ ����00(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.766667,["B",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB01,�긶������ ����01\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.666667,["B1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHB01R,�긶������ ����01(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.933333,["B1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHB02,�긶������ ����02\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB02R,�긶������ ����02(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB03,�긶������ ����03\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB03R,�긶������ ����03(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB04,�긶������ ����04\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB04R,�긶������ ����04(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHB05,�긶������ ����05\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.633333,["B5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHB05R,�긶������ ����05(����)\r +A,.00001,[KSC52,kosdic.shx,s=.1],-.966667,["B5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �;ϰ�\r +*H-DICHM00,�;ϰ� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["M",Standard,y=-.1,s=.2],-.216667\r +*H-DICHM00R,�;ϰ� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["M",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM01,�;ϰ� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.366667,["M1",Standard,y=-.1,s=.2,r=360],-.383333\r +*H-DICHM01R,�;ϰ� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["M1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHM02,�;ϰ� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM02R,�;ϰ� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["M2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM03,�;ϰ� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM03R,�;ϰ� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM04,�;ϰ� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM04R,�;ϰ� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHM05,�;ϰ� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["M5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHM05R,�;ϰ� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["M5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �������\r +*H-DICHO00,������� ����00\r +A,.7,[KSC35,kosdic.shx,s=.1],-.333333,["L/O",Standard,y=-.1,s=.2],-.616667\r +*H-DICHO00R,������� ����00(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.866667,["L/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO01,������� ����01\r +A,.5,[KSC35,kosdic.shx,s=.1],-.366667,["L1/O",Standard,y=-.1,s=.2],-.783333\r +*H-DICHO01R,������� ����01(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.033333,["L1/O",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHO02,������� ����02\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L2/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO02R,������� ����02(����)\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-1.066667,["L2/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO03,������� ����03\r +A,.5,[KSC35,kosdic.shx,s=.1],-.333333,["L3/O",Standard,y=-.1,s=.2],-.816667\r +*H-DICHO03R,������� ����03(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L3/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO04,������� ����04\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L4/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO04R,������� ����04(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L4/O",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHO05,������� ����05\r +A,.5,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["L5/O",Standard,y=-.1,s=.2,r=360],-.816667\r +*H-DICHO05R,������� ����05(����)\r +A,.5,[KSC35,kosdic.shx,s=.1],-1.066667,["L5/O",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �Ҵ�����\r +*H-DICHG00,�Ҵ����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["G",Standard,y=-.1,s=.2],-.216667\r +*H-DICHG00R,�Ҵ����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["G",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG01,�Ҵ����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["G1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHG01R,�Ҵ����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["G1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHG02,�Ҵ����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG02R,�Ҵ����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG03,�Ҵ����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G3",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG03R,�Ҵ����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG04,�Ҵ����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["G4",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHG04R,�Ҵ����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHG05,�Ҵ����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["G5",Standard,y=-.1,s=.2],-.416667\r +*H-DICHG05R,�Ҵ����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["G5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; J������\r +*H-DICHJ00,J������ ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.333333,["J",Standard,y=-.1,s=.2],-.216667\r +*H-DICHJ00R,J������ ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["J",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ01,J������ ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["J1",Standard,y=-.1,s=.2],-.383333\r +*H-DICHJ01R,J������ ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["J1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-DICHJ02,J������ ����02\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J2",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ02R,J������ ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ03,J������ ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J3",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ03R,J������ ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ04,J������ ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["J4",Standard,y=-.1,s=.2],-.416667\r +*H-DICHJ04R,J������ ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-DICHJ05,J������ ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["J5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-DICHJ05R,J������ ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["J5",Standard,y=.1,s=.2,r=180],-.083333\r +\r +;; �����\r +*H-CANAL00,����� ����00\r +A,1.1,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y",Standard,y=-.1,s=.2,r=360],-.216667\r +*H-CANAL00R,����� ����00(����)\r +A,1.1,[KSC35,kosdic.shx,s=.1],-.466667,["Y",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL01,����� ����01\r +A,.9,[KSC35,kosdic.shx,s=.1],-.366667,["Y1",Standard,y=-.1,s=.2],-.383333\r +*H-CANAL01R,����� ����01(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.633333,["Y1",Standard,y=.1,s=.2,r=180],-.116667\r +*H-CANAL02,����� ����02\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y2",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL02R,����� ����02(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y2",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL03,����� ����03\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y3",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL03R,����� ����03(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y3",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL04,����� ����04\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y4",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL04R,����� ����04(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y4",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL05,����� ����05\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.333333,["Y5",Standard,y=-.1,s=.2,r=360],-.416667\r +*H-CANAL05R,����� ����05(����)\r +A,.9,[KSC35,kosdic.shx,s=.1,r=360],-.666667,["Y5",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL06,����� ����06\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y6",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL06R,����� ����06(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y6",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL07,����� ����07\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y7",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL07R,����� ����07(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y7",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL08,����� ����08\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y8",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL08R,����� ����08(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y8",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL09,����� ����09\r +A,.9,[KSC35,kosdic.shx,s=.1],-.333333,["Y9",Standard,y=-.1,s=.2],-.416667\r +*H-CANAL09R,����� ����09(����)\r +A,.9,[KSC35,kosdic.shx,s=.1],-.666667,["Y9",Standard,y=.1,s=.2,r=180],-.083333\r +*H-CANAL10,����� ����10\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y10",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL10R,����� ����10(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y10",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL11,����� ����11\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y11",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL11R,����� ����11(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y11",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL12,����� ����12\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y12",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL12R,����� ����12(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y12",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL13,����� ����13\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y13",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL13R,����� ����13(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y13",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL14,����� ����14\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y14",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL14R,����� ����14(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y14",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL15,����� ����15\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y15",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL15R,����� ����15(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y15",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL16,����� ����16\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y16",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL16R,����� ����16(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y16",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL17,����� ����17\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y17",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL17R,����� ����17(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y17",Standard,y=.1,s=.2,r=180],-.133333\r +*H-CANAL18,����� ����18\r +A,.7,[KSC35,kosdic.shx,s=.1,r=360],-.383333,["Y18",Standard,y=-.1,s=.2,r=360],-.566667\r +*H-CANAL18R,����� ����18(����)\r +A,.7,[KSC35,kosdic.shx,s=.1],-.816667,["Y18",Standard,y=.1,s=.2,r=180],-.133333\r +\r +`;function mA(n){const e=[];let t="",i=!1;for(let g=0;g0){const g=e[0];g.startsWith('"')&&g.endsWith('"')?(s="text",o=g.slice(1,-1),e.length>1&&!e[1].includes("=")&&(l=e[1])):(s="shape",r=g,e.length>1&&!e[1].includes("=")&&(a=e[1]));for(let m=1;m0){const A=_.substring(0,b).trim().toLowerCase(),y=_.substring(b+1).trim(),M=parseFloat(y);isNaN(M)||(A==="s"?c=M:A==="r"?u=M:A==="a"?(u=M,d=!0):A==="u"?(u=M,h=!0):A==="x"?f=M:A==="y"&&(p=M))}}}return{type:s,shapeName:r,shxFile:a,text:o,style:l,scale:c,rotation:u,isAbsoluteAngle:d,isUprightAngle:h,xOffset:f,yOffset:p}}function gA(n){const e=n.replace(/^A\s*,\s*/i,"").trim(),t=[];let i="",s=!1,r=!1;for(let a=0;a0?(i=r.substring(1,a).trim(),s=r.substring(a+1).trim()):(i=r.substring(1).trim(),s="")}else if(i&&r.toUpperCase().startsWith("A,")){const a=gA(r),o=[];let l=0;for(const c of a)if(c.startsWith("[")&&c.endsWith("]")){const u=mA(c.slice(1,-1));o.push(u)}else{const u=parseFloat(c);if(!isNaN(u))if(u>1e-6)o.push({type:"dash",val:u,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=u;else if(u<-1e-6){const d=Math.abs(u);o.push({type:"gap",val:-d,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=d}else o.push({type:"dash",val:.05,scale:1,rotation:0,isAbsoluteAngle:!1,isUprightAngle:!1,xOffset:0,yOffset:0}),l+=.05}o.length>0&&e.set(i.toUpperCase(),{name:i,description:s,elements:o,patternLength:Math.max(l,.1)}),i=null}}return e}const Bp=new Map;function Hp(n){const e=_A(n);for(const[t,i]of e.entries())Bp.set(t,i)}Hp(fA);Hp(pA);const xA={"H-DICHL02":"L2-2/0","H-DICHL02R":"L2-2","H-DICHL01":"L2-3/0","H-DICHL01R":"L2-3","H-DICHL06":"L5-1","H-DICHL06R":"L5-1","H-DICHL05":"L5","H-DICHL05R":"L5","H-DICHU05":"U5","H-DICHU05R":"U5","H-DICHB01":"B1","H-DICHB01R":"B1","H-DICHM03":"M3","H-DICHM03R":"M3","H-DICHV01":"V1","H-DICHV01R":"V1","H-DICHO01":"O1","H-DICHO01R":"O1","H-DICHL03":"L3","H-DICHL03R":"L3","H-DICHL04":"L4","H-DICHL04R":"L4","H-DICHL08":"L8","H-DICHL08R":"L8"},yA=new Set(["H-DICHL05","H-DICHL05R","H-DICHU05","H-DICHU05R","H-DICHB01","H-DICHB01R","H-DICHM03","H-DICHM03R","H-DICHV01","H-DICHV01R","H-DICHO01","H-DICHO01R"]);function vA(n){if(!n)return;const e=n.toUpperCase().trim(),t=Bp.get(e);if(!t)return;let i=t.elements;yA.has(e)&&(i=i.filter(r=>r.type!=="shape"));const s=xA[e];return s&&(i=i.map(r=>r.type==="text"?{...r,text:s}:r)),{...t,elements:i}}const Sl=13226457,Sd=64,bl=72,SA=14;function Fs(n){return n?n.replace(/\\A\d+;/g,"").replace(/\\p[^;]*;/g,"").replace(/\\P/g,` +`).replace(/\\[a-zA-Z][^;]*;/g,"").replace(/\{[^{}]*\}/g,e=>Fs(e.slice(1,-1))).replace(/%%d/gi,"°").replace(/%%p/gi,"±").replace(/%%c/gi,"Ø").replace(/[{}]/g,"").replace(/[ \t]{2,}/g," ").replace(/^[ \t]+|[ \t]+$/gm,"").replace(/\n{3,}/g,` + +`).replace(/^\n+|\n+$/g,""):""}class bA{constructor(e){this._container=e,this._entityMeta=[],this._layerByHandle=new Map,this._layerByName=new Map,this._onSelectCb=null,this._measureActive=!1,this._measureCb=null,this._measurePtA=null,this._measureMarkers=[],this._textGen=0,Nr.shared().catch(()=>{}),this._scene=new J0,this._scene.background=new Qe(856343);const t=e.clientWidth||800,i=e.clientHeight||600;this._camera=new Yc(-t/2,t/2,i/2,-i/2,-1e4,1e4),this._camera.position.set(0,0,100),this._renderer=new Yy({antialias:!0,preserveDrawingBuffer:!0}),this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(t,i),e.appendChild(this._renderer.domElement),this._controls=new qy(this._camera,this._renderer.domElement),this._controls.enableRotate=!1,this._controls.screenSpacePanning=!0,this._controls.zoomToCursor=!0,this._controls.mouseButtons={LEFT:di.PAN,MIDDLE:di.PAN,RIGHT:di.PAN},this._controls.touches={ONE:Pi.PAN,TWO:Pi.DOLLY_PAN};const s=localStorage.getItem("hmw:zoom-speed");if(s){const r=parseFloat(s);isNaN(r)||(this._controls.zoomSpeed=r)}window.addEventListener("keydown",r=>{(r.key==="f"||r.key==="F")&&this.fit()}),this._group=new vr,this._scene.add(this._group),window.addEventListener("resize",()=>this._onResize()),this._renderer.domElement.addEventListener("pointerdown",r=>{r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("mousedown",r=>{this._downXY=[r.clientX,r.clientY],r.button===1&&r.preventDefault()}),this._renderer.domElement.addEventListener("click",r=>this._onClick(r)),this._renderer.domElement.addEventListener("pointermove",r=>this._onPointerMove(r)),this._renderer.domElement.addEventListener("pointerleave",()=>{this._onPointerWorldCb&&this._onPointerWorldCb(null)}),this._selColor={r:216/255,g:58/255,b:47/255},this._gridVisible=!1,this._gridMesh=null,this._activeSpaceHex=null,this._onPointerWorldCb=null,this._ptrWorldTmp=new B,this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0},this._controls.addEventListener("change",()=>{this._gridVisible&&this._rebuildGrid()}),this._animate()}onSelect(e){this._onSelectCb=e}resize(){this._onResize()}setZoomSpeed(e){this._controls&&(this._controls.zoomSpeed=e)}getZoomSpeed(){return this._controls?this._controls.zoomSpeed:1}onPointerWorld(e){this._onPointerWorldCb=e||null}screenToWorld(e,t){const i=this._screenToWcs(e,t);return i?this._wcsToCad(i.x,i.y):null}_screenToWcs(e,t){var b,A,y,M,S;const i=(b=this._renderer)==null?void 0:b.domElement,s=this._camera;if(!i||!s)return null;const r=i.getBoundingClientRect();if(r.width<1||r.height<1)return null;s.updateMatrixWorld(!0);const a=(e-r.left)/r.width*2-1,o=-((t-r.top)/r.height)*2+1,l=s.zoom||1,c=(s.right-s.left)*.5/l,u=(s.top-s.bottom)*.5/l,d=s.matrixWorld.elements,h=d[0],f=d[1],p=d[4],g=d[5],m=((y=(A=this._controls)==null?void 0:A.target)==null?void 0:y.x)??s.position.x,_=((S=(M=this._controls)==null?void 0:M.target)==null?void 0:S.y)??s.position.y;return{x:m+a*c*h+o*u*p,y:_+a*c*f+o*u*g,z:0}}_wcsToCad(e,t){const i=this._coordOrigin||{x:0,y:0},s=this._coordXAxis||{x:1,y:0},r=this._coordYAxis||{x:0,y:1},a=e-(i.x||0),o=t-(i.y||0);return{x:a*(s.x||0)+o*(s.y||0),y:a*(r.x||0)+o*(r.y||0),z:0}}_setCoordFrame(e){const i=Hs(e).find(r=>r.handleHex===this._activeSpaceHex),s=(e==null?void 0:e.vars)||{};(i==null?void 0:i.kind)==="model"&&s.ucsOrigin?(this._coordOrigin={x:s.ucsOrigin.x||0,y:s.ucsOrigin.y||0,z:s.ucsOrigin.z||0},this._coordXAxis=s.ucsXAxis||{x:1,y:0,z:0},this._coordYAxis=s.ucsYAxis||{x:0,y:1,z:0}):(this._coordOrigin={x:0,y:0,z:0},this._coordXAxis={x:1,y:0,z:0},this._coordYAxis={x:0,y:1,z:0})}_onPointerMove(e){if(!this._onPointerWorldCb)return;const t=this.screenToWorld(e.clientX,e.clientY);this._onPointerWorldCb(t)}fit(){if(this._contentBox&&!this._contentBox.isEmpty()){this._fit(this._contentBox);return}const e=new ki,t=[];if(this._group.traverse(s=>{var l;if(!s.geometry)return;e.expandByObject(s);const r=(l=s.geometry.attributes)==null?void 0:l.position;if(!(r!=null&&r.array))return;const a=r.array,o=Math.max(3,Math.floor(a.length/3/4e3)*3);for(let c=0;c+1G.handleHex===this._activeSpaceHex),x=(R==null?void 0:R.kind)==="paper";this.setTheme(!x)}const i=(e==null?void 0:e.entities)||[],s=[],r=[],a=new Map;let o=null;const l=new ki,c=new B,u=[],d=new Set,h=new Set,f=new Map,p=new Map;for(const se of((U=e==null?void 0:e.tables)==null?void 0:U.blocks)??[]){const R=(se.name??"").toLowerCase().replace(/\*/g,"").trim(),x=typeof se.handle=="object"?(P=(O=se.handle)==null?void 0:O.value)==null?void 0:P.toString(16):(Z=se.handle)==null?void 0:Z.toString(16);x&&(se.basePoint&&f.set(x,se.basePoint),p.set(x,(se.name??"").toLowerCase()),R==="model_space"||R==="paper_space"||R==="ms"||R==="ps"||R.startsWith("model")||R.startsWith("paper")||R===""?h.add(x):d.add(x))}const g=h.size>0;this._blockCount=d.size,this._activeSpaceHex&&h.size&&!h.has(this._activeSpaceHex)&&(this._activeSpaceHex=null);const m=this._activeSpaceHex?ul(i,this._activeSpaceHex):null,_=new Map;for(const se of i){const R=(W=(N=se.ownerHandle)==null?void 0:N.value)==null?void 0:W.toString(16);R!=null&&(_.has(R)||_.set(R,[]),_.get(R).push(se))}const b=[];let A=0;const y=(se,R,x=0)=>{!Number.isFinite(se)||!Number.isFinite(R)||(l.expandByPoint(c.set(se,R,x)),A++,!(A&7)&&b.length<1e5&&b.push(se,R))},M=(se,R,x,G,H,$)=>{const fe=($>>16&255)/255,X=($>>8&255)/255,F=($&255)/255;if(o){let Y=a.get(o.key);Y||(Y={dash:o.dash,gap:o.gap,verts:[],colors:[]},a.set(o.key,Y)),Y.verts.push(se,R,H,x,G,H),Y.colors.push(fe,X,F,fe,X,F)}else s.push(se,R,H,x,G,H),r.push(fe,X,F,fe,X,F);this._pickCurIdx>=0&&(this._pickSegs.push(se,R,x,G),this._pickSegMeta.push(this._pickCurIdx)),y(se,R,H),y(x,G,H)},S=-1,E=Hs(e),v=E.find(se=>se.handleHex===this._activeSpaceHex);if((v==null?void 0:v.kind)==="paper"){const se=E.find(R=>R.kind==="model");if(se){const R=ul(i,se.handleHex),x=i.filter($=>{var X,F;return($.type||$.typeName||"").toUpperCase()!=="VIEWPORT"?!1:((F=(X=$.ownerHandle)==null?void 0:X.value)==null?void 0:F.toString(16))===this._activeSpaceHex&&this._isModelViewport($)}),G=($,fe,X,F,Y,ae)=>{M($,fe,X,F,S,ae)},H=($,fe,X=0)=>y($,fe,S);for(const $ of x)this._emitModelThroughViewport($,{entities:i,modelAllowed:R,blockDefHandles:d,entsByOwner:_,blockBaseByHex:f,blockNameByHex:p,pushSeg:G,expand:H,pendingTexts:u,box:l,_tmp:c,underlay:!0})}}for(const se of i){const R=(re=(D=se.ownerHandle)==null?void 0:D.value)==null?void 0:re.toString(16);if(g&&R&&d.has(R)||m&&R&&!m.has(R))continue;if((ie=this._hiddenLayers)!=null&&ie.size){const X=((oe=se.layerHandle)==null?void 0:oe.value)??se.layerHandle,F=(X!=null&&this._layerNameByHandle.get(String(X)))??se.layer??se.layerName;if(F&&this._hiddenLayers.has(F))continue}const x=se.data||se,G=(se.type||se.typeName||"").toUpperCase(),H=this._entityColor(se),$=this._resolveComplexLinetype(se);$?o=null:o=this._resolveDash(se);const fe={entity:se,type:G,bounds:null,colStart:r.length};this._entityMeta.push(fe),this._pickCurIdx=this._entityMeta.length-1;try{switch(G){case"LINE":x.start&&x.end&&($?this._drawComplexPath([x.start,x.end],!1,$.pattern,$.ltscale,H,M,u):M(x.start.x,x.start.y,x.end.x,x.end.y,x.start.z||0,H),fe.bounds={type:"line",x1:x.start.x,y1:x.start.y,x2:x.end.x,y2:x.end.y});break;case"CIRCLE":if(x.center&&x.radius!=null){if($){const X=this._sampleArcPoints(x.center,x.radius,0,Math.PI*2,x.center.z||0);this._drawComplexPath(X,!0,$.pattern,$.ltscale,H,M,u)}else this._arcSegs(x.center,x.radius,0,Math.PI*2,x.center.z||0,H,M);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"ARC":if(x.center&&x.radius!=null){if($){const X=this._sampleArcPoints(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0);this._drawComplexPath(X,!1,$.pattern,$.ltscale,H,M,u)}else this._arcSegs(x.center,x.radius,x.startAngle??0,x.endAngle??Math.PI*2,x.center.z||0,H,M);fe.bounds={type:"circle",cx:x.center.x,cy:x.center.y,r:x.radius}}break;case"LWPOLYLINE":if((_e=x.points)!=null&&_e.length){const X=(de=x.bulges)==null?void 0:de.some(ae=>Math.abs(ae)>=1e-6),F=!!(x.closed||x.flags&1),Y=F?x.points.length:x.points.length-1;if(this._polyHasWidth(se,Y,1))this._widePolyMesh(x.points,x.bulges,F,se,H,1,y);else if($){const ae=this._samplePolylinePoints(x.points,x.bulges,F,x.elevation||0);this._drawComplexPath(ae,F,$.pattern,$.ltscale,H,M,u),ae.forEach(ce=>y(ce.x,ce.y,ce.z))}else X?this._bulgePolySegs(x.points,x.bulges,F,H,M,y):(this._polylineSegs(x.points,F,x.elevation||0,H,M),x.points.forEach(ae=>y(ae.x,ae.y,x.elevation||0)));fe.bounds={type:"point",cx:x.points[0].x,cy:x.points[0].y}}break;case"POLYLINE":if($&&(x.vertices||x.points)){const X=!!(x.closed||x.flags&1),F=x.vertices||x.points;this._drawComplexPath(F,X,$.pattern,$.ltscale,H,M,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))}else this._polylineSegs(x.vertices||x.points,x.closed||x.flags&1,0,H,M);break;case"POLYLINE_2D":{const X=(_.get((z=(le=se.handle)==null?void 0:le.value)==null?void 0:z.toString(16))??[]).filter(F=>(F.type||"").toUpperCase().startsWith("VERTEX")&&F.point);if(X.length>=2){const F=X.map(he=>he.point),Y=X.map(he=>he.bulge||0),ae=(x.flags&1)===1,ce=x.elevation||0;if($){const he=this._samplePolylinePoints(F,Y,ae,ce);this._drawComplexPath(he,ae,$.pattern,$.ltscale,H,M,u),he.forEach(ee=>y(ee.x,ee.y,ee.z))}else Y.some(he=>Math.abs(he)>=1e-6)?this._bulgePolySegs(F,Y,ae,H,M,y):(this._polylineSegs(F,ae,ce,H,M),F.forEach(he=>y(he.x,he.y,ce)));fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"POINT":{const X=x.position||x;typeof X.x=="number"&&(M(X.x-1,X.y,X.x+1,X.y,X.z||0,H),M(X.x,X.y-1,X.x,X.y+1,X.z||0,H),fe.bounds={type:"point",cx:X.x,cy:X.y});break}case"ELLIPSE":if(x.center){if($){const X=this._sampleEllipsePoints(x);this._drawComplexPath(X,!1,$.pattern,$.ltscale,H,M,u),X.forEach(F=>y(F.x,F.y,F.z||0))}else this._ellipseSegs(x,H,M);fe.bounds={type:"point",cx:x.center.x,cy:x.center.y}}break;case"SPLINE":{const X=x.controlPoints??x.fitPoints;if((X==null?void 0:X.length)>=2){const F=X.length>=3?(()=>{const Y=X.length*10,ae=[];for(let ce=0;ce<=Y;ce++){const he=ce/Y;ae.push(this._catmullRom(X,he))}return ae})():X;$?(this._drawComplexPath(F,!!x.closed,$.pattern,$.ltscale,H,M,u),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))):(this._polylineSegs(F,!1,0,H,M),F.forEach(Y=>y(Y.x,Y.y,Y.z||0))),fe.bounds={type:"point",cx:F[0].x,cy:F[0].y}}break}case"ATTRIB":case"ATTDEF":{if((x.flags??0)&1)break;const X=se.text??x.text??x.textValue??x.defaultValue??"",F=Fs(X),Y=se.textHeight??se.height??x.textHeight??x.height??2.5,ae=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ge=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};F&&(u.push({text:F,pos:ge,height:Y,rotation:ae,color:H,alignH:ce,alignV:2}),fe.bounds={type:"point",cx:ge.x,cy:ge.y},this._addTextPick(F,ge,Y,ce,2),y(ge.x,ge.y,0));break}case"XLINE":case"RAY":{const X=x.basePoint??x.point??x.startPoint,F=x.direction??x.unitDir??x.vector;if(X&&F){const ae=X.x+F.x*1e6,ce=X.y+F.y*1e6;G==="XLINE"?M(X.x-F.x*1e6,X.y-F.y*1e6,ae,ce,0,H):M(X.x,X.y,ae,ce,0,H),fe.bounds={type:"point",cx:X.x,cy:X.y},y(X.x,X.y)}break}case"SOLID":{const X=[x.corner1||x.pt1||x.point1,x.corner2||x.pt2||x.point2,x.corner3||x.pt3||x.point3,x.corner4||x.pt4||x.point4].filter(Boolean);X.length>=3&&(this._solidMesh(X,H),fe.bounds={type:"point",cx:X[0].x,cy:X[0].y});break}case"TEXT":case"MTEXT":{const X=se.text??x.text??"",F=Fs(X),Y=se.textHeight??se.height??x.textHeight??x.height??2.5;let ae=0,ce=0,he=0,ee;if(G==="TEXT")ae=se.rotationAngle??x.rotationAngle??0,ce=se.horizAlignment??x.horizAlignment??0,he=se.vertAlignment??x.vertAlignment??0,ce===4&&(he=2),ee=ce!==0||he!==0?se.alignmentPt??x.alignmentPt??se.insertionPt??x.insertionPt??{x:0,y:0}:se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0};else{const ge=se.xAxisDir??x.xAxisDir;ge&&(ae=Math.atan2(ge.y,ge.x));const we=se.attachment??x.attachment??se.attachmentPoint??x.attachmentPoint??5;ce=[1,4,7].includes(we)?0:[3,6,9].includes(we)?2:1,he=[1,2,3].includes(we)?3:[7,8,9].includes(we)?1:2,ee=se.insertionPt??x.insertionPt??x.insertionPoint??{x:0,y:0}}if(F){const ge={text:F,pos:ee,height:Y,rotation:ae,color:H,alignH:ce,alignV:he};G==="MTEXT"&&(ge.linespacingFactor=se.linespacingFactor??x.linespacingFactor??1,ge.rectWidth=se.rectWidth??x.rectWidth??0,ge.rectHeight=se.rectHeight??x.rectHeight??0,ge.bgFillFlags=se.bgFillFlags??x.bgFillFlags??0,ge.bgScale=se.bgScale??x.bgScale??1.5,ge.bgColorIndex=se.bgColorIndex??x.bgColorIndex,ge.bgColorRgb=se.bgColorRgb??x.bgColorRgb),u.push(ge),fe.bounds={type:"point",cx:ee.x,cy:ee.y},this._addTextPick(F,ee,Y,ce,he),y(ee.x,ee.y,0)}break}case"INSERT":{const X=se.insertionPt??x.insertionPt??x.insertionPoint,F=x.scaleX??((ne=x.scale)==null?void 0:ne.x)??((J=se.scale)==null?void 0:J.x)??1,Y=x.scaleY??((xe=x.scale)==null?void 0:xe.y)??((Ae=se.scale)==null?void 0:Ae.y)??1,ae=x.rotation??se.rotation??0,ce=((Se=se.blockHeaderHandle)==null?void 0:Se.value)??((Be=x.blockHeaderHandle)==null?void 0:Be.value);if(ce!=null){const he=ce.toString(16),ee=_.get(he)??[];if(ee.length>0){const ge=(Ue=(ze=e==null?void 0:e.tables)==null?void 0:ze.blocks)==null?void 0:Ue.find(we=>{var k;return(typeof we.handle=="object"?(k=we.handle)==null?void 0:k.value:we.handle)===ce});this._insertEntities(ee,{insertionPoint:X??{x:0,y:0,z:0},xScale:F,yScale:Y,rotation:ae,basePoint:ge==null?void 0:ge.basePoint},H,M,u,{entsByOwner:_,blockBase:f})}}X&&(fe.bounds={type:"point",cx:X.x,cy:X.y},y(X.x,X.y,0));break}case"HATCH":{const X=x.paths??se.paths,F=x.solidFill??se.solidFill??!1;if(!(X!=null&&X.length))break;let Y=null;for(const ae of X){if(!((Oe=ae.points)!=null&&Oe.length)||ae.points.length<2)continue;Y||(Y=ae.points[0]),((Xe=ae.bulges)==null?void 0:Xe.some(he=>Math.abs(he)>=1e-6))?this._bulgePolySegs(ae.points,ae.bulges,!0,H,M,y):(this._polylineSegs(ae.points,!0,0,H,M),ae.points.forEach(he=>y(he.x,he.y,0)))}F&&this._hatchFill(X,H),Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y});break}case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":case"DIMENSION_RADIUS":case"DIMENSION_DIAMETER":case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":case"DIMENSION_ORDINATE":{const X=((tt=se.blockHeaderHandle)==null?void 0:tt.value)??((rt=x.blockHeaderHandle)==null?void 0:rt.value);let F=[];if(X!=null){const Y=X.toString(16);F=_.get(Y)??[]}if(F.length>0){for(const ce of F){const he=(ce.type||ce.typeName||"").toUpperCase(),ee=ce.data||ce,ge=this._entityColor(ce)||H;if(he==="LINE"&&ee.start&&ee.end)M(ee.start.x,ee.start.y,ee.end.x,ee.end.y,0,ge),y(ee.start.x,ee.start.y),y(ee.end.x,ee.end.y);else if(he==="SOLID"){const we=[ee.corner1||ee.pt1,ee.corner2||ee.pt2,ee.corner3||ee.pt3,ee.corner4||ee.pt4].filter(Boolean);we.length>=3&&(this._solidMesh(we,ge),we.forEach(Ge=>y(Ge.x,Ge.y)))}else if(he==="ARC"&&ee.center&&ee.radius!=null)this._arcSegs(ee.center,ee.radius,ee.startAngle??0,ee.endAngle??Math.PI*2,0,ge,M);else if(he==="TEXT"||he==="MTEXT"){const we=ce.text??ee.text??ee.textValue??"",Ge=Fs(we),k=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},ye=ee.textHeight??ee.height??ce.textHeight??2.5;Ge&&(u.push({text:Ge,pos:k,height:ye,rotation:ee.rotationAngle??0,color:ge,alignH:1,alignV:2}),y(k.x,k.y))}else if(he==="INSERT"){const we=ce.insertionPt??ee.insertionPt??ee.insertionPoint??{x:0,y:0},Ge=ee.rotation??ce.rotation??0,k=ee.scaleX??((mt=ee.scale)==null?void 0:mt.x)??((yt=ce.scale)==null?void 0:yt.x)??1,ye=ee.scaleY??((ct=ee.scale)==null?void 0:ct.y)??((ut=ce.scale)==null?void 0:ut.y)??k,ue=((V=ce.blockHeaderHandle)==null?void 0:V.value)??((et=ee.blockHeaderHandle)==null?void 0:et.value),ve=ue==null?void 0:ue.toString(16),Me=p.get(ve)??"",pe=ve?_.get(ve)??[]:[];Me.includes("dot")?this._dotMesh(we,this._arrowDotRadius(pe)*Math.abs(k)||Math.abs(k)*.5,ge):pe.length?this._insertEntities(pe,{insertionPoint:we,xScale:k,yScale:ye,rotation:Ge,basePoint:f.get(ve)},ge,M,u,{entsByOwner:_,blockBase:f}):this._defaultArrow(Me,we,Ge,Math.abs(k)||1,ge,M),y(we.x,we.y)}}const Y=F.find(ce=>(ce.type||ce.typeName||"").toUpperCase()==="LINE"),ae=(Y==null?void 0:Y.data)||Y;ae!=null&&ae.start&&(fe.bounds={type:"point",cx:ae.start.x,cy:ae.start.y})}else{this._renderDimFallback(se,x,G,H,M,u,y);const Y=se.pt10??x.pt10;Y&&(fe.bounds={type:"point",cx:Y.x,cy:Y.y},y(Y.x,Y.y))}break}case"LEADER":{const X=x.points??se.points;if((X==null?void 0:X.length)>=2){if(this._polylineSegs(X,!1,0,H,M),X.forEach(F=>y(F.x,F.y,F.z||0)),x.arrowheadOn??se.arrowheadOn??!0){const F=X[0],Y=X[1],ae=Math.atan2(Y.y-F.y,Y.x-F.x),ce=x.arrowSize??se.arrowSize??2.5;this._arrowMesh(F,ae,ce,H)}fe.bounds={type:"point",cx:X[0].x,cy:X[0].y}}break}case"OLE2FRAME":{const X=se.upperLeft??x.upperLeft??{x:0,y:0,z:0},F=se.lowerRight??x.lowerRight??{x:0,y:0,z:0},Y=se.sourceApp??x.sourceApp??se.source_application??"",ae=se.imageDataUrl??x.imageDataUrl;let ce=Math.min(X.x,F.x),he=Math.max(X.x,F.x),ee=Math.min(X.y,F.y),ge=Math.max(X.y,F.y),we=he-ce,Ge=ge-ee;const k=X.z||0;if(M(ce,ee,he,ee,k,H),M(he,ee,he,ge,k,H),M(he,ge,ce,ge,k,H),M(ce,ge,ce,ee,k,H),ae)try{const ue=(Ne=>{const Mt=Ne.split(",")[1],ht=atob(Mt),Dt=new Uint8Array(ht.length);for(let un=0;un0,_n=document.createElement("canvas");_n.width=An,_n.height=ni;const ds=_n.getContext("2d"),ar=ds.createImageData(An,ni),En=ar.data;if(Yr===32){const un=An*4;for(let an=0;an0&&Number.isFinite(ce)&&x.push(ce)}x.sort((ae,ce)=>ae-ce);const G=x.length?x[x.length>>1]:2.5,H=Math.min(R*2e-4,G),$=2e4,fe=u.filter(ae=>ae.underlay),X=u.filter(ae=>!ae.underlay),F=fe.concat(X),Y=F.length>$?(console.warn(`텍스트 ${F.length}개 → ${$}개로 제한`),X.concat(fe).sort((ae,ce)=>ce.height-ae.height).slice(0,$)):F;this._drawTexts(Y,H)}if(this._lineColorAttr=null,this._origColors=null,s.length){const se=new Ct;se.setAttribute("position",new dt(s,3));const R=new dt(r,3);se.setAttribute("color",R),this._group.add(new ga(se,new Bs({vertexColors:!0}))),this._lineColorAttr=R,this._origColors=Float32Array.from(R.array)}for(const se of a.values()){if(!se.verts.length)continue;const R=new Ct;R.setAttribute("position",new dt(se.verts,3)),R.setAttribute("color",new dt(se.colors,3));const x=new ga(R,new Km({vertexColors:!0,dashSize:se.dash,gapSize:se.gap}));x.computeLineDistances(),this._group.add(x)}this._setCoordFrame(e);const T=l.isEmpty()?null:this._trimmedContentBox(b,l)||l;this._contentBox=T?T.clone():null,!t.keepView&&T&&!T.isEmpty()&&this._fit(T)}setTheme(e){this._scene.background=new Qe(e?658189:16777215),this._gridVisible&&this._rebuildGrid()}setGrid(e){this._gridVisible=e,e?this._rebuildGrid():this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null)}_rebuildGrid(){this._gridMesh&&(this._scene.remove(this._gridMesh),this._gridMesh.geometry.dispose(),this._gridMesh.material.dispose(),this._gridMesh=null);const e=this._camera.zoom||1,t=this._camera.position.x,i=this._camera.position.y,s=(this._camera.right-this._camera.left)/e/2,r=(this._camera.top-this._camera.bottom)/e/2,a=Math.max(s,r)*3,o=this._niceSpacing(Math.max(s,r)*2/20),[l,c,u,d]=[t-a,t+a,i-a,i+a],f=this._scene.background.r<.5?2829099:12303291,p=[];for(let m=Math.ceil(l/o)*o;m<=c;m+=o)p.push(m,u,-.5,m,d,-.5);for(let m=Math.ceil(u/o)*o;m<=d;m+=o)p.push(l,m,-.5,c,m,-.5);const g=new Ct;g.setAttribute("position",new dt(p,3)),this._gridMesh=new ga(g,new Bs({color:f})),this._scene.add(this._gridMesh)}_niceSpacing(e){if(e<=0)return 1;const t=Math.pow(10,Math.floor(Math.log10(e))),i=e/t;return(i<2?1:i<5?2:5)*t}getZoomPercent(){var e;return Math.round((((e=this._camera)==null?void 0:e.zoom)??1)*100)}onViewChange(e){var t;(t=this._controls)==null||t.addEventListener("change",e)}setHiddenLayers(e){this._hiddenLayers=e||new Set,this._lastResult&&this.load(this._lastResult,{keepView:!0})}getSpaces(){return Hs(this._lastResult)}getActiveSpace(){return this._activeSpaceHex}setSpace(e,t={}){e==null||e===""?this._activeSpaceHex=null:typeof e=="number"?this._activeSpaceHex=e.toString(16):this._activeSpaceHex=String(e).toLowerCase(),this._lastResult&&this.load(this._lastResult,{keepView:!!t.keepView,spaceHandle:this._activeSpaceHex})}_isModelViewport(e){if(!e||e.status&&e.status.isOn===!1||(e.id??0)===1)return!1;const i=Number(e.height)||0,s=Number(e.viewHeight)||0;if(i<=0||s<=0)return!1;const r=i/s,a=e.center||{},o=e.viewCenter||{},l=e.viewTarget||{},c=Math.hypot(l.x||0,l.y||0)<.001,u=Math.hypot((o.x||0)-(a.x||0),(o.y||0)-(a.y||0))1e-12?Number(e.viewHeight):r,o=r/a,l=Number(e.twistAngle)||0,c=Math.cos(l),u=Math.sin(l),d=(h,f)=>{const p=h-(s.x||0),g=f-(s.y||0),m=c*p-u*g,_=u*p+c*g;return{x:(t.x||0)+(m-(i.x||0))*o,y:(t.y||0)+(_-(i.y||0))*o}};return d.scale=o,d.twist=l,d}_viewportPaperClip(e){const t=e.center||{x:0,y:0},i=(Number(e.width)||0)/2,s=(Number(e.height)||0)/2,r=Math.max(i,s)*1e-6;return{minX:(t.x||0)-i-r,maxX:(t.x||0)+i+r,minY:(t.y||0)-s-r,maxY:(t.y||0)+s+r}}_clipSegToRect(e,t,i,s,r,a){const h=(g,m)=>{let _=0;return gr.maxX&&(_|=2),mr.maxY&&(_|=8),_};let f=h(e,t),p=h(i,s);for(;;){if(!(f|p)){a(e,t,i,s);return}if(f&p)return;const g=f||p;let m=0,_=0;g&8?(m=e+(i-e)*(r.maxY-t)/(s-t||1e-30),_=r.maxY):g&4?(m=e+(i-e)*(r.minY-t)/(s-t||1e-30),_=r.minY):g&2?(_=t+(s-t)*(r.maxX-e)/(i-e||1e-30),m=r.maxX):(_=t+(s-t)*(r.minX-e)/(i-e||1e-30),m=r.minX),g===f?(e=m,t=_,f=h(e,t)):(i=m,s=_,p=h(i,s))}}_emitModelThroughViewport(e,t){var A,y,M,S,E,v,T,I,L,w,U,O,P,Z;const{entities:i,modelAllowed:s,blockDefHandles:r,entsByOwner:a,blockBaseByHex:o,pushSeg:l,expand:c,pendingTexts:u,underlay:d=!1}=t,h=this._viewportModelToPaper(e),f=this._viewportPaperClip(e),p=h.scale||1,g=new Set((e.frozenLayers||[]).map(N=>String(N))),m=(N,W,D,re,ie,oe)=>{const _e=h(N,W),de=h(D,re);this._clipSegToRect(_e.x,_e.y,de.x,de.y,f,(le,z,ne,J)=>{l(le,z,ne,J,ie||0,oe)})},_=(N,W,D=0)=>{const re=h(N,W);re.x>=f.minX&&re.x<=f.maxX&&re.y>=f.minY&&re.y<=f.maxY&&c(re.x,re.y,D)},b=(N,W)=>N>=f.minX&&N<=f.maxX&&W>=f.minY&&W<=f.maxY;for(const N of i){const W=(y=(A=N.ownerHandle)==null?void 0:A.value)==null?void 0:y.toString(16);if(!W||!s.has(W)||r.has(W))continue;if((M=this._hiddenLayers)!=null&&M.size){const de=((S=N.layerHandle)==null?void 0:S.value)??N.layerHandle,le=(de!=null&&this._layerNameByHandle.get(String(de)))??N.layer??N.layerName;if(le&&this._hiddenLayers.has(le))continue}if(g.size){const de=(E=N.layerHandle)==null?void 0:E.value;if(de!=null&&g.has(String(de)))continue}const D=N.data||N,re=(N.type||N.typeName||"").toUpperCase(),ie=this._entityColor(N),oe=this._resolveComplexLinetype(N),_e=u.length;try{switch(re){case"LINE":D.start&&D.end&&(oe?this._drawComplexPath([D.start,D.end],!1,oe.pattern,oe.ltscale,ie,m,u):m(D.start.x,D.start.y,D.end.x,D.end.y,D.start.z||0,ie));break;case"CIRCLE":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,0,Math.PI*2,D.center.z||0);this._drawComplexPath(de,!0,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,0,Math.PI*2,D.center.z||0,ie,m);break;case"ARC":if(D.center&&D.radius!=null)if(oe){const de=this._sampleArcPoints(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0);this._drawComplexPath(de,!1,oe.pattern,oe.ltscale,ie,m,u)}else this._arcSegs(D.center,D.radius,D.startAngle??0,D.endAngle??Math.PI*2,D.center.z||0,ie,m);break;case"LWPOLYLINE":if((v=D.points)!=null&&v.length){const de=(T=D.bulges)==null?void 0:T.some(z=>Math.abs(z)>=1e-6),le=!!(D.closed||D.flags&1);if(oe){const z=this._samplePolylinePoints(D.points,D.bulges,le,D.elevation||0);this._drawComplexPath(z,le,oe.pattern,oe.ltscale,ie,m,u),z.forEach(ne=>_(ne.x,ne.y,ne.z))}else de?this._bulgePolySegs(D.points,D.bulges,le,ie,m,_):(this._polylineSegs(D.points,le,D.elevation||0,ie,m),D.points.forEach(z=>_(z.x,z.y,D.elevation||0)))}break;case"POLYLINE":if(oe&&(D.vertices||D.points)){const de=!!(D.closed||D.flags&1),le=D.vertices||D.points;this._drawComplexPath(le,de,oe.pattern,oe.ltscale,ie,m,u),le.forEach(z=>_(z.x,z.y,z.z||0))}else this._polylineSegs(D.vertices||D.points,D.closed||D.flags&1,0,ie,m);break;case"ELLIPSE":if(D.center)if(typeof this._ellipseSegs=="function")this._ellipseSegs(D,ie,m);else{const de=D.center.x,le=D.center.y,z=D.smAxis||D.majorAxis||{x:D.radius||1,y:0},ne=D.axisRatio??D.minorAxisRatio??.5,J=D.startAngle??D.startParameter??0,xe=D.endAngle??D.endParameter??Math.PI*2,Ae=64;let Se,Be;for(let ze=0;ze<=Ae;ze++){const Ue=J+(xe-J)*(ze/Ae),Oe=Math.cos(Ue),Xe=Math.sin(Ue),tt=de+z.x*Oe-z.y*ne*Xe,rt=le+z.y*Oe+z.x*ne*Xe;ze>0&&m(Se,Be,tt,rt,0,ie),Se=tt,Be=rt}}break;case"SOLID":{const de=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(de.length>=2)for(let le=0;leMath.abs(xe)>=1e-6)?this._bulgePolySegs(z,J,ne,ie,m,_):(this._polylineSegs(z,ne,0,ie,m),z.forEach(xe=>_(xe.x,xe.y)))}break}case"SPLINE":{const de=(I=D.fitPoints)!=null&&I.length?D.fitPoints:D.controlPoints;(de==null?void 0:de.length)>=2&&this._polylineSegs(de,!!D.closed,0,ie,m);break}case"TEXT":case"MTEXT":{const de=N.text??D.text??"",le=Fs(de);if(!le)break;const z=(N.textHeight??N.height??D.textHeight??D.height??2.5)*p;let ne=(N.rotationAngle??D.rotationAngle??0)+(h.twist||0),J=0,xe=0,Ae;if(re==="TEXT")J=N.horizAlignment??D.horizAlignment??0,xe=N.vertAlignment??D.vertAlignment??0,J===4&&(xe=2),Ae=J!==0||xe!==0?N.alignmentPt??D.alignmentPt??N.insertionPt??D.insertionPt??{x:0,y:0}:N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0};else{const Be=N.xAxisDir??D.xAxisDir;Be&&(ne=Math.atan2(Be.y,Be.x)+(h.twist||0));const ze=N.attachment??D.attachment??N.attachmentPoint??D.attachmentPoint??5;J=[1,4,7].includes(ze)?0:[3,6,9].includes(ze)?2:1,xe=[1,2,3].includes(ze)?3:[7,8,9].includes(ze)?1:2,Ae=N.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0}}const Se=h(Ae.x,Ae.y);if(!b(Se.x,Se.y))break;u.push({text:le,pos:Se,height:z,rotation:ne,color:ie,alignH:J,alignV:xe,underlay:!!d}),_(Ae.x,Ae.y);break}case"INSERT":{const de=N.insertionPt??D.insertionPt??D.insertionPoint;if(!de)break;const le=D.scaleX??((L=D.scale)==null?void 0:L.x)??((w=N.scale)==null?void 0:w.x)??1,z=D.scaleY??((U=D.scale)==null?void 0:U.y)??((O=N.scale)==null?void 0:O.y)??1,ne=((P=N.blockHeaderHandle)==null?void 0:P.value)??((Z=D.blockHeaderHandle)==null?void 0:Z.value),J=ne!=null?ne.toString(16):null,xe=J?a.get(J)??[]:[];if(xe.length){const Ae=u.length;this._insertEntities(xe,{insertionPoint:de,xScale:le,yScale:z,rotation:D.rotation??N.rotation??0,basePoint:o.get(J)},ie,m,u,{entsByOwner:a,blockBase:o});for(let Se=Ae;Se_e)for(let de=_e;de{this._renderer.render(this._scene,this._camera),this._renderer.domElement.toBlob(t=>e(t),"image/webp",.75)})}getLayerInfo(){var r,a,o,l,c;const e=this._lastResult;if(!e)return[];const t=new Map,i=this._activeSpaceHex?ul(e.entities||[],this._activeSpaceHex):null;for(const u of e.entities||[]){const d=(a=(r=u.ownerHandle)==null?void 0:r.value)==null?void 0:a.toString(16);if(i&&d&&!i.has(d))continue;const h=((o=u.layerHandle)==null?void 0:o.value)??u.layerHandle,f=(h!=null&&((l=this._layerNameByHandle)==null?void 0:l.get(String(h))))??u.layer??u.layerName??"0";t.set(f,(t.get(f)||0)+1)}const s=this._hiddenLayers||new Set;return(((c=e.tables)==null?void 0:c.layers)||[]).map(u=>{const d=u.name??u.layerName??"0",h=Math.abs(u.colorIndex??u.color??u.colorNumber??7);return{name:d,colorHex:"#"+(Ea(h)??Sl).toString(16).padStart(6,"0"),count:t.get(d)||0,visible:!s.has(d)}}).filter(u=>u.count>0||!u.name.startsWith("*"))}_resolveComplexLinetype(e){var a,o,l,c;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;t=u!=null&&((o=this._layerLtByHandle)==null?void 0:o.get(String(u)))||((l=this._layerLtByName)==null?void 0:l.get(e.layer??e.layerName))||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=vA(t);if(!i)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=(this._globalLtscale||1)*s;return{pattern:i,ltscale:r}}_sampleArcPoints(e,t,i,s,r=0){let a=s-i;a<=0&&(a+=Math.PI*2);const o=Math.max(16,Math.ceil(a/(Math.PI*2)*Sd)),l=[],c=e.z||r||0;for(let u=0;u<=o;u++){const d=i+a*u/o;l.push({x:e.x+t*Math.cos(d),y:e.y+t*Math.sin(d),z:c})}return l}_samplePolylinePoints(e,t,i,s=0){if(!e||e.length<2)return e||[];const r=[],a=i?e.length:e.length-1;for(let o=0;o1e-9){const g=4*Math.atan(u),m=Math.abs(g)/2,_=p/2/Math.sin(m),b=_*Math.cos(m),A=(l.x+c.x)/2,y=(l.y+c.y)/2,M=-f/p,S=h/p,E=u>0?1:-1,v=A+E*M*b,T=y+E*S*b,I=Math.atan2(l.y-T,l.x-v),L=Math.max(4,Math.ceil(Math.abs(g)/(Math.PI/16)));for(let w=r.length===0?0:1;w<=L;w++){const U=I+g*w/L;r.push({x:v+_*Math.cos(U),y:T+_*Math.sin(U),z:d})}}}}return r}_sampleEllipsePoints(e){const t=e.majorAxis??e.smAxis??{x:e.radius||1,y:0},i=e.center||{x:0,y:0},s=e.ratio??e.axisRatio??e.minorAxisRatio??.5,r=e.startParam??e.startAngle??0,a=e.endParam??e.endAngle??Math.PI*2,o=Math.hypot(t.x??1,t.y??0),l=o*s,c=Math.atan2(t.y??0,t.x??1);let u=a-r;u<=0&&(u+=Math.PI*2);const d=bl,h=[],f=i.z||0;for(let p=0;p<=d;p++){const g=r+u*p/d,m=o*Math.cos(g),_=l*Math.sin(g),b=i.x+m*Math.cos(c)-_*Math.sin(c),A=i.y+m*Math.sin(c)+_*Math.cos(c);h.push({x:b,y:A,z:f})}return h}_drawComplexPath(e,t,i,s,r,a,o){var _;if(!e||e.length<2)return;const l=e.slice();t&&Math.hypot(l[l.length-1].x-l[0].x,l[l.length-1].y-l[0].y)>1e-6&&l.push(l[0]);const c=[];let u=0;for(let b=0;b{let A=Math.max(0,Math.min(b,u));for(let S=0;S1e-9?A/E:0,T=l[S],I=l[S+1],L=T.x+(I.x-T.x)*v,w=T.y+(I.y-T.y)*v,U=(T.z||0)+((I.z||0)-(T.z||0))*v,O=Math.atan2(I.y-T.y,I.x-T.x);return{x:L,y:w,z:U,angle:O}}A-=E}const y=l[l.length-1],M=l[l.length-2];return{x:y.x,y:y.y,z:y.z||0,angle:Math.atan2(y.y-M.y,y.x-M.x)}},h=i.patternLength*s;if(h<1e-6)return;let f=-1,p=0;for(const b of elements){if(b.type==="shape"){f=p;break}b.type==="dash"?p+=Math.max((b.val||.05)*s,.01*s):b.type==="gap"&&(p+=Math.abs(b.val||.1)*s)}let g=0,m=0;for(;gy){const S=d(y),E=d(M);a(S.x,S.y,E.x,E.y,S.z,r)}g+=A}else if(b.type==="gap"){const A=Math.abs(b.val||.1)*s;g+=A}else if(b.type==="shape"){const A=d(g);this._renderShapeSymbol(b,A,s,r,a)}else if(b.type==="text"){const A=d(g);if(b.text&&o){const y=(b.style||"STANDARD").toUpperCase(),M=((_=this._textStyleHeightMap)==null?void 0:_.get(y))||0,E=(M>0?M:b.scale||.2)*s;let v=A.angle+(b.rotation||0)*Math.PI/180;b.isAbsoluteAngle&&(v=(b.rotation||0)*Math.PI/180);let T=Math.atan2(Math.sin(v),Math.cos(v));T>Math.PI/2?T-=Math.PI:T<-Math.PI/2&&(T+=Math.PI),v=T;const I=Math.cos(v),L=Math.sin(v),w=(b.xOffset||0)*s,U=0,O=Math.floor(g/h)*h;let P;if(f>=0){const W=O+f+h/2;P=d(Math.min(W,u))}else{let W=0;const D=elements[m%elements.length];D&&D.type==="gap"&&(W=Math.abs(D.val||0)*s/2),P=W>1e-6?d(g+W):A}const Z=P.x+(w*I-U*L),N=P.y+(w*L+U*I);o.push({text:b.text,pos:{x:Z,y:N,z:P.z},height:Math.max(E,.01),rotation:v,color:r,alignH:1,alignV:2})}}}}_renderShapeSymbol(e,t,i,s,r){const a=(e.shapeName||"").toUpperCase(),o=(e.scale||.1)*i,l=e.isAbsoluteAngle?(e.rotation||0)*Math.PI/180:t.angle+(e.rotation||0)*Math.PI/180,c=(e.xOffset||0)*i,u=(e.yOffset||0)*i,d=Math.cos(t.angle),h=Math.sin(t.angle),f=t.x+(c*d-u*h),p=t.y+(c*h+u*d),g=t.z||0,m=Math.cos(l),_=Math.sin(l),b=(A,y)=>({x:f+(A*m-y*_)*o,y:p+(A*_+y*m)*o});if(a.includes("KSC35")||a.includes("KSC36")||a.includes("KSC19")||a.includes("ARROW")){for(let E=0;E<=12;E++){const v=E/12,T=-.5+v,I=.25*(1-v),L=b(T,I),w=b(T,-I);r(L.x,L.y,w.x,w.y,g,s)}const y=b(.5,0),M=b(-.5,.25),S=b(-.5,-.25);r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,S.x,S.y,g,s),r(S.x,S.y,y.x,y.y,g,s)}else if(a.includes("CIRC")||a.includes("KSC11")||a.includes("KSC01")){let y=b(.3,0);for(let M=1;M<=12;M++){const S=M/12*Math.PI*2,E=b(.3*Math.cos(S),.3*Math.sin(S));r(y.x,y.y,E.x,E.y,g,s),y=E}}else if(a.includes("BOX")||a.includes("KSC02")||a.includes("KSC05")){const A=b(-.3,-.3),y=b(.3,-.3),M=b(.3,.3),S=b(-.3,.3);r(A.x,A.y,y.x,y.y,g,s),r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,S.x,S.y,g,s),r(S.x,S.y,A.x,A.y,g,s)}else if(a.includes("TRACK1")){const A=b(0,-.4),y=b(0,.4);r(A.x,A.y,y.x,y.y,g,s)}else if(a.includes("BAT")||a.includes("DIAMOND")){const A=b(0,.4),y=b(.4,0),M=b(0,-.4),S=b(-.4,0);r(A.x,A.y,y.x,y.y,g,s),r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,S.x,S.y,g,s),r(S.x,S.y,A.x,A.y,g,s)}else{const A=b(.3,0),y=b(-.3,.2),M=b(-.3,-.2);r(A.x,A.y,y.x,y.y,g,s),r(y.x,y.y,M.x,M.y,g,s),r(M.x,M.y,A.x,A.y,g,s)}}_buildStyleMap(e){if(this._textStyleHeightMap||(this._textStyleHeightMap=new Map),this._textStyleHeightMap.clear(),!(!e||!Array.isArray(e)))for(const t of e){const i=(t.name||t.styleName||"").toUpperCase(),s=t.height??t.fixedTextHeight??0;i&&s>0&&this._textStyleHeightMap.set(i,s)}}_buildLayerMap(e){var t;if(this._layerByHandle.clear(),this._layerByName.clear(),this._layerNameByHandle=new Map,this._layer0Handle=null,!!e)for(const i of e){const s=((t=i.handle)==null?void 0:t.value)??i.handle,r=i.name??i.layerName,a=Math.abs(i.colorIndex??i.color??i.colorNumber??7),o=Ea(a)??Sl;s!=null&&this._layerByHandle.set(String(s),o),r&&this._layerByName.set(r,o),s!=null&&r&&this._layerNameByHandle.set(String(s),r),r==="0"&&s!=null&&(this._layer0Handle=String(s))}}_readViewTwist(e){var r;const t=(r=e==null?void 0:e.tables)==null?void 0:r.vports;if(!Array.isArray(t)||!t.length)return 0;const i=t.find(a=>/active/i.test(a.name||""))||t[0],s=i==null?void 0:i.viewTwist;return typeof s=="number"&&isFinite(s)?s:0}_buildLinetypeMap(e){var t,i,s,r;this._ltPatterns=new Map,this._layerLtByName=new Map,this._layerLtByHandle=new Map,this._globalLtscale=((t=e==null?void 0:e.vars)==null?void 0:t.ltscale)>0?e.vars.ltscale:1;for(const a of((i=e==null?void 0:e.tables)==null?void 0:i.lineTypes)??[])a!=null&&a.name&&this._ltPatterns.set(a.name,Array.isArray(a.pattern)?a.pattern:[]);for(const a of((s=e==null?void 0:e.tables)==null?void 0:s.layers)??[]){const o=a.name??a.layerName,l=((r=a.handle)==null?void 0:r.value)??a.handle,c=a.lineType??a.linetype;o&&c&&this._layerLtByName.set(o,c),l!=null&&c&&this._layerLtByHandle.set(String(l),c)}}_resolveDash(e){var l,c;if(!this._ltPatterns||this._ltPatterns.size===0)return null;let t=e.lineType??e.linetype;if(!t||t==="ByLayer"||t==="BYLAYER"||t==="ByBlock"||t==="BYBLOCK"){const u=((l=e.layerHandle)==null?void 0:l.value)??e.layerHandle;t=u!=null&&this._layerLtByHandle.get(String(u))||this._layerLtByName.get(e.layer??e.layerName)||null}if(!t||t==="Continuous"||t==="ByLayer"||t==="ByBlock")return null;const i=this._ltPatterns.get(t);if(!i||i.length===0)return null;const s=((c=e.entityHeader)==null?void 0:c.linetypeScale)>0?e.entityHeader.linetypeScale:1,r=this._globalLtscale*s;let a=0,o=0;for(const u of i){const d=Math.abs(u)*r;u>1e-6?a+=d:u<-1e-6?o+=d:a+=Math.max(d,.01*r)}return a<1e-4||o<1e-4?null:{key:`${a.toFixed(3)}|${o.toFixed(3)}`,dash:a,gap:o}}_resolveBlockColor(e,t){var r,a;const i=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(i===0)return t;const s=String(((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle??"");return i===256&&this._layer0Handle&&s===this._layer0Handle?t:this._entityColor(e)}_entityColor(e){var r,a;const t=((r=e.entityHeader)==null?void 0:r.colorIndex)??e.color??e.colorIndex??e.colorNumber??256;if(t!=null){const o=Ea(t);if(o!==null)return o}const i=((a=e.layerHandle)==null?void 0:a.value)??e.layerHandle;if(i!=null){const o=this._layerByHandle.get(String(i));if(o!==void 0)return o}const s=e.layer??e.layerName;if(s){const o=this._layerByName.get(s);if(o!==void 0)return o}return Sl}_arrowMesh(e,t,i,s){if(!e||i<1e-4)return;const r=i*.166,a=(s>>16&255)/255,o=(s>>8&255)/255,l=(s&255)/255,c=new Ct;c.setAttribute("position",new dt([0,0,0,-i,r,0,-i,-r,0],3)),c.setAttribute("color",new dt([a,o,l,a,o,l,a,o,l],3));const u=new Vt(c,new Wn({vertexColors:!0,side:zt}));u.position.set(e.x,e.y,(e.z||0)+.5),u.rotation.z=t,this._group.add(u)}_defaultArrow(e,t,i,s,r,a){if(!t||s<1e-4)return;const o=(e||"").replace(/^[_*]+/,""),l=Math.cos(i),c=Math.sin(i),u=(d,h)=>({x:t.x+d*l-h*c,y:t.y+d*c+h*l});if(!(o==="none"||o==="small"||o==="integral")){if(o==="dot"||o==="dotsmall"||o==="dotblank"||o==="dotsmallblank"||o==="origin"||o==="origin2"){this._dotMesh(t,s*(o==="dotsmall"?.12:.5),r);return}if(o==="oblique"||o==="archtick"){const d=u(s*.5,s*.5),h=u(-s*.5,-s*.5);a(d.x,d.y,h.x,h.y,(t.z||0)+.5,r);return}if(o==="open"||o==="open30"||o==="open90"){const d=o==="open90"?s:s*.42,h=u(0,0),f=u(-s,d),p=u(-s,-d);a(f.x,f.y,h.x,h.y,(t.z||0)+.5,r),a(p.x,p.y,h.x,h.y,(t.z||0)+.5,r);return}this._arrowMesh(t,i,s,r)}}_dotMesh(e,t,i){if(!e||!(t>1e-5))return;const s=(i>>16&255)/255,r=(i>>8&255)/255,a=(i&255)/255,o=20,l=[],c=[],u=(e.z||0)+.5;for(let h=0;h{a+=l.x,o+=l.y}),a/=r.length,o/=r.length,r.forEach(l=>{t=Math.max(t,Math.hypot(l.x-a,l.y-o))})}}return t}_arcSegs(e,t,i,s,r,a,o){let l=s-i;l<=0&&(l+=Math.PI*2);const c=Math.max(8,Math.ceil(l/(Math.PI*2)*Sd));let u=null;for(let d=0;d<=c;d++){const h=i+l*d/c,f=e.x+t*Math.cos(h),p=e.y+t*Math.sin(h);u&&o(u.x,u.y,f,p,r,a),u={x:f,y:p}}}_catmullRom(e,t){const i=e.length,s=t*(i-1),r=Math.min(Math.floor(s),i-2),a=s-r,o=e[Math.max(r-1,0)],l=e[r],c=e[r+1],u=e[Math.min(r+2,i-1)],d=a*a,h=d*a;return{x:.5*(2*l.x+(-o.x+c.x)*a+(2*o.x-5*l.x+4*c.x-u.x)*d+(-o.x+3*l.x-3*c.x+u.x)*h),y:.5*(2*l.y+(-o.y+c.y)*a+(2*o.y-5*l.y+4*c.y-u.y)*d+(-o.y+3*l.y-3*c.y+u.y)*h),z:.5*(2*(l.z||0)+(-(o.z||0)+(c.z||0))*a+(2*(o.z||0)-5*(l.z||0)+4*(c.z||0)-(u.z||0))*d+(-(o.z||0)+3*(l.z||0)-3*(c.z||0)+(u.z||0))*h)}}_ellipseSegs(e,t,i){const s=e.majorAxis??e.smAxis??{x:1,y:0},r=e.center,a=e.ratio??e.axisRatio??1,o=e.startParam??0,l=e.endParam??Math.PI*2,c=(s==null?void 0:s.x)??1,u=(s==null?void 0:s.y)??0,d=Math.sqrt(c*c+u*u),h=d*a,f=Math.atan2(u,c);let p=l-o;p<=0&&(p+=Math.PI*2);let g=null;for(let m=0;m<=bl;m++){const _=o+p*m/bl,b=d*Math.cos(_),A=h*Math.sin(_),y=r.x+b*Math.cos(f)-A*Math.sin(f),M=r.y+b*Math.sin(f)+A*Math.cos(f);g&&i(g.x,g.y,y,M,r.z||0,t),g={x:y,y:M}}}_polylineSegs(e,t,i,s,r){if(!(!e||e.length<2)){for(let a=0;a1e-12?l:Math.abs(r)>1e-12?r:a,d=Math.abs(c)>1e-12?c:Math.abs(r)>1e-12?r:o;return{sw:Math.abs(u),ew:Math.abs(d)}}_polyHasWidth(e,t,i=1){for(let s=0;s1e-9||a>1e-9)return!0}return!1}_pushWideSeg(e,t,i,s,r){const a=i.x-t.x,o=i.y-t.y,l=Math.hypot(a,o);if(l<1e-12)return;const c=-o/l,u=a/l,d=s*.5,h=r*.5,f={x:t.x+c*d,y:t.y+u*d},p={x:t.x-c*d,y:t.y-u*d},g={x:i.x-c*h,y:i.y-u*h},m={x:i.x+c*h,y:i.y+u*h};e.push(f.x,f.y,0,p.x,p.y,0,g.x,g.y,0),e.push(f.x,f.y,0,g.x,g.y,0,m.x,m.y,0)}_widePolyMesh(e,t,i,s,r,a=1,o=null){if(!e||e.length<2)return;const l=e.length,c=i?l:l-1,u=[];for(let f=0;f0?1:-1,P=I+O*w*T,Z=L+O*U*T,N=Math.atan2(p.y-Z,p.x-P),W=Math.max(2,Math.ceil(Math.abs(S)/(Math.PI/16)));let D={x:p.x,y:p.y},re=m;for(let ie=1;ie<=W;ie++){const oe=ie/W,_e=N+S*ie/W,de={x:P+v*Math.cos(_e),y:Z+v*Math.sin(_e)},le=m+(_-m)*oe;this._pushWideSeg(u,D,de,re,le),D=de,re=le}o&&(o(p.x,p.y),o(g.x,g.y))}}if(u.length<9)return;const d=new Ct;d.setAttribute("position",new dt(u,3)),d.computeVertexNormals();const h=new Wn({color:new Qe(r),side:zt,depthWrite:!1});if(this._group.add(new Vt(d,h)),this._pickCurIdx>=0&&this._pickSegs)for(let f=0;f0?1:-1,T=y+v*S*A,I=M+v*E*A,L=Math.atan2(u.y-I,u.x-T),w=Math.max(2,Math.ceil(Math.abs(m)/(Math.PI/16)));let U=u;for(let O=1;O<=w;O++){const P=L+m*O/w,Z=T+b*Math.cos(P),N=I+b*Math.sin(P);r(U.x,U.y,Z,N,0,s),U={x:Z,y:N}}a&&(a(u.x,u.y),a(d.x,d.y))}}}_solidMesh(e,t){const i=(t>>16&255)/255,s=(t>>8&255)/255,r=(t&255)/255,a=[],o=[],l=(...u)=>{for(const d of u)a.push(d.x,d.y,d.z||0),o.push(i,s,r)};e.length>=4?(l(e[0],e[1],e[3]),l(e[0],e[3],e[2])):l(e[0],e[1],e[2]);const c=new Ct;if(c.setAttribute("position",new dt(a,3)),c.setAttribute("color",new dt(o,3)),this._group.add(new Vt(c,new Wn({vertexColors:!0,side:zt}))),this._pickCurIdx>=0&&e.length>=3){const u=e.length>=4?[e[0],e[1],e[3],e[2]]:e.slice(0,3);this._pickFills.push({metaIdx:this._pickCurIdx,loops:[u]})}}_addTextPick(e,t,i,s=0,r=0){if(this._pickCurIdx<0||!t)return;const a=String(e).split(` +`),l=a.reduce((h,f)=>Math.max(h,f.length),1)*i*.62,c=a.length*i*1.2;let u=t.x;s===2?u=t.x-l:(s===1||s===4)&&(u=t.x-l/2);let d=t.y;r===3?d=t.y-c:r===2&&(d=t.y-c/2),this._pickFills.push({metaIdx:this._pickCurIdx,loops:[[{x:u,y:d},{x:u+l,y:d},{x:u+l,y:d+c},{x:u,y:d+c}]]})}_fillHit(e,t,i){let s=!1;for(const r of e)for(let a=0,o=r.length-1;ai!=d>i&&t<(u-l)*(i-c)/(d-c)+l&&(s=!s)}return s}_pointInAnyLoop(e,t,i){for(const s of e){if(!(s!=null&&s.length))continue;let r=!1;for(let a=0,o=s.length-1;ai!=c.y>i&&t<(c.x-l.x)*(i-l.y)/(c.y-l.y)+l.x&&(r=!r)}if(r)return!0}return!1}_loopArea(e){let t=0;for(let i=0;ic&&(c=m.x),m.y>u&&(u=m.y);const d=Math.hypot(c-o,u-l)||1;if(a>d*1e-4&&a>1e-6)return;let h=0;for(let m=0;m5e3)return;let p=0,g=0;for(const m of e)p+=m.x,g+=m.y;p/=e.length,g/=e.length;for(const m of this._pickFills)if(this._pointInAnyLoop(m.loops,p,g))return;this._hatchFill([{points:e,bulges:t||null,closed:!0}],i)}_pathPoints(e){const t=e.points;if(!(t!=null&&t.length))return null;const i=e.bulges,s=t.length;if(!(i!=null&&i.some(a=>Math.abs(a)>=1e-6)))return t.map(a=>({x:a.x,y:a.y}));const r=[];for(let a=0;a0?1:-1,S=_+M*A*m,E=b+M*y*m,v=Math.atan2(o.y-E,o.x-S),T=Math.max(6,Math.ceil(Math.abs(f)/(Math.PI/16)));for(let I=1;I{var u;return l+(((u=c.points)==null?void 0:u.length)??0)},0)>8e3)return;let s=[];for(const l of e){const c=this._pathPoints(l);c&&c.length>=3&&s.push(c)}if(!s.length)return;const r=l=>{let c=0;for(let u=0;u{var c;return!((c=l.points)!=null&&c.length)})&&s.length>=3||s.length>=5){const l=s.map(r).sort((u,d)=>u-d),c=l[Math.floor(l.length/2)]||0;if(c>0&&(s=s.filter(u=>r(u)<=c*10)),!s.length)return}if(this._pickCurIdx>=0&&s.length&&this._pickFills.push({metaIdx:this._pickCurIdx,loops:s}),s.length>=5||s.some(l=>this._polySelfIntersects(l))||this._hatchHasNestedLoop(s)){this._hatchFillEvenOddCanvas(s,t);return}const o=new Wn({color:new Qe(t),side:zt});for(const l of s)try{const c=new mf;c.moveTo(l[0].x,l[0].y);for(let u=1;u{let l=0;for(let c=0;c{let l=1/0,c=1/0,u=-1/0,d=-1/0;for(const h of o)h.xu&&(u=h.x),h.y>d&&(d=h.y);return{minX:l,minY:c,maxX:u,maxY:d}},s=(o,l)=>{let c=!1;for(let u=0,d=o.length-1;ul.y!=f.y>l.y&&l.x<(f.x-h.x)*(l.y-h.y)/(f.y-h.y)+h.x&&(c=!c)}return c},r=e.map(t),a=e.map(i);for(let o=0;o=h.maxX&&d.maxY>=h.maxY||s(e[u],{x:l,y:c}))return!0}}return!1}_polySelfIntersects(e){const t=e.length;if(t<4)return!1;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=(a,o,l,c)=>{const u=i(a,o,l),d=i(a,o,c),h=i(l,c,a),f=i(l,c,o);return(u>0&&d<0||u<0&&d>0)&&(h>0&&f<0||h<0&&f>0)},r=Math.min(t,80);for(let a=0;as&&(s=b.x),b.y>r&&(r=b.y);const a=s-t,o=r-i,l=Math.min(a,o);if(!(l>1e-9))return!1;const c=(t+s)/2,u=(i+r)/2,d=.55*l,h=.22*l;let f=0;for(let b=0;b1e-9&&g>_*1.15}_convexHull(e){const t=e.map(a=>({x:a.x,y:a.y})).sort((a,o)=>a.x-o.x||a.y-o.y);if(t.length<=2)return t;const i=(a,o,l)=>(o.x-a.x)*(l.y-a.y)-(o.y-a.y)*(l.x-a.x),s=[];for(const a of t){for(;s.length>=2&&i(s[s.length-2],s[s.length-1],a)<=0;)s.pop();s.push(a)}const r=[];for(let a=t.length-1;a>=0;a--){const o=t[a];for(;r.length>=2&&i(r[r.length-2],r[r.length-1],o)<=0;)r.pop();r.push(o)}return s.pop(),r.pop(),s.concat(r)}_polyCentroid(e){let t=0,i=0;for(const s of e)t+=s.x,i+=s.y;return{x:t/e.length,y:i/e.length}}_pointInPoly(e,t){let i=!1;for(let s=0,r=e.length-1;st.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(i=!i)}return i}_hatchFillEvenOddCanvas(e,t){let i=1/0,s=1/0,r=-1/0,a=-1/0;for(const w of e)for(const U of w)U.xr&&(r=U.x),U.y>a&&(a=U.y);const o=r-i,l=a-s;if(!(o>1e-12)||!(l>1e-12))return;const c=2048,u=Math.min(c/o,c/l,64),d=Math.max(2,Math.ceil(o*u)+2),h=Math.max(2,Math.ceil(l*u)+2),f=(d-2)/o,p=(h-2)/l,g=document.createElement("canvas");g.width=d,g.height=h;const m=g.getContext("2d");if(!m)return;m.clearRect(0,0,d,h);const _=w=>({x:1+(w.x-i)*f,y:1+(a-w.y)*p}),b=w=>{if(w.length<3)return;const U=_(w[0]);m.moveTo(U.x,U.y);for(let O=1;Othis._convexHull(w)),S=w=>{if(w.length<3||!M.length)return!1;const U=this._polyCentroid(w);for(const O of M)if(O.length>=3&&this._pointInPoly(O,U))return!0;return!1};if(A.length){m.fillStyle="#ffffff",m.beginPath();for(const U of A)b(U);m.fill("nonzero");const w=y.filter(S);if(w.length){m.globalCompositeOperation="destination-out",m.beginPath();for(const U of w)b(U);m.fill("nonzero"),m.globalCompositeOperation="source-over"}}const E=y.filter(w=>!S(w));if(E.length){m.fillStyle="#ffffff",m.beginPath();for(const w of E)b(w);m.fill("evenodd")}const v=new _a(g);v.colorSpace=ci,v.magFilter=Xt,v.minFilter=Ui,v.generateMipmaps=!0,v.needsUpdate=!0;const T=new Wn({map:v,color:new Qe(t),transparent:!0,alphaTest:.4,side:zt,depthWrite:!1}),I=new ts(o,l),L=new Vt(I,T);L.position.set((i+r)/2,(s+a)/2,0),this._group.add(L)}_multilineSprite(e,t,i,s,r,a,o,l=0){const u="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",d=document.createElement("canvas"),h=d.getContext("2d");h.font=u;let f=1,p=96*.7,g=96*.2;for(const O of e){const P=h.measureText(O||" ");f=Math.max(f,Math.ceil(P.width)),p=Math.max(p,P.actualBoundingBoxAscent||96*.7),g=Math.max(g,P.actualBoundingBoxDescent||96*.2)}const m=Math.ceil(96*.15),_=Math.ceil(p+g+96*.35);d.width=f+m*2,d.height=_*e.length+m*2,h.font=u;const b=r>>16&255,A=r>>8&255,y=r&255;h.fillStyle=`rgb(${b},${A},${y})`,h.textBaseline="alphabetic";let M=m;a===1||a===4?(h.textAlign="center",M=d.width/2):a===2?(h.textAlign="right",M=d.width-m):(h.textAlign="left",M=m);for(let O=0;O0?e.linespacingFactor:1,u=o*(5/3)*c;let d=0;if(t!=null&&t.measureEm)for(const U of l)d=Math.max(d,t.measureEm(U||" "));else for(const U of l)d=Math.max(d,(U||" ").length*.9);let h=Math.max(d*o,o*.5),f=l.length<=1?o:o+(l.length-1)*u;e.rectWidth>0&&(h=Math.max(h,e.rectWidth)),e.rectHeight>0&&(f=Math.max(f,e.rectHeight));const p=e.bgScale>0?e.bgScale:1.5,g=h*p,m=f*p,_=e.alignH??1,b=e.alignV??2;let A=0,y=0;_===0||_===3||_===5?A=h/2:_===2&&(A=-h/2),b===3?y=-f/2:(b===0||b===1)&&(y=f/2);const M=e.rotation||0,S=Math.cos(M),E=Math.sin(M),v=e.pos.x+A*S-y*E,T=e.pos.y+A*E+y*S;let I=16776960;if(s&2)I=((w=(L=this._scene)==null?void 0:L.background)==null?void 0:w.r)<.5?658189:16250611;else if(e.bgColorRgb&&e.bgColorRgb.r!=null)I=(e.bgColorRgb.r&255)<<16|(e.bgColorRgb.g&255)<<8|e.bgColorRgb.b&255;else if(e.bgColorIndex!=null){const U=Ea(e.bgColorIndex);U!=null&&(I=U)}if(r){const U=new ts(g,m),O=new Wn({color:new Qe(I),side:zt,depthWrite:!1,transparent:!1}),P=new Vt(U,O);P.position.set(v,T,.4),P.rotation.z=M,this._group.add(P)}if(a&&!r){const U=g/2,O=m/2,Z=[[-U,-O],[U,-O],[U,O],[-U,O],[-U,-O]].map(([N,W])=>({x:v+N*S-W*E,y:T+N*E+W*S}));for(let N=0;N<4;N++){const W=Z[N],D=Z[N+1];this._widePolyMesh([W,D],null,!1,{constantWidth:Math.max(o*.05,.01)},I,1,null)}}}async _drawTexts(e,t){const i=this._textGen,s=e.filter(o=>o.underlay),r=e.filter(o=>!o.underlay),a=[{list:s,order:0},{list:r,order:1}];try{const o=await Nr.shared();if(i!==this._textGen)return;for(const{list:l,order:c}of a){if(!l.length)continue;for(const h of l)h.bgFillFlags|0&&this._drawMTextBackground(h,o,t);const u=new dA(o);for(const h of l)u.add(h.text,h.pos,Math.max(h.height,t),h.rotation||0,h.color,h.alignH??0,h.alignV??0);const d=u.build();d&&(d.renderOrder=c,d.material&&(d.material.depthWrite=!1,d.material.transparent=!0),this._group.add(d))}}catch(o){if(console.warn("[Viewer2D] Slug text unavailable, falling back to canvas sprites:",(o==null?void 0:o.message)??o),i!==this._textGen)return;for(const{list:l,order:c}of a)for(const u of l)u.bgFillFlags|0&&this._drawMTextBackground(u,null,t),this._textSprite(u.text,u.pos,Math.max(u.height,t),u.rotation,u.color,u.alignH??0,u.alignV??0,c)}}_textSprite(e,t,i,s,r,a=0,o=0,l=0){const c=String(e).split(` +`);if(c.length>1){this._multilineSprite(c,t,i,s,r,a,o,l);return}const u=e+"\0"+r;let d=(this._texCache??(this._texCache=new Map)).get(u);if(!d){const v="96px 'Malgun Gothic', 'Apple SD Gothic Neo', monospace",T=document.createElement("canvas"),I=T.getContext("2d");I.font=v;const L=I.measureText(e),w=Math.max(1,Math.ceil(L.width)),U=L.actualBoundingBoxAscent||96*.7,O=L.actualBoundingBoxDescent||96*.2,P=Math.ceil(96*.15);T.width=w+P*2,T.height=Math.ceil(U+O)+P*2,I.font=v;const Z=r>>16&255,N=r>>8&255,W=r&255;I.fillStyle=`rgb(${Z},${N},${W})`,I.textBaseline="alphabetic",I.fillText(e,P,P+U),d={texture:new _a(T),w:T.width,h:T.height,asc:U,pad:P},this._texCache.set(u,d)}const{texture:h,asc:f,pad:p}=d,g=i*d.h/f,m=g*(d.w/d.h),_=g/d.h,b=d.h/2;let A=0;a===0||a===3||a===5?A=m/2:a===1||a===4?A=0:a===2&&(A=-m/2);let y=0;a!==4&&(o===0||o===1?y=(p+f-b)*_:o===3&&(y=(p-b)*_));const M=new gc({map:h,transparent:!0,depthTest:!1});s&&(M.rotation=s);const S=new Nu(M);S.scale.set(m,g,1),S.position.set(t.x+A,t.y+y,1),S.renderOrder=l,this._group.add(S)}_insertEntities(e,t,i,s,r,a){var v,T,I,L,w,U,O,P,Z,N;const o=a==null?void 0:a.entsByOwner,l=a==null?void 0:a.blockBase,c=(a==null?void 0:a.parentXf)??null,u=(a==null?void 0:a.scale)??1,d=(a==null?void 0:a.rot)??0,h=(a==null?void 0:a.depth)??0,f=t.insertionPoint??{x:0,y:0},p=t.basePoint,g=t.xScale??1,m=t.yScale??1,_=t.rotation??0,b=Math.cos(_),A=Math.sin(_),y=(W,D)=>{const re=p?W-p.x:W,ie=p?D-p.y:D;return[f.x+re*g*b-ie*m*A,f.y+re*g*A+ie*m*b]},M=c?(W,D)=>c(...y(W,D)):y,S=u*Math.max(Math.abs(g),Math.abs(m)),E=d+_;for(const W of e){const D=W.data||W,re=(W.type||W.typeName||"").toUpperCase();if(re==="ATTDEF")continue;const ie=this._resolveBlockColor(W,i);try{if(re==="LINE"&&D.start&&D.end){const[oe,_e]=M(D.start.x,D.start.y),[de,le]=M(D.end.x,D.end.y);s(oe,_e,de,le,0,ie)}else if((re==="CIRCLE"||re==="ARC")&&D.center&&D.radius!=null){const[oe,_e]=M(D.center.x,D.center.y),de=D.radius*S,le=re==="ARC"?(D.startAngle??0)+E:0,z=re==="ARC"?(D.endAngle??Math.PI*2)+E:Math.PI*2;this._arcSegs({x:oe,y:_e,z:0},de,le,z,0,ie,s)}else if(re==="ELLIPSE"&&D.center){const[oe,_e]=M(D.center.x,D.center.y),de=D.majorAxis??D.smAxis??{x:1,y:0},le=Math.hypot(de.x??0,de.y??0)*S,z=Math.atan2(de.y??0,de.x??1)+E;this._ellipseSegs({center:{x:oe,y:_e,z:0},majorAxis:{x:le*Math.cos(z),y:le*Math.sin(z)},ratio:D.ratio??D.axisRatio??1,startParam:D.startParam??0,endParam:D.endParam??Math.PI*2},ie,s)}else if((re==="LWPOLYLINE"||re==="POLYLINE")&&(D.points||D.vertices)){const _e=(D.points??D.vertices).map(ne=>{const[J,xe]=M(ne.x,ne.y);return{x:J,y:xe}}),de=D.bulges??null,le=!!(D.closed||D.flags&1);let z=!1;if(_e.length>=2&&this._pickFills.length){let ne=0,J=0,xe=1/0,Ae=1/0,Se=-1/0,Be=-1/0;for(const Oe of _e)ne+=Oe.x,J+=Oe.y,Oe.xSe&&(Se=Oe.x),Oe.y>Be&&(Be=Oe.y);ne/=_e.length,J/=_e.length;const ze=Math.max(Se-xe,1e-9),Ue=Math.max(Be-Ae,1e-9);for(const Oe of this._pickFills)if(this._pointInAnyLoop(Oe.loops,ne,J)){for(const Xe of Oe.loops){if(!(Xe!=null&&Xe.length))continue;let tt=1/0,rt=1/0,mt=-1/0,yt=-1/0;for(const et of Xe)et.xmt&&(mt=et.x),et.y>yt&&(yt=et.y);const ct=Math.max(mt-tt,1e-9),ut=Math.max(yt-rt,1e-9);if(ze<=ct*1.5&&Ue<=ut*1.5&&ct<=ze*1.5&&ut<=Ue*1.5){z=!0;break}}if(z)break}}if(!z){const ne=le?_e.length:_e.length-1;this._polyHasWidth(W,ne,S)?this._widePolyMesh(_e,de,le,W,ie,S,null):(de!=null&&de.some(J=>Math.abs(J)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s),this._fillClosedPolyIfUncovered(_e,de,ie))}}else if(re==="POLYLINE_2D"&&o){const oe=(o.get((T=(v=W.handle)==null?void 0:v.value)==null?void 0:T.toString(16))??[]).filter(_e=>(_e.type||"").toUpperCase().startsWith("VERTEX")&&_e.point);if(oe.length>=2){const _e=oe.map(z=>{const[ne,J]=M(z.point.x,z.point.y);return{x:ne,y:J}}),de=oe.map(z=>z.bulge||0),le=(D.flags&1)===1;de.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(_e,de,le,ie,s):this._polylineSegs(_e,le,0,ie,s)}}else if(re==="HATCH"){const oe=D.paths??W.paths;if(oe!=null&&oe.length){const _e=D.solidFill??W.solidFill??!1,de=oe.map(le=>({...le,points:(le.points??[]).map(z=>{const[ne,J]=M(z.x,z.y);return{x:ne,y:J}})}));if(_e)this._hatchFill(de,ie);else for(const le of de)(((I=le.points)==null?void 0:I.length)??0)<2||((L=le.bulges)!=null&&L.some(z=>Math.abs(z)>=1e-6)?this._bulgePolySegs(le.points,le.bulges,!0,ie,s):this._polylineSegs(le.points,!0,0,ie,s))}}else if(re==="SOLID"){const oe=[D.corner1||D.pt1,D.corner2||D.pt2,D.corner3||D.pt3,D.corner4||D.pt4].filter(Boolean);if(oe.length>=3){const _e=oe.map(de=>{const[le,z]=M(de.x,de.y);return{x:le,y:z,z:de.z||0}});this._solidMesh(_e,ie)}}else if(re==="INSERT"&&o&&h<8){const oe=((w=W.blockHeaderHandle)==null?void 0:w.value)??((U=D.blockHeaderHandle)==null?void 0:U.value);if(oe!=null){const _e=oe.toString(16),de=o.get(_e)??[];if(de.length){const le=W.insertionPt??D.insertionPt??D.insertionPoint??{x:0,y:0},z=D.scaleX??((O=D.scale)==null?void 0:O.x)??((P=W.scale)==null?void 0:P.x)??1,ne=D.scaleY??((Z=D.scale)==null?void 0:Z.y)??((N=W.scale)==null?void 0:N.y)??1,J=D.rotation??W.rotation??0;this._insertEntities(de,{insertionPoint:le,xScale:z,yScale:ne,rotation:J,basePoint:l==null?void 0:l.get(_e)},ie,s,r,{entsByOwner:o,blockBase:l,parentXf:M,scale:S,rot:E,depth:h+1})}}}else if((re==="TEXT"||re==="MTEXT"||re==="ATTRIB"||re==="ATTDEF")&&r){if((re==="ATTRIB"||re==="ATTDEF")&&(D.flags??0)&1)continue;const oe=W.text??D.text??D.textValue??D.defaultValue??"",_e=Fs(oe);let de,le,z=(D.rotationAngle??0)+E;if(re==="MTEXT"){const Ue=W.attachment??D.attachment??W.attachmentPoint??D.attachmentPoint??5;de=[1,4,7].includes(Ue)?0:[3,6,9].includes(Ue)?2:1,le=[1,2,3].includes(Ue)?3:[7,8,9].includes(Ue)?1:2;const Oe=W.xAxisDir??D.xAxisDir;Oe&&(z=Math.atan2(Oe.y,Oe.x)+E)}else de=D.horizAlignment??W.horizAlignment??0,le=D.vertAlignment??W.vertAlignment??0;const ne=re!=="MTEXT"&&(de!==0||le!==0),J=W.alignmentPt??D.alignmentPt,xe=W.insertionPt??D.insertionPt??D.insertionPoint,Ae=ne?J??xe??{x:0,y:0}:xe??{x:0,y:0},[Se,Be]=M(Ae.x,Ae.y),ze=(D.textHeight??D.height??W.textHeight??2.5)*S;if(_e){const Ue={text:_e,pos:{x:Se,y:Be},height:ze,rotation:z,color:ie,alignH:de,alignV:le};re==="MTEXT"&&(Ue.linespacingFactor=W.linespacingFactor??D.linespacingFactor??1,Ue.rectWidth=(W.rectWidth??D.rectWidth??0)*S,Ue.rectHeight=(W.rectHeight??D.rectHeight??0)*S,Ue.bgFillFlags=W.bgFillFlags??D.bgFillFlags??0,Ue.bgScale=W.bgScale??D.bgScale??1.5,Ue.bgColorIndex=W.bgColorIndex??D.bgColorIndex,Ue.bgColorRgb=W.bgColorRgb??D.bgColorRgb),r.push(Ue)}}}catch{}}}_renderDimFallback(e,t,i,s,r,a,o){const l=e.pt10??t.pt10,c=e.pt13??t.pt13,u=e.pt14??t.pt14,d=e.pt15??t.pt15,h=e.textMidPt??t.textMidPt,f=e.actualMeasurement??t.actualMeasurement??0,p=e.textRot??t.textRot??0,g=e.dimRot??t.dimRot??0,m=e.userText??t.userText??"",_=S=>Math.abs(S)<1?S.toFixed(3):S.toFixed(2),b=(S,E)=>{!S||!E||(r(S.x,S.y,E.x,E.y,0,s),o(S.x,S.y),o(E.x,E.y))},A=(S,E,v,T,I)=>{this._arcSegs({x:S,y:E},v,T,I,0,s,r)},y=(S,E,v)=>this._arrowMesh(S,E,v,s),M=(S,E,v,T)=>{E&&S&&a.push({text:E,pos:S,height:v,rotation:T??0,color:s,alignH:1,alignV:2})};switch(i){case"DIMENSION":case"DIMENSION_LINEAR":case"DIMENSION_ALIGNED":{if(!c||!u||!l)return;let S,E,v,T;if(i==="DIMENSION_ALIGNED"){const L=u.x-c.x,w=u.y-c.y,U=Math.hypot(L,w);if(U<1e-9)return;const O=L/U,P=w/U,Z=f/2;S=l.x-O*Z,E=l.y-P*Z,v=l.x+O*Z,T=l.y+P*Z}else{const L=Math.abs(Math.sin(g))>.5,w=f/2;S=l.x-(L?0:w),E=l.y-(L?w:0),v=l.x+(L?0:w),T=l.y+(L?w:0)}const I=Math.max(f*.04,1);b({x:S,y:E},{x:v,y:T}),b(c,{x:S,y:E}),b(u,{x:v,y:T}),y({x:S,y:E,z:0},Math.atan2(E-T,S-v),I),y({x:v,y:T,z:0},Math.atan2(T-E,v-S),I),M(h??{x:(S+v)/2,y:(E+T)/2},m||_(f),Math.max(I*1.5,1),p);break}case"DIMENSION_RADIUS":{if(!l||!d)return;const S=Math.max(f*.05,.5);b(l,d),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),S),M(h??{x:(l.x+d.x)/2,y:(l.y+d.y)/2},m||`R${_(f)}`,Math.max(S*2,1));break}case"DIMENSION_DIAMETER":{if(!l||!d)return;const S={x:2*l.x-d.x,y:2*l.y-d.y},E=Math.max(f/2*.05,.5);b(d,S),y({x:d.x,y:d.y,z:0},Math.atan2(d.y-l.y,d.x-l.x),E),y({x:S.x,y:S.y,z:0},Math.atan2(S.y-l.y,S.x-l.x),E),M(h??l,m||`Ø${_(f)}`,Math.max(E*2,1));break}case"DIMENSION_ANG_3PT":case"DIMENSION_ANG_2LN":{if(!l||!c||!u)return;const S=l.x,E=l.y,v=Math.hypot(c.x-S,c.y-E);if(v<1e-9)return;let T=Math.atan2(c.y-E,c.x-S),I=Math.atan2(u.y-E,u.x-S),L=I-T;for(;L<0;)L+=Math.PI*2;L>Math.PI&&([T,I]=[I,T],L=Math.PI*2-L),A(S,E,v,T,T+L);const w=Math.max(v*.05,.5);y({x:S+Math.cos(T)*v,y:E+Math.sin(T)*v,z:0},T-Math.PI/2,w),y({x:S+Math.cos(T+L)*v,y:E+Math.sin(T+L)*v,z:0},T+L+Math.PI/2,w);const U=T+L/2;M(h??{x:S+Math.cos(U)*v*1.2,y:E+Math.sin(U)*v*1.2},m||`${(f*180/Math.PI).toFixed(1)}°`,Math.max(v*.1,1));break}case"DIMENSION_ORDINATE":{if(!l||!c)return;b(l,c),M(h??c,m||((f==null?void 0:f.toFixed(2))??""),2.5);break}}}_onClick(e){var f;if(this._downXY){const p=e.clientX-this._downXY[0],g=e.clientY-this._downXY[1];if(Math.hypot(p,g)>5)return}const t=this._camera,i=this._renderer.domElement.getBoundingClientRect(),s=this._screenToWcs(e.clientX,e.clientY);if(!s)return;const r=s.x,a=s.y;if(this._measureActive){this._doMeasure2D(r,a);return}const o=SA*(t.right-t.left)/(i.width*(t.zoom||1));let l=-1,c=o;const u=this._pickSegs,d=this._pickSegMeta;for(let p=0,g=0;p=0?this._entityMeta[l]:null;this._highlight(h),(f=this._onSelectCb)==null||f.call(this,h?h.entity:null)}_segDist(e,t,i,s,r,a){const o=r-i,l=a-s,c=o*o+l*l;if(!c)return Math.hypot(e-i,t-s);const u=Math.max(0,Math.min(1,((e-i)*o+(t-s)*l)/c));return Math.hypot(e-(i+u*o),t-(s+u*l))}startMeasure(e){this.stopMeasure(),this._measureCb=e,this._measureActive=!0}stopMeasure(){var e,t;this._measureActive=!1,this._measureCb=null,this._measurePtA=null;for(const i of this._measureMarkers)this._group.remove(i),(e=i.geometry)==null||e.dispose(),(t=i.material)==null||t.dispose();this._measureMarkers=[]}_doMeasure2D(e,t){var i,s;if(this._measurePtA){const r=this._measurePtA,a=Math.hypot(e-r.x,t-r.y),o=this._mkMeasureMarker(e,t),l=this._mkMeasureLine(r.x,r.y,e,t);this._measureMarkers.push(o,l),this._group.add(o,l),(s=this._measureCb)==null||s.call(this,{phase:"done",ax:r.x,ay:r.y,az:0,bx:e,by:t,bz:0,d:a}),this._measurePtA=null}else{this._measurePtA={x:e,y:t};const r=this._mkMeasureMarker(e,t);this._measureMarkers.push(r),this._group.add(r),(i=this._measureCb)==null||i.call(this,{phase:"a",ax:e,ay:t,az:0,bx:e,by:t,bz:0,d:0})}}_mkMeasureMarker(e,t){const i=this._camera,s=this._renderer.domElement.getBoundingClientRect(),r=(i.right-i.left)/(s.width*(i.zoom||1))*8,a=[new B(e-r,t,0),new B(e+r,t,0),new B(e,t-r,0),new B(e,t+r,0)],o=new Ct().setFromPoints(a);o.setIndex([0,1,2,3]);const l=new Bs({color:15085616,depthTest:!1}),c=new ga(o,l);return c.renderOrder=100,c}_mkMeasureLine(e,t,i,s){const r=new Ct().setFromPoints([new B(e,t,0),new B(i,s,0)]),a=new Bs({color:15085616,depthTest:!1}),o=new lf(r,a);return o.renderOrder=100,o}_highlight(e){const t=this._lineColorAttr,i=this._origColors;if(this._selMeta&&t&&i){const s=this._selMeta;for(let r=s.colStart;re.colStart){const s=this._selColor;for(let r=e.colStart;r>1:0;if(i<32)return t.clone();const s=new Float64Array(i),r=new Float64Array(i);let a=0;for(let b=0;b+1d)||!(p>f))return t.clone();const g=Math.max((h-d)*.02,1),m=Math.max((p-f)*.02,1),_=new ki(new B(d-g,f-m,0),new B(h+g,p+m,0));return _.min.max(t.min),_.max.min(t.max),_}_fit(e){if(!e||e.isEmpty())return;const t=e.getCenter(new B),i=e.getSize(new B),s=this._container.clientWidth||800,r=this._container.clientHeight||600,a=s/Math.max(r,1),o=1.12,l=Math.max(i.x,1e-9),c=Math.max(i.y,1e-9),u=l/c;let d,h;u>a*8?(h=c*o,d=h*a):ua?h=d/a:d=h*a),this._camera.zoom=1,this._camera.left=-d/2,this._camera.right=d/2,this._camera.top=h/2,this._camera.bottom=-h/2;const f=Math.max(d,h,1e3);this._camera.near=-f,this._camera.far=f,this._camera.position.set(t.x,t.y,100);const p=-(this._viewTwist||0);this._camera.up.set(-Math.sin(p),Math.cos(p),0),this._controls.target.set(t.x,t.y,0),this._camera.lookAt(this._controls.target),this._camera.updateProjectionMatrix(),this._camera.updateMatrixWorld(!0),this._controls.update()}_clear(){var e,t,i;for(let s=this._group.children.length-1;s>=0;s--){const r=this._group.children[s];(e=r.geometry)==null||e.dispose(),r.material&&((t=r.material.map)==null||t.dispose(),r.material.dispose()),this._group.remove(r)}(i=this._texCache)==null||i.clear(),this._textGen++,this._contentBox=null}_onResize(){const e=this._container.clientWidth,t=this._container.clientHeight;if(!e||!t)return;this._renderer.setSize(e,t);const i=(this._camera.right-this._camera.left)/2,s=i/(e/t);this._camera.left=-i,this._camera.right=i,this._camera.top=s,this._camera.bottom=-s,this._camera.updateProjectionMatrix()}_animate(){requestAnimationFrame(()=>this._animate()),this._controls.update(),this._renderer.render(this._scene,this._camera)}}const MA="modulepreload",AA=function(n){return"/"+n},bd={},EA=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),o=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=AA(l),l in bd)return;bd[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":MA,c||(d.as="script"),d.crossOrigin="",d.href=l,o&&d.setAttribute("nonce",o),document.head.appendChild(d),c)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return s.then(a=>{for(const o of a||[])o.status==="rejected"&&r(o.reason);return e().catch(r)})},Md=/[\uAC00-\uD7A3]/,Ad=/[\u1100-\u11FF\u3130-\u318F]/,TA=["cp949","windows-949","euc-kr"];let xr;function CA(){if(xr!==void 0)return xr;for(const n of TA)try{return xr=new TextDecoder(n),xr}catch{}return xr=null,null}function Ed(n){if(!n||Md.test(n)||Ad.test(n))return n;let e=!1;const t=new Uint8Array(n.length);for(let r=0;r255)return n;a>127&&(e=!0),t[r]=a}if(!e)return n;const i=CA();if(!i)return n;let s;try{s=i.decode(t)}catch{return n}return(Md.test(s)||Ad.test(s))&&!s.includes("�")?s:n}function wA(n){if(n==null||typeof n!="object")return n;const e=new WeakSet,t=i=>{if(i==null||typeof i!="object"||e.has(i))return;if(e.add(i),Array.isArray(i)){for(let r=0;r{const{initAcadrustParser:i,parseDwgAcadrust:s}=await import("./acadrustParser-BLUkSD4E.js");return{initAcadrustParser:i,parseDwgAcadrust:s}},[]);return await e(),wA(t(n))}class RA{constructor(e){this._pointer=0,this._eof=!1,this._data=e}next(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return this._pointer++,e.value=Cd(e.code,this._data[this._pointer].trim()),this._pointer++,e.code===0&&e.value==="EOF"&&(this._eof=!0),this.lastReadGroup=e,e}peek(){if(!this.hasNext())throw this._eof?new Error("Cannot call 'next' after EOF group has been read"):new Error("Unexpected end of input: EOF group not read before end of file. Ended on code "+this._data[this._pointer]);const e={code:parseInt(this._data[this._pointer])};return e.value=Cd(e.code,this._data[this._pointer+1].trim()),e}rewind(e=1){this._pointer=this._pointer-e*2}hasNext(){return!(this._eof||this._pointer>this._data.length-2)}isEOF(){return this._eof}}function Cd(n,e){return n<=9?e:n>=10&&n<=59?parseFloat(e):n>=60&&n<=99?parseInt(e):n>=100&&n<=109?e:n>=110&&n<=149?parseFloat(e):n>=160&&n<=179?parseInt(e):n>=210&&n<=239?parseFloat(e):n>=270&&n<=289?parseInt(e):n>=290&&n<=299?DA(e):n>=300&&n<=369?e:n>=370&&n<=389?parseInt(e):n>=390&&n<=399?e:n>=400&&n<=409?parseInt(e):n>=410&&n<=419?e:n>=420&&n<=429?parseInt(e):n>=430&&n<=439?e:n>=440&&n<=459?parseInt(e):n>=460&&n<=469?parseFloat(e):n>=470&&n<=481||n===999||n>=1e3&&n<=1009?e:n>=1010&&n<=1059?parseFloat(e):n>=1060&&n<=1071?parseInt(e):(console.log("WARNING: Group code does not have a defined type: %j",{code:n,value:e}),e)}function DA(n){if(n==="0")return!1;if(n==="1")return!0;throw TypeError("String '"+n+"' cannot be cast to Boolean type")}const zp=[0,16711680,16776960,65280,65535,255,16711935,16777215,8421504,12632256,16711680,16744319,13369344,13395558,10027008,10046540,8323072,8339263,4980736,4990502,16727808,16752511,13382400,13401958,10036736,10051404,8331008,8343359,4985600,4992806,16744192,16760703,13395456,13408614,10046464,10056268,8339200,8347455,4990464,4995366,16760576,16768895,13408512,13415014,10056192,10061132,8347392,8351551,4995328,4997670,16776960,16777087,13421568,13421670,10000384,10000460,8355584,8355647,5000192,5000230,12582656,14679935,10079232,11717734,7510016,8755276,6258432,7307071,3755008,4344870,8388352,12582783,6736896,10079334,5019648,7510092,4161280,6258495,2509824,3755046,4194048,10485631,3394560,8375398,2529280,6264908,2064128,5209919,1264640,3099686,65280,8388479,52224,6736998,38912,5019724,32512,4161343,19456,2509862,65343,8388511,52275,6737023,38950,5019743,32543,4161359,19475,2509871,65407,8388543,52326,6737049,38988,5019762,32575,4161375,19494,2509881,65471,8388575,52377,6737074,39026,5019781,32607,4161391,19513,2509890,65535,8388607,52428,6737100,39064,5019800,32639,4161407,19532,2509900,49151,8380415,39372,6730444,29336,5014936,24447,4157311,14668,2507340,32767,8372223,26316,6724044,19608,5010072,16255,4153215,9804,2505036,16383,8364031,13260,6717388,9880,5005208,8063,4149119,4940,2502476,255,8355839,204,6710988,152,5000344,127,4145023,76,2500172,4129023,10452991,3342540,8349388,2490520,6245528,2031743,5193599,1245260,3089996,8323327,12550143,6684876,10053324,4980888,7490712,4128895,6242175,2490444,3745356,12517631,14647295,10027212,11691724,7471256,8735896,6226047,7290751,3735628,4335180,16711935,16744447,13369548,13395660,9961624,9981080,8323199,8339327,4980812,4990540,16711871,16744415,13369497,13395634,9961586,9981061,8323167,8339311,4980793,4990530,16711807,16744383,13369446,13395609,9961548,9981042,8323135,8339295,4980774,4990521,16711743,16744351,13369395,13395583,9961510,9981023,8323103,8339279,4980755,4990511,3355443,5987163,8684676,11382189,14079702,16777215];function LA(n){return zp[n]}function st(n){const e={};n.rewind();let t=n.next(),i=t.code;if(e.x=t.value,i+=10,t=n.next(),t.code!=i)throw new Error("Expected code for point value to be "+i+" but got "+t.code+".");return e.y=t.value,i+=10,t=n.next(),t.code!=i?(n.rewind(),e):(e.z=t.value,e)}function Yt(n,e,t){switch(e.code){case 0:n.type=e.value;break;case 5:n.handle=e.value;break;case 6:n.lineType=e.value;break;case 8:n.layer=e.value;break;case 48:n.lineTypeScale=e.value;break;case 60:n.visible=e.value===0;break;case 62:n.colorIndex=e.value,n.color=LA(Math.abs(e.value));break;case 67:n.inPaperSpace=e.value!==0;break;case 100:break;case 101:for(;e.code!=0;)e=t.next();t.rewind();break;case 330:n.ownerHandle=e.value;break;case 347:n.materialObjectHandle=e.value;break;case 370:n.lineweight=e.value;break;case 420:n.color=e.value;break;case 1e3:n.extendedData=n.extendedData||{},n.extendedData.customStrings=n.extendedData.customStrings||[],n.extendedData.customStrings.push(e.value);break;case 1001:n.extendedData=n.extendedData||{},n.extendedData.applicationName=e.value;break;default:return!1}return!0}class IA{constructor(){this.ForEntityName="3DFACE"}parseEntity(e,t){const i={type:t.value,vertices:[]};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.shape=(t.value&1)===1,i.hasContinuousLinetypePattern=(t.value&128)===128;break;case 10:i.vertices=PA(e,t),t=e.lastReadGroup;break;default:Yt(i,t,e);break}t=e.next()}return i}}function PA(n,e){var t=[],i=!1,s=!1,r=4;for(let o=0;o<=r;o++){for(var a={};!n.isEOF()&&!(e.code===0||s);){switch(e.code){case 10:case 11:case 12:case 13:if(i){s=!0;continue}a.x=e.value,i=!0;break;case 20:case 21:case 22:case 23:a.y=e.value;break;case 30:case 31:case 32:case 33:a.z=e.value;break;default:return t}e=n.next()}t.push(a),i=!1,s=!1}return n.rewind(),t}class UA{constructor(){this.ForEntityName="ARC"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:i.endAngle=Math.PI/180*t.value,i.angleLength=i.endAngle-i.startAngle;break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class OA{constructor(){this.ForEntityName="ATTDEF"}parseEntity(e,t){var i={type:t.value,scale:1,textStyle:"STANDARD"};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 1:i.text=t.value;break;case 2:i.tag=t.value;break;case 3:i.prompt=t.value;break;case 7:i.textStyle=t.value;break;case 10:i.startPoint=st(e);break;case 11:i.endPoint=st(e);break;case 39:i.thickness=t.value;break;case 40:i.textHeight=t.value;break;case 41:i.scale=t.value;break;case 50:i.rotation=t.value;break;case 51:i.obliqueAngle=t.value;break;case 70:i.invisible=!!(t.value&1),i.constant=!!(t.value&2),i.verificationRequired=!!(t.value&4),i.preset=!!(t.value&8);break;case 71:i.backwards=!!(t.value&2),i.mirrored=!!(t.value&4);break;case 72:i.horizontalJustification=t.value;break;case 73:i.fieldLength=t.value;break;case 74:i.verticalJustification=t.value;break;case 100:break;case 210:i.extrusionDirectionX=t.value;break;case 220:i.extrusionDirectionY=t.value;break;case 230:i.extrusionDirectionZ=t.value;break;default:Yt(i,t,e);break}t=e.next()}return i}}class NA{constructor(){this.ForEntityName="CIRCLE"}parseEntity(e,t){const i={type:t.value};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 10:i.center=st(e);break;case 40:i.radius=t.value;break;case 50:i.startAngle=Math.PI/180*t.value;break;case 51:const s=Math.PI/180*t.value;s=0&&w<=_.levels.SILENT)return w;throw new TypeError("log.setLevel() called with invalid level: "+L)}_.name=g,_.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},_.methodFactory=m||h,_.getLevel=function(){return y??A??b},_.setLevel=function(L,w){return y=T(L),w!==!1&&S(y),u.call(_)},_.setDefaultLevel=function(L){A=T(L),E()||_.setLevel(L,!1)},_.resetLevel=function(){y=null,v(),u.call(_)},_.enableAll=function(L){_.setLevel(_.levels.TRACE,L)},_.disableAll=function(L){_.setLevel(_.levels.SILENT,L)},_.rebuild=function(){if(a!==_&&(b=T(a.getLevel())),u.call(_),a===_)for(var L in r)r[L].rebuild()},b=T(a?a.getLevel():"WARN");var I=E();I!=null&&(y=T(I)),u.call(_)}a=new f,a.getLogger=function(m){if(typeof m!="symbol"&&typeof m!="string"||m==="")throw new TypeError("You must supply a name when creating a logger.");var _=r[m];return _||(_=r[m]=new f(m,a.methodFactory)),_};var p=typeof window!==t?window.log:void 0;return a.noConflict=function(){return typeof window!==t&&window.log===a&&(window.log=p),a},a.getLoggers=function(){return r},a.default=a,a})})(Vp);var eE=Vp.exports;const nt=QA(eE);nt.setLevel("error");function tE(n){n.registerEntityHandler(IA),n.registerEntityHandler(UA),n.registerEntityHandler(OA),n.registerEntityHandler(NA),n.registerEntityHandler(kA),n.registerEntityHandler(FA),n.registerEntityHandler(BA),n.registerEntityHandler(HA),n.registerEntityHandler(zA),n.registerEntityHandler(GA),n.registerEntityHandler(WA),n.registerEntityHandler(YA),n.registerEntityHandler(ZA),n.registerEntityHandler($A),n.registerEntityHandler(JA)}class nE{constructor(){this._entityHandlers={},tE(this)}parse(e){return typeof e=="string"?this._parse(e):(console.error("Cannot read dxf source of type `"+typeof e),null)}registerEntityHandler(e){const t=new e;this._entityHandlers[t.ForEntityName]=t}parseSync(e){return this.parse(e)}parseStream(e){let t="";const i=this;return new Promise((s,r)=>{e.on("data",a=>{t+=a}),e.on("end",()=>{try{s(i._parse(t))}catch(a){r(a)}}),e.on("error",a=>{r(a)})})}_parse(e){const t={};let i=0;const s=e.split(/\r\n|\r|\n/g),r=new RA(s);if(!r.hasNext())throw Error("Empty file");const a=this;let o;function l(){for(o=r.next();!r.isEOF();)if(o.code===0&&o.value==="SECTION"){if(o=r.next(),o.code!==2){console.error("Unexpected code %s after 0:SECTION",Gp(o)),o=r.next();continue}o.value==="HEADER"?(nt.debug("> HEADER"),t.header=c(),nt.debug("<")):o.value==="BLOCKS"?(nt.debug("> BLOCKS"),t.blocks=u(),nt.debug("<")):o.value==="ENTITIES"?(nt.debug("> ENTITIES"),t.entities=A(!1),nt.debug("<")):o.value==="TABLES"?(nt.debug("> TABLES"),t.tables=h(),nt.debug("<")):o.value==="EOF"?nt.debug("EOF"):nt.warn("Skipping section '%s'",o.value)}else o=r.next()}function c(){let S=null,E=null;const v={};for(o=r.next();;){if(Gn(o,0,"ENDSEC")){S&&(v[S]=E);break}else o.code===9?(S&&(v[S]=E),S=o.value):o.code===10?E={x:o.value}:o.code===20?E.y=o.value:o.code===30?E.z=o.value:E=o.value;o=r.next()}return o=r.next(),v}function u(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)if(Gn(o,0,"BLOCK")){nt.debug("block {");const E=d();nt.debug("}"),M(E),E.name?S[E.name]=E:nt.error('block with handle "'+E.handle+'" is missing a name.')}else Zi(o),o=r.next();return S}function d(){const S={};for(o=r.next();o.value!=="EOF";){switch(o.code){case 1:S.xrefPath=o.value,o=r.next();break;case 2:S.name=o.value,o=r.next();break;case 3:S.name2=o.value,o=r.next();break;case 5:S.handle=o.value,o=r.next();break;case 8:S.layer=o.value,o=r.next();break;case 10:S.position=y(o),o=r.next();break;case 67:S.paperSpace=!!(o.value&&o.value==1),o=r.next();break;case 70:o.value!=0&&(S.type=o.value),o=r.next();break;case 100:o=r.next();break;case 330:S.ownerHandle=o.value,o=r.next();break;case 0:if(o.value=="ENDBLK")break;S.entities=A(!0);break;default:Zi(o),o=r.next()}if(Gn(o,0,"ENDBLK")){o=r.next();break}}return S}function h(){const S={};for(o=r.next();o.value!=="EOF"&&!Gn(o,0,"ENDSEC");)Gn(o,0,"TABLE")?(o=r.next(),b[o.value]?(nt.debug(o.value+" Table {"),S[b[o.value].tableName]=p(o),nt.debug("}")):nt.debug("Unhandled Table "+o.value)):o=r.next();return o=r.next(),S}const f="ENDTAB";function p(S){const E=b[S.value],v={};let T=0;for(o=r.next();!Gn(o,0,f);)switch(o.code){case 5:v.handle=o.value,o=r.next();break;case 330:v.ownerHandle=o.value,o=r.next();break;case 100:o.value==="AcDbSymbolTable"||Zi(o),o=r.next();break;case 70:T=o.value,o=r.next();break;case 0:o.value===E.dxfSymbolName?v[E.tableRecordsProperty]=E.parseTableRecords():(Zi(o),o=r.next());break;default:Zi(o),o=r.next()}const I=v[E.tableRecordsProperty];if(I){let L=(()=>{if(I.constructor===Array)return I.length;if(typeof I=="object")return Object.keys(I).length})();T!==L&&nt.warn("Parsed "+L+" "+E.dxfSymbolName+"'s but expected "+T)}return o=r.next(),v}function g(){const S=[];let E={};for(nt.debug("ViewPort {"),o=r.next();!Gn(o,0,f);)switch(o.code){case 2:E.name=o.value,o=r.next();break;case 10:E.lowerLeftCorner=y(o),o=r.next();break;case 11:E.upperRightCorner=y(o),o=r.next();break;case 12:E.center=y(o),o=r.next();break;case 13:E.snapBasePoint=y(o),o=r.next();break;case 14:E.snapSpacing=y(o),o=r.next();break;case 15:E.gridSpacing=y(o),o=r.next();break;case 16:E.viewDirectionFromTarget=y(o),o=r.next();break;case 17:E.viewTarget=y(o),o=r.next();break;case 42:E.lensLength=o.value,o=r.next();break;case 43:E.frontClippingPlane=o.value,o=r.next();break;case 44:E.backClippingPlane=o.value,o=r.next();break;case 45:E.viewHeight=o.value,o=r.next();break;case 50:E.snapRotationAngle=o.value,o=r.next();break;case 51:E.viewTwistAngle=o.value,o=r.next();break;case 79:E.orthographicType=o.value,o=r.next();break;case 110:E.ucsOrigin=y(o),o=r.next();break;case 111:E.ucsXAxis=y(o),o=r.next();break;case 112:E.ucsYAxis=y(o),o=r.next();break;case 110:E.ucsOrigin=y(o),o=r.next();break;case 281:E.renderMode=o.value,o=r.next();break;case 281:E.defaultLightingType=o.value,o=r.next();break;case 292:E.defaultLightingOn=o.value,o=r.next();break;case 330:E.ownerHandle=o.value,o=r.next();break;case 63:case 421:case 431:E.ambientColor=o.value,o=r.next();break;case 0:o.value==="VPORT"&&(nt.debug("}"),S.push(E),nt.debug("ViewPort {"),E={},o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S.push(E),S}function m(){const S={};let E={},v=0,T;for(nt.debug("LType {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:E.name=o.value,T=o.value,o=r.next();break;case 3:E.description=o.value,o=r.next();break;case 73:v=o.value,v>0&&(E.pattern=[]),o=r.next();break;case 40:E.patternLength=o.value,o=r.next();break;case 49:E.pattern.push(o.value),o=r.next();break;case 0:nt.debug("}"),v>0&&v!==E.pattern.length&&nt.warn("lengths do not match on LTYPE pattern"),S[T]=E,E={},nt.debug("LType {"),o=r.next();break;default:o=r.next()}return nt.debug("}"),S[T]=E,S}function _(){const S={};let E={},v;for(nt.debug("Layer {"),o=r.next();!Gn(o,0,"ENDTAB");)switch(o.code){case 2:E.name=o.value,v=o.value,o=r.next();break;case 62:E.visible=o.value>=0,E.colorIndex=Math.abs(o.value),E.color=iE(E.colorIndex),o=r.next();break;case 70:E.frozen=(o.value&1)!=0||(o.value&2)!=0,o=r.next();break;case 0:o.value==="LAYER"&&(nt.debug("}"),S[v]=E,nt.debug("Layer {"),E={},v=void 0,o=r.next());break;default:Zi(o),o=r.next();break}return nt.debug("}"),S[v]=E,S}const b={VPORT:{tableRecordsProperty:"viewPorts",tableName:"viewPort",dxfSymbolName:"VPORT",parseTableRecords:g},LTYPE:{tableRecordsProperty:"lineTypes",tableName:"lineType",dxfSymbolName:"LTYPE",parseTableRecords:m},LAYER:{tableRecordsProperty:"layers",tableName:"layer",dxfSymbolName:"LAYER",parseTableRecords:_}};function A(S){const E=[],v=S?"ENDBLK":"ENDSEC";for(S||(o=r.next());;)if(o.code===0){if(o.value===v)break;const T=a._entityHandlers[o.value];if(T!=null){nt.debug(o.value+" {");const I=T.parseEntity(r,o);o=r.lastReadGroup,nt.debug("}"),M(I),E.push(I)}else{nt.warn("Unhandled entity "+o.value),o=r.next();continue}}else o=r.next();return v=="ENDSEC"&&(o=r.next()),E}function y(S){const E={};let v=S.code;if(E.x=S.value,v+=10,S=r.next(),S.code!=v)throw new Error("Expected code for point value to be "+v+" but got "+S.code+".");return E.y=S.value,v+=10,S=r.next(),S.code!=v?(r.rewind(),E):(E.z=S.value,E)}function M(S){if(!S)throw new TypeError("entity cannot be undefined or null");S.handle||(S.handle=i++)}return l(),t}}function Gn(n,e,t){return n.code===e&&n.value===t}function Zi(n){nt.debug("unhandled group "+Gp(n))}function Gp(n){return n.code+":"+n.value}function iE(n){return zp[n]}const Pa=Math.PI/180,sE=48;function rE(n,e,t,i,s,r,a){let o=s-i;if(r)for(;o<=0;)o+=Math.PI*2;else for(;o>=0;)o-=Math.PI*2;const l=Math.max(2,Math.ceil(Math.abs(o)/(Math.PI*2)*sE));for(let c=0;c<=l;c++){const u=i+o*c/l;a.push({x:n+t*Math.cos(u),y:e+t*Math.sin(u)})}}class aE{constructor(){this.ForEntityName="HATCH"}parseEntity(e,t){const i={type:t.value,paths:[],solidFill:!1};for(t=e.next();!e.isEOF()&&t.code!==0;){switch(t.code){case 70:i.solidFill=t.value!==0;break;case 2:i.patternName=t.value;break;case 8:i.layer=t.value;break;case 62:i.colorIndex=t.value;break;case 91:{const s=t.value;let r=e.next();for(let a=0;a=2&&t.paths.push(a),o}_readEdge(e,t,i,s){if(i===1){let r=0,a=0,o=0,l=0;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),t.points.push({x:r,y:a}),t.points.push({x:o,y:l})}else if(i===2){let r=0,a=0,o=0,l=0,c=0,u=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===40&&(o=s.value,s=e.next()),s.code===50&&(l=s.value*Pa,s=e.next()),s.code===51&&(c=s.value*Pa,s=e.next()),s.code===73&&(u=s.value,s=e.next()),rE(r,a,o,l,c,u!==0,t.points)}else if(i===3){let r=0,a=0,o=1,l=0,c=1,u=0,d=Math.PI*2,h=1;s.code===10&&(r=s.value,s=e.next()),s.code===20&&(a=s.value,s=e.next()),s.code===11&&(o=s.value,s=e.next()),s.code===21&&(l=s.value,s=e.next()),s.code===40&&(c=s.value,s=e.next()),s.code===50&&(u=s.value*Pa,s=e.next()),s.code===51&&(d=s.value*Pa,s=e.next()),s.code===73&&(h=s.value,s=e.next());const f=Math.hypot(o,l),p=f*c,g=Math.atan2(l,o);let m=d-u;if(h!==0)for(;m<=0;)m+=Math.PI*2;else for(;m>=0;)m-=Math.PI*2;const _=Math.max(4,Math.ceil(Math.abs(m)/(Math.PI*2)*72));for(let b=0;b<=_;b++){const A=u+m*b/_,y=f*Math.cos(A),M=p*Math.sin(A);t.points.push({x:r+y*Math.cos(g)-M*Math.sin(g),y:a+y*Math.sin(g)+M*Math.cos(g)})}}else if(i===4){let r=0,a=0;const o=()=>{const l=s.value|0;return s=e.next(),l};for(;!e.isEOF();)if(s.code===95)r=o();else if(s.code===96)a=o();else if(s.code===94||s.code===73||s.code===74)s=e.next();else break;for(let l=0;ln&&{x:n.x,y:n.y,z:n.z||0};function wd(n,e){var s;const t={...n};switch(delete t.color,(n.type||"").toUpperCase()){case"LINE":((s=n.vertices)==null?void 0:s.length)>=2&&(t.start=Wt(n.vertices[0]),t.end=Wt(n.vertices[1]));break;case"POLYLINE":case"LWPOLYLINE":t.type="LWPOLYLINE",t.points=(n.vertices||[]).map(Wt),t.bulges=(n.vertices||[]).map(r=>r.bulge||0),t.closed=!!n.shape||((n.flags||0)&1)===1;break;case"ARC":case"CIRCLE":t.center=Wt(n.center);break;case"ELLIPSE":t.center=Wt(n.center),t.majorAxis=Wt(n.majorAxisEndPoint),t.ratio=n.axisRatio,t.startParam=n.startAngle,t.endParam=n.endAngle;break;case"POINT":t.position=Wt(n.position);break;case"SOLID":case"3DFACE":{const r=n.points||[];r[0]&&(t.corner1=Wt(r[0])),r[1]&&(t.corner2=Wt(r[1])),r[2]&&(t.corner3=Wt(r[2])),r[3]&&(t.corner4=Wt(r[3])),t.type="SOLID";break}case"TEXT":case"ATTRIB":case"ATTDEF":t.insertionPoint=Wt(n.startPoint||n.position),t.alignmentPt=Wt(n.endPoint),t.rotationAngle=(n.rotation||0)*Ua,t.horizAlignment=n.halign||0,t.vertAlignment=n.valign||0,t.textHeight=n.textHeight??n.height;break;case"MTEXT":t.insertionPoint=Wt(n.position),t.textHeight=n.height??n.textHeight,n.directionVector?t.xAxisDir=Wt(n.directionVector):n.rotation!=null&&(t.xAxisDir={x:Math.cos(n.rotation*Ua),y:Math.sin(n.rotation*Ua)});break;case"INSERT":{t.insertionPoint=Wt(n.position),t.scaleX=n.xScale??1,t.scaleY=n.yScale??1,t.rotation=(n.rotation||0)*Ua;const r=e.get(n.name);r!=null&&(t.blockHeaderHandle={value:r});break}case"DIMENSION":{const r=e.get(n.block);r!=null&&(t.blockHeaderHandle={value:r});break}}return t}function oE(n){var u,d;const e=n.blocks||{},t=Object.keys(e),i=new Map;t.forEach((h,f)=>i.set(h,f+1));const s=t.find(h=>/model_space/i.test(h))??t.find(h=>/model/i.test(h)),r=s!=null?i.get(s):0,a=[];for(const h of n.entities||[]){const f=wd(h,i);f.ownerHandle={value:r},a.push(f)}for(const h of t){const f=i.get(h);for(const p of e[h].entities||[]){const g=wd(p,i);g.ownerHandle={value:f},a.push(g)}}const o=t.map(h=>({name:h,handle:{value:i.get(h)},basePoint:Wt(e[h].position)||{x:0,y:0,z:0}})),l=((d=(u=n.tables)==null?void 0:u.layer)==null?void 0:d.layers)||{},c=Object.values(l).map(h=>({name:h.name,colorIndex:h.colorIndex}));return{version:"dxf",vars:n.header||{},entities:a,tables:{blocks:o,layers:c}}}function lE(n){var s,r;try{return new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{}const t=(r=(s=new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(n.byteLength,4096))).match(/\$DWGCODEPAGE[\s\S]*?\n\s*3\s*\n\s*([^\r\n]+)/i))==null?void 0:s[1])==null?void 0:r.trim().toLowerCase();let i="windows-1252";t&&(/949/.test(t)?i="euc-kr":/932/.test(t)?i="shift_jis":/936/.test(t)?i="gbk":/950/.test(t)&&(i="big5"));try{return new TextDecoder(i).decode(n)}catch{return new TextDecoder("utf-8").decode(n)}}function Rd(n){return cE(lE(n))}function cE(n){const e=new nE;e.registerEntityHandler(aE);const t=e.parseSync(n);return oE(t)}const Wp=/\.dwg$/i,Xp=/\.dxf$/i;function uE(n){return Wp.test(n)}function hE(n){return Xp.test(n)}function dE(n){return Wp.test(n)||Xp.test(n)}cA("/fonts/NanumGothic-Regular.ttf");const fE=document.getElementById("app"),Dd=document.getElementById("status"),Ml=document.getElementById("layerList"),Ld=document.getElementById("layers"),Oa=document.getElementById("spaces");function tr(n,e=!1){Dd.textContent=n,Dd.classList.toggle("err",e)}const nn=new bA(fE);nn.onSelect(n=>{var t;if(!n){tr("deselected");return}const e=n;tr(`select ${e.type??"?"} · layer=${e.layer??"-"} · h=${((t=e.handle)==null?void 0:t.value)??"-"}`)});const Id=document.getElementById("coordX"),Pd=document.getElementById("coordY");function Ud(n){const e=Math.abs(n);return e>=1e6?n.toFixed(1):e>=1e3?n.toFixed(2):e>=1?n.toFixed(3):n.toFixed(4)}nn.onPointerWorld(n=>{if(!n){Id.textContent="—",Pd.textContent="—";return}Id.textContent=Ud(n.x),Pd.textContent=Ud(n.y)});function Yp(){var t;const n=nn.getSpaces(),e=nn.getActiveSpace();if(Oa.innerHTML="",n.length<2&&!((t=n[0])!=null&&t.entityCount)){Oa.style.display="none";return}Oa.style.display="flex";for(const i of n){const s=document.createElement("button");s.type="button",s.textContent=`${i.label}${i.entityCount?` (${i.entityCount})`:""}`,s.title=`${i.name} · handle ${i.handleHex}`,i.handleHex===e&&s.classList.add("active"),s.addEventListener("click",()=>{i.handleHex!==nn.getActiveSpace()&&(nn.setSpace(i.handleHex),Yp(),Zp(),nn.fit(),tr(`space ${i.label} · ${i.entityCount} entities`))}),Oa.append(s)}}async function pE(n,e){return hE(e)?Rd(n):uE(e)?Td(new Uint8Array(n)):new TextDecoder("latin1").decode(new Uint8Array(n,0,Math.min(6,n.byteLength))).startsWith("AC")?Td(new Uint8Array(n)):Rd(n)}async function Kp(n,e){const t=await pE(n,e),i=Hs(t),s=dv(i);return nn.load(t,{spaceHandle:(s==null?void 0:s.handleHex)??null}),nn.resize(),t}async function kr(n,e){const t=e??n.split("?")[0].split("/").pop()??n,i=await fetch(n);if(!i.ok)throw new Error(`HTTP ${i.status}`);return Kp(await i.arrayBuffer(),t)}async function qp(n){if(!dE(n.name))throw new Error(`not .dwg/.dxf: ${n.name}`);return Kp(await n.arrayBuffer(),n.name)}function Zp(){Ml.innerHTML="";for(const n of nn.getLayerInfo()){const e=document.createElement("label");e.dataset.name=n.name;const t=document.createElement("span");t.className="swatch",t.style.background=n.colorHex||"#888";const i=document.createElement("input");i.type="checkbox",i.checked=n.visible,i.addEventListener("change",()=>{const r=new Set;Ml.querySelectorAll("label").forEach(a=>{a.querySelector("input").checked||r.add(a.dataset.name)}),nn.setHiddenLayers(r)});const s=document.createElement("span");s.textContent=`${n.name} (${n.count})`,e.append(t,i,s),Ml.append(e)}}async function mE(n,e){var r;const i=Hs(e).find(a=>a.handleHex===nn.getActiveSpace()),s=i?` · ${i.label}`:"";tr(`✓ ${n} · ${((r=e.entities)==null?void 0:r.length)??0} entities${s}`),Yp(),Zp(),nn.fit()}async function os(n,e){tr(`loading ${n}…`);try{await mE(n,await e())}catch(t){tr(`${n}: ${t.message}`,!0),console.error(t)}}const $p="/samples/civil.dwg";document.getElementById("sample").addEventListener("click",()=>{os("BasicSample.dwg",()=>kr("/samples/BasicSample.dwg","BasicSample.dwg"))});var Od;(Od=document.getElementById("sampleCivil"))==null||Od.addEventListener("click",()=>{os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"))});document.getElementById("sampleDxf").addEventListener("click",()=>{os("simple.dxf",()=>kr("/samples/simple.dxf","simple.dxf"))});document.getElementById("file").addEventListener("change",n=>{var t;const e=(t=n.target.files)==null?void 0:t[0];e&&(os(e.name,()=>qp(e)),n.target.value="")});let Al=!0;document.getElementById("theme").addEventListener("click",()=>{Al=!Al,nn.setTheme(Al)});document.getElementById("layersBtn").addEventListener("click",()=>{Ld.style.display=Ld.style.display==="block"?"none":"block"});window.addEventListener("dragover",n=>n.preventDefault());window.addEventListener("drop",n=>{var t,i;n.preventDefault();const e=(i=(t=n.dataTransfer)==null?void 0:t.files)==null?void 0:i[0];e&&os(e.name,()=>qp(e))});const El=new URLSearchParams(location.search).get("model");El?os(El,()=>kr(El)):os("C0060202-001-평면및종단면도.dwg",()=>kr($p,"C0060202-001-평면및종단면도.dwg"));window.addEventListener("resize",()=>nn.resize()); diff --git a/dist2/index.html b/dist2/index.html index f4aae6f..b05feac 100644 --- a/dist2/index.html +++ b/dist2/index.html @@ -97,7 +97,7 @@ #coords .lbl { color: var(--accent); margin-right: 6px; font-weight: 600; } #coords .sep { color: var(--line); margin: 0 12px; } - +
@@ -108,6 +108,7 @@ +
diff --git a/dist2/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg b/dist2/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg new file mode 100644 index 0000000..3ee01bb Binary files /dev/null and b/dist2/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg differ diff --git a/dist2/samples/civil.dwg b/dist2/samples/civil.dwg new file mode 100644 index 0000000..3ee01bb Binary files /dev/null and b/dist2/samples/civil.dwg differ diff --git a/e2e_lin_test.cjs b/e2e_lin_test.cjs new file mode 100644 index 0000000..52631d0 --- /dev/null +++ b/e2e_lin_test.cjs @@ -0,0 +1,74 @@ +const fs = require('fs'); + +async function runE2EDataTest() { + console.log('=== STARTING DWG DATA & LINETYPE ACCURACY E2E TEST ==='); + + const acadrust = await import('./src/viewer2d/acadrust-dwg/acadrust_dwg.js'); + const wasmBuffer = fs.readFileSync('./src/viewer2d/acadrust-dwg/acadrust_dwg_bg.wasm'); + await acadrust.default({ module_or_path: wasmBuffer }); + + const dwgFile = './dist/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg'; + const buf = fs.readFileSync(dwgFile); + const result = acadrust.parse_dwg(new Uint8Array(buf)); + + console.log('1. Checking DWG Header & Vars:'); + console.log(' Global LTSCALE:', result.vars?.ltscale); + + console.log('\n2. Checking DWG Text Styles Table:'); + const styles = result.tables?.styles || result.tables?.textStyles || []; + console.log(` Found ${styles.length} text styles:`); + for (const st of styles) { + console.log(` - Style [${st.name || st.styleName}]: height=${st.height ?? 0}, font=${st.fontFile || st.font || 'default'}`); + } + + console.log('\n3. Checking DWG Linetype Table:'); + const lineTypes = result.tables?.lineTypes || []; + console.log(` Found ${lineTypes.length} linetypes in DWG table:`); + for (const lt of lineTypes) { + if (lt.name && (lt.name.includes('DICH') || lt.name.includes('L06') || lt.name.includes('L02'))) { + console.log(` - Linetype [${lt.name}]: desc="${lt.description}", patternLen=${lt.patternLength}, elements=[${lt.pattern?.join(', ')}]`); + } + } + + console.log('\n4. Verifying Complex Linetype Math in Viewer2D:'); + const { getLinPattern } = require('./src/viewer2d/linParser.ts'); + const targetTypes = ['H-DICHL06', 'H-DICHL06R', 'H-DICHL02R', 'H-DICHL01R', 'H-DICHL05']; + + for (const name of targetTypes) { + const pattern = getLinPattern(name); + if (!pattern) { + console.error(` [FAIL] Pattern ${name} not found in registry!`); + continue; + } + console.log(`\n * Pattern [${pattern.name}] (patternLength = ${pattern.patternLength}):`); + let cumulativeDist = 0; + for (let i = 0; i < pattern.elements.length; i++) { + const elem = pattern.elements[i]; + const nextElem = pattern.elements[(i + 1) % pattern.elements.length]; + if (elem.type === 'dash') { + const dLen = elem.val || 0; + console.log(` - [${i}] DASH: len=${dLen} (dist: ${cumulativeDist.toFixed(4)} -> ${(cumulativeDist + dLen).toFixed(4)})`); + cumulativeDist += dLen; + } else if (elem.type === 'gap') { + const gLen = Math.abs(elem.val || 0); + console.log(` - [${i}] GAP: len=${gLen} (dist: ${cumulativeDist.toFixed(4)} -> ${(cumulativeDist + gLen).toFixed(4)})`); + cumulativeDist += gLen; + } else if (elem.type === 'shape') { + console.log(` - [${i}] SHAPE: name=${elem.shapeName}, scale=${elem.scale}, rot=${elem.rotation} at dist=${cumulativeDist.toFixed(4)}`); + } else if (elem.type === 'text') { + const textGapLen = (nextElem && nextElem.type === 'gap') ? Math.abs(nextElem.val || 0) : 0; + const textMidDist = cumulativeDist + textGapLen / 2; + console.log(` - [${i}] TEXT: "${elem.text}", scale=${elem.scale}, style=${elem.style}, yOffset=${elem.yOffset}`); + console.log(` -> Text Gap Start: ${cumulativeDist.toFixed(4)}, Gap End: ${(cumulativeDist + textGapLen).toFixed(4)}`); + console.log(` -> Text EXACT MIDPOINT: ${textMidDist.toFixed(4)} (Midpoint between previous element and next element)`); + } + } + } + + console.log('\n=== E2E DATA ACCURACY TEST COMPLETED SUCCESSFULLY ==='); +} + +runE2EDataTest().catch(err => { + console.error('E2E Test Error:', err); + process.exit(1); +}); diff --git a/index.html b/index.html index ee53235..201458b 100644 --- a/index.html +++ b/index.html @@ -107,6 +107,7 @@ +
diff --git a/public/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg b/public/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg new file mode 100644 index 0000000..3ee01bb Binary files /dev/null and b/public/samples/C0060202-001-평면및종단면도(1)(대산방향STA.18+492.08-19+411.50).dwg differ diff --git a/public/samples/civil.dwg b/public/samples/civil.dwg new file mode 100644 index 0000000..3ee01bb Binary files /dev/null and b/public/samples/civil.dwg differ diff --git a/src/main.ts b/src/main.ts index 26aa81a..8f95c50 100644 --- a/src/main.ts +++ b/src/main.ts @@ -185,9 +185,14 @@ async function run(label: string, job: () => Promise) { } } +const civilFile = '/samples/civil.dwg'; + document.getElementById('sample')!.addEventListener('click', () => { void run('BasicSample.dwg', () => loadUrl('/samples/BasicSample.dwg', 'BasicSample.dwg')); }); +document.getElementById('sampleCivil')?.addEventListener('click', () => { + void run('C0060202-001-평면및종단면도.dwg', () => loadUrl(civilFile, 'C0060202-001-평면및종단면도.dwg')); +}); document.getElementById('sampleDxf')!.addEventListener('click', () => { void run('simple.dxf', () => loadUrl('/samples/simple.dxf', 'simple.dxf')); }); @@ -197,7 +202,6 @@ document.getElementById('file')!.addEventListener('change', (ev) => { void run(file.name, () => loadFile(file)); (ev.target as HTMLInputElement).value = ''; }); -document.getElementById('fit')!.addEventListener('click', () => viewer.fit()); let dark = true; document.getElementById('theme')!.addEventListener('click', () => { dark = !dark; @@ -216,6 +220,6 @@ window.addEventListener('drop', (e) => { const model = new URLSearchParams(location.search).get('model'); if (model) void run(model, () => loadUrl(model)); -else setStatus('ready · Sample DWG / DXF 또는 파일 드롭'); +else void run('C0060202-001-평면및종단면도.dwg', () => loadUrl(civilFile, 'C0060202-001-평면및종단면도.dwg')); window.addEventListener('resize', () => viewer.resize()); diff --git a/src/viewer2d/Viewer2D.js b/src/viewer2d/Viewer2D.js index 27f80ee..ab1dfa1 100644 --- a/src/viewer2d/Viewer2D.js +++ b/src/viewer2d/Viewer2D.js @@ -248,6 +248,7 @@ export class Viewer2D { this._clear(); this._entityMeta = []; this._buildLayerMap(result?.tables?.layers); + this._buildStyleMap(result?.tables?.styles || result?.tables?.textStyles); this._buildLinetypeMap(result); // Sheet orientation: the active model-space viewport's VIEWTWIST rotates the // view so a drawing stored tilted in WCS (rotated survey sheets — header UCS @@ -273,6 +274,13 @@ export class Viewer2D { else this._activeSpaceHex = typeof sh === 'number' ? sh.toString(16) : String(sh).toLowerCase(); } + if (!opts.keepTheme) { + const spacesList = listCadSpaces(result); + const activeSp = spacesList.find((s) => s.handleHex === this._activeSpaceHex); + const isPaper = activeSp?.kind === 'paper'; + this.setTheme(!isPaper); + } + const entities = result?.entities || []; const lineVerts = []; const lineColors = []; @@ -1045,9 +1053,9 @@ export class Viewer2D { // ── UI integration ───────────────────────────────────────────────────────── - /** Swap canvas background for theme. dark=true → near-black, false → light. */ + /** Swap canvas background for theme. dark=true → near-black (Model), false → white (Layout). */ setTheme(dark) { - this._scene.background = new THREE.Color(dark ? 0x0a0b0d : 0xf7f6f3); + this._scene.background = new THREE.Color(dark ? 0x0a0b0d : 0xffffff); if (this._gridVisible) this._rebuildGrid(); } @@ -1697,12 +1705,25 @@ export class Viewer2D { }; }; + const elements = linPattern.elements || []; const patternLen = linPattern.patternLength * ltscale; - if (patternLen < 1e-6) return; + if (patternLen < 1e-6 || !elements.length) return; + + // Calculate distance from pattern start to shape (arrowhead) element if present + let shapeOffset = -1; + let accum = 0; + for (const e of elements) { + if (e.type === 'shape') { + shapeOffset = accum; + break; + } + if (e.type === 'dash') accum += Math.max((e.val || 0.05) * ltscale, 0.01 * ltscale); + else if (e.type === 'gap') accum += Math.abs(e.val || 0.1) * ltscale; + } let s = 0; let elemIdx = 0; - const elements = linPattern.elements; + let lastShapePos = -1; while (s < totalLen) { const elem = elements[elemIdx % elements.length]; @@ -1723,12 +1744,18 @@ export class Viewer2D { const gapLen = Math.abs(elem.val || 0.1) * ltscale; s += gapLen; } else if (elem.type === 'shape') { + lastShapePos = s; const pState = getPathState(s); this._renderShapeSymbol(elem, pState, ltscale, color, pushSeg); } else if (elem.type === 'text') { const pState = getPathState(s); if (elem.text && pendingTexts) { - const h = (elem.scale || 0.2) * ltscale; + // 1. Text Height: Exact text style DWG table height if fixed, else linetype elem.scale + const sName = (elem.style || 'STANDARD').toUpperCase(); + const fixedH = this._textStyleHeightMap?.get(sName) || 0; + const baseH = fixedH > 0 ? fixedH : (elem.scale || 0.2); + const h = baseH * ltscale; + let angle = pState.angle + ((elem.rotation || 0) * Math.PI) / 180; if (elem.isAbsoluteAngle) { angle = ((elem.rotation || 0) * Math.PI) / 180; @@ -1744,20 +1771,30 @@ export class Viewer2D { const sinT = Math.sin(angle); const xo = (elem.xOffset || 0) * ltscale; - const rawYo = (elem.yOffset != null && Math.abs(elem.yOffset) > 1e-4) ? Math.abs(elem.yOffset) : 0.02; - const yo = rawYo * ltscale; + // alignV: 2 (middle) centers text quad on origin; set yo=0 so middle lies directly on grey arrow line axis + const yo = 0; - const tx = pState.x + (xo * cosT - yo * sinT); - const ty = pState.y + (xo * sinT + yo * cosT); + // 2. Exact Visual Midpoint: position text at exact midpoint of empty text gap (between arrowhead tip and next dash) + let gapMidOffset = 0; + const nextElem = elements[elemIdx % elements.length]; + if (nextElem && nextElem.type === 'gap') { + const gapLen = Math.abs(nextElem.val || 0) * ltscale; + gapMidOffset = gapLen / 2; + } + + const midState = gapMidOffset > 1e-6 ? getPathState(s + gapMidOffset) : pState; + + const tx = midState.x + (xo * cosT - yo * sinT); + const ty = midState.y + (xo * sinT + yo * cosT); pendingTexts.push({ text: elem.text, - pos: { x: tx, y: ty, z: pState.z }, + pos: { x: tx, y: ty, z: midState.z }, height: Math.max(h, 0.01), rotation: angle, color, - alignH: 1, - alignV: 2, + alignH: 1, // center horizontally in gap between arrowheads + alignV: 2, // center vertically on line axis }); } } @@ -1846,6 +1883,19 @@ export class Viewer2D { } } + _buildStyleMap(styles) { + if (!this._textStyleHeightMap) this._textStyleHeightMap = new Map(); + this._textStyleHeightMap.clear(); + if (!styles || !Array.isArray(styles)) return; + for (const st of styles) { + const sName = (st.name || st.styleName || '').toUpperCase(); + const h = st.height ?? st.fixedTextHeight ?? 0; + if (sName && h > 0) { + this._textStyleHeightMap.set(sName, h); + } + } + } + _buildLayerMap(layers) { this._layerByHandle.clear(); this._layerByName.clear(); diff --git a/src/viewer2d/slugText.ts b/src/viewer2d/slugText.ts index ab6e240..c440a7d 100644 --- a/src/viewer2d/slugText.ts +++ b/src/viewer2d/slugText.ts @@ -328,7 +328,7 @@ export class SlugTextBatch { colorInt: number, alignH: number, alignV: number): void { const eng = this.engine; const lines = String(text).split('\n'); - const scale = height / eng.capHeightEm; + const scale = height; const lineStep = height * 5 / 3; // CAD default MTEXT line spacing const blockH = (lines.length - 1) * lineStep + height;