Understanding-4D/spline scenes/4_d_donut_creation/js/spline.runtime.min.js
2021-08-21 20:45:29 +02:00

28 lines
806 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

var SpeRuntime=function(e,t){"use strict";class r extends t.Raycaster{setFromCamera(e,t){"OrthographicCamera"===t.cameraType?(this.ray.origin.set(e.x,e.y,-1).unproject(t),this.ray.direction.set(0,0,-1).transformDirection(t.matrixWorld),this.camera=t):"PerspectiveCamera"===t.cameraType?(this.ray.origin.setFromMatrixPosition(t.matrixWorld),this.ray.direction.set(e.x,e.y,.5).unproject(t).sub(this.ray.origin).normalize(),this.camera=t):console.error("Raycaster: Unsupported camera type.")}createRaycastLineHelper(){const e=new t.LineBasicMaterial({color:16711680,linewidth:10}),r=new t.Vector3(this.ray.origin.x,this.ray.origin.y,this.ray.origin.z),i=new t.Vector3(this.ray.direction.x,this.ray.direction.y,this.ray.direction.z),n=(new t.Vector3).lerpVectors(r,i,.5);i.multiplyScalar(0);const s=new t.BufferGeometry;return s.setAttribute("position",new t.BufferAttribute([r.x,r.y,r.z,n.x,n.y,n.z,i.x,i.y,i.z],3)),new t.Line(s,e)}}function i(e,t,r){r.x=e.x*t.x,r.y=e.y,r.z=e.x*t.y}function n(e){return new t.Vector2(e.y,-e.x)}class s extends t.BufferGeometry{constructor(e,r,s,o,a,l,c,h,u,d,p,f,m=!1){super(),this.type="RoundedCylinderBufferGeometry",e=void 0!==e?e:1,r=void 0!==r?r:1,s=s||1,o=Math.floor(o)||8,a=Math.floor(a)||1,l=void 0!==l&&l,c=void 0!==c?c:0,h=void 0!==h?h:2*Math.PI,l&&(u=0,d=0);const g=[],v=[],y=[],A=[];let w=0;const x=s/2,b=new t.Vector3,S=new t.Vector3;m&&0==e&&(e=u),m&&0==r&&(r=d);const E=new t.Vector2(e,x),C=new t.Vector2(r,-x);let T=null,O=null,D=null,M=null,_=E.clone().sub(C),N=0,L=0,B=0;f>0&&(N=Math.min(e,r)*(1-f),L=e-N,B=r-N);const I=E.clone();I.x-=N;const P=Math.PI-_.angle(),R=_.angle(),F=Math.tan(R/2),U=Math.tan(P/2),z=F+U,k=f?z:U,G=f?z:F;if(u=Math.min(u,(e-L)/k,_.length()/z),d=Math.min(d,(r-B)/G,_.length()/z),u>0){const e=u/F;T=E.clone().sub(new t.Vector2(e,u)),f&&(D=T.clone(),D.x-=N-z*u),E.sub(_.clone().setLength(e))}if(d>0){const e=d/U;O=C.clone().sub(new t.Vector2(e,-d)),C.add(_.clone().setLength(e)),f&&(M=O.clone(),M.x-=N-z*d,I.sub(_.clone().setLength(e)))}_=E.clone().sub(C);const j=_.length()<.5,V=[];for(let p=0;p<=o;p++){const m=[],g=p/o,x=g*h+c,E=new t.Vector2(Math.sin(x),Math.cos(x));M&&O?(H(m,g,E,P,d,M,-1,!0),H(m,g,E,R,d,O,-1,!1)):O?(J(m,E,O.x,0,-1),H(m,g,E,R,d,O,-1,!1)):l||J(m,E,r,B,-1);if(i(n(_).normalize(),E,b),!j)for(let e=0;e<=a;e++){const t=e/a;i(_.clone().multiplyScalar(t).add(C),E,S),v.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),A.push(g,.5+S.y/s),m.push(w++)}if(D&&T?(H(m,g,E,P,u,T,1,!1),H(m,g,E,R,u,D,1,!0)):T?(H(m,g,E,P,u,T,1,!1),J(m,E,T.x,0,1)):l||J(m,E,e,L,1),f&&!j){i(n(_).multiplyScalar(-1).normalize(),E,b);for(let e=0;e<=a;e++){const t=e/a;i(_.clone().multiplyScalar(-t).add(I),E,S),v.push(S.x,S.y,S.z),y.push(b.x,b.y,b.z),A.push(g,.5+S.y/s),m.push(w++)}}f&&!l&&m.push(m[0]),V.push(m)}for(let e=0;e<V.length-1;e++)for(let t=0;t<V[0].length-1;t++){if(l&&f&&t==a)continue;const r=V[e][t],i=V[e+1][t],n=V[e+1][t+1],s=V[e][t+1],o=v[3*n+0],c=v[3*n+2];g.push(r,i,s),0==o&&0==c||g.push(i,n,s)}function H(e,r,n,o,a,l,c,h){for(let u=0;u<p+1;u++){const d=u/p;let f=c<0?d:1-d;h&&(f-=1),f*=o;const m=new t.Vector2(Math.sin(f),Math.cos(f)*c);i(m.clone().multiplyScalar(a).add(l),n,S),v.push(S.x,S.y,S.z),i(m,n,b),y.push(b.x,b.y,b.z),A.push(r,.5+S.y/s),e.push(w++)}}function J(e,r,n,s,o){const a=new t.Vector3,l=new t.Vector2,c=[n,s];o<0&&c.reverse();for(const t of c)l.set(t,x*o),i(l,r,a),v.push(a.x,a.y,a.z),y.push(0,o,0),A.push(.5,.5),e.push(w++)}function Q(n,s,o){const a=new t.Vector2(Math.sin(o),Math.cos(o)),l=new t.Vector2(-Math.cos(o),Math.sin(o)),c=new t.Vector3,h=n<0?(e,t,r)=>g.push(e,t,r):(e,t,r)=>g.push(e,r,t);i(new t.Vector2((e+r+L+B)/4,0),a,c),v.push(c.x,c.y,c.z),y.push(l.x,0,l.y),A.push(.5,.5);const u=w++;for(const e of s){const t=v.slice(3*e,3*e+3);v.push(...t),y.push(l.x,0,l.y);const r=A.slice(2*e,2*e+2);A.push(...r),w++}for(let e=u+1;e<w-1;e++)h(u,e,e+1);h(u,w-1,u+1)}h<2*Math.PI&&(Q(-1,V[0],c),Q(1,V[V.length-1],c+h)),this.setIndex(g),this.setAttribute("position",new t.Float32BufferAttribute(v,3)),this.setAttribute("normal",new t.Float32BufferAttribute(y,3)),this.setAttribute("uv",new t.Float32BufferAttribute(A,2))}}const o=Math.PI/2;class a extends t.BufferGeometry{constructor(e=1,r=1,i=1,n=1,s=1,a=1,l=0,c=4){super(),this.type="BoxBufferGeometry";const h=this;n=Math.floor(n),s=Math.floor(s),a=Math.floor(a),c=Math.floor(c),l=Math.min(l,e/2,r/2,i/2);const u=[],d=[],p=[],f=[];let m=0,g=0;function v(e,r,i,n,s,o,a,c,v,y,A){const w=(o-2*l)/v,x=(a-2*l)/y,b=o/2-l,S=a/2-l,E=c/2,C=v+1,T=y+1;let O=0,D=0;const M=new t.Vector3;for(let t=0;t<T;t++){const o=t*x-S;for(let a=0;a<C;a++){const l=a*w-b;M[e]=l*n,M[r]=o*s,M[i]=E,d.push(M.x,M.y,M.z),M[e]=0,M[r]=0,M[i]=c>0?1:-1,p.push(M.x,M.y,M.z),f.push(a/v),f.push(1-t/y),O+=1}}for(let e=0;e<y;e++)for(let t=0;t<v;t++){const r=m+t+C*e,i=m+t+C*(e+1),n=m+(t+1)+C*(e+1),s=m+(t+1)+C*e;u.push(r,i,s),u.push(i,n,s),D+=6}h.addGroup(g,D,A),g+=D,m+=O}function y(e,r,i,n,s,a,v,y,A,w,x){const b=(v-2*l)/w,S=v/2-l,E=y/2-l,C=A/2,T=w+1;let O=0,D=0;const M=new t.Vector3,_=new t.Vector3;for(let t=0;t<c+1;t++){const h=t/c*o,u=Math.sin(h)*l,m=(1-Math.cos(h))*l,g=Math.sin(h),v=Math.cos(h);M[r]=(E+u)*s,M[i]=(C-m)*a,_[e]=0,_[r]=g*Math.sign(M[r]),_[i]=v*Math.sign(M[i]);for(let t=0;t<T;t++){const r=t*b-S;M[e]=r*n,d.push(M.x,M.y,M.z),p.push(_.x,_.y,_.z),f.push(t/w),f.push(0),O+=1}}for(let e=0;e<c;e++)for(let t=0;t<w;t++){const r=m+t+T*e,i=m+t+T*(e+1),n=m+(t+1)+T*(e+1),s=m+(t+1)+T*e;u.push(r,i,s),u.push(i,n,s),D+=6}h.addGroup(g,D,x),g+=D,m+=O}function A(n,s,a){const h=new t.Vector3,g=new t.Vector3(e/2,r/2,i/2);g.subScalar(l);const v=[],y=n*s*a>0?(e,t,r)=>u.push(e,t,r):(e,t,r)=>u.push(e,r,t);for(let e=0;e<=c;e++){const t=[],r=o*(1-e/c),i=Math.cos(r),u=Math.sin(r);let y=0;for(let r=0;r<=e;r++){const r=Math.cos(y),c=Math.sin(y);h.x=i*r,h.y=u,h.z=i*c;const v=g.clone().addScaledVector(h,l);d.push(n*v.x,s*v.y,a*v.z),p.push(n*h.x,s*h.y,a*h.z),f.push(0,0),t.push(m++),y+=o/e}v.push(t)}const A=v.length-1;for(let e=0;e<A;e++){const t=v[e],r=v[e+1],i=t.length-1;y(t[0],r[1],r[0]);for(let e=1;e<=i;e++)y(t[e-1],t[e],r[e]),y(t[e],r[e+1],r[e])}}v("z","y","x",-1,-1,i,r,e,a,s,0),v("z","y","x",1,-1,i,r,-e,a,s,1),v("x","z","y",1,1,e,i,r,n,a,2),v("x","z","y",1,-1,e,i,-r,n,a,3),v("x","y","z",1,-1,e,r,i,n,s,4),v("x","y","z",-1,-1,e,r,-i,n,s,5),l>0&&(y("z","y","x",-1,-1,1,i,r,e,a,0),y("z","y","x",1,-1,-1,i,r,e,a,1),y("z","y","x",-1,1,-1,i,r,e,a,1),y("z","y","x",1,1,1,i,r,e,a,0),y("x","y","z",-1,-1,-1,e,r,i,n,0),y("x","y","z",1,-1,1,e,r,i,n,1),y("x","y","z",-1,1,1,e,r,i,n,0),y("x","y","z",1,1,-1,e,r,i,n,1),y("y","x","z",-1,-1,1,r,e,i,s,0),y("y","x","z",1,-1,-1,r,e,i,s,1),y("y","x","z",1,1,1,r,e,i,s,1),y("y","x","z",-1,1,-1,r,e,i,s,0),A(1,1,1),A(-1,1,1),A(1,-1,1),A(-1,-1,1),A(1,1,-1),A(-1,1,-1),A(1,-1,-1),A(-1,-1,-1)),this.setIndex(u),this.setAttribute("position",new t.Float32BufferAttribute(d,3)),this.setAttribute("normal",new t.Float32BufferAttribute(p,3)),this.setAttribute("uv",new t.Float32BufferAttribute(f,2))}}const l=1e-12;class c{constructor(e){this.position=new t.Vector2,this.startPosition=new t.Vector2,this.uuid=t.MathUtils.generateUUID(),this.position=e.clone()}start(){this.reset()}reset(){this.startPosition.copy(this.position)}applyOffset(e){this.position.copy(this.startPosition).add(e)}copy(e){return this.position.copy(e.position),this.startPosition.copy(e.startPosition),this}clone(){return new c(this.position).copy(this)}toJSON(){return[this.position.x,this.position.y]}}class h extends c{constructor(e){super(e.position),this.parent=e}copy(e){return super.copy(e),this}clone(){return new h(this.parent).copy(this)}}class u extends c{constructor(e,t){super(t),this.controls=[],this.roundness=0,this.areControlsDirectionsMirrored=!0,this.uuid=e,this.controls.push(new h(this),new h(this))}getOppositeControl(e){const t=this.controls.indexOf(e);return 0===t?this.controls[1]:1===t?this.controls[0]:null}applyOffsetToControls(e,t=1){for(let r=0,i=this.controls.length;r<i;r++){const i=this.controls[r];this.position.distanceTo(i.position)<=t?i.position.copy(this.position):i.applyOffset(e)}}controlsMoved(){return!(this.position.equals(this.controls[0].position)&&this.position.equals(this.controls[1].position))}copy(e){return super.copy(e),this.controls[0].copy(e.controls[0]),this.controls[1].copy(e.controls[1]),this.roundness=e.roundness,this.uuid=e.uuid,this}clone(){return new u(this.uuid,this.position).copy(this)}toJSON(){return super.toJSON().concat(this.controls[0].toJSON(),this.controls[1].toJSON(),[this.roundness])}}const d=new t.Vector2,p=new t.Vector2,f=new t.Vector2,m=new t.Vector2,g=new t.Vector2,v=new t.Vector2,y=new t.Vector3,A=new t.Vector3;function w(e){const r=new t.Vector2;r.addVectors(e.v0,d.subVectors(e.v1,e.v0).multiplyScalar(2/3));const i=new t.Vector2;return i.addVectors(e.v2,p.subVectors(e.v1,e.v2).multiplyScalar(2/3)),new t.CubicBezierCurve(e.v0,r,i,e.v2)}function x(e,t,r=Number.EPSILON){return Math.abs(e-t)<r}function b(e,t,r=Number.EPSILON){return e.distanceTo(t)<r}function S(e,t,r=Number.EPSILON){return e.distanceTo(t)<r}function E(e,t,r){const i=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),n=Math.sqrt(Math.pow(t.x-r.x,2)+Math.pow(t.y-r.y,2)),s=Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2));return Math.acos((n*n+i*i-s*s)/(2*n*i))}function C(e,t,r,i,n){const s=Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2)),o=(e.y+t.y)/2,a=(e.x+t.x)/2,l=Math.sqrt(Math.pow(r,2)-Math.pow(s/2,2))*(e.y-t.y)/s,c=Math.sqrt(Math.pow(r,2)-Math.pow(s/2,2))*(t.x-e.x)/s;return i.set(a+l,o+c),n.set(a-l,o-c),[i,n]}function T(e,t,r,i,n,s){const o=t.x-e.x,a=t.y-e.y,l=r.x-e.x,c=r.y-e.y;let h,u=Math.sqrt((o+l)*(o+l)+(a+c)*(a+c));return E(t,e,r)>Math.PI&&(u*=-1),h=x(c,a)?(a+c)*(i/u-.5)*8/3/(o-l):(o+l)*(i/u-.5)*8/3/(c-a),n.set(t.x-h*a,t.y+h*o),s.set(r.x+h*c,r.y-h*l),[n,s]}function O(e,t){return e.position.equals(e.controls[1].position)&&t.position.equals(t.controls[0].position)}function D(e,t=12,r=!1){const i=[];for(let n=0,s=e.length;n<s;n++){const s=e[n];let o=0;if(r&&void 0!==s.roundedCurveCorner){const e=.5*M(s.roundedCurveCorner,t);n>0&&(i[n-1]+=e),o+=e}void 0!==s.curveAfter&&(o+=M(s.curveAfter,t)),i.push(o)}return e.length>0&&r&&void 0!==e[0].roundedCurveCorner&&(i[e.length-1]+=.5*M(e[0].roundedCurveCorner,t)),i}function M(e,r=12){return e&&e instanceof t.EllipseCurve?2*r:e&&(e instanceof t.LineCurve||e instanceof t.LineCurve3)?1:e&&e instanceof t.SplineCurve?r*e.points.length:r}const _=new t.Vector2,N=new t.Vector2,L=new t.Vector2,B=new t.Vector2,I=new t.Vector2,P=new t.Vector2;class R extends t.Shape{constructor(e=100,r=100){super(),this.points=[],this.shapeHoles=[],this.eventDispatcher=new t.EventDispatcher,this.plane=new t.Plane(new t.Vector3(0,0,-1)),this.subdivision=0,this.controlSnapDistance=4,this.pointIDs=0,this.isMesh2D=!1,this._roundness=0,this.isClosed=!1,this.useCubicForRoundedCorners=!0,this.uuid=t.MathUtils.generateUUID(),this.needsUpdate=!1,this.roundedCurves=[],this._width=e,this._height=r}get width(){return this._width}get height(){return this._height}get roundness(){return this._roundness}set roundness(e){if(this._roundness!==e){this._roundness=e;for(let t=0,r=this.points.length;t<r;t++)this.points[t].roundness=e;this.needsUpdate=!0}}getBezierPoint(e){if(e<=this.points.length-1)return this.points[e];if(this.shapeHoles.length>0)for(let t=0,r=this.shapeHoles.length;t<r;t++){const r=this.shapeHoles[t],i=e-this.points.length;if(i<=r.points.length-1)return r.points[i]}throw new Error("This shape does not have a point for this index: "+e)}getBezierPointIndex(e){let t=this.points.indexOf(e);if(t>=0)return t;if(t=this.points.length,this.shapeHoles.length>0)for(let r=0,i=this.shapeHoles.length;r<i;r++){const i=this.shapeHoles[r],n=i.points.indexOf(e);if(n>=0)return t+n;t+=i.points.length}return-1}getAllPoints(){const e=[].concat(...this.shapeHoles.map((e=>e.points)));return[...this.points,...e]}applySize(e,t){0===e&&(e=.001),0===t&&(t=.001),this.applyScale(e/this.width,t/this.height),this._width=e,this._height=t}applyScale(e,t){const r=_.set(e,t);for(let e=0,t=this.points.length;e<t;e++){const t=this.points[e];t.position.multiply(r),t.controls[0].position.multiply(r),t.controls[1].position.multiply(r)}for(let r=0,i=this.shapeHoles.length;r<i;r++){this.shapeHoles[r].applyScale(e,t)}this._update(!1)}createPoint(e,r=0,i=t.MathUtils.generateUUID()){let n;n=e instanceof t.Vector2?e:new t.Vector2(e,r);const s=new u(i,n);return s.roundness=this.roundness,s}addPoint(e){this.points.push(e),this.needsUpdate=!0}addPointAt(e,t){this.points.splice(t,0,e),this.needsUpdate=!0}getPointByUuid(e){for(let t=0,r=this.points.length;t<r;t++){const r=this.points[t];if(r.uuid===e)return r}return null}getFirstPoint(){return this.points[0]}getLastPoint(){return this.points[this.points.length-1]}removePoint(e){const t=this.points.indexOf(e);t>=0&&this.points.splice(t,1),this.needsUpdate=!0}update(e=!0){for(let e=0,t=this.shapeHoles.length;e<t;e++){this.shapeHoles[e].update(!1)}this._update(e)}extractShapePointsToBuffer(e,r=12,i=!1){this.subdivision=r,void 0===this.curveDivisions&&this.computeCurveDivisions(r);const n=i?this.roundedCurveDivisions:this.curveDivisions;return function(e,r,i=12,n=!0){const s=A.set(0,0,0);let o,a=0;for(let n=0;n<r.length;n++){const l=r[n],c=d,h=M(l,i);for(let r=0;r<=h;r++)if(l instanceof t.CubicBezierCurve||l instanceof t.QuadraticBezierCurve||l instanceof t.LineCurve){if(l.getPoint(r/h,c),s.set(c.x,c.y,0),void 0!==o&&S(o,s))continue;void 0===o&&(o=y),o.copy(s),e.setXYZ(a,s.x,s.y,s.z),a++}}n&&a>1&&(e.getX(a-1)!==e.getX(0)||e.getY(a-1)!==e.getY(0)||e.getZ(a-1)!==e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++)}(e,i?this.roundedCurves:this.curves,r,this.autoClose),n.reduce(((e,t)=>e+t),0)+1}computeCurveDivisions(e=12){this.curveDivisions=D(this.points,e,!1),this.roundedCurveDivisions=D(this.points,e,!0)}extractFilteredShapePointsToBuffer(e,r,i=12){return 2*function(e,r,i,n=12,s=!0){const o=A.set(0,0,0);let a=0;const l=[];for(let s=0;s<r.length;s++){if(!1===i[s])continue;let c;const h=r[s],u=d,p=M(h,n);l.push(p);for(let r=0;r<=p;r++)if(h instanceof t.CubicBezierCurve||h instanceof t.QuadraticBezierCurve||h instanceof t.LineCurve){if(h.getPoint(r/p,u),o.set(u.x,u.y,0),null==c?void 0:c.equals(o))continue;void 0===c?c=y:(e.setXYZ(a,c.x,c.y,c.z),a++,e.setXYZ(a,o.x,o.y,o.z),a++),c.copy(o)}}return s&&a>1&&(e.getX(a-1)!==e.getX(0)||e.getY(a-1)!==e.getY(0)||e.getZ(a-1)!==e.getZ(0))&&(e.setXYZ(a,e.getX(0),e.getY(0),e.getZ(0)),a++),l}(e,this.curves,r,i,this.autoClose).reduce(((e,t)=>e+t),0)}extractShapePointsToFlatArray(e,r=12){return this.subdivision=r,void 0===this.curveDivisions&&this.computeCurveDivisions(r),function(e,r,i=12,n=!0){let s,o=0;for(let n=0;n<r.length;n++){const a=r[n],c=M(a,i),h=d;for(let r=0;r<=c;r++)if(a instanceof t.CubicBezierCurve||a instanceof t.QuadraticBezierCurve||a instanceof t.LineCurve){if(a.getPoint(r/c,h),void 0!==s&&b(s,h,l))continue;void 0===s&&(s=p),s.copy(h),e.push(h.x,h.y),o++}}return x(e[0],e[e.length-2],l)&&x(e[1],e[e.length-1],l)&&(e.pop(),e.pop()),!(n&&o>1)||x(e[o-1],e[1],l)&&x(e[o-2],e[0],l)||(e.push(e[0],e[1]),o++),e}(e,this.roundedCurves,r,this.autoClose)}getCurveIndexFromVertexId(e,t=!1){let r=0;void 0===this.curveDivisions&&this.computeCurveDivisions(this.subdivision);const i=t?this.roundedCurveDivisions:this.curveDivisions;let n=0;t&&void 0!==this.points[0].roundedCurveCorner&&(n=.5*M(this.points[0].roundedCurveCorner,this.subdivision));let s=e-n;s<0&&(s+=i.reduce(((e,t)=>e+t),0));for(let e=0,t=i.length;e<t;e++){const t=i[e];if(s<r+t)return[e,(s-r+1)/t];r+=t}return[0,1]}getCurveT(e,t,r){const i=this.points[e],n=this.points[e>=this.points.length-1?0:e+1],s=this.curveDivisions,o=s[e];if(O(i,n)){const e=i.position.distanceTo(n.position);return i.position.distanceTo(_.set(r.x,r.y))/e}let a=0;for(let t=0;t<e;t++)a+=s[t];return(t-a)/o}dispose(){this.eventDispatcher=null}_applyCurveForPoint(e,t){O(t,e)?this.lineTo(e.position.x,e.position.y):this.bezierCurveTo(t.controls[1].position.x,t.controls[1].position.y,e.controls[0].position.x,e.controls[0].position.y,e.position.x,e.position.y);const r=this.curves[this.curves.length-1];e.curveBefore=r,t.curveAfter=r;const i=r.clone();e.roundedCurveBefore=i,t.roundedCurveAfter=i,e.roundedCurveCorner=void 0,this.roundedCurves.push(i)}_update(e=!0){var r;this.curves=[],this.roundedCurves=[];for(let e=0,t=this.points.length;e<t;e++){const t=this.points[e];if(0===e)this.moveTo(t.position.x,t.position.y);else{const r=this.points[e-1];this._applyCurveForPoint(t,r)}}const i=this.getLastPoint();if((null==i?void 0:i.curveAfter)&&(i.curveAfter=void 0),this.isClosed){const e=this.points[0],t=this.points[this.points.length-1];this._applyCurveForPoint(e,t)}if(this.points.length>2){let e=0;for(let r=0,i=this.points.length;r<i;r++){const i=this.points[r],a=i.roundness;if(!i.controlsMoved()&&a>0){const l=i.curveBefore,c=i.curveAfter;if(void 0===l||void 0===c)continue;const h=i.roundedCurveBefore,u=i.roundedCurveAfter,d=l.getLength(),p=c.getLength(),f=Math.min(a,.499*d),m=Math.min(a,.499*p),g=Math.min(f,m),v=1-g/d,y=g/p,A=l.getPointAt(v,_),w=c.getPointAt(y,N);let x;if(this._subSplitCurve(l,h,v,A,void 0),this._subSplitCurve(c,u,y,void 0,w),this.useCubicForRoundedCorners){const e=E(A,i.position,w)/2,r=Math.tan(e)*A.distanceTo(i.position),[a,l]=C(A,w,r,L,B),c=(n=a,s=l,o=i.position,n.distanceTo(o)<s.distanceTo(o)?s:n),[h,u]=T(c,A,w,r,I,P);x=new t.CubicBezierCurve(A.clone(),h.clone(),u.clone(),w.clone())}else x=new t.QuadraticBezierCurve(A.clone(),i.position.clone(),w.clone());i.roundedCurveCorner=x,this.roundedCurves.splice(r+e,0,x),e++}}}var n,s,o;e&&(null===(r=this.eventDispatcher)||void 0===r||r.dispatchEvent({type:"update"}))}_subSplitCurve(e,r,i,n,s){if(!(e instanceof t.LineCurve)){const t=e,o=r,a=t.getUtoTmapping(i,0),l=function(e,t,r,i,n=.5){const s=d.subVectors(t,e).multiplyScalar(n).add(e),o=p.subVectors(r,t).multiplyScalar(n).add(t),a=f.subVectors(i,r).multiplyScalar(n).add(r),l=s,c=m.subVectors(o,s).multiplyScalar(n).add(s),h=g.subVectors(a,o).multiplyScalar(n).add(o),u=a,y=v.subVectors(h,c).multiplyScalar(n).add(c);return[e.x,e.y,l.x,l.y,c.x,c.y,y.x,y.y,h.x,h.y,u.x,u.y,i.x,i.y]}(t.v0,t.v1,t.v2,t.v3,a);return void 0!==n&&(o.v0.set(l[0],l[1]),o.v1.set(l[2],l[3]),o.v2.set(l[4],l[5]),o.v3.set(l[6],l[7])),void 0!==s&&(o.v0.set(l[6],l[7]),o.v1.set(l[8],l[9]),o.v2.set(l[10],l[11]),o.v3.set(l[12],l[13])),o}return void 0!==n&&r.v2.copy(n),void 0!==s&&r.v1.copy(s),r}clone(){const e=new R(this._width,this._height);return e.points=this.points.map((e=>e.clone())),e.isClosed=this.isClosed,e.roundness=this.roundness,e.isMesh2D=this.isMesh2D,e}toJSON(){return{points:this.points.reduce(((e,t)=>e.concat(t.toJSON())),[]),shapeHoles:this.shapeHoles.map((e=>e.toJSON())),isClosed:this.isClosed,roundness:this.roundness}}fromJSON(e){var r;this.points=[],this.pointIDs=0;const i=e.points.length/7;for(let r=0;r<i;r++){const i=7*r,n=e.points[i+0],s=e.points[i+1],o=e.points[i+2],a=e.points[i+3],l=e.points[i+4],c=e.points[i+5],h=e.points[i+6],d=new u(t.MathUtils.generateUUID(),new t.Vector2(n,s));d.controls[0].position.set(o,a),d.controls[1].position.set(l,c),d.roundness=h,this.points.push(d)}return this.shapeHoles=(null===(r=e.shapeHoles)||void 0===r?void 0:r.length)?e.shapeHoles.map((e=>{const t=new R;return t.fromJSON(e),t})):[],this.isClosed=e.isClosed,this._roundness=e.roundness,this._update(),this}fromShape(e){const r=(e,r)=>{r instanceof t.CubicBezierCurve&&r.v3.equals(e.position)&&e.controls[0].position.copy(r.v2)};return this.points=(e=>{const i=[];let n,s;for(n=0,s=e.length;n<s;n++)e[n]instanceof t.QuadraticBezierCurve&&(e[n]=w(e[n]));for(n=0,s=e.length;n<s;n++){const s=e[n],o=n>0?e[n-1]:null;let a;s instanceof t.CubicBezierCurve?(a=this.createPoint(s.v0),a.controls[1].position.copy(s.v1)):s instanceof t.LineCurve&&(a=this.createPoint(s.v1)),void 0!==a&&(null!==o&&r(a,o),i.push(a))}const o=e[e.length-1];let a=!1;return o instanceof t.CubicBezierCurve?o.v3.equals(i[0].position)&&(i[0].controls[0].position.copy(o.v2),a=!0):o instanceof t.LineCurve&&o.v2.equals(i[0].position)&&(a=!0),this.isClosed=a,i})(e.curves),e instanceof t.Shape&&(this.shapeHoles=e.holes.map((e=>{const t=new R;return t.fromShape(e),t}))),this.update(),this}}const F=2*Math.PI;function U({x:e,y:t},r,i,n,s){return{x:e*r+n,y:t*i+s}}function z(e,t){const r=1.5707963267948966===t?.551915024494:-1.5707963267948966===t?-.551915024494:4/3*Math.tan(t/4),i=Math.cos(e),n=Math.sin(e),s=Math.cos(e+t),o=Math.sin(e+t);return[{x:i-n*r,y:n+i*r},{x:s+o*r,y:o-s*r},{x:s,y:o}]}function k(e,t,r,i){const n=e*i-t*r<0?-1:1,s=Math.min(1,Math.max(-1,e*r+t*i));return n*Math.acos(s)}function G({px:e,py:t,cx:r,cy:i,rx:n,ry:s,largeArcFlag:o,sweepFlag:a}){const l=[];if(0===n||0===s)return[];const c=(e-r)/2,h=(t-i)/2;if(0===c&&0===h)return[];n=Math.abs(n),s=Math.abs(s);const u=Math.pow(c,2)/Math.pow(n,2)+Math.pow(h,2)/Math.pow(s,2);u>1&&(n*=Math.sqrt(u),s*=Math.sqrt(u));const d=function(e,t,r,i,n,s,o,a,l,c){const h=Math.pow(n,2),u=Math.pow(s,2),d=Math.pow(o,2),p=Math.pow(a,2);let f=h*u-h*p-u*d;f<0&&(f=0),f/=h*p+u*d,f=Math.sqrt(f)*(l===c?-1:1);const m=f*n/s*a,g=f*-s/n*o,v=m+(e+r)/2,y=g+(t+i)/2,A=(o-m)/n,w=(a-g)/s,x=(-o-m)/n,b=(-a-g)/s,S=k(1,0,A,w);let E=k(A,w,x,b);return!c&&E>0&&(E-=F),c&&E<0&&(E+=F),{centerx:v,centery:y,ang1:S,ang2:E}}(e,t,r,i,n,s,c,h,o,a);let{ang1:p,ang2:f}=d;const{centerx:m,centery:g}=d;let v=Math.abs(f)/(F/4);Math.abs(1-v)<1e-7&&(v=1);const y=Math.max(Math.ceil(v),1);f/=y;for(let e=0;e<y;e++)l.push(z(p,f)),p+=f;return l.map((e=>{const{x:t,y:r}=U(e[0],n,s,m,g),{x:i,y:o}=U(e[1],n,s,m,g),{x:a,y:l}=U(e[2],n,s,m,g);return{x1:t,y1:r,x2:i,y2:o,x:a,y:l}}))}var j,V;function H(e,t){if(!e)throw t||"Assertion Failed!"}!function(e){e[e.ODD=0]="ODD",e[e.NONZERO=1]="NONZERO",e[e.POSITIVE=2]="POSITIVE",e[e.NEGATIVE=3]="NEGATIVE",e[e.ABS_GEQ_TWO=4]="ABS_GEQ_TWO"}(j||(j={})),function(e){e[e.POLYGONS=0]="POLYGONS",e[e.CONNECTED_POLYGONS=1]="CONNECTED_POLYGONS",e[e.BOUNDARY_CONTOURS=2]="BOUNDARY_CONTOURS"}(V||(V={}));var J=function(){function e(){}return e.vertEq=function(e,t){return e.s===t.s&&e.t===t.t},e.vertLeq=function(e,t){return e.s<t.s||e.s===t.s&&e.t<=t.t},e.transLeq=function(e,t){return e.t<t.t||e.t===t.t&&e.s<=t.s},e.edgeGoesLeft=function(t){return e.vertLeq(t.Dst,t.Org)},e.edgeGoesRight=function(t){return e.vertLeq(t.Org,t.Dst)},e.vertL1dist=function(e,t){return Math.abs(e.s-t.s)+Math.abs(e.t-t.t)},e.edgeEval=function(t,r,i){H(e.vertLeq(t,r)&&e.vertLeq(r,i));var n=r.s-t.s,s=i.s-r.s;return n+s>0?n<s?r.t-t.t+(t.t-i.t)*(n/(n+s)):r.t-i.t+(i.t-t.t)*(s/(n+s)):0},e.edgeSign=function(t,r,i){H(e.vertLeq(t,r)&&e.vertLeq(r,i));var n=r.s-t.s,s=i.s-r.s;return n+s>0?(r.t-i.t)*n+(r.t-t.t)*s:0},e.transEval=function(t,r,i){H(e.transLeq(t,r)&&e.transLeq(r,i));var n=r.t-t.t,s=i.t-r.t;return n+s>0?n<s?r.s-t.s+(t.s-i.s)*(n/(n+s)):r.s-i.s+(i.s-t.s)*(s/(n+s)):0},e.transSign=function(t,r,i){H(e.transLeq(t,r)&&e.transLeq(r,i));var n=r.t-t.t,s=i.t-r.t;return n+s>0?(r.s-i.s)*n+(r.s-t.s)*s:0},e.vertCCW=function(e,t,r){return e.s*(t.t-r.t)+t.s*(r.t-e.t)+r.s*(e.t-t.t)>=0},e.interpolate=function(e,t,r,i){return(e=e<0?0:e)<=(r=r<0?0:r)?0===r?(t+i)/2:t+e/(e+r)*(i-t):i+r/(e+r)*(t-i)},e.intersect=function(t,r,i,n,s){var o,a,l;e.vertLeq(t,r)||(l=t,t=r,r=l),e.vertLeq(i,n)||(l=i,i=n,n=l),e.vertLeq(t,i)||(l=t,t=i,i=l,l=r,r=n,n=l),e.vertLeq(i,r)?e.vertLeq(r,n)?((o=e.edgeEval(t,i,r))+(a=e.edgeEval(i,r,n))<0&&(o=-o,a=-a),s.s=e.interpolate(o,i.s,a,r.s)):((o=e.edgeSign(t,i,r))+(a=-e.edgeSign(t,n,r))<0&&(o=-o,a=-a),s.s=e.interpolate(o,i.s,a,n.s)):s.s=(i.s+r.s)/2,e.transLeq(t,r)||(l=t,t=r,r=l),e.transLeq(i,n)||(l=i,i=n,n=l),e.transLeq(t,i)||(l=t,t=i,i=l,l=r,r=n,n=l),e.transLeq(i,r)?e.transLeq(r,n)?((o=e.transEval(t,i,r))+(a=e.transEval(i,r,n))<0&&(o=-o,a=-a),s.t=e.interpolate(o,i.t,a,r.t)):((o=e.transSign(t,i,r))+(a=-e.transSign(t,n,r))<0&&(o=-o,a=-a),s.t=e.interpolate(o,i.t,a,n.t)):s.t=(i.t+r.t)/2},e}(),Q=function(){this.next=null,this.prev=null,this.anEdge=null,this.trail=null,this.n=0,this.marked=!1,this.inside=!1},Y=function(){function e(e){this.side=e,this.next=null,this.Org=null,this.Sym=null,this.Onext=null,this.Lnext=null,this.Lface=null,this.activeRegion=null,this.winding=0}return Object.defineProperty(e.prototype,"Rface",{get:function(){return this.Sym.Lface},set:function(e){this.Sym.Lface=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dst",{get:function(){return this.Sym.Org},set:function(e){this.Sym.Org=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Oprev",{get:function(){return this.Sym.Lnext},set:function(e){this.Sym.Lnext=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Lprev",{get:function(){return this.Onext.Sym},set:function(e){this.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dprev",{get:function(){return this.Lnext.Sym},set:function(e){this.Lnext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rprev",{get:function(){return this.Sym.Onext},set:function(e){this.Sym.Onext=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Dnext",{get:function(){return this.Sym.Onext.Sym},set:function(e){this.Sym.Onext.Sym=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"Rnext",{get:function(){return this.Sym.Lnext.Sym},set:function(e){this.Sym.Lnext.Sym=e},enumerable:!0,configurable:!0}),e}(),W=function(){this.next=null,this.prev=null,this.anEdge=null,this.coords=[0,0,0],this.s=0,this.t=0,this.pqHandle=0,this.n=0,this.idx=0},X=function(){function e(){var e=new W,t=new Q,r=new Y(0),i=new Y(1);e.next=e.prev=e,e.anEdge=null,t.next=t.prev=t,r.next=r,r.Sym=i,i.next=i,i.Sym=r,this.vHead=e,this.fHead=t,this.eHead=r,this.eHeadSym=i}return e.prototype.makeEdge_=function(e){var t=new Y(0),r=new Y(1);e.Sym.side<e.side&&(e=e.Sym);var i=e.Sym.next;return r.next=i,i.Sym.next=t,t.next=e,e.Sym.next=r,t.Sym=r,t.Onext=t,t.Lnext=r,t.Org=null,t.Lface=null,t.winding=0,t.activeRegion=null,r.Sym=t,r.Onext=r,r.Lnext=t,r.Org=null,r.Lface=null,r.winding=0,r.activeRegion=null,t},e.prototype.splice_=function(e,t){var r=e.Onext,i=t.Onext;r.Sym.Lnext=t,i.Sym.Lnext=e,e.Onext=i,t.Onext=r},e.prototype.makeVertex_=function(e,t,r){var i=e;H(i,"Vertex can't be null!");var n=r.prev;i.prev=n,n.next=i,i.next=r,r.prev=i,i.anEdge=t;var s=t;do{s.Org=i,s=s.Onext}while(s!==t)},e.prototype.makeFace_=function(e,t,r){var i=e;H(i,"Face can't be null");var n=r.prev;i.prev=n,n.next=i,i.next=r,r.prev=i,i.anEdge=t,i.trail=null,i.marked=!1,i.inside=r.inside;var s=t;do{s.Lface=i,s=s.Lnext}while(s!==t)},e.prototype.killEdge_=function(e){e.Sym.side<e.side&&(e=e.Sym);var t=e.next,r=e.Sym.next;t.Sym.next=r,r.Sym.next=t},e.prototype.killVertex_=function(e,t){var r=e.anEdge,i=r;do{i.Org=t,i=i.Onext}while(i!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},e.prototype.killFace_=function(e,t){var r=e.anEdge,i=r;do{i.Lface=t,i=i.Lnext}while(i!==r);var n=e.prev,s=e.next;s.prev=n,n.next=s},e.prototype.makeEdge=function(){var e=new W,t=new W,r=new Q,i=this.makeEdge_(this.eHead);return this.makeVertex_(e,i,this.vHead),this.makeVertex_(t,i.Sym,this.vHead),this.makeFace_(r,i,this.fHead),i},e.prototype.splice=function(e,t){var r=!1,i=!1;if(e!==t){if(t.Org!==e.Org&&(i=!0,this.killVertex_(t.Org,e.Org)),t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(t,e),!i){var n=new W;this.makeVertex_(n,t,e.Org),e.Org.anEdge=e}if(!r){var s=new Q;this.makeFace_(s,t,e.Lface),e.Lface.anEdge=e}}},e.prototype.delete=function(e){var t=e.Sym,r=!1;if(e.Lface!==e.Rface&&(r=!0,this.killFace_(e.Lface,e.Rface)),e.Onext===e)this.killVertex_(e.Org,null);else if(e.Rface.anEdge=e.Oprev,e.Org.anEdge=e.Onext,this.splice_(e,e.Oprev),!r){var i=new Q;this.makeFace_(i,e,e.Lface)}t.Onext===t?(this.killVertex_(t.Org,null),this.killFace_(t.Lface,null)):(e.Lface.anEdge=t.Oprev,t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),this.killEdge_(e)},e.prototype.addEdgeVertex=function(e){var t=this.makeEdge_(e),r=t.Sym;this.splice_(t,e.Lnext),t.Org=e.Dst;var i=new W;return this.makeVertex_(i,r,t.Org),t.Lface=r.Lface=e.Lface,t},e.prototype.splitEdge=function(e){var t=this.addEdgeVertex(e).Sym;return this.splice_(e.Sym,e.Sym.Oprev),this.splice_(e.Sym,t),e.Dst=t.Org,t.Dst.anEdge=t.Sym,t.Rface=e.Rface,t.winding=e.winding,t.Sym.winding=e.Sym.winding,t.idx=e.idx,t.Sym.idx=e.Sym.idx,t},e.prototype.connect=function(e,t){var r=!1,i=this.makeEdge_(e),n=i.Sym;if(t.Lface!==e.Lface&&(r=!0,this.killFace_(t.Lface,e.Lface)),this.splice_(i,e.Lnext),this.splice_(n,t),i.Org=e.Dst,n.Org=t.Org,i.Lface=n.Lface=e.Lface,e.Lface.anEdge=n,!r){var s=new Q;this.makeFace_(s,i,e.Lface)}return i},e.prototype.zapFace=function(e){var t,r,i,n,s,o=e.anEdge;r=o.Lnext;do{r=(t=r).Lnext,t.Lface=null,null===t.Rface&&(t.Onext===t?this.killVertex_(t.Org,null):(t.Org.anEdge=t.Onext,this.splice_(t,t.Oprev)),(i=t.Sym).Onext===i?this.killVertex_(i.Org,null):(i.Org.anEdge=i.Onext,this.splice_(i,i.Oprev)),this.killEdge_(t))}while(t!=o);n=e.prev,(s=e.next).prev=n,n.next=s},e.prototype.countFaceVerts_=function(e){var t=e.anEdge,r=0;do{r++,t=t.Lnext}while(t!==e.anEdge);return r},e.prototype.mergeConvexFaces=function(e){var t,r,i,n,s;for(t=this.fHead.next;t!==this.fHead;t=t.next)if(t.inside)for(s=(r=t.anEdge).Org;i=r.Lnext,(n=r.Sym)&&n.Lface&&n.Lface.inside&&this.countFaceVerts_(t)+this.countFaceVerts_(n.Lface)-2<=e&&J.vertCCW(r.Lprev.Org,r.Org,n.Lnext.Lnext.Org)&&J.vertCCW(n.Lprev.Org,n.Org,r.Lnext.Lnext.Org)&&(i=n.Lnext,this.delete(n),r=null,n=null),!r||r.Lnext.Org!==s;)r=i;return!0},e.prototype.check=function(){var e,t,r,i,n,s,o=this.fHead,a=this.vHead,l=this.eHead;for(t=o,t=o;(e=t.next)!==o;t=e){H(e.prev===t),n=e.anEdge;do{H(n.Sym!==n),H(n.Sym.Sym===n),H(n.Lnext.Onext.Sym===n),H(n.Onext.Sym.Lnext===n),H(n.Lface===e),n=n.Lnext}while(n!==e.anEdge)}for(H(e.prev===t&&null===e.anEdge),i=a,i=a;(r=i.next)!==a;i=r){H(r.prev===i),n=r.anEdge;do{H(n.Sym!==n),H(n.Sym.Sym===n),H(n.Lnext.Onext.Sym===n),H(n.Onext.Sym.Lnext===n),H(n.Org===r),n=n.Onext}while(n!==r.anEdge)}for(H(r.prev===i&&null===r.anEdge),s=l,s=l;(n=s.next)!==l;s=n)H(n.Sym.next===s.Sym),H(n.Sym!==n),H(n.Sym.Sym===n),H(null!==n.Org),H(null!==n.Dst),H(n.Lnext.Onext.Sym===n),H(n.Onext.Sym.Lnext===n);H(n.Sym.next===s.Sym&&n.Sym===this.eHeadSym&&n.Sym.Sym===n&&null===n.Org&&null===n.Dst&&null===n.Lface&&null===n.Rface)},e}(),K=function(){this.handle=null},q=function(){this.key=null,this.node=0},Z=function(){function e(e,t){this.leq=t,this.max=0,this.nodes=[],this.handles=[],this.initialized=!1,this.freeList=0,this.size=0,this.max=e,this.nodes=[],this.handles=[];for(var r=0;r<e+1;r++)this.nodes[r]=new K,this.handles[r]=new q;this.initialized=!1,this.nodes[1].handle=1,this.handles[1].key=null}return e.prototype.floatDown_=function(e){var t,r,i,n=this.nodes,s=this.handles;for(t=n[e].handle;;){if((i=e<<1)<this.size&&this.leq(s[n[i+1].handle].key,s[n[i].handle].key)&&++i,H(i<=this.max),r=n[i].handle,i>this.size||this.leq(s[t].key,s[r].key)){n[e].handle=t,s[t].node=e;break}n[e].handle=r,s[r].node=e,e=i}},e.prototype.floatUp_=function(e){var t,r,i,n=this.nodes,s=this.handles;for(t=n[e].handle;;){if(r=n[i=e>>1].handle,0===i||this.leq(s[r].key,s[t].key)){n[e].handle=t,s[t].node=e;break}n[e].handle=r,s[r].node=e,e=i}},e.prototype.init=function(){for(var e=this.size;e>=1;--e)this.floatDown_(e);this.initialized=!0},e.prototype.min=function(){return this.handles[this.nodes[1].handle].key},e.prototype.insert=function(e){var t,r;if(2*(t=++this.size)>this.max){var i,n;for(this.max*=2,n=this.nodes.length,this.nodes.length=this.max+1,i=n;i<this.nodes.length;i++)this.nodes[i]=new K;for(n=this.handles.length,this.handles.length=this.max+1,i=n;i<this.handles.length;i++)this.handles[i]=new q}return 0===this.freeList?r=t:(r=this.freeList,this.freeList=this.handles[r].node),this.nodes[t].handle=r,this.handles[r].node=t,this.handles[r].key=e,this.initialized&&this.floatUp_(t),r},e.prototype.extractMin=function(){var e=this.nodes,t=this.handles,r=e[1].handle,i=t[r].key;return this.size>0&&(e[1].handle=e[this.size].handle,t[e[1].handle].node=1,t[r].key=null,t[r].node=this.freeList,this.freeList=r,--this.size,this.size>0&&this.floatDown_(1)),i},e.prototype.delete=function(e){var t,r=this.nodes,i=this.handles;H(e>=1&&e<=this.max&&null!==i[e].key),r[t=i[e].node].handle=r[this.size].handle,i[r[t].handle].node=t,--this.size,t<=this.size&&(t<=1||this.leq(i[r[t>>1].handle].key,i[r[t].handle].key)?this.floatDown_(t):this.floatUp_(t)),i[e].key=null,i[e].node=this.freeList,this.freeList=e},e}(),$=function(){this.eUp=null,this.nodeUp=null,this.windingNumber=0,this.inside=!1,this.sentinel=!1,this.dirty=!1,this.fixUpperEdge=!1},ee=function(){this.key=null,this.next=null,this.prev=null},te=function(){function e(e,t){this.frame=e,this.leq=t,this.head=new ee,this.head.next=this.head,this.head.prev=this.head}return e.prototype.min=function(){return this.head.next},e.prototype.max=function(){return this.head.prev},e.prototype.insert=function(e){return this.insertBefore(this.head,e)},e.prototype.search=function(e){var t=this.head;do{t=t.next}while(null!==t.key&&!this.leq(this.frame,e,t.key));return t},e.prototype.insertBefore=function(e,t){do{e=e.prev}while(null!==e.key&&!this.leq(this.frame,e.key,t));var r=new ee;return r.key=t,r.next=e.next,e.next.prev=r,r.prev=e,e.next=r,r},e.prototype.delete=function(e){e.next.prev=e.prev,e.prev.next=e.next},e}(),re=function(){function e(){}return e.regionBelow=function(e){return e.nodeUp.prev.key},e.regionAbove=function(e){return e.nodeUp.next.key},e.debugEvent=function(e){},e.addWinding=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},e.edgeLeq=function(e,t,r){var i=e.event,n=t.eUp,s=r.eUp;return n.Dst===i?s.Dst===i?J.vertLeq(n.Org,s.Org)?J.edgeSign(s.Dst,n.Org,s.Org)<=0:J.edgeSign(n.Dst,s.Org,n.Org)>=0:J.edgeSign(s.Dst,i,s.Org)<=0:s.Dst===i?J.edgeSign(n.Dst,i,n.Org)>=0:J.edgeEval(n.Dst,i,n.Org)>=J.edgeEval(s.Dst,i,s.Org)},e.deleteRegion=function(e,t){t.fixUpperEdge&&H(0===t.eUp.winding),t.eUp.activeRegion=null,e.dict.delete(t.nodeUp)},e.fixUpperEdge=function(e,t,r){H(t.fixUpperEdge),e.mesh.delete(t.eUp),t.fixUpperEdge=!1,t.eUp=r,r.activeRegion=t},e.topLeftRegion=function(t,r){var i,n=r.eUp.Org;do{r=e.regionAbove(r)}while(r.eUp.Org===n);if(r.fixUpperEdge){if(null===(i=t.mesh.connect(e.regionBelow(r).eUp.Sym,r.eUp.Lnext)))return null;e.fixUpperEdge(t,r,i),r=e.regionAbove(r)}return r},e.topRightRegion=function(t){var r=t.eUp.Dst;do{t=e.regionAbove(t)}while(t.eUp.Dst===r);return t},e.addRegionBelow=function(e,t,r){var i=new $;return i.eUp=r,i.nodeUp=e.dict.insertBefore(t.nodeUp,i),i.fixUpperEdge=!1,i.sentinel=!1,i.dirty=!1,r.activeRegion=i,i},e.isWindingInside=function(e,t){switch(e.windingRule){case j.ODD:return 0!=(1&t);case j.NONZERO:return 0!==t;case j.POSITIVE:return t>0;case j.NEGATIVE:return t<0;case j.ABS_GEQ_TWO:return t>=2||t<=-2}throw new Error("Invalid winding rulle")},e.computeWinding=function(t,r){r.windingNumber=e.regionAbove(r).windingNumber+r.eUp.winding,r.inside=e.isWindingInside(t,r.windingNumber)},e.finishRegion=function(t,r){var i=r.eUp,n=i.Lface;n.inside=r.inside,n.anEdge=i,e.deleteRegion(t,r)},e.finishLeftRegions=function(t,r,i){for(var n,s=null,o=r,a=r.eUp;o!==i;){if(o.fixUpperEdge=!1,(n=(s=e.regionBelow(o)).eUp).Org!=a.Org){if(!s.fixUpperEdge){e.finishRegion(t,o);break}n=t.mesh.connect(a.Lprev,n.Sym),e.fixUpperEdge(t,s,n)}a.Onext!==n&&(t.mesh.splice(n.Oprev,n),t.mesh.splice(a,n)),e.finishRegion(t,o),a=s.eUp,o=s}return a},e.addRightEdges=function(t,r,i,n,s,o){var a,l,c,h,u=!0;c=i;do{H(J.vertLeq(c.Org,c.Dst)),e.addRegionBelow(t,r,c.Sym),c=c.Onext}while(c!==n);for(null===s&&(s=e.regionBelow(r).eUp.Rprev),l=r,h=s;(c=(a=e.regionBelow(l)).eUp.Sym).Org===h.Org;)c.Onext!==h&&(t.mesh.splice(c.Oprev,c),t.mesh.splice(h.Oprev,c)),a.windingNumber=l.windingNumber-c.winding,a.inside=e.isWindingInside(t,a.windingNumber),l.dirty=!0,!u&&e.checkForRightSplice(t,l)&&(e.addWinding(c,h),e.deleteRegion(t,l),t.mesh.delete(h)),u=!1,l=a,h=c;l.dirty=!0,H(l.windingNumber-c.winding===a.windingNumber),o&&e.walkDirtyRegions(t,l)},e.spliceMergeVertices=function(e,t,r){e.mesh.splice(t,r)},e.vertexWeights=function(e,t,r){var i=J.vertL1dist(t,e),n=J.vertL1dist(r,e),s=.5*n/(i+n),o=.5*i/(i+n);e.coords[0]+=s*t.coords[0]+o*r.coords[0],e.coords[1]+=s*t.coords[1]+o*r.coords[1],e.coords[2]+=s*t.coords[2]+o*r.coords[2]},e.getIntersectData=function(t,r,i,n,s,o){r.coords[0]=r.coords[1]=r.coords[2]=0,r.idx=-1,e.vertexWeights(r,i,n),e.vertexWeights(r,s,o)},e.checkForRightSplice=function(t,r){var i=e.regionBelow(r),n=r.eUp,s=i.eUp;if(J.vertLeq(n.Org,s.Org)){if(J.edgeSign(s.Dst,n.Org,s.Org)>0)return!1;J.vertEq(n.Org,s.Org)?n.Org!==s.Org&&(t.pq.delete(n.Org.pqHandle),e.spliceMergeVertices(t,s.Oprev,n)):(t.mesh.splitEdge(s.Sym),t.mesh.splice(n,s.Oprev),r.dirty=i.dirty=!0)}else{if(J.edgeSign(n.Dst,s.Org,n.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,t.mesh.splitEdge(n.Sym),t.mesh.splice(s.Oprev,n)}return!0},e.checkForLeftSplice=function(t,r){var i,n=e.regionBelow(r),s=r.eUp,o=n.eUp;if(H(!J.vertEq(s.Dst,o.Dst)),J.vertLeq(s.Dst,o.Dst)){if(J.edgeSign(s.Dst,o.Dst,s.Org)<0)return!1;e.regionAbove(r).dirty=r.dirty=!0,i=t.mesh.splitEdge(s),t.mesh.splice(o.Sym,i),i.Lface.inside=r.inside}else{if(J.edgeSign(o.Dst,s.Dst,o.Org)>0)return!1;r.dirty=n.dirty=!0,i=t.mesh.splitEdge(o),t.mesh.splice(s.Lnext,o.Sym),i.Rface.inside=r.inside}return!0},e.checkForIntersect=function(t,r){var i,n,s=e.regionBelow(r),o=r.eUp,a=s.eUp,l=o.Org,c=a.Org,h=o.Dst,u=a.Dst,d=new W;if(H(!J.vertEq(u,h)),H(J.edgeSign(h,t.event,l)<=0),H(J.edgeSign(u,t.event,c)>=0),H(l!==t.event&&c!==t.event),H(!r.fixUpperEdge&&!s.fixUpperEdge),l===c)return!1;if(Math.min(l.t,h.t)>Math.max(c.t,u.t))return!1;if(J.vertLeq(l,c)){if(J.edgeSign(u,l,c)>0)return!1}else if(J.edgeSign(h,c,l)<0)return!1;return e.debugEvent(t),J.intersect(h,l,u,c,d),H(Math.min(l.t,h.t)<=d.t),H(d.t<=Math.max(c.t,u.t)),H(Math.min(u.s,h.s)<=d.s),H(d.s<=Math.max(c.s,l.s)),J.vertLeq(d,t.event)&&(d.s=t.event.s,d.t=t.event.t),i=J.vertLeq(l,c)?l:c,J.vertLeq(i,d)&&(d.s=i.s,d.t=i.t),J.vertEq(d,l)||J.vertEq(d,c)?(e.checkForRightSplice(t,r),!1):!J.vertEq(h,t.event)&&J.edgeSign(h,t.event,d)>=0||!J.vertEq(u,t.event)&&J.edgeSign(u,t.event,d)<=0?u===t.event?(t.mesh.splitEdge(o.Sym),t.mesh.splice(a.Sym,o),r=e.topLeftRegion(t,r),o=e.regionBelow(r).eUp,e.finishLeftRegions(t,e.regionBelow(r),s),e.addRightEdges(t,r,o.Oprev,o,o,!0),!0):h===t.event?(t.mesh.splitEdge(a.Sym),t.mesh.splice(o.Lnext,a.Oprev),s=r,r=e.topRightRegion(r),n=e.regionBelow(r).eUp.Rprev,s.eUp=a.Oprev,a=e.finishLeftRegions(t,s,null),e.addRightEdges(t,r,a.Onext,o.Rprev,n,!0),!0):(J.edgeSign(h,t.event,d)>=0&&(e.regionAbove(r).dirty=r.dirty=!0,t.mesh.splitEdge(o.Sym),o.Org.s=t.event.s,o.Org.t=t.event.t),J.edgeSign(u,t.event,d)<=0&&(r.dirty=s.dirty=!0,t.mesh.splitEdge(a.Sym),a.Org.s=t.event.s,a.Org.t=t.event.t),!1):(t.mesh.splitEdge(o.Sym),t.mesh.splitEdge(a.Sym),t.mesh.splice(a.Oprev,o),o.Org.s=d.s,o.Org.t=d.t,o.Org.pqHandle=t.pq.insert(o.Org),e.getIntersectData(t,o.Org,l,h,c,u),e.regionAbove(r).dirty=r.dirty=s.dirty=!0,!1)},e.walkDirtyRegions=function(t,r){for(var i,n,s=e.regionBelow(r);;){for(;s.dirty;)r=s,s=e.regionBelow(s);if(!r.dirty&&(s=r,null===(r=e.regionAbove(r))||!r.dirty))return;if(r.dirty=!1,i=r.eUp,n=s.eUp,i.Dst!==n.Dst&&e.checkForLeftSplice(t,r)&&(s.fixUpperEdge?(e.deleteRegion(t,s),t.mesh.delete(n),n=(s=e.regionBelow(r)).eUp):r.fixUpperEdge&&(e.deleteRegion(t,r),t.mesh.delete(i),i=(r=e.regionAbove(s)).eUp)),i.Org!==n.Org)if(i.Dst===n.Dst||r.fixUpperEdge||s.fixUpperEdge||i.Dst!==t.event&&n.Dst!==t.event)e.checkForRightSplice(t,r);else if(e.checkForIntersect(t,r))return;i.Org===n.Org&&i.Dst===n.Dst&&(e.addWinding(n,i),e.deleteRegion(t,r),t.mesh.delete(i),r=e.regionAbove(s))}},e.connectRightVertex=function(t,r,i){var n,s=i.Onext,o=e.regionBelow(r),a=r.eUp,l=o.eUp,c=!1;a.Dst!==l.Dst&&e.checkForIntersect(t,r),J.vertEq(a.Org,t.event)&&(t.mesh.splice(s.Oprev,a),r=e.topLeftRegion(t,r),s=e.regionBelow(r).eUp,e.finishLeftRegions(t,e.regionBelow(r),o),c=!0),J.vertEq(l.Org,t.event)&&(t.mesh.splice(i,l.Oprev),i=e.finishLeftRegions(t,o,null),c=!0),c?e.addRightEdges(t,r,i.Onext,s,s,!0):(n=J.vertLeq(l.Org,a.Org)?l.Oprev:a,n=t.mesh.connect(i.Lprev,n),e.addRightEdges(t,r,n,n.Onext,n.Onext,!1),n.Sym.activeRegion.fixUpperEdge=!0,e.walkDirtyRegions(t,r))},e.connectLeftDegenerate=function(t,r,i){var n,s,o,a,l;return n=r.eUp,J.vertEq(n.Org,i)?(H(!1),void e.spliceMergeVertices(t,n,i.anEdge)):J.vertEq(n.Dst,i)?(H(!1),r=e.topRightRegion(r),s=a=(o=(l=e.regionBelow(r)).eUp.Sym).Onext,l.fixUpperEdge&&(H(s!==o),e.deleteRegion(t,l),t.mesh.delete(o),o=s.Oprev),t.mesh.splice(i.anEdge,o),J.edgeGoesLeft(s)||(s=null),void e.addRightEdges(t,r,o.Onext,a,s,!0)):(t.mesh.splitEdge(n.Sym),r.fixUpperEdge&&(t.mesh.delete(n.Onext),r.fixUpperEdge=!1),t.mesh.splice(i.anEdge,n),void e.sweepEvent(t,i))},e.connectLeftVertex=function(t,r){var i,n,s,o,a,l,c=new $;if(c.eUp=r.anEdge.Sym,i=t.dict.search(c).key,n=e.regionBelow(i))if(o=i.eUp,a=n.eUp,0!==J.edgeSign(o.Dst,r,o.Org))if(s=J.vertLeq(a.Dst,o.Dst)?i:n,i.inside||s.fixUpperEdge){if(s===i)l=t.mesh.connect(r.anEdge.Sym,o.Lnext);else l=t.mesh.connect(a.Dnext,r.anEdge).Sym;s.fixUpperEdge?e.fixUpperEdge(t,s,l):e.computeWinding(t,e.addRegionBelow(t,i,l)),e.sweepEvent(t,r)}else e.addRightEdges(t,i,r.anEdge,r.anEdge,null,!0);else e.connectLeftDegenerate(t,i,r)},e.sweepEvent=function(t,r){t.event=r,e.debugEvent(t);for(var i=r.anEdge;null===i.activeRegion;)if((i=i.Onext)===r.anEdge)return void e.connectLeftVertex(t,r);var n=e.topLeftRegion(t,i.activeRegion);H(null!==n);var s=e.regionBelow(n),o=s.eUp,a=e.finishLeftRegions(t,s,null);a.Onext===o?e.connectRightVertex(t,n,a):e.addRightEdges(t,n,a.Onext,o,o,!0)},e.addSentinel=function(e,t,r,i){var n=new $,s=e.mesh.makeEdge();s.Org.s=r,s.Org.t=i,s.Dst.s=t,s.Dst.t=i,e.event=s.Dst,n.eUp=s,n.windingNumber=0,n.inside=!1,n.fixUpperEdge=!1,n.sentinel=!0,n.dirty=!1,n.nodeUp=e.dict.insert(n)},e.initEdgeDict=function(t){t.dict=new te(t,e.edgeLeq);var r=t.bmax[0]-t.bmin[0],i=t.bmax[1]-t.bmin[1],n=t.bmin[0]-r,s=t.bmax[0]+r,o=t.bmin[1]-i,a=t.bmax[1]+i;e.addSentinel(t,n,s,o),e.addSentinel(t,n,s,a)},e.doneEdgeDict=function(t){for(var r,i=0;null!==(r=t.dict.min().key);)r.sentinel||(H(r.fixUpperEdge),H(1==++i)),H(0===r.windingNumber),e.deleteRegion(t,r)},e.removeDegenerateEdges=function(t){var r,i,n,s=t.mesh.eHead;for(r=s.next;r!==s;r=i)i=r.next,n=r.Lnext,J.vertEq(r.Org,r.Dst)&&r.Lnext.Lnext!==r&&(e.spliceMergeVertices(t,n,r),t.mesh.delete(r),n=(r=n).Lnext),n.Lnext===r&&(n!==r&&(n!==i&&n!==i.Sym||(i=i.next),t.mesh.delete(n)),r!==i&&r!==i.Sym||(i=i.next),t.mesh.delete(r))},e.initPriorityQ=function(e){var t,r,i,n=0;for(r=(i=e.mesh.vHead).next;r!==i;r=r.next)n++;for(n+=8,t=e.pq=new Z(n,J.vertLeq),r=(i=e.mesh.vHead).next;r!==i;r=r.next)r.pqHandle=t.insert(r);return r===i&&(t.init(),!0)},e.donePriorityQ=function(e){e.pq=null},e.removeDegenerateFaces=function(t,r){var i,n,s;for(i=r.fHead.next;i!==r.fHead;i=n)n=i.next,H((s=i.anEdge).Lnext!==s),s.Lnext.Lnext===s&&(e.addWinding(s.Onext,s),t.mesh.delete(s));return!0},e.computeInterior=function(t,r){var i,n;if(void 0===r&&(r=!0),e.removeDegenerateEdges(t),!e.initPriorityQ(t))return!1;for(e.initEdgeDict(t);null!==(i=t.pq.extractMin());){for(;null!==(n=t.pq.min())&&J.vertEq(n,i);)n=t.pq.extractMin(),e.spliceMergeVertices(t,i.anEdge,n.anEdge);e.sweepEvent(t,i)}return t.event=t.dict.min().key.eUp.Org,e.debugEvent(t),e.doneEdgeDict(t),e.donePriorityQ(t),!!e.removeDegenerateFaces(t,t.mesh)&&(r&&t.mesh.check(),!0)},e}(),ie=function(){function e(){this.mesh=new X,this.normal=[0,0,0],this.sUnit=[0,0,0],this.tUnit=[0,0,0],this.bmin=[0,0],this.bmax=[0,0],this.windingRule=j.ODD,this.dict=null,this.pq=null,this.event=null,this.vertexIndexCounter=0,this.vertices=[],this.vertexIndices=[],this.vertexCount=0,this.elements=[],this.elementCount=0}return e.prototype.dot_=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.prototype.normalize_=function(e){var t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];if(!t)throw"Zero-size vector!";t=Math.sqrt(t),e[0]/=t,e[1]/=t,e[2]/=t},e.prototype.longAxis_=function(e){var t=0;return Math.abs(e[1])>Math.abs(e[0])&&(t=1),Math.abs(e[2])>Math.abs(e[t])&&(t=2),t},e.prototype.computeNormal_=function(e){var t,r,i,n,s,o,a=[0,0,0],l=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],d=[null,null,null],p=[null,null,null],f=this.mesh.vHead;t=f.next;for(var m=0;m<3;++m)n=t.coords[m],l[m]=n,p[m]=t,a[m]=n,d[m]=t;for(t=f.next;t!==f;t=t.next)for(var g=0;g<3;++g)(n=t.coords[g])<l[g]&&(l[g]=n,p[g]=t),n>a[g]&&(a[g]=n,d[g]=t);var v=0;if(a[1]-l[1]>a[0]-l[0]&&(v=1),a[2]-l[2]>a[v]-l[v]&&(v=2),l[v]>=a[v])return e[0]=0,e[1]=0,void(e[2]=1);for(o=0,r=p[v],i=d[v],c[0]=r.coords[0]-i.coords[0],c[1]=r.coords[1]-i.coords[1],c[2]=r.coords[2]-i.coords[2],t=f.next;t!==f;t=t.next)h[0]=t.coords[0]-i.coords[0],h[1]=t.coords[1]-i.coords[1],h[2]=t.coords[2]-i.coords[2],u[0]=c[1]*h[2]-c[2]*h[1],u[1]=c[2]*h[0]-c[0]*h[2],u[2]=c[0]*h[1]-c[1]*h[0],(s=u[0]*u[0]+u[1]*u[1]+u[2]*u[2])>o&&(o=s,e[0]=u[0],e[1]=u[1],e[2]=u[2]);o<=0&&(e[0]=e[1]=e[2]=0,e[this.longAxis_(c)]=1)},e.prototype.checkOrientation_=function(){for(var e,t,r=this.mesh.fHead,i=this.mesh.vHead,n=0,s=r.next;s!==r;s=s.next)if(!((t=s.anEdge).winding<=0))do{n+=(t.Org.s-t.Dst.s)*(t.Org.t+t.Dst.t),t=t.Lnext}while(t!==s.anEdge);if(n<0){for(e=i.next;e!==i;e=e.next)e.t=-e.t;this.tUnit[0]=-this.tUnit[0],this.tUnit[1]=-this.tUnit[1],this.tUnit[2]=-this.tUnit[2]}},e.prototype.projectPolygon_=function(){var e,t,r=this.mesh.vHead,i=[0,0,0],n=!1;i[0]=this.normal[0],i[1]=this.normal[1],i[2]=this.normal[2],i[0]||i[1]||i[2]||(this.computeNormal_(i),n=!0),e=this.sUnit,t=this.tUnit;var s=this.longAxis_(i);e[s]=0,e[(s+1)%3]=1,e[(s+2)%3]=0,t[s]=0,t[(s+1)%3]=0,t[(s+2)%3]=i[s]>0?1:-1;for(var o=r.next;o!==r;o=o.next)o.s=this.dot_(o.coords,e),o.t=this.dot_(o.coords,t);n&&this.checkOrientation_();for(var a=!0,l=r.next;l!==r;l=l.next)a?(this.bmin[0]=this.bmax[0]=l.s,this.bmin[1]=this.bmax[1]=l.t,a=!1):(l.s<this.bmin[0]&&(this.bmin[0]=l.s),l.s>this.bmax[0]&&(this.bmax[0]=l.s),l.t<this.bmin[1]&&(this.bmin[1]=l.t),l.t>this.bmax[1]&&(this.bmax[1]=l.t))},e.prototype.addWinding_=function(e,t){e.winding+=t.winding,e.Sym.winding+=t.Sym.winding},e.prototype.tessellateMonoRegion_=function(e,t){var r,i;if((r=t.anEdge).Lnext===r||r.Lnext.Lnext===r)throw"Mono region invalid";for(;J.vertLeq(r.Dst,r.Org);r=r.Lprev);for(;J.vertLeq(r.Org,r.Dst);r=r.Lnext);i=r.Lprev;for(;r.Lnext!==i;)if(J.vertLeq(r.Dst,i.Org)){for(;i.Lnext!==r&&(J.edgeGoesLeft(i.Lnext)||J.edgeSign(i.Org,i.Dst,i.Lnext.Dst)<=0);)i=e.connect(i.Lnext,i).Sym;i=i.Lprev}else{for(;i.Lnext!==r&&(J.edgeGoesRight(r.Lprev)||J.edgeSign(r.Dst,r.Org,r.Lprev.Org)>=0);)r=e.connect(r,r.Lprev).Sym;r=r.Lnext}if(i.Lnext===r)throw"Mono region invalid";for(;i.Lnext.Lnext!==r;)i=e.connect(i.Lnext,i).Sym;return!0},e.prototype.tessellateInterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)if(t=r.next,r.inside&&!this.tessellateMonoRegion_(e,r))return!1;return!0},e.prototype.discardExterior_=function(e){for(var t,r=e.fHead.next;r!==e.fHead;r=t)t=r.next,r.inside||e.zapFace(r)},e.prototype.setWindingNumber_=function(e,t,r){for(var i,n=e.eHead.next;n!==e.eHead;n=i)i=n.next,n.Rface.inside!==n.Lface.inside?n.winding=n.Lface.inside?t:-t:r?e.delete(n):n.winding=0},e.prototype.getNeighbourFace_=function(e){return e.Rface&&e.Rface.inside?e.Rface.n:-1},e.prototype.outputPolymesh_=function(e,t,r,i){var n,s,o=0,a=0;r>3&&e.mergeConvexFaces(r);for(var l=e.vHead.next;l!==e.vHead;l=l.next)l.n=-1;for(var c=e.fHead.next;c!==e.fHead;c=c.next)if(c.n=-1,c.inside){n=c.anEdge,s=0;do{-1===(l=n.Org).n&&(l.n=a,a++),s++,n=n.Lnext}while(n!==c.anEdge);if(s>r)throw"Face vertex greater that support polygon";c.n=o,++o}this.elementCount=o,t===V.CONNECTED_POLYGONS&&(o*=2),this.elements=[],this.elements.length=o*r,this.vertexCount=a,this.vertices=[],this.vertices.length=a*i,this.vertexIndices=[],this.vertexIndices.length=a;for(l=e.vHead.next;l!==e.vHead;l=l.next)if(-1!==l.n){var h=l.n*i;this.vertices[h+0]=l.coords[0],this.vertices[h+1]=l.coords[1],i>2&&(this.vertices[h+2]=l.coords[2]),this.vertexIndices[l.n]=l.idx}var u=0;for(c=e.fHead.next;c!==e.fHead;c=c.next)if(c.inside){n=c.anEdge,s=0;do{l=n.Org;this.elements[u++]=l.n,s++,n=n.Lnext}while(n!==c.anEdge);for(var d=s;d<r;++d)this.elements[u++]=-1;if(t===V.CONNECTED_POLYGONS){n=c.anEdge;do{this.elements[u++]=this.getNeighbourFace_(n),n=n.Lnext}while(n!==c.anEdge);for(var p=s;p<r;++p)this.elements[u++]=-1}}},e.prototype.outputContours_=function(e,t){var r,i,n=0,s=0;this.vertexCount=0,this.elementCount=0;for(var o=e.fHead.next;o!==e.fHead;o=o.next)if(o.inside){i=r=o.anEdge;do{this.vertexCount++,r=r.Lnext}while(r!==i);this.elementCount++}this.elements=[],this.elements.length=2*this.elementCount,this.vertices=[],this.vertices.length=this.vertexCount*t,this.vertexIndices=[],this.vertexIndices.length=this.vertexCount;var a=0,l=0,c=0;n=0;for(o=e.fHead.next;o!==e.fHead;o=o.next)if(o.inside){s=0,i=r=o.anEdge;do{this.vertices[a++]=r.Org.coords[0],this.vertices[a++]=r.Org.coords[1],t>2&&(this.vertices[a++]=r.Org.coords[2]),this.vertexIndices[l++]=this.vertexIdCallback?this.vertexIdCallback(r):r.Org.idx,s++,r=r.Lnext}while(r!==i);this.elements[c++]=n,this.elements[c++]=s,n+=s}},e.prototype.addContour=function(e,t){null===this.mesh&&(this.mesh=new X),e<2&&(e=2),e>3&&(e=3);for(var r=null,i=0;i<t.length;i+=e)null===r?(r=this.mesh.makeEdge(),this.mesh.splice(r,r.Sym)):(this.mesh.splitEdge(r),r=r.Lnext),r.Org.coords[0]=t[i+0],r.Org.coords[1]=t[i+1],r.Org.coords[2]=e>2?t[i+2]:0,r.Org.idx=this.vertexIndexCounter++,this.edgeCreateCallback&&this.edgeCreateCallback(r),r.winding=1,r.Sym.winding=-1},e.prototype.tesselate=function(e,t,r,i,n,s){if(void 0===e&&(e=j.ODD),void 0===t&&(t=V.POLYGONS),void 0===s&&(s=!0),this.vertices=[],this.elements=[],this.vertexIndices=[],this.vertexIndexCounter=0,n&&(this.normal[0]=n[0],this.normal[1]=n[1],this.normal[2]=n[2]),this.windingRule=e,i<2&&(i=2),i>3&&(i=3),!this.mesh)return!1;this.projectPolygon_(),re.computeInterior(this,s);var o=this.mesh;return t===V.BOUNDARY_CONTOURS?this.setWindingNumber_(o,1,!0):this.tessellateInterior_(o),s&&o.check(),t===V.BOUNDARY_CONTOURS?this.outputContours_(o,i):this.outputPolymesh_(o,t,r,i),!0},e}();function ne(e){var t=e.windingRule,r=void 0===t?j.ODD:t,i=e.elementType,n=void 0===i?V.POLYGONS:i,s=e.polySize,o=void 0===s?3:s,a=e.vertexSize,l=void 0===a?2:a,c=e.normal,h=void 0===c?[0,0,1]:c,u=e.contours,d=void 0===u?[]:u,p=e.strict,f=void 0===p||p,m=e.debug,g=void 0!==m&&m;if(!d&&f)throw new Error("Contours can't be empty");if(d){var v=new ie;e.edgeCreateCallback&&(v.edgeCreateCallback=e.edgeCreateCallback),e.vertexIdCallback&&(v.vertexIdCallback=e.vertexIdCallback);for(var y=0;y<d.length;y++)v.addContour(l||2,d[y]);return v.tesselate(r,n,o,l,h,f),{vertices:v.vertices,vertexIndices:v.vertexIndices,vertexCount:v.vertexCount,elements:v.elements,elementCount:v.elementCount,mesh:g?v.mesh:void 0}}}j.ODD,j.NONZERO,j.POSITIVE,j.NEGATIVE,j.ABS_GEQ_TWO,V.POLYGONS,V.CONNECTED_POLYGONS,V.BOUNDARY_CONTOURS;class se extends t.BufferGeometry{constructor(e,r=12,i=100,n={}){super(),this.type="ShapeGeometry",this.windingRule=j.ODD,this.elementType=V.POLYGONS,this.polySize=3,this.vertexSize=2,this.strict=!0,this._drawCount=0,this._shape=e,this._curveSegments=r,this._maxCount=i,this._maxDrawCount=3*i,this._triangulationOptions=Object.assign({windingRule:j.ODD,elementType:V.POLYGONS,polySize:3,vertexSize:2,strict:!0},n),this._positionAttribute=new t.BufferAttribute(new Float32Array(3*i),3),this._normalAttribute=new t.BufferAttribute(new Float32Array(3*i),3),this._uvAttribute=new t.BufferAttribute(new Float32Array(2*i),2),this._indexAttribute=new t.BufferAttribute(new Uint32Array(3*i),1),this.setAttribute("position",this._positionAttribute),this.setAttribute("normal",this._normalAttribute),this.setAttribute("uv",this._uvAttribute),this.setIndex(this._indexAttribute),this.updateFromShape()}copy(e){return this._drawCount=e.drawCount,this._maxDrawCount=e._maxDrawCount,this._maxCount=e.maxCount,super.copy(e)}get curveSegments(){return this._curveSegments}set curveSegments(e){this._curveSegments=e,this.updateFromShape()}get drawCount(){return this._drawCount}get maxDrawCount(){return this._maxDrawCount}get maxCount(){return this._maxCount}updateFromShape(){const e=this._shape.extractShapePointsToFlatArray([],this._curveSegments),t=this._shape.shapeHoles.map((e=>e.extractShapePointsToFlatArray([],this._curveSegments)));let r,i,n,s=!0,o=!0;for(let t=0,r=e.length/2;t<r;t++){const r=2*t,a=e[r+0],l=e[r+1];if(void 0!==i&&a!==i&&(s=!1),void 0!==n&&l!==n&&(o=!1),i=a,n=l,!s&&!o)break}if(s||o||(r=ne({contours:[e,...t],windingRule:this._triangulationOptions.windingRule,elementType:this._triangulationOptions.elementType,polySize:this._triangulationOptions.polySize,vertexSize:this._triangulationOptions.vertexSize,strict:this._triangulationOptions.strict})),r){this._positionAttribute.array.fill(0),this._normalAttribute.array.fill(0),this._uvAttribute.array.fill(0),this._indexAttribute.array.fill(0),this._drawCount=0;let e=1/0,t=-1/0,i=1/0,n=-1/0;for(let s=0,o=r.vertexCount;s<o;s++){const o=2*s,a=r.vertices[o+0],l=r.vertices[o+1];a<e&&(e=a),a>t&&(t=a),l<i&&(i=l),l>n&&(n=l)}const s=t-e,o=n-i;for(let t=0,n=r.vertexCount;t<n;t++){const n=2*t,a=r.vertices[n+0],l=r.vertices[n+1],c=(a-e)/s,h=(l-i)/o;this._positionAttribute.setXYZ(t,a,l,0),this._normalAttribute.setXYZ(t,0,0,1),this._uvAttribute.setXY(t,c,h)}for(let e=0,t=r.elementCount;e<t;e++){const t=3*e,i=r.elements[t+0],n=r.elements[t+1],s=r.elements[t+2];this._indexAttribute.setX(t+0,i),this._indexAttribute.setX(t+1,n),this._indexAttribute.setX(t+2,s),this._drawCount+=3}this._positionAttribute.needsUpdate=!0,this._normalAttribute.needsUpdate=!0,this._uvAttribute.needsUpdate=!0,this._indexAttribute.needsUpdate=!0,this.setDrawRange(0,this._drawCount)}return this._drawCount>this._maxDrawCount}}class oe{constructor(e=256,t=!1){this.capacity=e,this.size=0,this.debug=t,this.debug&&console.log(`allocating with cap ${e}`);const r=e*oe.eSize;this.buffer=new ArrayBuffer(r);const i=Float32Array.BYTES_PER_ELEMENT;let n=0;this.positions=new Float32Array(this.buffer,n*i,3*e),n+=3*e,this.normals=new Float32Array(this.buffer,n*i,3*e),n+=3*e,this.uvs=new Float32Array(this.buffer,n*i,2*e)}realloc(e,t=!1){if(e<this.size)throw Error("cannot shrink buffer");if(e<=this.capacity&&!t)return;this.debug&&console.log(`resizing from ${this.capacity}${e}`);const r=e*oe.eSize,i=new ArrayBuffer(r),n=Float32Array.BYTES_PER_ELEMENT;let s=0;const o=new Float32Array(i,s*n,3*e);s+=3*e;const a=new Float32Array(i,s*n,3*e);s+=3*e;const l=new Float32Array(i,s*n,2*e);o.set(this.positions.slice(0,3*this.size)),a.set(this.normals.slice(0,3*this.size)),l.set(this.uvs.slice(0,2*this.size)),this.buffer=i,this.positions=o,this.normals=a,this.uvs=l,this.capacity=e}get(e=1){const t=this.size+e;if(t>this.capacity){let e=this.capacity;for(;t>e;)e*=2;this.realloc(e)}const r=this.size;return this.size=t,r}reserve(e){const t=this.size+e;t>this.capacity&&this.realloc(t)}shrink(){this.debug&&console.log(`shrinking ${this.capacity}${this.size}`),this.realloc(this.size,!0)}}oe.eSize=8*Float32Array.BYTES_PER_ELEMENT;const ae=(e,t)=>([r,i])=>(i<r&&(i+=t),(e>=r?e:e+t)<=i);class le extends t.BufferGeometry{constructor(e,r,i=0,n=12,s=3){super(),this.type="ShapeGeometry",this.vertexCache={},this._shape=e,this._depth=r,i<=0?(this._bevelSize=0,this._bevelSegments=0):(this._bevelSize=Math.min(i,r/2-1e-12),this._bevelSegments=Math.floor(s));const o=this._shape.extractShapePointsToFlatArray([],n),a=this._shape.shapeHoles.map((e=>e.extractShapePointsToFlatArray([],n))),l=ne({windingRule:j.ODD,elementType:V.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[o,...a]});if(!l)throw new Error("error generating geometry");let c=1/0,h=-1/0,u=1/0,d=-1/0;for(let e=0,t=l.vertexCount;e<t;e++){const t=2*e,r=l.vertices[t+0],i=l.vertices[t+1];r<c&&(c=r),r>h&&(h=r),i<u&&(u=i),i>d&&(d=i)}this._minX=c,this._minY=u,this._width=h-c,this._height=d-u;const p=2*l.vertexCount*(2+this._bevelSegments);this._buffer=new oe(p);const f=[];for(let e=0,t=l.elementCount;e<t;e++){const t=2*e,r=l.elements[t+0],i=l.elements[t+1],s=r+i,o={start:r,count:i,normals:[],continuous:[],concave:[]};let c=r,h=s-1,u=r+1;const d=this._shape.roundedCurves.length;do{const e=c-r,t=l.vertices[2*h+0],n=l.vertices[2*h+1],a=l.vertices[2*c+0],p=l.vertices[2*c+1],f=l.vertices[2*u+0],m=l.vertices[2*u+1];let g=a-t,v=p-n;const y=Math.sqrt(g*g+v*v);g/=y,v/=y;let A=a-f,w=p-m;const x=Math.sqrt(A*A+w*w);A/=x,w/=x,o.normals[2*e+0]=-w,o.normals[2*e+1]=A,o.concave[e]=g*w-v*A>0;const b=l.vertexIndices[c];if(Array.isArray(b))o.continuous[e]=!1;else{const[t,r]=this._shape.getCurveIndexFromVertexId(b-1,!0);if(r>0&&r<1)o.continuous[e]=!0;else{let i=1===r?t+1:t-1;i=(i+d)%d;const n=1===r?0:1,s=this._shape.roundedCurves[t].getTangent(r),a=this._shape.roundedCurves[i].getTangent(n);o.continuous[e]=s.dot(a)>.95}}[h,c,u]=[c,u,u+1],u>=s&&(u-=i)}while(u!==r+1);const p=[];p.push({bevelI:0,angle:0,size:0,boundary:{vertices:l.vertices.slice(2*r,2*s),vertexCount:i,vertexIndices:new Array(i).fill(!0).map(((e,t)=>[t,t])),elements:[0,i],elementCount:1,mesh:null},reverseMap:[],insetPoints:l.vertices.slice(2*r,2*s)});for(let e=1;e<=this._bevelSegments;e++){const t=e/this._bevelSegments*Math.PI/2,r=(1-Math.cos(t))*this._bevelSize,s=[],a=[],c=[],h=[];let u=0;for(let e=0;e<i;e++){const t=2*e,d=(e-1+i)%i*2,p=l.vertices[2*o.start+t+0],f=l.vertices[2*o.start+t+1],m=-o.normals[d+0]*r,g=-o.normals[d+1]*r,v=-o.normals[t+0]*r,y=-o.normals[t+1]*r;if(o.concave[e]){const t=Math.atan2(g,m);let i=Math.atan2(y,v);i>t&&(i-=2*Math.PI);const a=i-t;if(o.continuous[e]){const i=t+a/2,n=Math.cos(i)*r,o=Math.sin(i)*r;s[2*u+0]=p+n,s[2*u+1]=f+o,h[u]=e,u++}else{const i=Math.max(1,Math.floor(n/4*Math.abs(a)/Math.PI));for(let n=0;n<=i;n++){const o=t+a*(n/i),l=Math.cos(o)*r,c=Math.sin(o)*r;s[2*u+0]=p+l,s[2*u+1]=f+c,h[u]=e,u++}}}else s[2*u+0]=p+m,s[2*u+1]=f+g,h[u]=e,a[e]=u,u++,s[2*u+0]=p,s[2*u+1]=f,h[u]=e,u++,s[2*u+0]=p+v,s[2*u+1]=f+y,h[u]=e,c[e]=u,u++}const d=ne({windingRule:j.POSITIVE,elementType:V.BOUNDARY_CONTOURS,vertexSize:2,strict:!0,contours:[s],edgeCreateCallback:e=>{const t=e.Org.idx,r=h[t],i=h[(t+1)%h.length];e.idx=[r,i],e.Sym.idx=[i,r]},vertexIdCallback:e=>{const t=e.Lprev.idx;return[t?t[1]:0,e.idx[0]]}});if(!d)throw new Error(`error generating bevel geometry for ${e}'th loop`);if(!d.vertexCount)break;for(let e=0;e<d.vertexIndices.length;e++){const[t,r]=d.vertexIndices[e];if(t===r)continue;let n=r;r<t&&(n+=i);for(let s=t;s<n;s++){const n=s%i,a=(s+1)%i;if(!o.continuous[n]||!o.continuous[a]){d.vertexIndices[e]=[t,n],d.vertexIndices.splice(e+1,0,[a,r]),d.vertices.splice(2*(e+1),0,d.vertices[2*e],d.vertices[2*e+1]);break}}}p.push({bevelI:e,angle:t,size:r,boundary:d,reverseMap:h,insetPoints:s})}const m=(e,t,r)=>{let i=0;const n=e.boundary.vertexIndices.length;for(;i<n&&r(e.boundary.vertexIndices[t]);)t=(t+1)%n,i++;return i};for(let e=1;e<p.length;e++){const t=p[e-1],r=p[e],n=t.boundary.vertexIndices.length,s=r.boundary.vertexIndices.length;if(!n||!s)break;const a=o.concave.length;let l=0,c=ae(l,i);for(;!t.boundary.vertexIndices.filter(c).length||!r.boundary.vertexIndices.filter(c).length;)l++,c=ae(l,i);let h=t.boundary.vertexIndices.findIndex(c),u=r.boundary.vertexIndices.findIndex(c);do{h=(h+1)%n}while(c(t.boundary.vertexIndices[h]));do{u=(u+1)%s}while(c(r.boundary.vertexIndices[u]));l=(l+1)%i;const d=l;let g,v,y=this.buildBevelVert(o,t,(h-1+n)%n),A=this.buildBevelVert(o,r,(u-1+s)%s),w=!1;do{c=ae(l,i);const e=m(t,h,c),d=m(r,u,c),p=w;if(w=!1,e&&!d){for(let r=0;r<e;r++)g=this.buildBevelVert(o,t,(h+r)%n,r/(e-1)),f.push(y.topN,g.topP,A.topN),f.push(g.bottomP,y.bottomN,A.bottomN),y=g;w=!0}else if(!e&&d)for(let e=0;e<d;e++)v=this.buildBevelVert(o,r,(u+e)%s,e/(d-1)),f.push(A.topN,y.topP,v.topP),f.push(y.bottomP,A.bottomN,v.bottomP),A=v;else if(e&&d)if(g=this.buildBevelVert(o,t,h,0),v=this.buildBevelVert(o,r,u,0),p?(f.push(y.topN,v.topP,A.topN),f.push(y.topN,g.topP,v.topP),f.push(v.bottomP,y.bottomN,A.bottomN),f.push(g.bottomP,y.bottomN,v.bottomP)):(f.push(y.topN,g.topP,A.topN),f.push(A.topN,g.topP,v.topP),f.push(g.bottomP,y.bottomN,A.bottomN),f.push(g.bottomP,A.bottomN,v.bottomP)),y=g,A=v,e===d)for(let i=1;i<e;i++)g=this.buildBevelVert(o,t,(h+i)%n,i/(e-1)),v=this.buildBevelVert(o,r,(u+i)%s,i/(d-1)),f.push(y.topN,g.topP,A.topN),f.push(A.topN,g.topP,v.topP),f.push(g.bottomP,y.bottomN,A.bottomN),f.push(g.bottomP,A.bottomN,v.bottomP),y=g,A=v;else if(e>d){const i=e/d;let a=0;for(let l=1;l<e;l++)g=this.buildBevelVert(o,t,(h+l)%n,l/(e-1)),f.push(y.topN,g.topP,A.topN),f.push(g.bottomP,y.bottomN,A.bottomN),y=g,l>(a+1)*i&&(a++,v=this.buildBevelVert(o,r,(u+a)%s,a/(d-1)),f.push(A.topN,g.topP,v.topP),f.push(g.bottomP,A.bottomN,v.bottomP),A=v)}else{const i=d/e;let a=0;for(let l=1;l<d;l++)v=this.buildBevelVert(o,r,(u+l)%s,l/(d-1)),f.push(A.topN,g.topP,v.topP),f.push(g.bottomP,A.bottomN,v.bottomP),A=v,l>(a+1)*i&&(a++,g=this.buildBevelVert(o,t,(h+a)%n,a/(e-1)),f.push(y.topN,g.topP,A.topN),f.push(g.bottomP,y.bottomN,A.bottomN),y=g)}h=(h+e)%n,u=(u+d)%s,l=(l+1)%a}while(l!==d)}{const e=p[0];for(let t=0,r=e.boundary.vertexCount;t<r;t++){const i=this.buildBevelVert(o,e,t),n=this.buildBevelVert(o,e,(t+1)%r);f.push(n.topP,i.topN,i.bottomN),f.push(n.topP,i.bottomN,n.bottomP)}}{const e=p[p.length-1],t=ne({windingRule:p.length>1?j.POSITIVE:j.ODD,elementType:V.POLYGONS,vertexSize:2,strict:!0,contours:[e.insetPoints,...a]});if(!t)throw new Error("Error generating geometry for surface");for(let e=0;e<3*t.elementCount;e+=3){const r=this.buildSurfaceVert(t,t.elements[e+0]),i=this.buildSurfaceVert(t,t.elements[e+1]),n=this.buildSurfaceVert(t,t.elements[e+2]);f.push(r.top,i.top,n.top),f.push(n.bottom,i.bottom,r.bottom)}}this.vertexCache={}}this._buffer.shrink();const m=new t.BufferAttribute(Uint32Array.from(f),1),g=new t.BufferAttribute(this._buffer.positions,3),v=new t.BufferAttribute(this._buffer.normals,3),y=new t.BufferAttribute(this._buffer.uvs,2);g.needsUpdate=!0,v.needsUpdate=!0,y.needsUpdate=!0,m.needsUpdate=!0,this.setAttribute("position",g),this.setAttribute("normal",v),this.setAttribute("uv",y),this.setIndex(m)}buildSurfaceVert(e,t){const r=t.toString();if(r in this.vertexCache)return this.vertexCache[r];const i=e.vertices[2*t+0],n=e.vertices[2*t+1],s=(i-this._minX)/this._width,o=(n-this._minY)/this._height,a=this._buffer.get(2),l=3*a,c=2*a,h={top:a+0,bottom:a+1};return this._buffer.positions[l+0]=i,this._buffer.positions[l+1]=n,this._buffer.positions[l+2]=this._depth,this._buffer.normals[l+0]=0,this._buffer.normals[l+1]=0,this._buffer.normals[l+2]=1,this._buffer.uvs[c+0]=s,this._buffer.uvs[c+1]=o,this._buffer.positions[l+3]=i,this._buffer.positions[l+4]=n,this._buffer.positions[l+5]=0,this._buffer.normals[l+3]=0,this._buffer.normals[l+4]=0,this._buffer.normals[l+5]=-1,this._buffer.uvs[c+2]=s,this._buffer.uvs[c+3]=o,this.vertexCache[r]=h,h}buildBevelVert(e,t,r,i=1){const n=`${t.bevelI}:${r}`;if(n in this.vertexCache)return this.vertexCache[n];const[s,o]=t.boundary.vertexIndices[r];let a,l,c,h;s!==o?(l=s,a=o,h=!1,c=e.continuous[l]&&e.continuous[a]):(a=s,l=(a-1+e.count)%e.count,h=e.concave[a]&&t.bevelI>0,c=e.continuous[a]||h);const u=Math.cos(t.angle),d=Math.sin(t.angle),p=2*r,f=2*a,m=2*l,g=t.boundary.vertices[p+0],v=t.boundary.vertices[p+1],y=(1-d)*this._bevelSize,A=(g-this._minX)/this._width,w=(v-this._minY)/this._height;let x=e.normals[f+0],b=e.normals[f+1];const S=e.normals[m+0],E=e.normals[m+1];if(h){x+=(S-x)*(1-i),b+=(E-b)*(1-i);const e=Math.sqrt(x*x+b*b);x/=e,b/=e}let C=this._buffer.get(c?2:4),T=3*C,O=2*C;const D={i:r,fi:a,topP:C+0,topN:C+0,bottomP:C+1,bottomN:C+1};return this._buffer.positions[T+0]=g,this._buffer.positions[T+1]=v,this._buffer.positions[T+2]=this._depth-y,this._buffer.normals[T+0]=x*u,this._buffer.normals[T+1]=b*u,this._buffer.normals[T+2]=d,this._buffer.uvs[O+0]=A,this._buffer.uvs[O+1]=w,this._buffer.positions[T+3]=g,this._buffer.positions[T+4]=v,this._buffer.positions[T+5]=y,this._buffer.normals[T+3]=x*u,this._buffer.normals[T+4]=b*u,this._buffer.normals[T+5]=-d,this._buffer.uvs[O+2]=w,this._buffer.uvs[O+3]=A,c||(C+=2,T+=6,O+=4,D.topP=C+0,D.bottomP=C+1,this._buffer.positions[T+0]=g,this._buffer.positions[T+1]=v,this._buffer.positions[T+2]=this._depth-y,this._buffer.normals[T+0]=S*u,this._buffer.normals[T+1]=E*u,this._buffer.normals[T+2]=d,this._buffer.uvs[O+0]=A,this._buffer.uvs[O+1]=w,this._buffer.positions[T+3]=g,this._buffer.positions[T+4]=v,this._buffer.positions[T+5]=y,this._buffer.normals[T+3]=S*u,this._buffer.normals[T+4]=E*u,this._buffer.normals[T+5]=-d,this._buffer.uvs[O+2]=w,this._buffer.uvs[O+3]=A),this.vertexCache[n]=D,D}}const ce=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n,s,o,a;const l=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0,subdivisions:40,roundness:0,extrudeDepth:0,surfaceMaxCount:100,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters),c=Math.abs(l.width),h=Math.abs(null!==(i=l.height)&&void 0!==i?i:l.width);let u=null!==(n=e.shape)&&void 0!==n?n:null==t?void 0:t.shape;const d=null!==(s=null==u?void 0:u.roundness)&&void 0!==s?s:l.roundness;void 0!==u&&(u instanceof R?u.width===c&&u.height===h||u.applySize(c,h):u=new R(c,h).fromJSON(u),void 0!==(null===(o=e.parameters)||void 0===o?void 0:o.roundness)&&(null===(a=e.parameters)||void 0===a?void 0:a.roundness)>0&&u.update(!1));const p=null!=u?u:new R(c,h);return{parameters:Object.assign(l,{width:c,height:h,roundness:d}),shape:p}}static build(e){const{extrudeDepth:t,extrudeBevelSize:r,extrudeBevelSegments:i,subdivisions:n,roundness:s,surfaceMaxCount:o}=e.parameters;let a;return e.shape.roundness=s,a=t<=0?new se(e.shape,n,o):new le(e.shape,t,r,n,i),Object.assign(a,{userData:Object.assign(Object.assign({},e),{type:"VectorGeometry"})})}},he=2*Math.PI;function ue(e,t,r,i,n,s){const o=-t/r;for(let t=0;t<=r;t++){const r=o*t,s=Math.sin(r)*i,a=Math.cos(r)*n;e.addPoint(de(s,a))}return t<he?s>0?fe(e,i,n,s):e.addPoint(de(0,0)):(e.removePoint(e.points[e.points.length-1]),s>0&&me(e,i,n,s)),1}function de(e,r){return new u(t.MathUtils.generateUUID(),new t.Vector2(e,r))}function pe(e,t,r,i,n,s){const o=de(e,t);return o.controls[0].position.set(r,i),o.controls[1].position.set(n,s),o}function fe(e,t,r,i){ge(e,t,r,i).forEach((t=>e.addPoint(t)))}function me(e,t,r,i){const n=ge(e,t,r,i),s=new R;n.forEach((e=>s.addPoint(e))),s.isClosed=!0,e.shapeHoles.push(s)}function ge(e,r,i,n){const s=n*r/100,o=s*(Math.abs(i)/Math.abs(r)),a=new t.Vector2(s/r,o/i),l=e.points.map((e=>e.clone())).reverse();return l.forEach((e=>{e.position.multiply(a);const t=e.controls[0].position.clone().multiply(a),r=e.controls[1].position.clone().multiply(a);e.controls[0].position.copy(r),e.controls[1].position.copy(t)})),l}class ve extends t.BufferGeometry{constructor(e,r,i,n,s,o,a,l,c,h,u,d){super();const p=[],f=[],m=[],g=[],v=[],y=[],A=[],w=new t.Vector3,x=new t.Vector3,b=new t.Vector3,S=new t.Vector3;let E,C,T,O,D,M,_,N;const L=new t.Vector3,B=new t.Vector3,I=new t.Vector3,P=new t.Vector3,R=new t.Vector3,F=new t.Vector3,U=new t.Vector3,z=s-l,k=i-2*l+.001,G=k/o,j=Math.ceil(a*o),V=k/j,H=-k/2,J=2*Math.PI/h,Q=Math.PI/2/d,Y=Math.min((1-u/100)*l,l-.1),W=l-Y,X=e&&1==o;function K(t,r){const i=Math.PI/2;M=r*V,N=2*Math.PI*(M%G)/G+i,M+=H,_=Math.sin(N)*z,D=Math.cos(N)*z,e?t.set(D,_,M):t.set(D,M,_)}X&&(d=0),K(b,-1),K(S,0),L.copy(b);const q=b.distanceTo(S),Z=q*j+2*W,$=Z-W;for(let t=0;t<=j;t++){K(w,t),U.subVectors(w,L).normalize(),L.copy(w),R.copy(w).setComponent(+e+1,0).normalize(),F.crossVectors(U,R).normalize();const r=0==t?3*Math.PI/2:Q,i=0==t?0:$;for(let e=0,n=0;e<=h;e++,n=e*J){if(B.addVectors(b.copy(R).multiplyScalar(l*Math.cos(n)),S.copy(F).multiplyScalar(l*Math.sin(n))),P.copy(B).normalize(),0==t||t==j){S.copy(P).multiplyScalar(Y),x.addVectors(w,S);for(let n=0,s=r;n<d;n++,s=n*Q+r){I.addVectors(b.copy(U).multiplyScalar(W*Math.sin(s)),S.copy(P).multiplyScalar(W*Math.cos(s))),S.addVectors(x,I),I.normalize(),v.push(S.x,S.y,S.z),y.push(I.x,I.y,I.z);const r=+(0==t)+Math.sin(s);A.push((i+W*r)/Z,e/h,0)}}S.addVectors(w,B),f.push(S.x,S.y,S.z),m.push(P.x,P.y,P.z),g.push((W+t*q)/Z,e/h)}}const ee=v.length/2;for(let e=0;e<d;e++)for(let t=0;t<=h;t++){const r=ee+3*(t*d+e),i=3*((h-t)*d+d-e-1);f.push(...v.slice(r,r+3)),f.unshift(...v.slice(i,i+3)),m.push(...y.slice(r,r+3)),m.unshift(...y.slice(i,i+3)),g.push(...A.slice(r,r+2)),g.unshift(...A.slice(i,i+2))}const te=h+1;for(let e=0;e<j+2*d;e++){const t=X&&e==j-1;for(let r=0;r<te-1;r++)E=e*te+r,C=E+1,T=t?r:E+te,O=t?r+1:C+te,p.push(E,C,T,C,O,T)}if(E=f.length/3-h-1,!X)for(let e=0;e<h-2;e++)p.push(E,E+e+1,E+e+2),p.push(0,e+2,e+1);this.setIndex(p),this.setAttribute("position",new t.Float32BufferAttribute(f,3)),this.setAttribute("normal",new t.Float32BufferAttribute(m,3)),this.setAttribute("uv",new t.Float32BufferAttribute(g,2))}}const ye=new t.Matrix4,Ae=new t.Object3D,we=new t.Vector3;class xe extends t.EventDispatcher{constructor(){super(),this.uuid=t.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1}applyMatrix4(e){const r=(new t.Matrix3).getNormalMatrix(e);for(let t=0,r=this.vertices.length;t<r;t++){this.vertices[t].applyMatrix4(e)}for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e];t.normal.applyMatrix3(r).normalize();for(let e=0,i=t.vertexNormals.length;e<i;e++)t.vertexNormals[e].applyMatrix3(r).normalize()}return null!==this.boundingBox&&this.computeBoundingBox(),null!==this.boundingSphere&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this}rotateX(e){return ye.makeRotationX(e),this.applyMatrix4(ye),this}rotateY(e){return ye.makeRotationY(e),this.applyMatrix4(ye),this}rotateZ(e){return ye.makeRotationZ(e),this.applyMatrix4(ye),this}translate(e,t,r){return ye.makeTranslation(e,t,r),this.applyMatrix4(ye),this}scale(e,t,r){return ye.makeScale(e,t,r),this.applyMatrix4(ye),this}lookAt(e){return Ae.lookAt(e),Ae.updateMatrix(),this.applyMatrix4(Ae.matrix),this}fromBufferGeometry(e){const r=this,i=null!==e.index?e.index:void 0,n=e.attributes;if(void 0===n.position)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;const s=n.position,o=n.normal,a=n.color,l=n.uv,c=n.uv2;void 0!==c&&(this.faceVertexUvs[1]=[]);for(let e=0;e<s.count;e++)r.vertices.push((new t.Vector3).fromBufferAttribute(s,e)),void 0!==a&&r.colors.push((new t.Color).fromBufferAttribute(a,e));function h(e,i,n,s){const h=void 0===a?[]:[r.colors[e].clone(),r.colors[i].clone(),r.colors[n].clone()],u=void 0===o?[]:[(new t.Vector3).fromBufferAttribute(o,e),(new t.Vector3).fromBufferAttribute(o,i),(new t.Vector3).fromBufferAttribute(o,n)],d=new Se(e,i,n,u,h,s);r.faces.push(d),void 0!==l&&r.faceVertexUvs[0].push([(new t.Vector2).fromBufferAttribute(l,e),(new t.Vector2).fromBufferAttribute(l,i),(new t.Vector2).fromBufferAttribute(l,n)]),void 0!==c&&r.faceVertexUvs[1].push([(new t.Vector2).fromBufferAttribute(c,e),(new t.Vector2).fromBufferAttribute(c,i),(new t.Vector2).fromBufferAttribute(c,n)])}const u=e.groups;if(u.length>0)for(let e=0;e<u.length;e++){const t=u[e],r=t.start;for(let e=r,n=r+t.count;e<n;e+=3)void 0!==i?h(i.getX(e),i.getX(e+1),i.getX(e+2),t.materialIndex):h(e,e+1,e+2,t.materialIndex)}else if(void 0!==i)for(let e=0;e<i.count;e+=3)h(i.getX(e),i.getX(e+1),i.getX(e+2));else for(let e=0;e<s.count;e+=3)h(e,e+1,e+2);return this.computeFaceNormals(),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),this}center(){return this.computeBoundingBox(),this.boundingBox.getCenter(we).negate(),this.translate(we.x,we.y,we.z),this}normalize(){this.computeBoundingSphere();const e=this.boundingSphere.center,r=this.boundingSphere.radius,i=0===r?1:1/r,n=new t.Matrix4;return n.set(i,0,0,-i*e.x,0,i,0,-i*e.y,0,0,i,-i*e.z,0,0,0,1),this.applyMatrix4(n),this}computeFaceNormals(){const e=new t.Vector3,r=new t.Vector3;for(let t=0,i=this.faces.length;t<i;t++){const i=this.faces[t],n=this.vertices[i.a],s=this.vertices[i.b],o=this.vertices[i.c];e.subVectors(o,s),r.subVectors(n,s),e.cross(r),e.normalize(),i.normal.copy(e)}}computeVertexNormals(e=!0){const r=new Array(this.vertices.length);for(let e=0,i=this.vertices.length;e<i;e++)r[e]=new t.Vector3;if(e){const e=new t.Vector3,i=new t.Vector3;for(let t=0,n=this.faces.length;t<n;t++){const n=this.faces[t],s=this.vertices[n.a],o=this.vertices[n.b],a=this.vertices[n.c];e.subVectors(a,o),i.subVectors(s,o),e.cross(i),r[n.a].add(e),r[n.b].add(e),r[n.c].add(e)}}else{this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e];r[t.a].add(t.normal),r[t.b].add(t.normal),r[t.c].add(t.normal)}}for(let e=0,t=this.vertices.length;e<t;e++)r[e].normalize();for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e],i=t.vertexNormals;3===i.length?(i[0].copy(r[t.a]),i[1].copy(r[t.b]),i[2].copy(r[t.c])):(i[0]=r[t.a].clone(),i[1]=r[t.b].clone(),i[2]=r[t.c].clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeFlatVertexNormals(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e],r=t.vertexNormals;3===r.length?(r[0].copy(t.normal),r[1].copy(t.normal),r[2].copy(t.normal)):(r[0]=t.normal.clone(),r[1]=t.normal.clone(),r[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)}computeMorphNormals(){for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e];t.__originalFaceNormal?t.__originalFaceNormal.copy(t.normal):t.__originalFaceNormal=t.normal.clone(),t.__originalVertexNormals||(t.__originalVertexNormals=[]);for(let e=0,r=t.vertexNormals.length;e<r;e++)t.__originalVertexNormals[e]?t.__originalVertexNormals[e].copy(t.vertexNormals[e]):t.__originalVertexNormals[e]=t.vertexNormals[e].clone()}const e=new xe;e.faces=this.faces;for(let r=0,i=this.morphTargets.length;r<i;r++){if(!this.morphNormals[r]){this.morphNormals[r]={},this.morphNormals[r].faceNormals=[],this.morphNormals[r].vertexNormals=[];const e=this.morphNormals[r].faceNormals,i=this.morphNormals[r].vertexNormals;for(let r=0,n=this.faces.length;r<n;r++){const r=new t.Vector3,n={a:new t.Vector3,b:new t.Vector3,c:new t.Vector3};e.push(r),i.push(n)}}const i=this.morphNormals[r];e.vertices=this.morphTargets[r].vertices,e.computeFaceNormals(),e.computeVertexNormals();for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e],r=i.faceNormals[e],n=i.vertexNormals[e];r.copy(t.normal),n.a.copy(t.vertexNormals[0]),n.b.copy(t.vertexNormals[1]),n.c.copy(t.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e];t.normal=t.__originalFaceNormal,t.vertexNormals=t.__originalVertexNormals}}computeBoundingBox(){null===this.boundingBox&&(this.boundingBox=new t.Box3),this.boundingBox.setFromPoints(this.vertices)}computeBoundingSphere(){null===this.boundingSphere&&(this.boundingSphere=new t.Sphere),this.boundingSphere.setFromPoints(this.vertices)}merge(e,r,i=0){if(!e||!e.isGeometry)return void console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",e);let n;const s=this.vertices.length,o=this.vertices,a=e.vertices,l=this.faces,c=e.faces,h=this.colors,u=e.colors;void 0!==r&&(n=(new t.Matrix3).getNormalMatrix(r));for(let e=0,t=a.length;e<t;e++){const t=a[e].clone();void 0!==r&&t.applyMatrix4(r),o.push(t)}for(let e=0,t=u.length;e<t;e++)h.push(u[e].clone());for(let e=0,t=c.length;e<t;e++){const t=c[e];let r,o;const a=t.vertexNormals,h=t.vertexColors,u=new Se(t.a+s,t.b+s,t.c+s);u.normal.copy(t.normal),void 0!==n&&u.normal.applyMatrix3(n).normalize();for(let e=0,t=a.length;e<t;e++)r=a[e].clone(),void 0!==n&&r.applyMatrix3(n).normalize(),u.vertexNormals.push(r);u.color.copy(t.color);for(let e=0,t=h.length;e<t;e++)o=h[e],u.vertexColors.push(o.clone());u.materialIndex=t.materialIndex+i,l.push(u)}for(let t=0,r=e.faceVertexUvs.length;t<r;t++){const r=e.faceVertexUvs[t];void 0===this.faceVertexUvs[t]&&(this.faceVertexUvs[t]=[]);for(let e=0,i=r.length;e<i;e++){const i=r[e],n=[];for(let e=0,t=i.length;e<t;e++)n.push(i[e].clone());this.faceVertexUvs[t].push(n)}}}mergeMesh(e){e&&e.isMesh?(e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)):console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",e)}mergeVertices(e=4){const t={},r=[],i=[],n=Math.pow(10,e);for(let e=0,s=this.vertices.length;e<s;e++){const s=this.vertices[e],o=Math.round(s.x*n)+"_"+Math.round(s.y*n)+"_"+Math.round(s.z*n);void 0===t[o]?(t[o]=e,r.push(this.vertices[e]),i[e]=r.length-1):i[e]=i[t[o]]}const s=[];for(let e=0,t=this.faces.length;e<t;e++){const t=this.faces[e];t.a=i[t.a],t.b=i[t.b],t.c=i[t.c];const r=[t.a,t.b,t.c];for(let t=0;t<3;t++)if(r[t]===r[(t+1)%3]){s.push(e);break}}for(let e=s.length-1;e>=0;e--){const t=s[e];this.faces.splice(t,1);for(let e=0,r=this.faceVertexUvs.length;e<r;e++)this.faceVertexUvs[e].splice(t,1)}const o=this.vertices.length-r.length;return this.vertices=r,o}setFromPoints(e){this.vertices=[];for(let r=0,i=e.length;r<i;r++){const i=e[r];this.vertices.push(new t.Vector3(i.x,i.y,i.z||0))}return this}sortFacesByMaterialIndex(){const e=this.faces,t=e.length;for(let r=0;r<t;r++)e[r]._id=r;e.sort((function(e,t){return e.materialIndex-t.materialIndex}));const r=this.faceVertexUvs[0],i=this.faceVertexUvs[1];let n,s;r&&r.length===t&&(n=[]),i&&i.length===t&&(s=[]);for(let o=0;o<t;o++){const t=e[o]._id;n&&n.push(r[t]),s&&s.push(i[t])}n&&(this.faceVertexUvs[0]=n),s&&(this.faceVertexUvs[1]=s)}toJSON(){const e={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(e.uuid=this.uuid,e.type=this.type,""!==this.name&&(e.name=this.name),void 0!==this.parameters){const t=this.parameters;for(const r in t)void 0!==t[r]&&(e[r]=t[r]);return e}const t=[];for(let e=0;e<this.vertices.length;e++){const r=this.vertices[e];t.push(r.x,r.y,r.z)}const r=[],i=[],n={},s=[],o={},a=[],l={};for(let e=0;e<this.faces.length;e++){const t=this.faces[e],i=!0,n=!1,s=void 0!==this.faceVertexUvs[0][e],o=t.normal.length()>0,a=t.vertexNormals.length>0,l=1!==t.color.r||1!==t.color.g||1!==t.color.b,p=t.vertexColors.length>0;let f=0;if(f=c(f,0,0),f=c(f,1,i),f=c(f,2,n),f=c(f,3,s),f=c(f,4,o),f=c(f,5,a),f=c(f,6,l),f=c(f,7,p),r.push(f),r.push(t.a,t.b,t.c),r.push(t.materialIndex),s){const t=this.faceVertexUvs[0][e];r.push(d(t[0]),d(t[1]),d(t[2]))}if(o&&r.push(h(t.normal)),a){const e=t.vertexNormals;r.push(h(e[0]),h(e[1]),h(e[2]))}if(l&&r.push(u(t.color)),p){const e=t.vertexColors;r.push(u(e[0]),u(e[1]),u(e[2]))}}function c(e,t,r){return r?e|1<<t:e&~(1<<t)}function h(e){const t=e.x.toString()+e.y.toString()+e.z.toString();return void 0!==n[t]||(n[t]=i.length/3,i.push(e.x,e.y,e.z)),n[t]}function u(e){const t=e.r.toString()+e.g.toString()+e.b.toString();return void 0!==o[t]||(o[t]=s.length,s.push(e.getHex())),o[t]}function d(e){const t=e.x.toString()+e.y.toString();return void 0!==l[t]||(l[t]=a.length/2,a.push(e.x,e.y)),l[t]}return e.data={},e.data.vertices=t,e.data.normals=i,s.length>0&&(e.data.colors=s),a.length>0&&(e.data.uvs=[a]),e.data.faces=r,e}clone(){return(new xe).copy(this)}copy(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;const t=e.vertices;for(let e=0,r=t.length;e<r;e++)this.vertices.push(t[e].clone());const r=e.colors;for(let e=0,t=r.length;e<t;e++)this.colors.push(r[e].clone());const i=e.faces;for(let e=0,t=i.length;e<t;e++)this.faces.push(i[e].clone());for(let t=0,r=e.faceVertexUvs.length;t<r;t++){const r=e.faceVertexUvs[t];void 0===this.faceVertexUvs[t]&&(this.faceVertexUvs[t]=[]);for(let e=0,i=r.length;e<i;e++){const i=r[e],n=[];for(let e=0,t=i.length;e<t;e++){const t=i[e];n.push(t.clone())}this.faceVertexUvs[t].push(n)}}const n=e.morphTargets;for(let e=0,t=n.length;e<t;e++){const t={};if(t.name=n[e].name,void 0!==n[e].vertices){t.vertices=[];for(let r=0,i=n[e].vertices.length;r<i;r++)t.vertices.push(n[e].vertices[r].clone())}if(void 0!==n[e].normals){t.normals=[];for(let r=0,i=n[e].normals.length;r<i;r++)t.normals.push(n[e].normals[r].clone())}this.morphTargets.push(t)}const s=e.morphNormals;for(let e=0,t=s.length;e<t;e++){const t={};if(void 0!==s[e].vertexNormals){t.vertexNormals=[];for(let r=0,i=s[e].vertexNormals.length;r<i;r++){const i=s[e].vertexNormals[r],n={};n.a=i.a.clone(),n.b=i.b.clone(),n.c=i.c.clone(),t.vertexNormals.push(n)}}if(void 0!==s[e].faceNormals){t.faceNormals=[];for(let r=0,i=s[e].faceNormals.length;r<i;r++)t.faceNormals.push(s[e].faceNormals[r].clone())}this.morphNormals.push(t)}const o=e.skinWeights;for(let e=0,t=o.length;e<t;e++)this.skinWeights.push(o[e].clone());const a=e.skinIndices;for(let e=0,t=a.length;e<t;e++)this.skinIndices.push(a[e].clone());const l=e.lineDistances;for(let e=0,t=l.length;e<t;e++)this.lineDistances.push(l[e]);const c=e.boundingBox;null!==c&&(this.boundingBox=c.clone());const h=e.boundingSphere;return null!==h&&(this.boundingSphere=h.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this}toBufferGeometry(){const e=(new be).fromGeometry(this),r=new t.BufferGeometry,i=new Float32Array(3*e.vertices.length);if(r.setAttribute("position",new t.BufferAttribute(i,3).copyVector3sArray(e.vertices)),e.normals.length>0){const i=new Float32Array(3*e.normals.length);r.setAttribute("normal",new t.BufferAttribute(i,3).copyVector3sArray(e.normals))}if(e.colors.length>0){const i=new Float32Array(3*e.colors.length);r.setAttribute("color",new t.BufferAttribute(i,3).copyColorsArray(e.colors))}if(e.uvs.length>0){const i=new Float32Array(2*e.uvs.length);r.setAttribute("uv",new t.BufferAttribute(i,2).copyVector2sArray(e.uvs))}if(e.uvs2.length>0){const i=new Float32Array(2*e.uvs2.length);r.setAttribute("uv2",new t.BufferAttribute(i,2).copyVector2sArray(e.uvs2))}r.groups=e.groups;for(const i in e.morphTargets){const n=[],s=e.morphTargets[i];for(let e=0,r=s.length;e<r;e++){const r=s[e],i=new t.Float32BufferAttribute(3*r.data.length,3);i.name=r.name,n.push(i.copyVector3sArray(r.data))}r.morphAttributes[i]=n}if(e.skinIndices.length>0){const i=new t.Float32BufferAttribute(4*e.skinIndices.length,4);r.setAttribute("skinIndex",i.copyVector4sArray(e.skinIndices))}if(e.skinWeights.length>0){const i=new t.Float32BufferAttribute(4*e.skinWeights.length,4);r.setAttribute("skinWeight",i.copyVector4sArray(e.skinWeights))}return null!==e.boundingSphere&&(r.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(r.boundingBox=e.boundingBox.clone()),r}computeTangents(){console.error("THREE.Geometry: .computeTangents() has been removed.")}computeLineDistances(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")}applyMatrix(e){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(e)}dispose(){this.dispatchEvent({type:"dispose"})}static createBufferGeometryFromObject(e){let r=new t.BufferGeometry;const i=e.geometry;if(e.isPoints||e.isLine){const e=new t.Float32BufferAttribute(3*i.vertices.length,3),n=new t.Float32BufferAttribute(3*i.colors.length,3);if(r.setAttribute("position",e.copyVector3sArray(i.vertices)),r.setAttribute("color",n.copyColorsArray(i.colors)),i.lineDistances&&i.lineDistances.length===i.vertices.length){const e=new t.Float32BufferAttribute(i.lineDistances.length,1);r.setAttribute("lineDistance",e.copyArray(i.lineDistances))}null!==i.boundingSphere&&(r.boundingSphere=i.boundingSphere.clone()),null!==i.boundingBox&&(r.boundingBox=i.boundingBox.clone())}else e.isMesh&&(r=i.toBufferGeometry());return r}}xe.prototype.isGeometry=!0;class be{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){const t=[];let r,i,n;const s=e.faces;for(i=0;i<s.length;i++){const e=s[i];e.materialIndex!==n&&(n=e.materialIndex,void 0!==r&&(r.count=3*i-r.start,t.push(r)),r={start:3*i,materialIndex:n})}void 0!==r&&(r.count=3*i-r.start,t.push(r)),this.groups=t}fromGeometry(e){const r=e.faces,i=e.vertices,n=e.faceVertexUvs,s=n[0]&&n[0].length>0,o=n[1]&&n[1].length>0,a=e.morphTargets,l=a.length;let c;if(l>0){c=[];for(let e=0;e<l;e++)c[e]={name:a[e].name,data:[]};this.morphTargets.position=c}const h=e.morphNormals,u=h.length;let d;if(u>0){d=[];for(let e=0;e<u;e++)d[e]={name:h[e].name,data:[]};this.morphTargets.normal=d}const p=e.skinIndices,f=e.skinWeights,m=p.length===i.length,g=f.length===i.length;i.length>0&&0===r.length&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let e=0;e<r.length;e++){const v=r[e];this.vertices.push(i[v.a],i[v.b],i[v.c]);const y=v.vertexNormals;if(3===y.length)this.normals.push(y[0],y[1],y[2]);else{const e=v.normal;this.normals.push(e,e,e)}const A=v.vertexColors;if(3===A.length)this.colors.push(A[0],A[1],A[2]);else{const e=v.color;this.colors.push(e,e,e)}if(!0===s){const r=n[0][e];void 0!==r?this.uvs.push(r[0],r[1],r[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",e),this.uvs.push(new t.Vector2,new t.Vector2,new t.Vector2))}if(!0===o){const r=n[1][e];void 0!==r?this.uvs2.push(r[0],r[1],r[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",e),this.uvs2.push(new t.Vector2,new t.Vector2,new t.Vector2))}for(let e=0;e<l;e++){const t=a[e].vertices;c[e].data.push(t[v.a],t[v.b],t[v.c])}for(let t=0;t<u;t++){const r=h[t].vertexNormals[e];d[t].data.push(r.a,r.b,r.c)}m&&this.skinIndices.push(p[v.a],p[v.b],p[v.c]),g&&this.skinWeights.push(f[v.a],f[v.b],f[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,null!==e.boundingSphere&&(this.boundingSphere=e.boundingSphere.clone()),null!==e.boundingBox&&(this.boundingBox=e.boundingBox.clone()),this}}class Se{constructor(e,r,i,n,s,o=0){this.a=e,this.b=r,this.c=i,this.normal=n&&n.isVector3?n:new t.Vector3,this.vertexNormals=Array.isArray(n)?n:[],this.color=s&&s.isColor?s:new t.Color,this.vertexColors=Array.isArray(s)?s:[],this.materialIndex=o}clone(){return(new this.constructor).copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,r=e.vertexNormals.length;t<r;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,r=e.vertexColors.length;t<r;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}}const Ee=["a","b","c"];function Ce(e,t){switch(t){case"c":return e.c;case"b":return e.b;case"a":default:return e.a}}function Te(e,t,r){const i=Math.min(e,t)+"_"+Math.max(e,t);return r.get(i)}function Oe(e,t,r,i,n,s){const o=Math.min(e,t),a=Math.max(e,t),l=o+"_"+a;let c;if(i.has(l))c=i.get(l);else{c={a:r[o],b:r[a],newEdge:null,faces:[]},i.set(l,c)}c.faces.push(n),s[e].edges.push(c),s[t].edges.push(c)}function De(e,t,r,i,n){e.push(new Se(t,r,i,void 0,void 0,n))}function Me(e,t){return Math.abs(t-e)/2+Math.min(e,t)}function _e(e,t,r,i){e.push([t.clone(),r.clone(),i.clone()])}class Ne{constructor(e=1){this.subdivisions=e}modify(e){(e=e instanceof t.BufferGeometry?(new xe).fromBufferGeometry(e):e.clone()).mergeVertices();let r=this.subdivisions;for(;r-- >0;)this._smooth(e);return e.computeFaceNormals(),e.computeVertexNormals(),e}_smooth(e){const r=new t.Vector3;let i,n,s,o,a;const l=e.vertices,c=e.faces,h=e.faceVertexUvs[0],u=void 0!==h&&h.length>0,d=[],p=new Map;!function(e,t,r,i){let n,s,o;for(n=0,s=e.length;n<s;n++)r[n]={edges:[]};for(n=0,s=t.length;n<s;n++)o=t[n],Oe(o.a,o.b,e,i,o,r),Oe(o.b,o.c,e,i,o,r),Oe(o.c,o.a,e,i,o,r)}(l,c,d,p);const f=[];let m,g,v,y,A,w,x,b,S,E,C,T,O,D;for(const e of Array.from(p.keys())){for(g=p.get(e),v=new t.Vector3,A=3/8,w=1/8,x=g.faces.length,2!=x&&(A=.5,w=0),v.addVectors(g.a,g.b).multiplyScalar(A),r.set(0,0,0),o=0;o<x;o++){for(y=g.faces[o],a=0;a<3&&(m=l[Ce(y,Ee[a])],m===g.a||m===g.b);a++);m&&r.add(m)}r.multiplyScalar(w),v.add(r),g.newEdge=f.length,f.push(v)}const M=[];for(n=0,s=l.length;n<s;n++){for(O=l[n],T=d[n].edges,i=T.length,3==i?b=3/16:i>3&&(b=3/(8*i)),S=1-i*Number(b),E=b,i<=2&&2==i&&(S=3/4,E=1/8),D=O.clone().multiplyScalar(S),r.set(0,0,0),o=0;o<i;o++)C=T[o],m=C.a!==O?C.a:C.b,r.add(m);r.multiplyScalar(Number(E)),D.add(r),M.push(D)}const _=M.concat(f),N=M.length;let L,B,I;const P=[],R=[];let F,U,z,k;const G=new t.Vector2,j=new t.Vector2,V=new t.Vector2;for(n=0,s=c.length;n<s;n++)y=c[n],L=Number(Te(y.a,y.b,p).newEdge)+N,B=Number(Te(y.b,y.c,p).newEdge)+N,I=Number(Te(y.c,y.a,p).newEdge)+N,De(P,L,B,I,y.materialIndex),De(P,y.a,L,I,y.materialIndex),De(P,y.b,B,L,y.materialIndex),De(P,y.c,I,B,y.materialIndex),u&&(F=h[n],U=F[0],z=F[1],k=F[2],G.set(Me(U.x,z.x),Me(U.y,z.y)),j.set(Me(z.x,k.x),Me(z.y,k.y)),V.set(Me(U.x,k.x),Me(U.y,k.y)),_e(R,G,j,V),_e(R,U,G,V),_e(R,z,j,G),_e(R,k,V,j));e.vertices=_,e.faces=P,u&&(e.faceVertexUvs[0]=R)}}const Le=new t.Vector3,Be=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,r){var i,n;const s=null!==(n=null!==(i=e.geometry)&&void 0!==i?i:null==r?void 0:r.geometry)&&void 0!==n?n:(new t.BufferGeometry).copy(new t.BoxBufferGeometry(100,100,100));let o;void 0===r?(s.computeBoundingBox(),s.boundingBox.getSize(Le),o={width:Le.x,height:Le.y,depth:Le.z,subdivisions:0}):o=r.parameters;const a=Object.assign(Object.assign({},o),e.parameters);return{parameters:{width:Math.abs(a.width),height:Math.abs(a.height),depth:Math.abs(a.depth),subdivisions:Math.abs(a.subdivisions)},geometry:s}}static build(e){var r;const{width:i,height:n,depth:s,subdivisions:o}=e.parameters;let a=null!==(r=e.geometry)&&void 0!==r?r:(new t.BufferGeometry).copy(new t.BoxBufferGeometry(100,100,100));const l=a.userData.parameters;void 0===l?(a.computeBoundingBox(),a.boundingBox.getSize(Le)):Le.set(l.width,l.height,l.depth),i===Le.x&&n===Le.y&&s===Le.z||a.scale(0===Le.x?1:i/Le.x,0===Le.y?1:n/Le.y,0===Le.z?1:s/Le.z);let c=a.originalGeometry;if(o>0){if(void 0===c||(null==l?void 0:l.subdivisions)>o){void 0===c&&(c=a);a=new Ne(o).modify(c).toBufferGeometry()}}else void 0!==c&&(a=c),c=void 0;return void 0!==c&&Object.assign(a,{originalGeometry:c}),delete e.geometry,Object.assign(a,{userData:Object.assign(Object.assign({},e),{type:"NonParametricGeometry"})})}static loadFromUrl(e,r,i){new t.BufferGeometryLoader(i).load(e,(e=>{const t=this.normalizeInputs({geometry:e});e.boundingBox.getSize(Le);const i=100/Le.x;Object.assign(t.parameters,{width:100,height:Le.y*i,depth:Le.z*i}),r(this.build(t))}))}};function Ie(e,t,r){r.x=e.x*t.x,r.y=e.y,r.z=e.x*t.y}function Pe(e,t,r,i,n,s){const o=t.clone().sub(e),a=r.clone().sub(e),l=o.angleTo(a);if(o.normalize(),a.normalize(),i===n){const t=o.add(a).normalize();s.copy(e).addScaledVector(t,i/Math.sin(l/2))}else{const t=o.angleTo(a);s.copy(e),s.addScaledVector(o,n/Math.sin(t)),s.addScaledVector(a,i/Math.sin(t))}}function Re(e,t,r){const i=e.clone().sub(t),n=r.clone().sub(t);return i.projectOnVector(n),i.add(t)}class Fe extends t.BufferGeometry{constructor(e=.5,r=1,i=4,n=1,s=!1,o=0,a=4){super(),i=Math.floor(Math.max(3,i)),n=Math.floor(n),a=Math.floor(a);const l=[],c=[],h=[],u=[];let d=0;const p=r/2,f=Math.PI/i,m=e*Math.cos(Math.PI/i),g=2*Math.PI/i,v=(i-2)*Math.PI/i,y=Math.PI-v,A=new t.Vector3(0,-p,0),w=new t.Vector3(0,p,0),x=new t.Vector2(e,-p),b=new t.Vector2(m,-p),S=new t.Vector2(0,w.y).sub(b),E=new t.Vector2(0,w.y).sub(x),C=new t.Vector2(S.y,-S.x).normalize(),T=new t.Vector2(E.y,-E.x).normalize(),O=e*Math.cos(Math.PI/i)*Math.tan((Math.PI-S.angle())/2)-1e-8;let D;o=Math.min(o,O);{const e=new t.Vector3(C.x,C.y,0),r=new t.Vector3(Math.cos(g)*e.x,e.y,Math.sin(g)*e.x);D=e.angleTo(r)}const M=o/Math.tan((Math.PI-S.angle())/2),_=o/Math.tan((Math.PI-D)/2),N=new t.Vector3;if(!s){c.push(A.x,A.y,A.z),h.push(0,-1,0),u.push(0,0);const e=d++,r=[],n=x.clone(),s=M/Math.cos(Math.PI/i);n.x-=s;for(let e=0;e<i;e++){const s=e/i*Math.PI*2+f;Ie(n,new t.Vector2(Math.sin(s),Math.cos(s)),N),c.push(N.x,N.y,N.z),h.push(0,-1,0),u.push(0,0),r.push(d++)}for(let t=0;t<r.length;t++)l.push(r[t],e,r[(t+1)%r.length])}{const e=new t.Vector3,r=new t.Vector3,n=new t.Vector3,s=new t.Vector3,p=new t.Vector3,m=new t.Vector3;for(let g=0;g<i;g++){const v=g/i*Math.PI*2+f,y=(g+.5)/i*Math.PI*2+f,b=(g+1)/i*Math.PI*2+f,E=new t.Vector2(Math.sin(v),Math.cos(v)),O=new t.Vector2(Math.sin(y),Math.cos(y)),N=new t.Vector2(Math.sin(b),Math.cos(b));Ie(x,E,r),Ie(x,N,n),Ie(C,O,e),Pe(w,r,n,_,_,s),c.push(s.x,s.y,s.z),Pe(r,w,n,_,M,p),c.push(p.x,p.y,p.z),Pe(n,r,w,M,_,m),c.push(m.x,m.y,m.z),h.push(e.x,e.y,e.z),h.push(e.x,e.y,e.z),h.push(e.x,e.y,e.z),u.push(0,0),u.push(0,0),u.push(0,0);const I=d++,P=d++,R=d++;if(l.push(I,P,R),o>0){{const e=r.clone().add(n).multiplyScalar(.5),t=w.clone().sub(e).normalize(),i=A.clone().sub(e).normalize().add(t).normalize().multiplyScalar(-1);L(e,m.clone().sub(p),i,S.angle())}let f,g;{const e=new t.Vector3;Ie(T,N,e);let r=m.clone().add(s).multiplyScalar(.5);r=Re(r,n,w);const i=m.clone().sub(s);[f,g]=L(r,i,e,D,s.y)}{const e=f,r=e.clone().setY(0).normalize(),i=new t.Vector3(0,-1,0),n=r.clone().cross(i);B(e,r,i,n)}{const r=S.angle(),n=Math.PI-r,s=w.clone();s.y-=o/Math.sin(r-Math.PI/2);const p=new t.Vector3,f=[];for(let t=0;t<a;t++){const r=[],l=Math.PI/2-n*t/a,m=Math.cos(l),g=Math.sin(l);let v=y;for(let n=0;n<=t;n++){const n=Math.cos(v),a=Math.sin(v);e.x=m*a,e.y=g,e.z=m*n,p.copy(s).addScaledVector(e,o),c.push(p.x,p.y,p.z),h.push(e.x,e.y,e.z),u.push(0,0),r.push(d++),v+=2*Math.PI/t/i}f.push(r)}g.reverse(),f.push(g);const m=f.length-1;for(let e=0;e<m;e++){const t=f[e],r=f[e+1],i=t.length-1;l.push(r[1],t[0],r[0]);for(let e=1;e<=i;e++)l.push(t[e],t[e-1],r[e]),l.push(r[e+1],t[e],r[e])}}}}}function L(e,r,i,n,s){const p=-n/2,f=(Math.PI-n)/2,m=r.clone().normalize().cross(i);e.addScaledVector(i,-o/Math.sin(f));const g=new t.Vector3,v=new t.Vector3,y=d,A=[];for(let t=0;t<=a;t++){const l=p+t/a*n;v.set(0,0,0),v.addScaledVector(m,Math.sin(l)),v.addScaledVector(i,Math.cos(l));for(let t=0;t<=1;t++){const i=t/1-.5;if(g.copy(e),g.addScaledVector(r,i),g.addScaledVector(v,o),null!=s){const e=Math.max(0,g.y-s);g.addScaledVector(r,-e/r.y)}c.push(g.x,g.y,g.z),h.push(v.x,v.y,v.z),u.push(0,0),0===t&&A.push(d),d++}}for(let e=0;e<a;e++)for(let t=0;t<1;t++){const r=y+t+2*e,i=r+2,n=i+1,s=r+1;l.push(r,i,s),l.push(i,n,s)}return[e.clone().addScaledVector(r,.5),A]}function B(e,r,i,n){const s=Math.PI/2,p=E.angle()-s,f=[],m=new t.Vector3,g=new t.Vector3;for(let t=0;t<=a;t++){const l=[],v=t/a;for(let a=0;a<=t;a++){const f=((t?a/t:0)-.5)*y,A=Math.cos(f),w=Math.sin(f),x=(s+Math.atan(Math.tan(p)*A))*v,b=Math.cos(x),S=Math.sin(x);m.set(0,0,0),m.addScaledVector(r,S*A),m.addScaledVector(i,b),m.addScaledVector(n,S*w),g.copy(e).addScaledVector(m,o),c.push(g.x,g.y,g.z),h.push(m.x,m.y,m.z),u.push(0,0),l.push(d++)}f.push(l)}const v=f.length-1;for(let e=0;e<v;e++){const t=f[e],r=f[e+1],i=t.length-1;l.push(t[0],r[1],r[0]);for(let e=1;e<=i;e++)l.push(t[e-1],t[e],r[e]),l.push(t[e],r[e+1],r[e])}}this.setIndex(l),this.setAttribute("position",new t.Float32BufferAttribute(c,3)),this.setAttribute("normal",new t.Float32BufferAttribute(h,3)),this.setAttribute("uv",new t.Float32BufferAttribute(u,2))}}const Ue=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n,s;const o=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0,cornerRadius:[0,0,0,0],cornerType:1,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters),a=Object.assign(null!==(i=null==t?void 0:t.ui)&&void 0!==i?i:{enabledIndieCorners:!1},e.ui),l=o.cornerRadius.reduce(((e,t)=>e+t),0);return{shape:new R,parameters:Object.assign(o,{surfaceMaxCount:(null!==(n=o.surfaceMaxCount)&&void 0!==n?n:l>0)?1e3:100,width:Math.abs(o.width),height:Math.abs(null!==(s=o.height)&&void 0!==s?s:o.width)}),ui:a}}static build(e){const t=e.shape,{width:r,height:i,cornerRadius:n,cornerType:s,extrudeDepth:o,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=e.parameters,h={x:.5*r,y:.5*i},u={x:-h.x,y:-h.y},d={x:h.x,y:h.y};function p(e,t,n){return t>r&&n>i?Math.min(e*r/t,e*i/n):t>r?e*r/t:n>i?e*i/n:e}const f=[];f[0]=0===n[0]?0:p(n[0],n[0]+n[3],n[0]+n[1]),f[1]=0===n[1]?0:p(n[1],n[1]+n[2],n[1]+n[0]),f[2]=0===n[2]?0:p(n[2],n[2]+n[1],n[2]+n[3]),f[3]=0===n[3]?0:p(n[3],n[3]+n[0],n[3]+n[2]);const m=u.x,g=d.x,v=d.y,y=u.y;t.addPoint(t.createPoint(m,v)),t.addPoint(t.createPoint(g,v)),t.addPoint(t.createPoint(g,y)),t.addPoint(t.createPoint(m,y)),t.isClosed=!0;let A=!0;for(let e=0,r=t.points.length;e<r;e++)t.points[e].roundness=f[e],e>0&&f[e]!==f[e-1]&&(A=!1);A&&(t.roundness=f[0]),t.useCubicForRoundedCorners=1!==s,t.update();const w=ce.create({shape:t,parameters:{surfaceMaxCount:c,extrudeDepth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(w,{userData:Object.assign(Object.assign({},e),{type:"RectangleGeometry"})})}};function ze(e,...t){let r=0;for(const e of t)r+=e.length;const i=new e(r);let n=0;for(const e of t)i.set(e,n),n+=e.length;return i}class ke{static computeTangents(e){e.computeTangents(),console.warn("THREE.BufferGeometryUtils: .computeTangents() has been removed. Use BufferGeometry.computeTangents() instead.")}static mergeBufferGeometries(e,r=!1){const i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),o={},a={},l=e[0].morphTargetsRelative,c=new t.BufferGeometry;let h=0;for(let t=0;t<e.length;++t){const u=e[t];let d=0;if(i!==(null!==u.index))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+t+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in u.attributes){if(!n.has(e))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+t+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===o[e]&&(o[e]=[]),o[e].push(u.attributes[e]),d++}if(d!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+t+". Make sure all geometries have the same number of attributes."),null;if(l!==u.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+t+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in u.morphAttributes){if(!s.has(e))return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+t+". .morphAttributes must be consistent throughout all geometries."),null;void 0===a[e]&&(a[e]=[]),a[e].push(u.morphAttributes[e])}if(c.userData.mergedUserData=c.userData.mergedUserData||[],c.userData.mergedUserData.push(u.userData),r){let e;if(i)e=u.index.count;else{if(void 0===u.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed with geometry at index "+t+". The geometry must have either an index or a position attribute"),null;e=u.attributes.position.count}c.addGroup(h,e,t),h+=e}}if(i){let t=0;const r=[];for(let i=0;i<e.length;++i){const n=e[i].index;for(let e=0;e<n.count;++e)r.push(n.getX(e)+t);t+=e[i].attributes.position.count}c.setIndex(r)}for(const e in o){const t=this.mergeBufferAttributes(o[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+e+" attribute."),null;c.setAttribute(e,t)}for(const e in a){const t=a[e][0].length;if(0===t)break;c.morphAttributes=c.morphAttributes||{},c.morphAttributes[e]=[];for(let r=0;r<t;++r){const t=[];for(let i=0;i<a[e].length;++i)t.push(a[e][i][r]);const i=this.mergeBufferAttributes(t);if(!i)return console.error("THREE.BufferGeometryUtils: .mergeBufferGeometries() failed while trying to merge the "+e+" morphAttribute."),null;c.morphAttributes[e].push(i)}}return c}static mergeBufferAttributes(e){let r,i,n,s=0;for(let t=0;t<e.length;++t){const o=e[t];if(o.isInterleavedBufferAttribute)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. InterleavedBufferAttributes are not supported."),null;if(void 0===r&&(r=o.array.constructor),r!==o.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=o.itemSize),i!==o.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=o.normalized),n!==o.normalized)return console.error("THREE.BufferGeometryUtils: .mergeBufferAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;s+=o.array.length}const o=new r(s);let a=0;for(let t=0;t<e.length;++t)o.set(e[t].array,a),a+=e[t].array.length;return new t.BufferAttribute(o,i,n)}static interleaveAttributes(e){let r,i=0,n=0;for(let t=0,s=e.length;t<s;++t){const s=e[t];if(void 0===r&&(r=s.array.constructor),r!==s.array.constructor)return console.error("AttributeBuffers of different types cannot be interleaved"),null;i+=s.array.length,n+=s.itemSize}const s=new t.InterleavedBuffer(new r(i),n);let o=0;const a=[],l=["getX","getY","getZ","getW"],c=["setX","setY","setZ","setW"];for(let r=0,i=e.length;r<i;r++){const i=e[r],n=i.itemSize,h=i.count,u=new t.InterleavedBufferAttribute(s,n,o,i.normalized);a.push(u),o+=n;for(let e=0;e<h;e++)for(let t=0;t<n;t++)u[c[t]](e,i[l[t]](e))}return a}static estimateBytesUsed(e){let t=0;for(const r in e.attributes){const i=e.getAttribute(r);t+=i.count*i.itemSize*i.array.BYTES_PER_ELEMENT}const r=e.getIndex();return t+=r?r.count*r.itemSize*r.array.BYTES_PER_ELEMENT:0,t}static mergeVertices(e,r=1e-4){r=Math.max(r,Number.EPSILON);const i={},n=e.getIndex(),s=e.getAttribute("position"),o=n?n.count:s.count;let a=0;const l=Object.keys(e.attributes),c={},h={},u=[],d=["getX","getY","getZ","getW"];for(let t=0,r=l.length;t<r;t++){const r=l[t];c[r]=[];const i=e.morphAttributes[r];i&&(h[r]=new Array(i.length).fill().map((()=>[])))}const p=Math.log10(1/r),f=Math.pow(10,p);for(let t=0;t<o;t++){const r=n?n.getX(t):t;let s="";for(let t=0,i=l.length;t<i;t++){const i=l[t],n=e.getAttribute(i),o=n.itemSize;for(let e=0;e<o;e++)s+=~~(n[d[e]](r)*f)+","}if(s in i)u.push(i[s]);else{for(let t=0,i=l.length;t<i;t++){const i=l[t],n=e.getAttribute(i),s=e.morphAttributes[i],o=n.itemSize,a=c[i],u=h[i];for(let e=0;e<o;e++){const t=d[e];if(a.push(n[t](r)),s)for(let e=0,i=s.length;e<i;e++)u[e].push(s[e][t](r))}}i[s]=a,u.push(a),a++}}const m=e.clone();for(let r=0,i=l.length;r<i;r++){const i=l[r],n=e.getAttribute(i),s=new n.array.constructor(c[i]),o=new t.BufferAttribute(s,n.itemSize,n.normalized);if(m.setAttribute(i,o),i in h)for(let r=0;r<h[i].length;r++){const n=e.morphAttributes[i][r],s=new n.array.constructor(h[i][r]),o=new t.BufferAttribute(s,n.itemSize,n.normalized);m.morphAttributes[i][r]=o}}return m.setIndex(u),m}static toTrianglesDrawMode(e,r){if(r===t.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(r===t.TriangleFanDrawMode||r===t.TriangleStripDrawMode){let i=e.getIndex();if(null===i){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const n=i.count-2,s=[];if(r===t.TriangleFanDrawMode)for(let e=1;e<=n;e++)s.push(i.getX(0)),s.push(i.getX(e)),s.push(i.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(s.push(i.getX(e)),s.push(i.getX(e+1)),s.push(i.getX(e+2))):(s.push(i.getX(e+2)),s.push(i.getX(e+1)),s.push(i.getX(e)));s.length/3!==n&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(s),o.clearGroups(),o}return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",r),e}static computeMorphedAttributes(e){if(!0!==e.geometry.isBufferGeometry)return console.error("THREE.BufferGeometryUtils: Geometry is not of type BufferGeometry."),null;const r=new t.Vector3,i=new t.Vector3,n=new t.Vector3,s=new t.Vector3,o=new t.Vector3,a=new t.Vector3,l=new t.Vector3,c=new t.Vector3,h=new t.Vector3;function u(e,t,u,d,p,f,m,g,v){r.fromBufferAttribute(u,f),i.fromBufferAttribute(u,m),n.fromBufferAttribute(u,g);const y=e.morphTargetInfluences;if(t.morphTargets&&d&&y){l.set(0,0,0),c.set(0,0,0),h.set(0,0,0);for(let e=0,t=d.length;e<t;e++){const t=y[e],u=d[e];0!==t&&(s.fromBufferAttribute(u,f),o.fromBufferAttribute(u,m),a.fromBufferAttribute(u,g),p?(l.addScaledVector(s,t),c.addScaledVector(o,t),h.addScaledVector(a,t)):(l.addScaledVector(s.sub(r),t),c.addScaledVector(o.sub(i),t),h.addScaledVector(a.sub(n),t)))}r.add(l),i.add(c),n.add(h)}e.isSkinnedMesh&&(e.boneTransform(f,r),e.boneTransform(m,i),e.boneTransform(g,n)),v[3*f+0]=r.x,v[3*f+1]=r.y,v[3*f+2]=r.z,v[3*m+0]=i.x,v[3*m+1]=i.y,v[3*m+2]=i.z,v[3*g+0]=n.x,v[3*g+1]=n.y,v[3*g+2]=n.z}const d=e.geometry,p=e.material;let f,m,g;const v=d.index,y=d.attributes.position,A=d.morphAttributes.position,w=d.morphTargetsRelative,x=d.attributes.normal,b=d.morphAttributes.position,S=d.groups,E=d.drawRange;let C,T,O,D,M,_,N,L;const B=new Float32Array(y.count*y.itemSize),I=new Float32Array(x.count*x.itemSize);if(null!==v)if(Array.isArray(p))for(C=0,O=S.length;C<O;C++)for(M=S[C],_=p[M.materialIndex],N=Math.max(M.start,E.start),L=Math.min(M.start+M.count,E.start+E.count),T=N,D=L;T<D;T+=3)f=v.getX(T),m=v.getX(T+1),g=v.getX(T+2),u(e,_,y,A,w,f,m,g,B),u(e,_,x,b,w,f,m,g,I);else for(N=Math.max(0,E.start),L=Math.min(v.count,E.start+E.count),C=N,O=L;C<O;C+=3)f=v.getX(C),m=v.getX(C+1),g=v.getX(C+2),u(e,p,y,A,w,f,m,g,B),u(e,p,x,b,w,f,m,g,I);else if(void 0!==y)if(Array.isArray(p))for(C=0,O=S.length;C<O;C++)for(M=S[C],_=p[M.materialIndex],N=Math.max(M.start,E.start),L=Math.min(M.start+M.count,E.start+E.count),T=N,D=L;T<D;T+=3)f=T,m=T+1,g=T+2,u(e,_,y,A,w,f,m,g,B),u(e,_,x,b,w,f,m,g,I);else for(N=Math.max(0,E.start),L=Math.min(y.count,E.start+E.count),C=N,O=L;C<O;C+=3)f=C,m=C+1,g=C+2,u(e,p,y,A,w,f,m,g,B),u(e,p,x,b,w,f,m,g,I);return{positionAttribute:y,normalAttribute:x,morphedPositionAttribute:new t.Float32BufferAttribute(B,3),morphedNormalAttribute:new t.Float32BufferAttribute(I,3)}}}var Ge,je,Ve=(Ge="undefined"!=typeof document&&document.currentScript?document.currentScript.src:void 0,function(e){var t,r;(e=void 0!==(e=e||{})?e:{}).ready=new Promise((function(e,i){t=e,r=i}));var i,n={};for(i in e)e.hasOwnProperty(i)&&(n[i]=e[i]);var s,o="./this.program",a="";"undefined"!=typeof document&&document.currentScript&&(a=document.currentScript.src),Ge&&(a=Ge),a=0!==a.indexOf("blob:")?a.substr(0,a.lastIndexOf("/")+1):"",s=function(e){var t=new XMLHttpRequest;return t.open("GET",e,!1),t.send(null),t.responseText};var l,c,h=e.print||console.log.bind(console),u=e.printErr||console.warn.bind(console);for(i in n)n.hasOwnProperty(i)&&(e[i]=n[i]);n=null,e.arguments&&e.arguments,e.thisProgram&&(o=e.thisProgram),e.quit&&e.quit,e.wasmBinary&&(l=e.wasmBinary),e.noExitRuntime&&e.noExitRuntime,"object"!=typeof WebAssembly&&Y("no native wasm support detected");var d=!1;function p(e,t){e||Y("Assertion failed: "+t)}var f="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0;function m(e,t,r){for(var i=t+r,n=t;e[n]&&!(n>=i);)++n;if(n-t>16&&e.subarray&&f)return f.decode(e.subarray(t,n));for(var s="";t<n;){var o=e[t++];if(128&o){var a=63&e[t++];if(192!=(224&o)){var l=63&e[t++];if((o=224==(240&o)?(15&o)<<12|a<<6|l:(7&o)<<18|a<<12|l<<6|63&e[t++])<65536)s+=String.fromCharCode(o);else{var c=o-65536;s+=String.fromCharCode(55296|c>>10,56320|1023&c)}}else s+=String.fromCharCode((31&o)<<6|a)}else s+=String.fromCharCode(o)}return s}function g(e,t){return e?m(b,e,t):""}function v(e,t,r,i){if(!(i>0))return 0;for(var n=r,s=r+i-1,o=0;o<e.length;++o){var a=e.charCodeAt(o);if(a>=55296&&a<=57343&&(a=65536+((1023&a)<<10)|1023&e.charCodeAt(++o)),a<=127){if(r>=s)break;t[r++]=a}else if(a<=2047){if(r+1>=s)break;t[r++]=192|a>>6,t[r++]=128|63&a}else if(a<=65535){if(r+2>=s)break;t[r++]=224|a>>12,t[r++]=128|a>>6&63,t[r++]=128|63&a}else{if(r+3>=s)break;t[r++]=240|a>>18,t[r++]=128|a>>12&63,t[r++]=128|a>>6&63,t[r++]=128|63&a}}return t[r]=0,r-n}function y(e,t,r){return v(e,b,t,r)}function A(e){for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&(i=65536+((1023&i)<<10)|1023&e.charCodeAt(++r)),i<=127?++t:t+=i<=2047?2:i<=65535?3:4}return t}var w,x,b,S,E,C,T,O,D,M="undefined"!=typeof TextDecoder?new TextDecoder("utf-16le"):void 0;function _(e,t){for(var r=e,i=r>>1,n=i+t/2;!(i>=n)&&E[i];)++i;if((r=i<<1)-e>32&&M)return M.decode(b.subarray(e,r));for(var s="",o=0;!(o>=t/2);++o){var a=S[e+2*o>>1];if(0==a)break;s+=String.fromCharCode(a)}return s}function N(e,t,r){if(void 0===r&&(r=2147483647),r<2)return 0;for(var i=t,n=(r-=2)<2*e.length?r/2:e.length,s=0;s<n;++s){var o=e.charCodeAt(s);S[t>>1]=o,t+=2}return S[t>>1]=0,t-i}function L(e){return 2*e.length}function B(e,t){for(var r=0,i="";!(r>=t/4);){var n=C[e+4*r>>2];if(0==n)break;if(++r,n>=65536){var s=n-65536;i+=String.fromCharCode(55296|s>>10,56320|1023&s)}else i+=String.fromCharCode(n)}return i}function I(e,t,r){if(void 0===r&&(r=2147483647),r<4)return 0;for(var i=t,n=i+r-4,s=0;s<e.length;++s){var o=e.charCodeAt(s);if(o>=55296&&o<=57343&&(o=65536+((1023&o)<<10)|1023&e.charCodeAt(++s)),C[t>>2]=o,(t+=4)+4>n)break}return C[t>>2]=0,t-i}function P(e){for(var t=0,r=0;r<e.length;++r){var i=e.charCodeAt(r);i>=55296&&i<=57343&&++r,t+=4}return t}function R(e,t){x.set(e,t)}function F(t){w=t,e.HEAP8=x=new Int8Array(t),e.HEAP16=S=new Int16Array(t),e.HEAP32=C=new Int32Array(t),e.HEAPU8=b=new Uint8Array(t),e.HEAPU16=E=new Uint16Array(t),e.HEAPU32=T=new Uint32Array(t),e.HEAPF32=O=new Float32Array(t),e.HEAPF64=D=new Float64Array(t)}e.INITIAL_MEMORY;var U,z=[],k=[],G=[],j=[];k.push({func:function(){Xt()}});var V=0,H=null;function J(t){V++,e.monitorRunDependencies&&e.monitorRunDependencies(V)}function Q(t){if(V--,e.monitorRunDependencies&&e.monitorRunDependencies(V),0==V&&H){var r=H;H=null,r()}}function Y(t){e.onAbort&&e.onAbort(t),u(t+=""),d=!0,t="abort("+t+"). Build with -s ASSERTIONS=1 for more info.";var i=new WebAssembly.RuntimeError(t);throw r(i),i}function W(e){return t=e,r="data:application/octet-stream;base64,",String.prototype.startsWith?t.startsWith(r):0===t.indexOf(r);var t,r}e.preloadedImages={},e.preloadedAudios={};var X,K,q,Z="process.wasm";function $(e){try{if(e==Z&&l)return new Uint8Array(l);throw"both async and sync fetching of the wasm failed"}catch(e){Y(e)}}function ee(t){for(;t.length>0;){var r=t.shift();if("function"!=typeof r){var i=r.func;"number"==typeof i?void 0===r.arg?U.get(i)():U.get(i)(r.arg):i(void 0===r.arg?null:r.arg)}else r(e)}}W(Z)||(X=Z,Z=e.locateFile?e.locateFile(X,a):a+X);var te=0,re=4,ie=8,ne=12,se=13,oe=16;function ae(e){this.excPtr=e,this.ptr=e-oe,this.set_type=function(e){C[this.ptr+ie>>2]=e},this.get_type=function(){return C[this.ptr+ie>>2]},this.set_destructor=function(e){C[this.ptr+te>>2]=e},this.get_destructor=function(){return C[this.ptr+te>>2]},this.set_refcount=function(e){C[this.ptr+re>>2]=e},this.set_caught=function(e){e=e?1:0,x[this.ptr+ne>>0]=e},this.get_caught=function(){return 0!=x[this.ptr+ne>>0]},this.set_rethrown=function(e){e=e?1:0,x[this.ptr+se>>0]=e},this.get_rethrown=function(){return 0!=x[this.ptr+se>>0]},this.init=function(e,t){this.set_type(e),this.set_destructor(t),this.set_refcount(0),this.set_caught(!1),this.set_rethrown(!1)},this.add_ref=function(){var e=C[this.ptr+re>>2];C[this.ptr+re>>2]=e+1},this.release_ref=function(){var e=C[this.ptr+re>>2];return C[this.ptr+re>>2]=e-1,1===e}}var le={};function ce(e){for(;e.length;){var t=e.pop();e.pop()(t)}}function he(e){return this.fromWireType(T[e>>2])}var ue={},de={},pe={};function fe(e){if(void 0===e)return"_unknown";var t=(e=e.replace(/[^a-zA-Z0-9_]/g,"$")).charCodeAt(0);return t>=48&&t<=57?"_"+e:e}function me(e,t){return e=fe(e),new Function("body","return function "+e+'() {\n "use strict"; return body.apply(this, arguments);\n};\n')(t)}function ge(e,t){var r=me(t,(function(e){this.name=t,this.message=e;var r=new Error(e).stack;void 0!==r&&(this.stack=this.toString()+"\n"+r.replace(/^Error(:[^\n]*)?\n/,""))}));return r.prototype=Object.create(e.prototype),r.prototype.constructor=r,r.prototype.toString=function(){return void 0===this.message?this.name:this.name+": "+this.message},r}var ve=void 0;function ye(e){throw new ve(e)}function Ae(e,t,r){function i(t){var i=r(t);i.length!==e.length&&ye("Mismatched type converter count");for(var n=0;n<e.length;++n)Te(e[n],i[n])}e.forEach((function(e){pe[e]=t}));var n=new Array(t.length),s=[],o=0;t.forEach((function(e,t){de.hasOwnProperty(e)?n[t]=de[e]:(s.push(e),ue.hasOwnProperty(e)||(ue[e]=[]),ue[e].push((function(){n[t]=de[e],++o===s.length&&i(n)})))})),0===s.length&&i(n)}var we={};function xe(e){switch(e){case 1:return 0;case 2:return 1;case 4:return 2;case 8:return 3;default:throw new TypeError("Unknown type size: "+e)}}var be=void 0;function Se(e){for(var t="",r=e;b[r];)t+=be[b[r++]];return t}var Ee=void 0;function Ce(e){throw new Ee(e)}function Te(e,t,r){if(r=r||{},!("argPackAdvance"in t))throw new TypeError("registerType registeredInstance requires argPackAdvance");var i=t.name;if(e||Ce('type "'+i+'" must have a positive integer typeid pointer'),de.hasOwnProperty(e)){if(r.ignoreDuplicateRegistrations)return;Ce("Cannot register type '"+i+"' twice")}if(de[e]=t,delete pe[e],ue.hasOwnProperty(e)){var n=ue[e];delete ue[e],n.forEach((function(e){e()}))}}function Oe(e){if(!(this instanceof ke))return!1;if(!(e instanceof ke))return!1;for(var t=this.$$.ptrType.registeredClass,r=this.$$.ptr,i=e.$$.ptrType.registeredClass,n=e.$$.ptr;t.baseClass;)r=t.upcast(r),t=t.baseClass;for(;i.baseClass;)n=i.upcast(n),i=i.baseClass;return t===i&&r===n}function De(e){Ce(e.$$.ptrType.registeredClass.name+" instance already deleted")}var Me=!1;function _e(e){}function Ne(e){e.count.value-=1,0===e.count.value&&function(e){e.smartPtr?e.smartPtrType.rawDestructor(e.smartPtr):e.ptrType.registeredClass.rawDestructor(e.ptr)}(e)}function Le(e){return"undefined"==typeof FinalizationGroup?(Le=function(e){return e},e):(Me=new FinalizationGroup((function(e){for(var t=e.next();!t.done;t=e.next()){var r=t.value;r.ptr?Ne(r):console.warn("object already deleted: "+r.ptr)}})),_e=function(e){Me.unregister(e.$$)},(Le=function(e){return Me.register(e,e.$$,e.$$),e})(e))}function Be(){if(this.$$.ptr||De(this),this.$$.preservePointerOnDelete)return this.$$.count.value+=1,this;var e,t=Le(Object.create(Object.getPrototypeOf(this),{$$:{value:(e=this.$$,{count:e.count,deleteScheduled:e.deleteScheduled,preservePointerOnDelete:e.preservePointerOnDelete,ptr:e.ptr,ptrType:e.ptrType,smartPtr:e.smartPtr,smartPtrType:e.smartPtrType})}}));return t.$$.count.value+=1,t.$$.deleteScheduled=!1,t}function Ie(){this.$$.ptr||De(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Ce("Object already scheduled for deletion"),_e(this),Ne(this.$$),this.$$.preservePointerOnDelete||(this.$$.smartPtr=void 0,this.$$.ptr=void 0)}function Pe(){return!this.$$.ptr}var Re=void 0,Fe=[];function Ue(){for(;Fe.length;){var e=Fe.pop();e.$$.deleteScheduled=!1,e.delete()}}function ze(){return this.$$.ptr||De(this),this.$$.deleteScheduled&&!this.$$.preservePointerOnDelete&&Ce("Object already scheduled for deletion"),Fe.push(this),1===Fe.length&&Re&&Re(Ue),this.$$.deleteScheduled=!0,this}function ke(){}var je={};function Ve(e,t,r){if(void 0===e[t].overloadTable){var i=e[t];e[t]=function(){return e[t].overloadTable.hasOwnProperty(arguments.length)||Ce("Function '"+r+"' called with an invalid number of arguments ("+arguments.length+") - expects one of ("+e[t].overloadTable+")!"),e[t].overloadTable[arguments.length].apply(this,arguments)},e[t].overloadTable=[],e[t].overloadTable[i.argCount]=i}}function He(t,r,i){e.hasOwnProperty(t)?((void 0===i||void 0!==e[t].overloadTable&&void 0!==e[t].overloadTable[i])&&Ce("Cannot register public name '"+t+"' twice"),Ve(e,t,t),e.hasOwnProperty(i)&&Ce("Cannot register multiple overloads of a function with the same number of arguments ("+i+")!"),e[t].overloadTable[i]=r):(e[t]=r,void 0!==i&&(e[t].numArguments=i))}function Je(e,t,r,i,n,s,o,a){this.name=e,this.constructor=t,this.instancePrototype=r,this.rawDestructor=i,this.baseClass=n,this.getActualType=s,this.upcast=o,this.downcast=a,this.pureVirtualFunctions=[]}function Qe(e,t,r){for(;t!==r;)t.upcast||Ce("Expected null or instance of "+r.name+", got an instance of "+t.name),e=t.upcast(e),t=t.baseClass;return e}function Ye(e,t){if(null===t)return this.isReference&&Ce("null is not a valid "+this.name),0;t.$$||Ce('Cannot pass "'+Ct(t)+'" as a '+this.name),t.$$.ptr||Ce("Cannot pass deleted object as a pointer of type "+this.name);var r=t.$$.ptrType.registeredClass;return Qe(t.$$.ptr,r,this.registeredClass)}function We(e,t){var r;if(null===t)return this.isReference&&Ce("null is not a valid "+this.name),this.isSmartPointer?(r=this.rawConstructor(),null!==e&&e.push(this.rawDestructor,r),r):0;t.$$||Ce('Cannot pass "'+Ct(t)+'" as a '+this.name),t.$$.ptr||Ce("Cannot pass deleted object as a pointer of type "+this.name),!this.isConst&&t.$$.ptrType.isConst&&Ce("Cannot convert argument of type "+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+" to parameter type "+this.name);var i=t.$$.ptrType.registeredClass;if(r=Qe(t.$$.ptr,i,this.registeredClass),this.isSmartPointer)switch(void 0===t.$$.smartPtr&&Ce("Passing raw pointer to smart pointer is illegal"),this.sharingPolicy){case 0:t.$$.smartPtrType===this?r=t.$$.smartPtr:Ce("Cannot convert argument of type "+(t.$$.smartPtrType?t.$$.smartPtrType.name:t.$$.ptrType.name)+" to parameter type "+this.name);break;case 1:r=t.$$.smartPtr;break;case 2:if(t.$$.smartPtrType===this)r=t.$$.smartPtr;else{var n=t.clone();r=this.rawShare(r,bt((function(){n.delete()}))),null!==e&&e.push(this.rawDestructor,r)}break;default:Ce("Unsupporting sharing policy")}return r}function Xe(e,t){if(null===t)return this.isReference&&Ce("null is not a valid "+this.name),0;t.$$||Ce('Cannot pass "'+Ct(t)+'" as a '+this.name),t.$$.ptr||Ce("Cannot pass deleted object as a pointer of type "+this.name),t.$$.ptrType.isConst&&Ce("Cannot convert argument of type "+t.$$.ptrType.name+" to parameter type "+this.name);var r=t.$$.ptrType.registeredClass;return Qe(t.$$.ptr,r,this.registeredClass)}function Ke(e){return this.rawGetPointee&&(e=this.rawGetPointee(e)),e}function qe(e){this.rawDestructor&&this.rawDestructor(e)}function Ze(e){null!==e&&e.delete()}function $e(e,t,r){if(t===r)return e;if(void 0===r.baseClass)return null;var i=$e(e,t,r.baseClass);return null===i?null:r.downcast(i)}function et(){return Object.keys(it).length}function tt(){var e=[];for(var t in it)it.hasOwnProperty(t)&&e.push(it[t]);return e}function rt(e){Re=e,Fe.length&&Re&&Re(Ue)}var it={};function nt(e,t){return t=function(e,t){for(void 0===t&&Ce("ptr should not be undefined");e.baseClass;)t=e.upcast(t),e=e.baseClass;return t}(e,t),it[t]}function st(e,t){return t.ptrType&&t.ptr||ye("makeClassHandle requires ptr and ptrType"),!!t.smartPtrType!=!!t.smartPtr&&ye("Both smartPtrType and smartPtr must be specified"),t.count={value:1},Le(Object.create(e,{$$:{value:t}}))}function ot(e){var t=this.getPointee(e);if(!t)return this.destructor(e),null;var r=nt(this.registeredClass,t);if(void 0!==r){if(0===r.$$.count.value)return r.$$.ptr=t,r.$$.smartPtr=e,r.clone();var i=r.clone();return this.destructor(e),i}function n(){return this.isSmartPointer?st(this.registeredClass.instancePrototype,{ptrType:this.pointeeType,ptr:t,smartPtrType:this,smartPtr:e}):st(this.registeredClass.instancePrototype,{ptrType:this,ptr:e})}var s,o=this.registeredClass.getActualType(t),a=je[o];if(!a)return n.call(this);s=this.isConst?a.constPointerType:a.pointerType;var l=$e(t,this.registeredClass,s.registeredClass);return null===l?n.call(this):this.isSmartPointer?st(s.registeredClass.instancePrototype,{ptrType:s,ptr:l,smartPtrType:this,smartPtr:e}):st(s.registeredClass.instancePrototype,{ptrType:s,ptr:l})}function at(e,t,r,i,n,s,o,a,l,c,h){this.name=e,this.registeredClass=t,this.isReference=r,this.isConst=i,this.isSmartPointer=n,this.pointeeType=s,this.sharingPolicy=o,this.rawGetPointee=a,this.rawConstructor=l,this.rawShare=c,this.rawDestructor=h,n||void 0!==t.baseClass?this.toWireType=We:i?(this.toWireType=Ye,this.destructorFunction=null):(this.toWireType=Xe,this.destructorFunction=null)}function lt(t,r,i){e.hasOwnProperty(t)||ye("Replacing nonexistant public symbol"),void 0!==e[t].overloadTable&&void 0!==i?e[t].overloadTable[i]=r:(e[t]=r,e[t].argCount=i)}function ct(t,r,i){return-1!=t.indexOf("j")?function(t,r,i){var n=e["dynCall_"+t];return i&&i.length?n.apply(null,[r].concat(i)):n.call(null,r)}(t,r,i):U.get(r).apply(null,i)}function ht(e,t){var r,i,n,s=-1!=(e=Se(e)).indexOf("j")?(r=e,i=t,n=[],function(){n.length=arguments.length;for(var e=0;e<arguments.length;e++)n[e]=arguments[e];return ct(r,i,n)}):U.get(t);return"function"!=typeof s&&Ce("unknown function pointer with signature "+e+": "+t),s}var ut=void 0;function dt(e){var t=Zt(e),r=Se(t);return qt(t),r}function pt(e,t){var r=[],i={};throw t.forEach((function e(t){i[t]||de[t]||(pe[t]?pe[t].forEach(e):(r.push(t),i[t]=!0))})),new ut(e+": "+r.map(dt).join([", "]))}function ft(e,t){for(var r=[],i=0;i<e;i++)r.push(C[(t>>2)+i]);return r}function mt(e,t,r,i,n){var s=t.length;s<2&&Ce("argTypes array size mismatch! Must at least get return value and 'this' types!");for(var o=null!==t[1]&&null!==r,a=!1,l=1;l<t.length;++l)if(null!==t[l]&&void 0===t[l].destructorFunction){a=!0;break}var c="void"!==t[0].name,h="",u="";for(l=0;l<s-2;++l)h+=(0!==l?", ":"")+"arg"+l,u+=(0!==l?", ":"")+"arg"+l+"Wired";var d="return function "+fe(e)+"("+h+") {\nif (arguments.length !== "+(s-2)+") {\nthrowBindingError('function "+e+" called with ' + arguments.length + ' arguments, expected "+(s-2)+" args!');\n}\n";a&&(d+="var destructors = [];\n");var p=a?"destructors":"null",f=["throwBindingError","invoker","fn","runDestructors","retType","classParam"],m=[Ce,i,n,ce,t[0],t[1]];for(o&&(d+="var thisWired = classParam.toWireType("+p+", this);\n"),l=0;l<s-2;++l)d+="var arg"+l+"Wired = argType"+l+".toWireType("+p+", arg"+l+"); // "+t[l+2].name+"\n",f.push("argType"+l),m.push(t[l+2]);if(o&&(u="thisWired"+(u.length>0?", ":"")+u),d+=(c?"var rv = ":"")+"invoker(fn"+(u.length>0?", ":"")+u+");\n",a)d+="runDestructors(destructors);\n";else for(l=o?1:2;l<t.length;++l){var g=1===l?"thisWired":"arg"+(l-2)+"Wired";null!==t[l].destructorFunction&&(d+=g+"_dtor("+g+"); // "+t[l].name+"\n",f.push(g+"_dtor"),m.push(t[l].destructorFunction))}return c&&(d+="var ret = retType.fromWireType(rv);\nreturn ret;\n"),d+="}\n",f.push(d),function(e,t){if(!(e instanceof Function))throw new TypeError("new_ called with constructor type "+typeof e+" which is not a function");var r=me(e.name||"unknownFunctionName",(function(){}));r.prototype=e.prototype;var i=new r,n=e.apply(i,t);return n instanceof Object?n:i}(Function,f).apply(null,m)}function gt(e,t,r){return e instanceof Object||Ce(r+' with invalid "this": '+e),e instanceof t.registeredClass.constructor||Ce(r+' incompatible with "this" of type '+e.constructor.name),e.$$.ptr||Ce("cannot call emscripten binding method "+r+" on deleted object"),Qe(e.$$.ptr,e.$$.ptrType.registeredClass,t.registeredClass)}var vt=[],yt=[{},{value:void 0},{value:null},{value:!0},{value:!1}];function At(e){e>4&&0==--yt[e].refcount&&(yt[e]=void 0,vt.push(e))}function wt(){for(var e=0,t=5;t<yt.length;++t)void 0!==yt[t]&&++e;return e}function xt(){for(var e=5;e<yt.length;++e)if(void 0!==yt[e])return yt[e];return null}function bt(e){switch(e){case void 0:return 1;case null:return 2;case!0:return 3;case!1:return 4;default:var t=vt.length?vt.pop():yt.length;return yt[t]={refcount:1,value:e},t}}function St(e,t,r){switch(t){case 0:return function(e){var t=r?x:b;return this.fromWireType(t[e])};case 1:return function(e){var t=r?S:E;return this.fromWireType(t[e>>1])};case 2:return function(e){var t=r?C:T;return this.fromWireType(t[e>>2])};default:throw new TypeError("Unknown integer type: "+e)}}function Et(e,t){var r=de[e];return void 0===r&&Ce(t+" has unknown type "+dt(e)),r}function Ct(e){if(null===e)return"null";var t=typeof e;return"object"===t||"array"===t||"function"===t?e.toString():""+e}function Tt(e,t){switch(t){case 2:return function(e){return this.fromWireType(O[e>>2])};case 3:return function(e){return this.fromWireType(D[e>>3])};default:throw new TypeError("Unknown float type: "+e)}}function Ot(e,t,r){switch(t){case 0:return r?function(e){return x[e]}:function(e){return b[e]};case 1:return r?function(e){return S[e>>1]}:function(e){return E[e>>1]};case 2:return r?function(e){return C[e>>2]}:function(e){return T[e>>2]};default:throw new TypeError("Unknown integer type: "+e)}}function Dt(e){try{return c.grow(e-w.byteLength+65535>>>16),F(c.buffer),1}catch(e){}}var Mt={};function _t(){if(!_t.strings){var e={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:o||"./this.program"};for(var t in Mt)e[t]=Mt[t];var r=[];for(var t in e)r.push(t+"="+e[t]);_t.strings=r}return _t.strings}var Nt={splitPath:function(e){return/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(e).slice(1)},normalizeArray:function(e,t){for(var r=0,i=e.length-1;i>=0;i--){var n=e[i];"."===n?e.splice(i,1):".."===n?(e.splice(i,1),r++):r&&(e.splice(i,1),r--)}if(t)for(;r;r--)e.unshift("..");return e},normalize:function(e){var t="/"===e.charAt(0),r="/"===e.substr(-1);return(e=Nt.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||t||(e="."),e&&r&&(e+="/"),(t?"/":"")+e},dirname:function(e){var t=Nt.splitPath(e),r=t[0],i=t[1];return r||i?(i&&(i=i.substr(0,i.length-1)),r+i):"."},basename:function(e){if("/"===e)return"/";var t=(e=(e=Nt.normalize(e)).replace(/\/$/,"")).lastIndexOf("/");return-1===t?e:e.substr(t+1)},extname:function(e){return Nt.splitPath(e)[3]},join:function(){var e=Array.prototype.slice.call(arguments,0);return Nt.normalize(e.join("/"))},join2:function(e,t){return Nt.normalize(e+"/"+t)}},Lt={resolve:function(){for(var e="",t=!1,r=arguments.length-1;r>=-1&&!t;r--){var i=r>=0?arguments[r]:Rt.cwd();if("string"!=typeof i)throw new TypeError("Arguments to path.resolve must be strings");if(!i)return"";e=i+"/"+e,t="/"===i.charAt(0)}return(t?"/":"")+(e=Nt.normalizeArray(e.split("/").filter((function(e){return!!e})),!t).join("/"))||"."},relative:function(e,t){function r(e){for(var t=0;t<e.length&&""===e[t];t++);for(var r=e.length-1;r>=0&&""===e[r];r--);return t>r?[]:e.slice(t,r-t+1)}e=Lt.resolve(e).substr(1),t=Lt.resolve(t).substr(1);for(var i=r(e.split("/")),n=r(t.split("/")),s=Math.min(i.length,n.length),o=s,a=0;a<s;a++)if(i[a]!==n[a]){o=a;break}var l=[];for(a=o;a<i.length;a++)l.push("..");return(l=l.concat(n.slice(o))).join("/")}},Bt={ttys:[],init:function(){},shutdown:function(){},register:function(e,t){Bt.ttys[e]={input:[],output:[],ops:t},Rt.registerDevice(e,Bt.stream_ops)},stream_ops:{open:function(e){var t=Bt.ttys[e.node.rdev];if(!t)throw new Rt.ErrnoError(43);e.tty=t,e.seekable=!1},close:function(e){e.tty.ops.flush(e.tty)},flush:function(e){e.tty.ops.flush(e.tty)},read:function(e,t,r,i,n){if(!e.tty||!e.tty.ops.get_char)throw new Rt.ErrnoError(60);for(var s=0,o=0;o<i;o++){var a;try{a=e.tty.ops.get_char(e.tty)}catch(e){throw new Rt.ErrnoError(29)}if(void 0===a&&0===s)throw new Rt.ErrnoError(6);if(null==a)break;s++,t[r+o]=a}return s&&(e.node.timestamp=Date.now()),s},write:function(e,t,r,i,n){if(!e.tty||!e.tty.ops.put_char)throw new Rt.ErrnoError(60);try{for(var s=0;s<i;s++)e.tty.ops.put_char(e.tty,t[r+s])}catch(e){throw new Rt.ErrnoError(29)}return i&&(e.node.timestamp=Date.now()),s}},default_tty_ops:{get_char:function(e){if(!e.input.length){var t=null;if("undefined"!=typeof window&&"function"==typeof window.prompt?null!==(t=window.prompt("Input: "))&&(t+="\n"):"function"==typeof readline&&null!==(t=readline())&&(t+="\n"),!t)return null;e.input=Qt(t,!0)}return e.input.shift()},put_char:function(e,t){null===t||10===t?(h(m(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&e.output.length>0&&(h(m(e.output,0)),e.output=[])}},default_tty1_ops:{put_char:function(e,t){null===t||10===t?(u(m(e.output,0)),e.output=[]):0!=t&&e.output.push(t)},flush:function(e){e.output&&e.output.length>0&&(u(m(e.output,0)),e.output=[])}}};function It(e){for(var t=function(e,t){return t||(t=16),Math.ceil(e/t)*t}(e,16384),r=Kt(t);e<t;)x[r+e++]=0;return r}var Pt={ops_table:null,mount:function(e){return Pt.createNode(null,"/",16895,0)},createNode:function(e,t,r,i){if(Rt.isBlkdev(r)||Rt.isFIFO(r))throw new Rt.ErrnoError(63);Pt.ops_table||(Pt.ops_table={dir:{node:{getattr:Pt.node_ops.getattr,setattr:Pt.node_ops.setattr,lookup:Pt.node_ops.lookup,mknod:Pt.node_ops.mknod,rename:Pt.node_ops.rename,unlink:Pt.node_ops.unlink,rmdir:Pt.node_ops.rmdir,readdir:Pt.node_ops.readdir,symlink:Pt.node_ops.symlink},stream:{llseek:Pt.stream_ops.llseek}},file:{node:{getattr:Pt.node_ops.getattr,setattr:Pt.node_ops.setattr},stream:{llseek:Pt.stream_ops.llseek,read:Pt.stream_ops.read,write:Pt.stream_ops.write,allocate:Pt.stream_ops.allocate,mmap:Pt.stream_ops.mmap,msync:Pt.stream_ops.msync}},link:{node:{getattr:Pt.node_ops.getattr,setattr:Pt.node_ops.setattr,readlink:Pt.node_ops.readlink},stream:{}},chrdev:{node:{getattr:Pt.node_ops.getattr,setattr:Pt.node_ops.setattr},stream:Rt.chrdev_stream_ops}});var n=Rt.createNode(e,t,r,i);return Rt.isDir(n.mode)?(n.node_ops=Pt.ops_table.dir.node,n.stream_ops=Pt.ops_table.dir.stream,n.contents={}):Rt.isFile(n.mode)?(n.node_ops=Pt.ops_table.file.node,n.stream_ops=Pt.ops_table.file.stream,n.usedBytes=0,n.contents=null):Rt.isLink(n.mode)?(n.node_ops=Pt.ops_table.link.node,n.stream_ops=Pt.ops_table.link.stream):Rt.isChrdev(n.mode)&&(n.node_ops=Pt.ops_table.chrdev.node,n.stream_ops=Pt.ops_table.chrdev.stream),n.timestamp=Date.now(),e&&(e.contents[t]=n,e.timestamp=n.timestamp),n},getFileDataAsTypedArray:function(e){return e.contents?e.contents.subarray?e.contents.subarray(0,e.usedBytes):new Uint8Array(e.contents):new Uint8Array(0)},expandFileStorage:function(e,t){var r=e.contents?e.contents.length:0;if(!(r>=t)){t=Math.max(t,r*(r<1048576?2:1.125)>>>0),0!=r&&(t=Math.max(t,256));var i=e.contents;e.contents=new Uint8Array(t),e.usedBytes>0&&e.contents.set(i.subarray(0,e.usedBytes),0)}},resizeFileStorage:function(e,t){if(e.usedBytes!=t)if(0==t)e.contents=null,e.usedBytes=0;else{var r=e.contents;e.contents=new Uint8Array(t),r&&e.contents.set(r.subarray(0,Math.min(t,e.usedBytes))),e.usedBytes=t}},node_ops:{getattr:function(e){var t={};return t.dev=Rt.isChrdev(e.mode)?e.id:1,t.ino=e.id,t.mode=e.mode,t.nlink=1,t.uid=0,t.gid=0,t.rdev=e.rdev,Rt.isDir(e.mode)?t.size=4096:Rt.isFile(e.mode)?t.size=e.usedBytes:Rt.isLink(e.mode)?t.size=e.link.length:t.size=0,t.atime=new Date(e.timestamp),t.mtime=new Date(e.timestamp),t.ctime=new Date(e.timestamp),t.blksize=4096,t.blocks=Math.ceil(t.size/t.blksize),t},setattr:function(e,t){void 0!==t.mode&&(e.mode=t.mode),void 0!==t.timestamp&&(e.timestamp=t.timestamp),void 0!==t.size&&Pt.resizeFileStorage(e,t.size)},lookup:function(e,t){throw Rt.genericErrors[44]},mknod:function(e,t,r,i){return Pt.createNode(e,t,r,i)},rename:function(e,t,r){if(Rt.isDir(e.mode)){var i;try{i=Rt.lookupNode(t,r)}catch(e){}if(i)for(var n in i.contents)throw new Rt.ErrnoError(55)}delete e.parent.contents[e.name],e.parent.timestamp=Date.now(),e.name=r,t.contents[r]=e,t.timestamp=e.parent.timestamp,e.parent=t},unlink:function(e,t){delete e.contents[t],e.timestamp=Date.now()},rmdir:function(e,t){var r=Rt.lookupNode(e,t);for(var i in r.contents)throw new Rt.ErrnoError(55);delete e.contents[t],e.timestamp=Date.now()},readdir:function(e){var t=[".",".."];for(var r in e.contents)e.contents.hasOwnProperty(r)&&t.push(r);return t},symlink:function(e,t,r){var i=Pt.createNode(e,t,41471,0);return i.link=r,i},readlink:function(e){if(!Rt.isLink(e.mode))throw new Rt.ErrnoError(28);return e.link}},stream_ops:{read:function(e,t,r,i,n){var s=e.node.contents;if(n>=e.node.usedBytes)return 0;var o=Math.min(e.node.usedBytes-n,i);if(o>8&&s.subarray)t.set(s.subarray(n,n+o),r);else for(var a=0;a<o;a++)t[r+a]=s[n+a];return o},write:function(e,t,r,i,n,s){if(t.buffer===x.buffer&&(s=!1),!i)return 0;var o=e.node;if(o.timestamp=Date.now(),t.subarray&&(!o.contents||o.contents.subarray)){if(s)return o.contents=t.subarray(r,r+i),o.usedBytes=i,i;if(0===o.usedBytes&&0===n)return o.contents=t.slice(r,r+i),o.usedBytes=i,i;if(n+i<=o.usedBytes)return o.contents.set(t.subarray(r,r+i),n),i}if(Pt.expandFileStorage(o,n+i),o.contents.subarray&&t.subarray)o.contents.set(t.subarray(r,r+i),n);else for(var a=0;a<i;a++)o.contents[n+a]=t[r+a];return o.usedBytes=Math.max(o.usedBytes,n+i),i},llseek:function(e,t,r){var i=t;if(1===r?i+=e.position:2===r&&Rt.isFile(e.node.mode)&&(i+=e.node.usedBytes),i<0)throw new Rt.ErrnoError(28);return i},allocate:function(e,t,r){Pt.expandFileStorage(e.node,t+r),e.node.usedBytes=Math.max(e.node.usedBytes,t+r)},mmap:function(e,t,r,i,n,s){if(0!==t)throw new Rt.ErrnoError(28);if(!Rt.isFile(e.node.mode))throw new Rt.ErrnoError(43);var o,a,l=e.node.contents;if(2&s||l.buffer!==w){if((i>0||i+r<l.length)&&(l=l.subarray?l.subarray(i,i+r):Array.prototype.slice.call(l,i,i+r)),a=!0,!(o=It(r)))throw new Rt.ErrnoError(48);x.set(l,o)}else a=!1,o=l.byteOffset;return{ptr:o,allocated:a}},msync:function(e,t,r,i,n){if(!Rt.isFile(e.node.mode))throw new Rt.ErrnoError(43);return 2&n||Pt.stream_ops.write(e,t,0,i,r,!1),0}}},Rt={root:null,mounts:[],devices:{},streams:[],nextInode:1,nameTable:null,currentPath:"/",initialized:!1,ignorePermissions:!0,trackingDelegate:{},tracking:{openFlags:{READ:1,WRITE:2}},ErrnoError:null,genericErrors:{},filesystems:null,syncFSRequests:0,lookupPath:function(e,t){if(t=t||{},!(e=Lt.resolve(Rt.cwd(),e)))return{path:"",node:null};var r={follow_mount:!0,recurse_count:0};for(var i in r)void 0===t[i]&&(t[i]=r[i]);if(t.recurse_count>8)throw new Rt.ErrnoError(32);for(var n=Nt.normalizeArray(e.split("/").filter((function(e){return!!e})),!1),s=Rt.root,o="/",a=0;a<n.length;a++){var l=a===n.length-1;if(l&&t.parent)break;if(s=Rt.lookupNode(s,n[a]),o=Nt.join2(o,n[a]),Rt.isMountpoint(s)&&(!l||l&&t.follow_mount)&&(s=s.mounted.root),!l||t.follow)for(var c=0;Rt.isLink(s.mode);){var h=Rt.readlink(o);if(o=Lt.resolve(Nt.dirname(o),h),s=Rt.lookupPath(o,{recurse_count:t.recurse_count}).node,c++>40)throw new Rt.ErrnoError(32)}}return{path:o,node:s}},getPath:function(e){for(var t;;){if(Rt.isRoot(e)){var r=e.mount.mountpoint;return t?"/"!==r[r.length-1]?r+"/"+t:r+t:r}t=t?e.name+"/"+t:e.name,e=e.parent}},hashName:function(e,t){for(var r=0,i=0;i<t.length;i++)r=(r<<5)-r+t.charCodeAt(i)|0;return(e+r>>>0)%Rt.nameTable.length},hashAddNode:function(e){var t=Rt.hashName(e.parent.id,e.name);e.name_next=Rt.nameTable[t],Rt.nameTable[t]=e},hashRemoveNode:function(e){var t=Rt.hashName(e.parent.id,e.name);if(Rt.nameTable[t]===e)Rt.nameTable[t]=e.name_next;else for(var r=Rt.nameTable[t];r;){if(r.name_next===e){r.name_next=e.name_next;break}r=r.name_next}},lookupNode:function(e,t){var r=Rt.mayLookup(e);if(r)throw new Rt.ErrnoError(r,e);for(var i=Rt.hashName(e.id,t),n=Rt.nameTable[i];n;n=n.name_next){var s=n.name;if(n.parent.id===e.id&&s===t)return n}return Rt.lookup(e,t)},createNode:function(e,t,r,i){var n=new Rt.FSNode(e,t,r,i);return Rt.hashAddNode(n),n},destroyNode:function(e){Rt.hashRemoveNode(e)},isRoot:function(e){return e===e.parent},isMountpoint:function(e){return!!e.mounted},isFile:function(e){return 32768==(61440&e)},isDir:function(e){return 16384==(61440&e)},isLink:function(e){return 40960==(61440&e)},isChrdev:function(e){return 8192==(61440&e)},isBlkdev:function(e){return 24576==(61440&e)},isFIFO:function(e){return 4096==(61440&e)},isSocket:function(e){return 49152==(49152&e)},flagModes:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},modeStringToFlags:function(e){var t=Rt.flagModes[e];if(void 0===t)throw new Error("Unknown file open mode: "+e);return t},flagsToPermissionString:function(e){var t=["r","w","rw"][3&e];return 512&e&&(t+="w"),t},nodePermissions:function(e,t){return Rt.ignorePermissions||(-1===t.indexOf("r")||292&e.mode)&&(-1===t.indexOf("w")||146&e.mode)&&(-1===t.indexOf("x")||73&e.mode)?0:2},mayLookup:function(e){var t=Rt.nodePermissions(e,"x");return t||(e.node_ops.lookup?0:2)},mayCreate:function(e,t){try{return Rt.lookupNode(e,t),20}catch(e){}return Rt.nodePermissions(e,"wx")},mayDelete:function(e,t,r){var i;try{i=Rt.lookupNode(e,t)}catch(e){return e.errno}var n=Rt.nodePermissions(e,"wx");if(n)return n;if(r){if(!Rt.isDir(i.mode))return 54;if(Rt.isRoot(i)||Rt.getPath(i)===Rt.cwd())return 10}else if(Rt.isDir(i.mode))return 31;return 0},mayOpen:function(e,t){return e?Rt.isLink(e.mode)?32:Rt.isDir(e.mode)&&("r"!==Rt.flagsToPermissionString(t)||512&t)?31:Rt.nodePermissions(e,Rt.flagsToPermissionString(t)):44},MAX_OPEN_FDS:4096,nextfd:function(e,t){e=e||0,t=t||Rt.MAX_OPEN_FDS;for(var r=e;r<=t;r++)if(!Rt.streams[r])return r;throw new Rt.ErrnoError(33)},getStream:function(e){return Rt.streams[e]},createStream:function(e,t,r){Rt.FSStream||(Rt.FSStream=function(){},Rt.FSStream.prototype={object:{get:function(){return this.node},set:function(e){this.node=e}},isRead:{get:function(){return 1!=(2097155&this.flags)}},isWrite:{get:function(){return 0!=(2097155&this.flags)}},isAppend:{get:function(){return 1024&this.flags}}});var i=new Rt.FSStream;for(var n in e)i[n]=e[n];e=i;var s=Rt.nextfd(t,r);return e.fd=s,Rt.streams[s]=e,e},closeStream:function(e){Rt.streams[e]=null},chrdev_stream_ops:{open:function(e){var t=Rt.getDevice(e.node.rdev);e.stream_ops=t.stream_ops,e.stream_ops.open&&e.stream_ops.open(e)},llseek:function(){throw new Rt.ErrnoError(70)}},major:function(e){return e>>8},minor:function(e){return 255&e},makedev:function(e,t){return e<<8|t},registerDevice:function(e,t){Rt.devices[e]={stream_ops:t}},getDevice:function(e){return Rt.devices[e]},getMounts:function(e){for(var t=[],r=[e];r.length;){var i=r.pop();t.push(i),r.push.apply(r,i.mounts)}return t},syncfs:function(e,t){"function"==typeof e&&(t=e,e=!1),Rt.syncFSRequests++,Rt.syncFSRequests>1&&u("warning: "+Rt.syncFSRequests+" FS.syncfs operations in flight at once, probably just doing extra work");var r=Rt.getMounts(Rt.root.mount),i=0;function n(e){return Rt.syncFSRequests--,t(e)}function s(e){if(e)return s.errored?void 0:(s.errored=!0,n(e));++i>=r.length&&n(null)}r.forEach((function(t){if(!t.type.syncfs)return s(null);t.type.syncfs(t,e,s)}))},mount:function(e,t,r){var i,n="/"===r,s=!r;if(n&&Rt.root)throw new Rt.ErrnoError(10);if(!n&&!s){var o=Rt.lookupPath(r,{follow_mount:!1});if(r=o.path,i=o.node,Rt.isMountpoint(i))throw new Rt.ErrnoError(10);if(!Rt.isDir(i.mode))throw new Rt.ErrnoError(54)}var a={type:e,opts:t,mountpoint:r,mounts:[]},l=e.mount(a);return l.mount=a,a.root=l,n?Rt.root=l:i&&(i.mounted=a,i.mount&&i.mount.mounts.push(a)),l},unmount:function(e){var t=Rt.lookupPath(e,{follow_mount:!1});if(!Rt.isMountpoint(t.node))throw new Rt.ErrnoError(28);var r=t.node,i=r.mounted,n=Rt.getMounts(i);Object.keys(Rt.nameTable).forEach((function(e){for(var t=Rt.nameTable[e];t;){var r=t.name_next;-1!==n.indexOf(t.mount)&&Rt.destroyNode(t),t=r}})),r.mounted=null;var s=r.mount.mounts.indexOf(i);r.mount.mounts.splice(s,1)},lookup:function(e,t){return e.node_ops.lookup(e,t)},mknod:function(e,t,r){var i=Rt.lookupPath(e,{parent:!0}).node,n=Nt.basename(e);if(!n||"."===n||".."===n)throw new Rt.ErrnoError(28);var s=Rt.mayCreate(i,n);if(s)throw new Rt.ErrnoError(s);if(!i.node_ops.mknod)throw new Rt.ErrnoError(63);return i.node_ops.mknod(i,n,t,r)},create:function(e,t){return t=void 0!==t?t:438,t&=4095,t|=32768,Rt.mknod(e,t,0)},mkdir:function(e,t){return t=void 0!==t?t:511,t&=1023,t|=16384,Rt.mknod(e,t,0)},mkdirTree:function(e,t){for(var r=e.split("/"),i="",n=0;n<r.length;++n)if(r[n]){i+="/"+r[n];try{Rt.mkdir(i,t)}catch(e){if(20!=e.errno)throw e}}},mkdev:function(e,t,r){return void 0===r&&(r=t,t=438),t|=8192,Rt.mknod(e,t,r)},symlink:function(e,t){if(!Lt.resolve(e))throw new Rt.ErrnoError(44);var r=Rt.lookupPath(t,{parent:!0}).node;if(!r)throw new Rt.ErrnoError(44);var i=Nt.basename(t),n=Rt.mayCreate(r,i);if(n)throw new Rt.ErrnoError(n);if(!r.node_ops.symlink)throw new Rt.ErrnoError(63);return r.node_ops.symlink(r,i,e)},rename:function(e,t){var r,i,n=Nt.dirname(e),s=Nt.dirname(t),o=Nt.basename(e),a=Nt.basename(t);if(r=Rt.lookupPath(e,{parent:!0}).node,i=Rt.lookupPath(t,{parent:!0}).node,!r||!i)throw new Rt.ErrnoError(44);if(r.mount!==i.mount)throw new Rt.ErrnoError(75);var l,c=Rt.lookupNode(r,o),h=Lt.relative(e,s);if("."!==h.charAt(0))throw new Rt.ErrnoError(28);if("."!==(h=Lt.relative(t,n)).charAt(0))throw new Rt.ErrnoError(55);try{l=Rt.lookupNode(i,a)}catch(e){}if(c!==l){var d=Rt.isDir(c.mode),p=Rt.mayDelete(r,o,d);if(p)throw new Rt.ErrnoError(p);if(p=l?Rt.mayDelete(i,a,d):Rt.mayCreate(i,a))throw new Rt.ErrnoError(p);if(!r.node_ops.rename)throw new Rt.ErrnoError(63);if(Rt.isMountpoint(c)||l&&Rt.isMountpoint(l))throw new Rt.ErrnoError(10);if(i!==r&&(p=Rt.nodePermissions(r,"w")))throw new Rt.ErrnoError(p);try{Rt.trackingDelegate.willMovePath&&Rt.trackingDelegate.willMovePath(e,t)}catch(r){u("FS.trackingDelegate['willMovePath']('"+e+"', '"+t+"') threw an exception: "+r.message)}Rt.hashRemoveNode(c);try{r.node_ops.rename(c,i,a)}catch(e){throw e}finally{Rt.hashAddNode(c)}try{Rt.trackingDelegate.onMovePath&&Rt.trackingDelegate.onMovePath(e,t)}catch(r){u("FS.trackingDelegate['onMovePath']('"+e+"', '"+t+"') threw an exception: "+r.message)}}},rmdir:function(e){var t=Rt.lookupPath(e,{parent:!0}).node,r=Nt.basename(e),i=Rt.lookupNode(t,r),n=Rt.mayDelete(t,r,!0);if(n)throw new Rt.ErrnoError(n);if(!t.node_ops.rmdir)throw new Rt.ErrnoError(63);if(Rt.isMountpoint(i))throw new Rt.ErrnoError(10);try{Rt.trackingDelegate.willDeletePath&&Rt.trackingDelegate.willDeletePath(e)}catch(t){u("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+t.message)}t.node_ops.rmdir(t,r),Rt.destroyNode(i);try{Rt.trackingDelegate.onDeletePath&&Rt.trackingDelegate.onDeletePath(e)}catch(t){u("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+t.message)}},readdir:function(e){var t=Rt.lookupPath(e,{follow:!0}).node;if(!t.node_ops.readdir)throw new Rt.ErrnoError(54);return t.node_ops.readdir(t)},unlink:function(e){var t=Rt.lookupPath(e,{parent:!0}).node,r=Nt.basename(e),i=Rt.lookupNode(t,r),n=Rt.mayDelete(t,r,!1);if(n)throw new Rt.ErrnoError(n);if(!t.node_ops.unlink)throw new Rt.ErrnoError(63);if(Rt.isMountpoint(i))throw new Rt.ErrnoError(10);try{Rt.trackingDelegate.willDeletePath&&Rt.trackingDelegate.willDeletePath(e)}catch(t){u("FS.trackingDelegate['willDeletePath']('"+e+"') threw an exception: "+t.message)}t.node_ops.unlink(t,r),Rt.destroyNode(i);try{Rt.trackingDelegate.onDeletePath&&Rt.trackingDelegate.onDeletePath(e)}catch(t){u("FS.trackingDelegate['onDeletePath']('"+e+"') threw an exception: "+t.message)}},readlink:function(e){var t=Rt.lookupPath(e).node;if(!t)throw new Rt.ErrnoError(44);if(!t.node_ops.readlink)throw new Rt.ErrnoError(28);return Lt.resolve(Rt.getPath(t.parent),t.node_ops.readlink(t))},stat:function(e,t){var r=Rt.lookupPath(e,{follow:!t}).node;if(!r)throw new Rt.ErrnoError(44);if(!r.node_ops.getattr)throw new Rt.ErrnoError(63);return r.node_ops.getattr(r)},lstat:function(e){return Rt.stat(e,!0)},chmod:function(e,t,r){var i;if(!(i="string"==typeof e?Rt.lookupPath(e,{follow:!r}).node:e).node_ops.setattr)throw new Rt.ErrnoError(63);i.node_ops.setattr(i,{mode:4095&t|-4096&i.mode,timestamp:Date.now()})},lchmod:function(e,t){Rt.chmod(e,t,!0)},fchmod:function(e,t){var r=Rt.getStream(e);if(!r)throw new Rt.ErrnoError(8);Rt.chmod(r.node,t)},chown:function(e,t,r,i){var n;if(!(n="string"==typeof e?Rt.lookupPath(e,{follow:!i}).node:e).node_ops.setattr)throw new Rt.ErrnoError(63);n.node_ops.setattr(n,{timestamp:Date.now()})},lchown:function(e,t,r){Rt.chown(e,t,r,!0)},fchown:function(e,t,r){var i=Rt.getStream(e);if(!i)throw new Rt.ErrnoError(8);Rt.chown(i.node,t,r)},truncate:function(e,t){if(t<0)throw new Rt.ErrnoError(28);var r;if(!(r="string"==typeof e?Rt.lookupPath(e,{follow:!0}).node:e).node_ops.setattr)throw new Rt.ErrnoError(63);if(Rt.isDir(r.mode))throw new Rt.ErrnoError(31);if(!Rt.isFile(r.mode))throw new Rt.ErrnoError(28);var i=Rt.nodePermissions(r,"w");if(i)throw new Rt.ErrnoError(i);r.node_ops.setattr(r,{size:t,timestamp:Date.now()})},ftruncate:function(e,t){var r=Rt.getStream(e);if(!r)throw new Rt.ErrnoError(8);if(0==(2097155&r.flags))throw new Rt.ErrnoError(28);Rt.truncate(r.node,t)},utime:function(e,t,r){var i=Rt.lookupPath(e,{follow:!0}).node;i.node_ops.setattr(i,{timestamp:Math.max(t,r)})},open:function(t,r,i,n,s){if(""===t)throw new Rt.ErrnoError(44);var o;if(i=void 0===i?438:i,i=64&(r="string"==typeof r?Rt.modeStringToFlags(r):r)?4095&i|32768:0,"object"==typeof t)o=t;else{t=Nt.normalize(t);try{o=Rt.lookupPath(t,{follow:!(131072&r)}).node}catch(e){}}var a=!1;if(64&r)if(o){if(128&r)throw new Rt.ErrnoError(20)}else o=Rt.mknod(t,i,0),a=!0;if(!o)throw new Rt.ErrnoError(44);if(Rt.isChrdev(o.mode)&&(r&=-513),65536&r&&!Rt.isDir(o.mode))throw new Rt.ErrnoError(54);if(!a){var l=Rt.mayOpen(o,r);if(l)throw new Rt.ErrnoError(l)}512&r&&Rt.truncate(o,0),r&=-131713;var c=Rt.createStream({node:o,path:Rt.getPath(o),flags:r,seekable:!0,position:0,stream_ops:o.stream_ops,ungotten:[],error:!1},n,s);c.stream_ops.open&&c.stream_ops.open(c),!e.logReadFiles||1&r||(Rt.readFiles||(Rt.readFiles={}),t in Rt.readFiles||(Rt.readFiles[t]=1,u("FS.trackingDelegate error on read file: "+t)));try{if(Rt.trackingDelegate.onOpenFile){var h=0;1!=(2097155&r)&&(h|=Rt.tracking.openFlags.READ),0!=(2097155&r)&&(h|=Rt.tracking.openFlags.WRITE),Rt.trackingDelegate.onOpenFile(t,h)}}catch(e){u("FS.trackingDelegate['onOpenFile']('"+t+"', flags) threw an exception: "+e.message)}return c},close:function(e){if(Rt.isClosed(e))throw new Rt.ErrnoError(8);e.getdents&&(e.getdents=null);try{e.stream_ops.close&&e.stream_ops.close(e)}catch(e){throw e}finally{Rt.closeStream(e.fd)}e.fd=null},isClosed:function(e){return null===e.fd},llseek:function(e,t,r){if(Rt.isClosed(e))throw new Rt.ErrnoError(8);if(!e.seekable||!e.stream_ops.llseek)throw new Rt.ErrnoError(70);if(0!=r&&1!=r&&2!=r)throw new Rt.ErrnoError(28);return e.position=e.stream_ops.llseek(e,t,r),e.ungotten=[],e.position},read:function(e,t,r,i,n){if(i<0||n<0)throw new Rt.ErrnoError(28);if(Rt.isClosed(e))throw new Rt.ErrnoError(8);if(1==(2097155&e.flags))throw new Rt.ErrnoError(8);if(Rt.isDir(e.node.mode))throw new Rt.ErrnoError(31);if(!e.stream_ops.read)throw new Rt.ErrnoError(28);var s=void 0!==n;if(s){if(!e.seekable)throw new Rt.ErrnoError(70)}else n=e.position;var o=e.stream_ops.read(e,t,r,i,n);return s||(e.position+=o),o},write:function(e,t,r,i,n,s){if(i<0||n<0)throw new Rt.ErrnoError(28);if(Rt.isClosed(e))throw new Rt.ErrnoError(8);if(0==(2097155&e.flags))throw new Rt.ErrnoError(8);if(Rt.isDir(e.node.mode))throw new Rt.ErrnoError(31);if(!e.stream_ops.write)throw new Rt.ErrnoError(28);e.seekable&&1024&e.flags&&Rt.llseek(e,0,2);var o=void 0!==n;if(o){if(!e.seekable)throw new Rt.ErrnoError(70)}else n=e.position;var a=e.stream_ops.write(e,t,r,i,n,s);o||(e.position+=a);try{e.path&&Rt.trackingDelegate.onWriteToFile&&Rt.trackingDelegate.onWriteToFile(e.path)}catch(t){u("FS.trackingDelegate['onWriteToFile']('"+e.path+"') threw an exception: "+t.message)}return a},allocate:function(e,t,r){if(Rt.isClosed(e))throw new Rt.ErrnoError(8);if(t<0||r<=0)throw new Rt.ErrnoError(28);if(0==(2097155&e.flags))throw new Rt.ErrnoError(8);if(!Rt.isFile(e.node.mode)&&!Rt.isDir(e.node.mode))throw new Rt.ErrnoError(43);if(!e.stream_ops.allocate)throw new Rt.ErrnoError(138);e.stream_ops.allocate(e,t,r)},mmap:function(e,t,r,i,n,s){if(0!=(2&n)&&0==(2&s)&&2!=(2097155&e.flags))throw new Rt.ErrnoError(2);if(1==(2097155&e.flags))throw new Rt.ErrnoError(2);if(!e.stream_ops.mmap)throw new Rt.ErrnoError(43);return e.stream_ops.mmap(e,t,r,i,n,s)},msync:function(e,t,r,i,n){return e&&e.stream_ops.msync?e.stream_ops.msync(e,t,r,i,n):0},munmap:function(e){return 0},ioctl:function(e,t,r){if(!e.stream_ops.ioctl)throw new Rt.ErrnoError(59);return e.stream_ops.ioctl(e,t,r)},readFile:function(e,t){if((t=t||{}).flags=t.flags||0,t.encoding=t.encoding||"binary","utf8"!==t.encoding&&"binary"!==t.encoding)throw new Error('Invalid encoding type "'+t.encoding+'"');var r,i=Rt.open(e,t.flags),n=Rt.stat(e).size,s=new Uint8Array(n);return Rt.read(i,s,0,n,0),"utf8"===t.encoding?r=m(s,0):"binary"===t.encoding&&(r=s),Rt.close(i),r},writeFile:function(e,t,r){(r=r||{}).flags=r.flags||577;var i=Rt.open(e,r.flags,r.mode);if("string"==typeof t){var n=new Uint8Array(A(t)+1),s=v(t,n,0,n.length);Rt.write(i,n,0,s,void 0,r.canOwn)}else{if(!ArrayBuffer.isView(t))throw new Error("Unsupported data type");Rt.write(i,t,0,t.byteLength,void 0,r.canOwn)}Rt.close(i)},cwd:function(){return Rt.currentPath},chdir:function(e){var t=Rt.lookupPath(e,{follow:!0});if(null===t.node)throw new Rt.ErrnoError(44);if(!Rt.isDir(t.node.mode))throw new Rt.ErrnoError(54);var r=Rt.nodePermissions(t.node,"x");if(r)throw new Rt.ErrnoError(r);Rt.currentPath=t.path},createDefaultDirectories:function(){Rt.mkdir("/tmp"),Rt.mkdir("/home"),Rt.mkdir("/home/web_user")},createDefaultDevices:function(){Rt.mkdir("/dev"),Rt.registerDevice(Rt.makedev(1,3),{read:function(){return 0},write:function(e,t,r,i,n){return i}}),Rt.mkdev("/dev/null",Rt.makedev(1,3)),Bt.register(Rt.makedev(5,0),Bt.default_tty_ops),Bt.register(Rt.makedev(6,0),Bt.default_tty1_ops),Rt.mkdev("/dev/tty",Rt.makedev(5,0)),Rt.mkdev("/dev/tty1",Rt.makedev(6,0));var e=function(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var e=new Uint8Array(1);return function(){return crypto.getRandomValues(e),e[0]}}return function(){Y("randomDevice")}}();Rt.createDevice("/dev","random",e),Rt.createDevice("/dev","urandom",e),Rt.mkdir("/dev/shm"),Rt.mkdir("/dev/shm/tmp")},createSpecialDirectories:function(){Rt.mkdir("/proc");var e=Rt.mkdir("/proc/self");Rt.mkdir("/proc/self/fd"),Rt.mount({mount:function(){var t=Rt.createNode(e,"fd",16895,73);return t.node_ops={lookup:function(e,t){var r=+t,i=Rt.getStream(r);if(!i)throw new Rt.ErrnoError(8);var n={parent:null,mount:{mountpoint:"fake"},node_ops:{readlink:function(){return i.path}}};return n.parent=n,n}},t}},{},"/proc/self/fd")},createStandardStreams:function(){e.stdin?Rt.createDevice("/dev","stdin",e.stdin):Rt.symlink("/dev/tty","/dev/stdin"),e.stdout?Rt.createDevice("/dev","stdout",null,e.stdout):Rt.symlink("/dev/tty","/dev/stdout"),e.stderr?Rt.createDevice("/dev","stderr",null,e.stderr):Rt.symlink("/dev/tty1","/dev/stderr"),Rt.open("/dev/stdin",0),Rt.open("/dev/stdout",1),Rt.open("/dev/stderr",1)},ensureErrnoError:function(){Rt.ErrnoError||(Rt.ErrnoError=function(e,t){this.node=t,this.setErrno=function(e){this.errno=e},this.setErrno(e),this.message="FS error"},Rt.ErrnoError.prototype=new Error,Rt.ErrnoError.prototype.constructor=Rt.ErrnoError,[44].forEach((function(e){Rt.genericErrors[e]=new Rt.ErrnoError(e),Rt.genericErrors[e].stack="<generic error, no stack>"})))},staticInit:function(){Rt.ensureErrnoError(),Rt.nameTable=new Array(4096),Rt.mount(Pt,{},"/"),Rt.createDefaultDirectories(),Rt.createDefaultDevices(),Rt.createSpecialDirectories(),Rt.filesystems={MEMFS:Pt}},init:function(t,r,i){Rt.init.initialized=!0,Rt.ensureErrnoError(),e.stdin=t||e.stdin,e.stdout=r||e.stdout,e.stderr=i||e.stderr,Rt.createStandardStreams()},quit:function(){Rt.init.initialized=!1;var t=e._fflush;t&&t(0);for(var r=0;r<Rt.streams.length;r++){var i=Rt.streams[r];i&&Rt.close(i)}},getMode:function(e,t){var r=0;return e&&(r|=365),t&&(r|=146),r},findObject:function(e,t){var r=Rt.analyzePath(e,t);return r.exists?r.object:null},analyzePath:function(e,t){try{e=(i=Rt.lookupPath(e,{follow:!t})).path}catch(e){}var r={isRoot:!1,exists:!1,error:0,name:null,path:null,object:null,parentExists:!1,parentPath:null,parentObject:null};try{var i=Rt.lookupPath(e,{parent:!0});r.parentExists=!0,r.parentPath=i.path,r.parentObject=i.node,r.name=Nt.basename(e),i=Rt.lookupPath(e,{follow:!t}),r.exists=!0,r.path=i.path,r.object=i.node,r.name=i.node.name,r.isRoot="/"===i.path}catch(e){r.error=e.errno}return r},createPath:function(e,t,r,i){e="string"==typeof e?e:Rt.getPath(e);for(var n=t.split("/").reverse();n.length;){var s=n.pop();if(s){var o=Nt.join2(e,s);try{Rt.mkdir(o)}catch(e){}e=o}}return o},createFile:function(e,t,r,i,n){var s=Nt.join2("string"==typeof e?e:Rt.getPath(e),t),o=Rt.getMode(i,n);return Rt.create(s,o)},createDataFile:function(e,t,r,i,n,s){var o=t?Nt.join2("string"==typeof e?e:Rt.getPath(e),t):e,a=Rt.getMode(i,n),l=Rt.create(o,a);if(r){if("string"==typeof r){for(var c=new Array(r.length),h=0,u=r.length;h<u;++h)c[h]=r.charCodeAt(h);r=c}Rt.chmod(l,146|a);var d=Rt.open(l,577);Rt.write(d,r,0,r.length,0,s),Rt.close(d),Rt.chmod(l,a)}return l},createDevice:function(e,t,r,i){var n=Nt.join2("string"==typeof e?e:Rt.getPath(e),t),s=Rt.getMode(!!r,!!i);Rt.createDevice.major||(Rt.createDevice.major=64);var o=Rt.makedev(Rt.createDevice.major++,0);return Rt.registerDevice(o,{open:function(e){e.seekable=!1},close:function(e){i&&i.buffer&&i.buffer.length&&i(10)},read:function(e,t,i,n,s){for(var o=0,a=0;a<n;a++){var l;try{l=r()}catch(e){throw new Rt.ErrnoError(29)}if(void 0===l&&0===o)throw new Rt.ErrnoError(6);if(null==l)break;o++,t[i+a]=l}return o&&(e.node.timestamp=Date.now()),o},write:function(e,t,r,n,s){for(var o=0;o<n;o++)try{i(t[r+o])}catch(e){throw new Rt.ErrnoError(29)}return n&&(e.node.timestamp=Date.now()),o}}),Rt.mkdev(n,s,o)},forceLoadFile:function(e){if(e.isDevice||e.isFolder||e.link||e.contents)return!0;if("undefined"!=typeof XMLHttpRequest)throw new Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread.");if(!s)throw new Error("Cannot load without read() or XMLHttpRequest.");try{e.contents=Qt(s(e.url),!0),e.usedBytes=e.contents.length}catch(e){throw new Rt.ErrnoError(29)}},createLazyFile:function(e,t,r,i,n){function s(){this.lengthKnown=!1,this.chunks=[]}if(s.prototype.get=function(e){if(!(e>this.length-1||e<0)){var t=e%this.chunkSize,r=e/this.chunkSize|0;return this.getter(r)[t]}},s.prototype.setDataGetter=function(e){this.getter=e},s.prototype.cacheLength=function(){var e=new XMLHttpRequest;if(e.open("HEAD",r,!1),e.send(null),!(e.status>=200&&e.status<300||304===e.status))throw new Error("Couldn't load "+r+". Status: "+e.status);var t,i=Number(e.getResponseHeader("Content-length")),n=(t=e.getResponseHeader("Accept-Ranges"))&&"bytes"===t,s=(t=e.getResponseHeader("Content-Encoding"))&&"gzip"===t,o=1048576;n||(o=i);var a=this;a.setDataGetter((function(e){var t=e*o,n=(e+1)*o-1;if(n=Math.min(n,i-1),void 0===a.chunks[e]&&(a.chunks[e]=function(e,t){if(e>t)throw new Error("invalid range ("+e+", "+t+") or no bytes requested!");if(t>i-1)throw new Error("only "+i+" bytes available! programmer error!");var n=new XMLHttpRequest;if(n.open("GET",r,!1),i!==o&&n.setRequestHeader("Range","bytes="+e+"-"+t),"undefined"!=typeof Uint8Array&&(n.responseType="arraybuffer"),n.overrideMimeType&&n.overrideMimeType("text/plain; charset=x-user-defined"),n.send(null),!(n.status>=200&&n.status<300||304===n.status))throw new Error("Couldn't load "+r+". Status: "+n.status);return void 0!==n.response?new Uint8Array(n.response||[]):Qt(n.responseText||"",!0)}(t,n)),void 0===a.chunks[e])throw new Error("doXHR failed!");return a.chunks[e]})),!s&&i||(o=i=1,i=this.getter(0).length,o=i,h("LazyFiles on gzip forces download of the whole file when length is accessed")),this._length=i,this._chunkSize=o,this.lengthKnown=!0},"undefined"!=typeof XMLHttpRequest)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var o={isDevice:!1,url:r},a=Rt.createFile(e,t,o,i,n);o.contents?a.contents=o.contents:o.url&&(a.contents=null,a.url=o.url),Object.defineProperties(a,{usedBytes:{get:function(){return this.contents.length}}});var l={};return Object.keys(a.stream_ops).forEach((function(e){var t=a.stream_ops[e];l[e]=function(){return Rt.forceLoadFile(a),t.apply(null,arguments)}})),l.read=function(e,t,r,i,n){Rt.forceLoadFile(a);var s=e.node.contents;if(n>=s.length)return 0;var o=Math.min(s.length-n,i);if(s.slice)for(var l=0;l<o;l++)t[r+l]=s[n+l];else for(l=0;l<o;l++)t[r+l]=s.get(n+l);return o},a.stream_ops=l,a},createPreloadedFile:function(t,r,i,n,s,o,a,l,c,h){Browser.init();var u=r?Lt.resolve(Nt.join2(t,r)):t;function d(i){function d(e){h&&h(),l||Rt.createDataFile(t,r,e,n,s,c),o&&o(),Q()}var p=!1;e.preloadPlugins.forEach((function(e){p||e.canHandle(u)&&(e.handle(i,u,d,(function(){a&&a(),Q()})),p=!0)})),p||d(i)}J(),"string"==typeof i?Browser.asyncLoad(i,(function(e){d(e)}),a):d(i)},indexedDB:function(){return window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB},DB_NAME:function(){return"EM_FS_"+window.location.pathname},DB_VERSION:20,DB_STORE_NAME:"FILE_DATA",saveFilesToDB:function(e,t,r){t=t||function(){},r=r||function(){};var i=Rt.indexedDB();try{var n=i.open(Rt.DB_NAME(),Rt.DB_VERSION)}catch(e){return r(e)}n.onupgradeneeded=function(){h("creating db"),n.result.createObjectStore(Rt.DB_STORE_NAME)},n.onsuccess=function(){var i=n.result.transaction([Rt.DB_STORE_NAME],"readwrite"),s=i.objectStore(Rt.DB_STORE_NAME),o=0,a=0,l=e.length;function c(){0==a?t():r()}e.forEach((function(e){var t=s.put(Rt.analyzePath(e).object.contents,e);t.onsuccess=function(){++o+a==l&&c()},t.onerror=function(){a++,o+a==l&&c()}})),i.onerror=r},n.onerror=r},loadFilesFromDB:function(e,t,r){t=t||function(){},r=r||function(){};var i=Rt.indexedDB();try{var n=i.open(Rt.DB_NAME(),Rt.DB_VERSION)}catch(e){return r(e)}n.onupgradeneeded=r,n.onsuccess=function(){var i=n.result;try{var s=i.transaction([Rt.DB_STORE_NAME],"readonly")}catch(e){return void r(e)}var o=s.objectStore(Rt.DB_STORE_NAME),a=0,l=0,c=e.length;function h(){0==l?t():r()}e.forEach((function(e){var t=o.get(e);t.onsuccess=function(){Rt.analyzePath(e).exists&&Rt.unlink(e),Rt.createDataFile(Nt.dirname(e),Nt.basename(e),t.result,!0,!0,!0),++a+l==c&&h()},t.onerror=function(){l++,a+l==c&&h()}})),s.onerror=r},n.onerror=r}},Ft={mappings:{},DEFAULT_POLLMASK:5,umask:511,calculateAt:function(e,t,r){if("/"===t[0])return t;var i;if(-100===e)i=Rt.cwd();else{var n=Rt.getStream(e);if(!n)throw new Rt.ErrnoError(8);i=n.path}if(0==t.length){if(!r)throw new Rt.ErrnoError(44);return i}return Nt.join2(i,t)},doStat:function(e,t,r){try{var i=e(t)}catch(e){if(e&&e.node&&Nt.normalize(t)!==Nt.normalize(Rt.getPath(e.node)))return-54;throw e}return C[r>>2]=i.dev,C[r+4>>2]=0,C[r+8>>2]=i.ino,C[r+12>>2]=i.mode,C[r+16>>2]=i.nlink,C[r+20>>2]=i.uid,C[r+24>>2]=i.gid,C[r+28>>2]=i.rdev,C[r+32>>2]=0,q=[i.size>>>0,(K=i.size,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],C[r+40>>2]=q[0],C[r+44>>2]=q[1],C[r+48>>2]=4096,C[r+52>>2]=i.blocks,C[r+56>>2]=i.atime.getTime()/1e3|0,C[r+60>>2]=0,C[r+64>>2]=i.mtime.getTime()/1e3|0,C[r+68>>2]=0,C[r+72>>2]=i.ctime.getTime()/1e3|0,C[r+76>>2]=0,q=[i.ino>>>0,(K=i.ino,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],C[r+80>>2]=q[0],C[r+84>>2]=q[1],0},doMsync:function(e,t,r,i,n){var s=b.slice(e,e+r);Rt.msync(t,s,n,r,i)},doMkdir:function(e,t){return"/"===(e=Nt.normalize(e))[e.length-1]&&(e=e.substr(0,e.length-1)),Rt.mkdir(e,t,0),0},doMknod:function(e,t,r){switch(61440&t){case 32768:case 8192:case 24576:case 4096:case 49152:break;default:return-28}return Rt.mknod(e,t,r),0},doReadlink:function(e,t,r){if(r<=0)return-28;var i=Rt.readlink(e),n=Math.min(r,A(i)),s=x[t+n];return y(i,t,r+1),x[t+n]=s,n},doAccess:function(e,t){if(-8&t)return-28;var r;if(!(r=Rt.lookupPath(e,{follow:!0}).node))return-44;var i="";return 4&t&&(i+="r"),2&t&&(i+="w"),1&t&&(i+="x"),i&&Rt.nodePermissions(r,i)?-2:0},doDup:function(e,t,r){var i=Rt.getStream(r);return i&&Rt.close(i),Rt.open(e,t,0,r,r).fd},doReadv:function(e,t,r,i){for(var n=0,s=0;s<r;s++){var o=C[t+8*s>>2],a=C[t+(8*s+4)>>2],l=Rt.read(e,x,o,a,i);if(l<0)return-1;if(n+=l,l<a)break}return n},doWritev:function(e,t,r,i){for(var n=0,s=0;s<r;s++){var o=C[t+8*s>>2],a=C[t+(8*s+4)>>2],l=Rt.write(e,x,o,a,i);if(l<0)return-1;n+=l}return n},varargs:void 0,get:function(){return Ft.varargs+=4,C[Ft.varargs-4>>2]},getStr:function(e){return g(e)},getStreamFromFD:function(e){var t=Rt.getStream(e);if(!t)throw new Rt.ErrnoError(8);return t},get64:function(e,t){return e}};function Ut(e){return e%4==0&&(e%100!=0||e%400==0)}function zt(e,t){for(var r=0,i=0;i<=t;r+=e[i++]);return r}var kt=[31,29,31,30,31,30,31,31,30,31,30,31],Gt=[31,28,31,30,31,30,31,31,30,31,30,31];function jt(e,t){for(var r=new Date(e.getTime());t>0;){var i=Ut(r.getFullYear()),n=r.getMonth(),s=(i?kt:Gt)[n];if(!(t>s-r.getDate()))return r.setDate(r.getDate()+t),r;t-=s-r.getDate()+1,r.setDate(1),n<11?r.setMonth(n+1):(r.setMonth(0),r.setFullYear(r.getFullYear()+1))}return r}ve=e.InternalError=ge(Error,"InternalError"),function(){for(var e=new Array(256),t=0;t<256;++t)e[t]=String.fromCharCode(t);be=e}(),Ee=e.BindingError=ge(Error,"BindingError"),ke.prototype.isAliasOf=Oe,ke.prototype.clone=Be,ke.prototype.delete=Ie,ke.prototype.isDeleted=Pe,ke.prototype.deleteLater=ze,at.prototype.getPointee=Ke,at.prototype.destructor=qe,at.prototype.argPackAdvance=8,at.prototype.readValueFromPointer=he,at.prototype.deleteObject=Ze,at.prototype.fromWireType=ot,e.getInheritedInstanceCount=et,e.getLiveInheritedInstances=tt,e.flushPendingDeletes=Ue,e.setDelayFunction=rt,ut=e.UnboundTypeError=ge(Error,"UnboundTypeError"),e.count_emval_handles=wt,e.get_first_emval=xt;var Vt=function(e,t,r,i){e||(e=this),this.parent=e,this.mount=e.mount,this.mounted=null,this.id=Rt.nextInode++,this.name=t,this.mode=r,this.node_ops={},this.stream_ops={},this.rdev=i},Ht=365,Jt=146;function Qt(e,t,r){var i=r>0?r:A(e)+1,n=new Array(i),s=v(e,n,0,n.length);return t&&(n.length=s),n}Object.defineProperties(Vt.prototype,{read:{get:function(){return(this.mode&Ht)===Ht},set:function(e){e?this.mode|=Ht:this.mode&=-366}},write:{get:function(){return(this.mode&Jt)===Jt},set:function(e){e?this.mode|=Jt:this.mode&=-147}},isFolder:{get:function(){return Rt.isDir(this.mode)}},isDevice:{get:function(){return Rt.isChrdev(this.mode)}}}),Rt.FSNode=Vt,Rt.staticInit();var Yt,Wt={h:function(e){return Kt(e+oe)+oe},j:function(e,t,r){throw new ae(e).init(t,r),e},n:function(e){var t=le[e];delete le[e];var r=t.elements,i=r.length,n=r.map((function(e){return e.getterReturnType})).concat(r.map((function(e){return e.setterArgumentType}))),s=t.rawConstructor,o=t.rawDestructor;Ae([e],n,(function(e){return r.forEach((function(t,r){var n=e[r],s=t.getter,o=t.getterContext,a=e[r+i],l=t.setter,c=t.setterContext;t.read=function(e){return n.fromWireType(s(o,e))},t.write=function(e,t){var r=[];l(c,e,a.toWireType(r,t)),ce(r)}})),[{name:t.name,fromWireType:function(e){for(var t=new Array(i),n=0;n<i;++n)t[n]=r[n].read(e);return o(e),t},toWireType:function(e,n){if(i!==n.length)throw new TypeError("Incorrect number of tuple elements for "+t.name+": expected="+i+", actual="+n.length);for(var a=s(),l=0;l<i;++l)r[l].write(a,n[l]);return null!==e&&e.push(o,a),a},argPackAdvance:8,readValueFromPointer:he,destructorFunction:o}]}))},s:function(e){var t=we[e];delete we[e];var r=t.rawConstructor,i=t.rawDestructor,n=t.fields;Ae([e],n.map((function(e){return e.getterReturnType})).concat(n.map((function(e){return e.setterArgumentType}))),(function(e){var s={};return n.forEach((function(t,r){var i=t.fieldName,o=e[r],a=t.getter,l=t.getterContext,c=e[r+n.length],h=t.setter,u=t.setterContext;s[i]={read:function(e){return o.fromWireType(a(l,e))},write:function(e,t){var r=[];h(u,e,c.toWireType(r,t)),ce(r)}}})),[{name:t.name,fromWireType:function(e){var t={};for(var r in s)t[r]=s[r].read(e);return i(e),t},toWireType:function(e,t){for(var n in s)if(!(n in t))throw new TypeError('Missing field: "'+n+'"');var o=r();for(n in s)s[n].write(o,t[n]);return null!==e&&e.push(i,o),o},argPackAdvance:8,readValueFromPointer:he,destructorFunction:i}]}))},F:function(e,t,r,i,n){var s=xe(r);Te(e,{name:t=Se(t),fromWireType:function(e){return!!e},toWireType:function(e,t){return t?i:n},argPackAdvance:8,readValueFromPointer:function(e){var i;if(1===r)i=x;else if(2===r)i=S;else{if(4!==r)throw new TypeError("Unknown boolean type size: "+t);i=C}return this.fromWireType(i[e>>s])},destructorFunction:null})},g:function(e,t,r,i,n,s,o,a,l,c,h,u,d){h=Se(h),s=ht(n,s),a&&(a=ht(o,a)),c&&(c=ht(l,c)),d=ht(u,d);var p=fe(h);He(p,(function(){pt("Cannot construct "+h+" due to unbound types",[i])})),Ae([e,t,r],i?[i]:[],(function(t){var r,n;t=t[0],n=i?(r=t.registeredClass).instancePrototype:ke.prototype;var o=me(p,(function(){if(Object.getPrototypeOf(this)!==l)throw new Ee("Use 'new' to construct "+h);if(void 0===u.constructor_body)throw new Ee(h+" has no accessible constructor");var e=u.constructor_body[arguments.length];if(void 0===e)throw new Ee("Tried to invoke ctor of "+h+" with invalid number of parameters ("+arguments.length+") - expected ("+Object.keys(u.constructor_body).toString()+") parameters instead!");return e.apply(this,arguments)})),l=Object.create(n,{constructor:{value:o}});o.prototype=l;var u=new Je(h,o,l,d,r,s,a,c),f=new at(h,u,!0,!1,!1),m=new at(h+"*",u,!1,!1,!1),g=new at(h+" const*",u,!1,!0,!1);return je[e]={pointerType:m,constPointerType:g},lt(p,o),[f,m,g]}))},f:function(e,t,r,i,n,s){p(t>0);var o=ft(t,r);n=ht(i,n);var a=[s],l=[];Ae([],[e],(function(e){var r="constructor "+(e=e[0]).name;if(void 0===e.registeredClass.constructor_body&&(e.registeredClass.constructor_body=[]),void 0!==e.registeredClass.constructor_body[t-1])throw new Ee("Cannot register multiple constructors with identical number of parameters ("+(t-1)+") for class '"+e.name+"'! Overload resolution is currently only performed using the parameter count, not actual type info!");return e.registeredClass.constructor_body[t-1]=function(){pt("Cannot construct "+e.name+" due to unbound types",o)},Ae([],o,(function(i){return e.registeredClass.constructor_body[t-1]=function(){arguments.length!==t-1&&Ce(r+" called with "+arguments.length+" arguments, expected "+(t-1)),l.length=0,a.length=t;for(var e=1;e<t;++e)a[e]=i[e].toWireType(l,arguments[e-1]);var s=n.apply(null,a);return ce(l),i[0].fromWireType(s)},[]})),[]}))},b:function(e,t,r,i,n,s,o,a){var l=ft(r,i);t=Se(t),s=ht(n,s),Ae([],[e],(function(e){var i=(e=e[0]).name+"."+t;function n(){pt("Cannot call "+i+" due to unbound types",l)}a&&e.registeredClass.pureVirtualFunctions.push(t);var c=e.registeredClass.instancePrototype,h=c[t];return void 0===h||void 0===h.overloadTable&&h.className!==e.name&&h.argCount===r-2?(n.argCount=r-2,n.className=e.name,c[t]=n):(Ve(c,t,i),c[t].overloadTable[r-2]=n),Ae([],l,(function(n){var a=mt(i,n,e,s,o);return void 0===c[t].overloadTable?(a.argCount=r-2,c[t]=a):c[t].overloadTable[r-2]=a,[]})),[]}))},r:function(e,t,r,i,n,s,o,a,l,c){t=Se(t),n=ht(i,n),Ae([],[e],(function(e){var i=(e=e[0]).name+"."+t,h={get:function(){pt("Cannot access "+i+" due to unbound types",[r,o])},enumerable:!0,configurable:!0};return h.set=l?function(){pt("Cannot access "+i+" due to unbound types",[r,o])}:function(e){Ce(i+" is a read-only property")},Object.defineProperty(e.registeredClass.instancePrototype,t,h),Ae([],l?[r,o]:[r],(function(r){var o=r[0],h={get:function(){var t=gt(this,e,i+" getter");return o.fromWireType(n(s,t))},enumerable:!0};if(l){l=ht(a,l);var u=r[1];h.set=function(t){var r=gt(this,e,i+" setter"),n=[];l(c,r,u.toWireType(n,t)),ce(n)}}return Object.defineProperty(e.registeredClass.instancePrototype,t,h),[]})),[]}))},E:function(e,t){Te(e,{name:t=Se(t),fromWireType:function(e){var t=yt[e].value;return At(e),t},toWireType:function(e,t){return bt(t)},argPackAdvance:8,readValueFromPointer:he,destructorFunction:null})},w:function(e,t,r,i){var n=xe(r);function s(){}t=Se(t),s.values={},Te(e,{name:t,constructor:s,fromWireType:function(e){return this.constructor.values[e]},toWireType:function(e,t){return t.value},argPackAdvance:8,readValueFromPointer:St(t,n,i),destructorFunction:null}),He(t,s)},o:function(e,t,r){var i=Et(e,"enum");t=Se(t);var n=i.constructor,s=Object.create(i.constructor.prototype,{value:{value:r},constructor:{value:me(i.name+"_"+t,(function(){}))}});n.values[r]=s,n[t]=s},v:function(e,t,r){var i=xe(r);Te(e,{name:t=Se(t),fromWireType:function(e){return e},toWireType:function(e,t){if("number"!=typeof t&&"boolean"!=typeof t)throw new TypeError('Cannot convert "'+Ct(t)+'" to '+this.name);return t},argPackAdvance:8,readValueFromPointer:Tt(t,i),destructorFunction:null})},a:function(e,t,r,i,n,s){var o=ft(t,r);e=Se(e),n=ht(i,n),He(e,(function(){pt("Cannot call "+e+" due to unbound types",o)}),t-1),Ae([],o,(function(r){var i=[r[0],null].concat(r.slice(1));return lt(e,mt(e,i,null,n,s),t-1),[]}))},e:function(e,t,r,i,n){t=Se(t),-1===n&&(n=4294967295);var s=xe(r),o=function(e){return e};if(0===i){var a=32-8*r;o=function(e){return e<<a>>>a}}var l=-1!=t.indexOf("unsigned");Te(e,{name:t,fromWireType:o,toWireType:function(e,r){if("number"!=typeof r&&"boolean"!=typeof r)throw new TypeError('Cannot convert "'+Ct(r)+'" to '+this.name);if(r<i||r>n)throw new TypeError('Passing a number "'+Ct(r)+'" from JS side to C/C++ side to an argument of type "'+t+'", which is outside the valid range ['+i+", "+n+"]!");return l?r>>>0:0|r},argPackAdvance:8,readValueFromPointer:Ot(t,s,0!==i),destructorFunction:null})},d:function(e,t,r){var i=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array][t];function n(e){var t=T,r=t[e>>=2],n=t[e+1];return new i(w,n,r)}Te(e,{name:r=Se(r),fromWireType:n,argPackAdvance:8,readValueFromPointer:n},{ignoreDuplicateRegistrations:!0})},u:function(e,t){var r="std::string"===(t=Se(t));Te(e,{name:t,fromWireType:function(e){var t,i=T[e>>2];if(r)for(var n=e+4,s=0;s<=i;++s){var o=e+4+s;if(s==i||0==b[o]){var a=g(n,o-n);void 0===t?t=a:(t+=String.fromCharCode(0),t+=a),n=o+1}}else{var l=new Array(i);for(s=0;s<i;++s)l[s]=String.fromCharCode(b[e+4+s]);t=l.join("")}return qt(e),t},toWireType:function(e,t){t instanceof ArrayBuffer&&(t=new Uint8Array(t));var i="string"==typeof t;i||t instanceof Uint8Array||t instanceof Uint8ClampedArray||t instanceof Int8Array||Ce("Cannot pass non-string to std::string");var n=(r&&i?function(){return A(t)}:function(){return t.length})(),s=Kt(4+n+1);if(T[s>>2]=n,r&&i)y(t,s+4,n+1);else if(i)for(var o=0;o<n;++o){var a=t.charCodeAt(o);a>255&&(qt(s),Ce("String has UTF-16 code units that do not fit in 8 bits")),b[s+4+o]=a}else for(o=0;o<n;++o)b[s+4+o]=t[o];return null!==e&&e.push(qt,s),s},argPackAdvance:8,readValueFromPointer:he,destructorFunction:function(e){qt(e)}})},q:function(e,t,r){var i,n,s,o,a;r=Se(r),2===t?(i=_,n=N,o=L,s=function(){return E},a=1):4===t&&(i=B,n=I,o=P,s=function(){return T},a=2),Te(e,{name:r,fromWireType:function(e){for(var r,n=T[e>>2],o=s(),l=e+4,c=0;c<=n;++c){var h=e+4+c*t;if(c==n||0==o[h>>a]){var u=i(l,h-l);void 0===r?r=u:(r+=String.fromCharCode(0),r+=u),l=h+t}}return qt(e),r},toWireType:function(e,i){"string"!=typeof i&&Ce("Cannot pass non-string to C++ string type "+r);var s=o(i),l=Kt(4+s+t);return T[l>>2]=s>>a,n(i,l+4,s+t),null!==e&&e.push(qt,l),l},argPackAdvance:8,readValueFromPointer:he,destructorFunction:function(e){qt(e)}})},m:function(e,t,r,i,n,s){le[e]={name:Se(t),rawConstructor:ht(r,i),rawDestructor:ht(n,s),elements:[]}},c:function(e,t,r,i,n,s,o,a,l){le[e].elements.push({getterReturnType:t,getter:ht(r,i),getterContext:n,setterArgumentType:s,setter:ht(o,a),setterContext:l})},p:function(e,t,r,i,n,s){we[e]={name:Se(t),rawConstructor:ht(r,i),rawDestructor:ht(n,s),fields:[]}},l:function(e,t,r,i,n,s,o,a,l,c){we[e].fields.push({fieldName:Se(t),getterReturnType:r,getter:ht(i,n),getterContext:s,setterArgumentType:o,setter:ht(a,l),setterContext:c})},D:function(e,t){Te(e,{isVoid:!0,name:t=Se(t),argPackAdvance:0,fromWireType:function(){},toWireType:function(e,t){}})},C:At,B:function(e){e>4&&(yt[e].refcount+=1)},k:function(e,t){return bt((e=Et(e,"_emval_take_value")).readValueFromPointer(t))},t:function(){Y()},A:function(e,t,r){b.copyWithin(e,t,t+r)},i:function(e){e>>>=0;var t=b.length,r=2147483648;if(e>r)return!1;for(var i,n,s=1;s<=4;s*=2){var o=t*(1+.2/s);if(o=Math.min(o,e+100663296),Dt(Math.min(r,((i=Math.max(16777216,e,o))%(n=65536)>0&&(i+=n-i%n),i))))return!0}return!1},K:function(e,t){try{var r=0;return _t().forEach((function(i,n){var s=t+r;C[e+4*n>>2]=s,function(e,t,r){for(var i=0;i<e.length;++i)x[t++>>0]=e.charCodeAt(i);r||(x[t>>0]=0)}(i,s),r+=i.length+1})),0}catch(e){return void 0!==Rt&&e instanceof Rt.ErrnoError||Y(e),e.errno}},J:function(e,t){try{var r=_t();C[e>>2]=r.length;var i=0;return r.forEach((function(e){i+=e.length+1})),C[t>>2]=i,0}catch(e){return void 0!==Rt&&e instanceof Rt.ErrnoError||Y(e),e.errno}},I:function(e){try{var t=Ft.getStreamFromFD(e);return Rt.close(t),0}catch(e){return void 0!==Rt&&e instanceof Rt.ErrnoError||Y(e),e.errno}},H:function(e,t,r,i){try{var n=Ft.getStreamFromFD(e),s=Ft.doReadv(n,t,r);return C[i>>2]=s,0}catch(e){return void 0!==Rt&&e instanceof Rt.ErrnoError||Y(e),e.errno}},z:function(e,t,r,i,n){try{var s=Ft.getStreamFromFD(e),o=4294967296*r+(t>>>0),a=9007199254740992;return o<=-a||o>=a?-61:(Rt.llseek(s,o,i),q=[s.position>>>0,(K=s.position,+Math.abs(K)>=1?K>0?(0|Math.min(+Math.floor(K/4294967296),4294967295))>>>0:~~+Math.ceil((K-+(~~K>>>0))/4294967296)>>>0:0)],C[n>>2]=q[0],C[n+4>>2]=q[1],s.getdents&&0===o&&0===i&&(s.getdents=null),0)}catch(e){return void 0!==Rt&&e instanceof Rt.ErrnoError||Y(e),e.errno}},G:function(e,t,r,i){try{var n=Ft.getStreamFromFD(e),s=Ft.doWritev(n,t,r);return C[i>>2]=s,0}catch(e){return void 0!==Rt&&e instanceof Rt.ErrnoError||Y(e),e.errno}},y:function(e){},x:function(e,t,r,i){return function(e,t,r,i){var n=C[i+40>>2],s={tm_sec:C[i>>2],tm_min:C[i+4>>2],tm_hour:C[i+8>>2],tm_mday:C[i+12>>2],tm_mon:C[i+16>>2],tm_year:C[i+20>>2],tm_wday:C[i+24>>2],tm_yday:C[i+28>>2],tm_isdst:C[i+32>>2],tm_gmtoff:C[i+36>>2],tm_zone:n?g(n):""},o=g(r),a={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d","%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var l in a)o=o.replace(new RegExp(l,"g"),a[l]);var c=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],h=["January","February","March","April","May","June","July","August","September","October","November","December"];function u(e,t,r){for(var i="number"==typeof e?e.toString():e||"";i.length<t;)i=r[0]+i;return i}function d(e,t){return u(e,t,"0")}function p(e,t){function r(e){return e<0?-1:e>0?1:0}var i;return 0===(i=r(e.getFullYear()-t.getFullYear()))&&0===(i=r(e.getMonth()-t.getMonth()))&&(i=r(e.getDate()-t.getDate())),i}function f(e){switch(e.getDay()){case 0:return new Date(e.getFullYear()-1,11,29);case 1:return e;case 2:return new Date(e.getFullYear(),0,3);case 3:return new Date(e.getFullYear(),0,2);case 4:return new Date(e.getFullYear(),0,1);case 5:return new Date(e.getFullYear()-1,11,31);case 6:return new Date(e.getFullYear()-1,11,30)}}function m(e){var t=jt(new Date(e.tm_year+1900,0,1),e.tm_yday),r=new Date(t.getFullYear(),0,4),i=new Date(t.getFullYear()+1,0,4),n=f(r),s=f(i);return p(n,t)<=0?p(s,t)<=0?t.getFullYear()+1:t.getFullYear():t.getFullYear()-1}var v={"%a":function(e){return c[e.tm_wday].substring(0,3)},"%A":function(e){return c[e.tm_wday]},"%b":function(e){return h[e.tm_mon].substring(0,3)},"%B":function(e){return h[e.tm_mon]},"%C":function(e){return d((e.tm_year+1900)/100|0,2)},"%d":function(e){return d(e.tm_mday,2)},"%e":function(e){return u(e.tm_mday,2," ")},"%g":function(e){return m(e).toString().substring(2)},"%G":function(e){return m(e)},"%H":function(e){return d(e.tm_hour,2)},"%I":function(e){var t=e.tm_hour;return 0==t?t=12:t>12&&(t-=12),d(t,2)},"%j":function(e){return d(e.tm_mday+zt(Ut(e.tm_year+1900)?kt:Gt,e.tm_mon-1),3)},"%m":function(e){return d(e.tm_mon+1,2)},"%M":function(e){return d(e.tm_min,2)},"%n":function(){return"\n"},"%p":function(e){return e.tm_hour>=0&&e.tm_hour<12?"AM":"PM"},"%S":function(e){return d(e.tm_sec,2)},"%t":function(){return"\t"},"%u":function(e){return e.tm_wday||7},"%U":function(e){var t=new Date(e.tm_year+1900,0,1),r=0===t.getDay()?t:jt(t,7-t.getDay()),i=new Date(e.tm_year+1900,e.tm_mon,e.tm_mday);if(p(r,i)<0){var n=zt(Ut(i.getFullYear())?kt:Gt,i.getMonth()-1)-31,s=31-r.getDate()+n+i.getDate();return d(Math.ceil(s/7),2)}return 0===p(r,t)?"01":"00"},"%V":function(e){var t,r=new Date(e.tm_year+1900,0,4),i=new Date(e.tm_year+1901,0,4),n=f(r),s=f(i),o=jt(new Date(e.tm_year+1900,0,1),e.tm_yday);return p(o,n)<0?"53":p(s,o)<=0?"01":(t=n.getFullYear()<e.tm_year+1900?e.tm_yday+32-n.getDate():e.tm_yday+1-n.getDate(),d(Math.ceil(t/7),2))},"%w":function(e){return e.tm_wday},"%W":function(e){var t=new Date(e.tm_year,0,1),r=1===t.getDay()?t:jt(t,0===t.getDay()?1:7-t.getDay()+1),i=new Date(e.tm_year+1900,e.tm_mon,e.tm_mday);if(p(r,i)<0){var n=zt(Ut(i.getFullYear())?kt:Gt,i.getMonth()-1)-31,s=31-r.getDate()+n+i.getDate();return d(Math.ceil(s/7),2)}return 0===p(r,t)?"01":"00"},"%y":function(e){return(e.tm_year+1900).toString().substring(2)},"%Y":function(e){return e.tm_year+1900},"%z":function(e){var t=e.tm_gmtoff,r=t>=0;return t=(t=Math.abs(t)/60)/60*100+t%60,(r?"+":"-")+String("0000"+t).slice(-4)},"%Z":function(e){return e.tm_zone},"%%":function(){return"%"}};for(var l in v)o.indexOf(l)>=0&&(o=o.replace(new RegExp(l,"g"),v[l](s)));var y=Qt(o,!1);return y.length>t?0:(R(y,e),y.length-1)}(e,t,r,i)}},Xt=(function(){var t={a:Wt};function i(t,r){var i=t.exports;e.asm=i,F((c=e.asm.L).buffer),U=e.asm.N,Q()}function n(e){i(e.instance)}function s(e){return(l||"function"!=typeof fetch?Promise.resolve().then((function(){return $(Z)})):fetch(Z,{credentials:"same-origin"}).then((function(e){if(!e.ok)throw"failed to load wasm binary file at '"+Z+"'";return e.arrayBuffer()})).catch((function(){return $(Z)}))).then((function(e){return WebAssembly.instantiate(e,t)})).then(e,(function(e){u("failed to asynchronously prepare wasm: "+e),Y(e)}))}if(J(),e.instantiateWasm)try{return e.instantiateWasm(t,i)}catch(e){return u("Module.instantiateWasm callback failed with error: "+e),!1}(l||"function"!=typeof WebAssembly.instantiateStreaming||W(Z)||"function"!=typeof fetch?s(n):fetch(Z,{credentials:"same-origin"}).then((function(e){return WebAssembly.instantiateStreaming(e,t).then(n,(function(e){return u("wasm streaming compile failed: "+e),u("falling back to ArrayBuffer instantiation"),s(n)}))}))).catch(r)}(),e.___wasm_call_ctors=function(){return(Xt=e.___wasm_call_ctors=e.asm.M).apply(null,arguments)}),Kt=e._malloc=function(){return(Kt=e._malloc=e.asm.O).apply(null,arguments)},qt=e._free=function(){return(qt=e._free=e.asm.P).apply(null,arguments)},Zt=e.___getTypeName=function(){return(Zt=e.___getTypeName=e.asm.Q).apply(null,arguments)},$t=(e.___embind_register_native_and_builtin_types=function(){return(e.___embind_register_native_and_builtin_types=e.asm.R).apply(null,arguments)},e.stackSave=function(){return($t=e.stackSave=e.asm.S).apply(null,arguments)}),er=e.stackRestore=function(){return(er=e.stackRestore=e.asm.T).apply(null,arguments)},tr=e.stackAlloc=function(){return(tr=e.stackAlloc=e.asm.U).apply(null,arguments)};function rr(r){function i(){Yt||(Yt=!0,e.calledRun=!0,d||(e.noFSInit||Rt.init.initialized||Rt.init(),Bt.init(),ee(k),Rt.ignorePermissions=!1,ee(G),t(e),e.onRuntimeInitialized&&e.onRuntimeInitialized(),function(){if(e.postRun)for("function"==typeof e.postRun&&(e.postRun=[e.postRun]);e.postRun.length;)t=e.postRun.shift(),j.unshift(t);var t;ee(j)}()))}V>0||(function(){if(e.preRun)for("function"==typeof e.preRun&&(e.preRun=[e.preRun]);e.preRun.length;)t=e.preRun.shift(),z.unshift(t);var t;ee(z)}(),V>0||(e.setStatus?(e.setStatus("Running..."),setTimeout((function(){setTimeout((function(){e.setStatus("")}),1),i()}),1)):i()))}if(e.dynCall_jiji=function(){return(e.dynCall_jiji=e.asm.V).apply(null,arguments)},e.dynCall_viijii=function(){return(e.dynCall_viijii=e.asm.W).apply(null,arguments)},e.dynCall_iiiiiijj=function(){return(e.dynCall_iiiiiijj=e.asm.X).apply(null,arguments)},e.dynCall_iiiiij=function(){return(e.dynCall_iiiiij=e.asm.Y).apply(null,arguments)},e.dynCall_iiiiijj=function(){return(e.dynCall_iiiiijj=e.asm.Z).apply(null,arguments)},e.ccall=function(t,r,i,n,s){var o={string:function(e){var t=0;if(null!=e&&0!==e){var r=1+(e.length<<2);y(e,t=tr(r),r)}return t},array:function(e){var t=tr(e.length);return R(e,t),t}},a=function(t){var r=e["_"+t];return p(r,"Cannot call unknown function "+t+", make sure it is exported"),r}(t),l=[],c=0;if(n)for(var h=0;h<n.length;h++){var u=o[i[h]];u?(0===c&&(c=$t()),l[h]=u(n[h])):l[h]=n[h]}var d=a.apply(null,l);return d=function(e){return"string"===r?g(e):"boolean"===r?Boolean(e):e}(d),0!==c&&er(c),d},H=function e(){Yt||rr(),Yt||(H=e)},e.run=rr,e.preInit)for("function"==typeof e.preInit&&(e.preInit=[e.preInit]);e.preInit.length>0;)e.preInit.pop()();return rr(),e.ready});const He=ke.mergeVertices;let Je;Ve().then((e=>Je=e),(()=>{}));const Qe=new t.Vector3,Ye=new t.Matrix4;new t.BoxGeometry(200,200,200).userData.type="CubeGeometry";const We=((je=class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i;const n=null!==(r=e.geometry)&&void 0!==r?r:null==t?void 0:t.geometry,{width:s,height:o,depth:a}=n.userData.parameters,l=Object.assign(Object.assign({},null!==(i=null==t?void 0:t.parameters)&&void 0!==i?i:{width:s,height:o,depth:a,subdivisions:1}),e.parameters);return{parameters:Object.assign(Object.assign({},l),{width:Math.abs(l.width),height:Math.abs(l.height),depth:Math.abs(l.depth)}),geometry:n,subdivPointer:null==t?void 0:t.subdivPointer,smoothShading:null==t?void 0:t.smoothShading}}static build(e){var t;let r=e.geometry,i=e.geometry.originalGeometry;const{width:n,height:s,depth:o,subdivisions:a}=e.parameters,l=r.userData.parameters;if(Qe.set(l.width,l.height,l.depth),n!==Qe.x||s!==Qe.y||o!==Qe.z){const e=[n/Qe.x,s/Qe.y,o/Qe.z];Ye.makeScale(e[0],e[1],e[2]);const a=null!==(t=null==i?void 0:i.boundingSphere)&&void 0!==t?t:r.boundingSphere;a.center.applyMatrix4(Ye),r.boundingSphere=null,null==r||r.applyMatrix4(Ye),r.boundingSphere=a,i&&(i.boundingSphere=null,i.applyMatrix4(Ye),i.boundingSphere=a)}let c,h;return void 0!==i?(h=r,c=i):c=r,void 0===e.subdivPointer&&(this.allocate(c),console.log("allocated new subdiv instance at: ",this.activeSubdivPtr),null==c||c.dispose(),c=this.buildLevel(!0,e.smoothShading),c.computeBoundingSphere(),e.subdivPointer=this.activeSubdivPtr),a>0?(a===(null==l?void 0:l.subdivisions)&&void 0!==i||(e.subdivPointer!==this.activeSubdivPtr&&(this.activeSubdivPtr=e.subdivPointer),null==h||h.dispose(),Je.set_destination_refinement_level(e.subdivPointer,a),h=this.buildLevel(!1,e.smoothShading),h.boundingSphere=c.boundingSphere),r=h,i=c,delete i.userData.parameters):(r=c,null==h||h.dispose(),i=void 0),Object.assign(r,{originalGeometry:i,subdivPointer:this.activeSubdivPtr,userData:{parameters:e.parameters,type:"SubdivGeometry"}})}static allocate(e){let t,r,i;const n=[],s=[];if("SubdivGeometry"!==e.userData.type){const n=He(e,1.5);t=n.attributes.position.array;const s=n.getIndex().array,o=s.length;switch(e.userData.type){case"TorusGeometry":case"CubeGeometry":r=new Array(o/3*2),i=new Array(o/6).fill(4);for(let e=0,t=0;e<o;e+=6)r[t++]=s[e],r[t++]=s[e+1],r[t++]=s[e+4],r[t++]=s[e+5];break;case"SphereGeometry":case"CylinderGeometry":case"ConeGeometry":let t,n;"SphereGeometry"===e.userData.type?(n=e.parameters.heightSegments,t=e.parameters.widthSegments):"CylinderGeometry"===e.userData.type?(n=e.parameters.heightSegments+2,t=e.parameters.radialSegments):(n=e.parameters.heightSegments+1,t=e.parameters.radialSegments),r=new Array(2*t*3+(n-2)*t*4),i=new Array(2*t+(n-2)*t);let a=0,l=0,c=0;if("SphereGeometry"===e.userData.type){for(;l<3*t;)r[l++]=s[a++],r[l++]=s[a++],r[l++]=s[a++],i[c++]=3;for(;l<3*t+4*(n-2)*t;a+=6)r[l++]=s[a],r[l++]=s[a+1],r[l++]=s[a+4],r[l++]=s[a+5],i[c++]=4}else for(;l<4*(n-2)*t;a+=6)r[l++]=s[a],r[l++]=s[a+1],r[l++]=s[a+4],r[l++]=s[a+5],i[c++]=4;for(;l<r.length;)r[l++]=s[a++],r[l++]=s[a++],r[l++]=s[a++],i[c++]=3;break;default:r=s,i=new Array(o/3).fill(3)}}else{console.log("sending existing SubdivGeometry back to WASM");const n=e.getAttribute("faceMap");e.deleteAttribute("faceMap");const s=He(e,2);e.setAttribute("faceMap",n),t=s.attributes.position.array,r=[];const o=n.array;i=new Array(o[o.length-1]+1).fill(3);const a=s.getIndex().array;for(let e=0,t=o.length;e<t;)o[e]===o[e+1]?(i[o[e]]++,r.push(...new Set(a.slice(3*e,3*e+6))),e+=2):(r.push(...a.slice(3*e,3*e+3)),e++)}console.log("wasm allocate:",i.length,"triangles");const o=t.length,a=r.length,l=i.length,c=t.length+n.length+s.length,h=r.length+i.length,u=c*Float32Array.BYTES_PER_ELEMENT+h*Uint32Array.BYTES_PER_ELEMENT;console.log("Total WASM memory size (in bytes):",u);const d=c*Float32Array.BYTES_PER_ELEMENT,p=Je._malloc(u);console.log("after malloc wasmPointer");const f=new Float32Array(Je.HEAPF32.buffer,p,c),m=new Uint32Array(Je.HEAPU32.buffer,p+d,h),g=ze(Float32Array,t,n,s),v=ze(Uint32Array,r,i);f.set(g,0),m.set(v,0),console.log("before wasm.alloc_subdivision_surface"),this.activeSubdivPtr=Je.alloc_subdivision_surface(p,o,p+d,a,p+d+r.length*Uint32Array.BYTES_PER_ELEMENT,l),console.log("allocate subdivPointer",this.activeSubdivPtr),console.log("after wasm.alloc_subdivision_surface"),Je._free(p)}static buildLevel(e,r,i){const n=Je.get_mesh_data(this.activeSubdivPtr,e?Je.Level.CONTROL:Je.Level.REFINED,null!=r?r:!e),s=Je.HEAPU32.subarray(n>>2,8+(n>>2)),o=s.subarray(4,8);let a=0;const l=Je.HEAPU32[s[a]>>2],c=Je.HEAPF32.subarray(l>>2,(l>>2)+o[a]);a++;const h=Je.HEAPU32[s[a]>>2],u=Je.HEAPF32.subarray(h>>2,(h>>2)+o[a]);a++;const d=Je.HEAPU32[s[a]>>2],p=Je.HEAPU32.subarray(d>>2,(d>>2)+o[a]);a++;const f=Je.HEAPU32[s[a]>>2],m=Je.HEAPU32.subarray(f>>2,(f>>2)+o[a]);if(a++,void 0===i){const r=new t.BufferGeometry;if(e&&r.setAttribute("faceMap",new t.BufferAttribute(p.slice(),1)),r.setIndex(new t.Uint32BufferAttribute(m,1)),r.setAttribute("position",new t.Float32BufferAttribute(c,3)),r.setAttribute("normal",new t.Float32BufferAttribute(u,3)),e){const e=new Float32Array(u.length/3*4).fill(0);r.setAttribute("color",new t.BufferAttribute(e,4))}return Je.free_mesh_data(n),r.userData.type="SubdivGeometry",r}i.getAttribute("position").copyArray(c),i.getAttribute("normal").copyArray(u),i.attributes.position.needsUpdate=!0,i.attributes.normal.needsUpdate=!0,Je.free_mesh_data(n)}static buildControlCageWireframe(e,r){const i=Je.get_wireframe_data_for_base_level(this.activeSubdivPtr),n=Je.HEAPU32.subarray(i>>2,4+(i>>2)),s=n.subarray(2,4);let o=0;const a=Je.HEAPU32[n[o]>>2],l=Je.HEAPF32.subarray(a>>2,(a>>2)+s[o]);o++;const c=Je.HEAPU32[n[o]>>2],h=Je.HEAPU32.subarray(c>>2,(c>>2)+s[o]);if(void 0===e){const e=new t.BufferGeometry;e.setAttribute("position",new t.Float32BufferAttribute(l,3));const n=new Float32Array(l.length);for(let e=0,t=l.length;e<t;)n[e++]=r.r,n[e++]=r.g,n[e++]=r.b;return e.setAttribute("color",new t.BufferAttribute(n,3)),e.setIndex(new t.Uint32BufferAttribute(h,1)),Je.free_wireframe_data_for_base_level(i),e}e.getAttribute("position").copyArray(l),e.attributes.position.needsUpdate=!0,Je.free_wireframe_data_for_base_level(i)}static clone(e,t,r){this.activeSubdivPtr=Je.copy_subdivision_surface(t),Je.set_destination_refinement_level(this.activeSubdivPtr,e.subdivisions);const i=this.buildLevel(!0,r);let n,s,o;return e.subdivisions>0?(o=this.buildLevel(!1,r),n=o,s=i,delete s.userData.parameters):(n=i,s=void 0),Object.assign(n,{originalGeometry:s,subdivPointer:this.activeSubdivPtr,userData:{parameters:e,type:"SubdivGeometry"}})}}).checkpoints=[],je.checkpointCurrentIndex=-1,je.maxCheckpoints=30,je),Xe=(new t.Sphere,new t.Matrix4,new t.Ray,new t.Vector3,new t.Vector3,new t.Vector3,new t.Vector3,{ConeGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,radialSegments:32,heightSegments:32,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadiusTop:0,cornerRadiusBottom:0,cornerSegments:8},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{width:r,depth:i,height:n,radialSegments:o,heightSegments:a,openEnded:l,thetaStart:c,thetaLength:h,cornerRadiusTop:u,cornerRadiusBottom:d,cornerSegments:p}=e.parameters;let f;return f=u>0||d>0||h<360?new s(0,r/2,n,o,a,l,c,h*Math.PI/180,u,d,p,0,!0):new t.ConeBufferGeometry(r/2,n,o,a,l),f.scale(1,1,i/r),Object.assign(f,{userData:Object.assign(Object.assign({},e),{type:"ConeGeometry"})})}},CubeGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,widthSegments:1,heightSegments:1,depthSegments:1,cornerRadius:0,cornerSegments:8},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{width:r,height:i,depth:n,widthSegments:s,heightSegments:o,depthSegments:l,cornerRadius:c,cornerSegments:h}=e.parameters;let u;return u=0==c?new t.BoxBufferGeometry(r,i,n,s,o,l):new a(r,i,n,s,o,l,c,h),Object.assign(u,{userData:Object.assign(Object.assign({},e),{type:"CubeGeometry"})})}},CylinderGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n,s,o;const a=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,radialSegments:64,heightSegments:1,openEnded:!1,thetaStart:0,thetaLength:360,cornerRadius:0,cornerSegments:8,hollow:0},e.parameters),l=a.width/2;let c=null!==(i=a.radiusTop)&&void 0!==i?i:l,h=null!==(n=a.radiusBottom)&&void 0!==n?n:l;return c===h?(c=l,h=l):c>h?(c=l,h=h*l/c):(c=c*l/h,h=l),{parameters:Object.assign(a,{width:Math.abs(a.width),height:Math.abs(null!==(s=a.height)&&void 0!==s?s:a.width),depth:Math.abs(null!==(o=a.depth)&&void 0!==o?o:a.width),radiusTop:c,radiusBottom:h})}}static build(e){const{width:r,depth:i,height:n,radialSegments:o,heightSegments:a,openEnded:l,thetaStart:c,thetaLength:h,radiusTop:u,radiusBottom:d,cornerRadius:p,cornerSegments:f,hollow:m}=e.parameters;let g;return g=p||m?new s(u,d,n,o,a,l,c,h*Math.PI/180,p,p,f,m):new t.CylinderBufferGeometry(u,d,n,o,a,l,c,h*Math.PI/180),g.scale(1,1,i/r),Object.assign(g,{userData:Object.assign(Object.assign({},e),{type:"CylinderGeometry"})})}},DodecahedronGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,detail:0},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{width:r,height:i,depth:n,detail:s}=e.parameters,o=new t.DodecahedronBufferGeometry(.5*r,s);return o.scale(1,i/r,n/r),Object.assign(o,{userData:Object.assign(Object.assign({},e),{type:"DodecahedronGeometry"})})}},EllipseGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i;const n=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0,spikes:128,angle:360,innerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,surfaceMaxCount:1e3},e.parameters);return{shape:new R,parameters:Object.assign(n,{width:Math.abs(n.width),height:Math.abs(null!==(i=n.height)&&void 0!==i?i:n.width)})}}static build(e){const{width:t,height:r,spikes:i,angle:n,innerRadius:s,extrudeDepth:o,extrudeBevelSize:a,extrudeBevelSegments:l,surfaceMaxCount:c}=e.parameters,h=e.shape,u=function(e,t,r,i,n,s){if(i>=he)return n>30||n%4==0?(function(e,t,r,i=0,n=0,s=0){const o=.5522847498,a=t*o,l=r*o;e.addPoint(pe(n-t,s,n-t,s-l,n-t,s+l)),e.addPoint(pe(n,s+r,n-a,s+r,n+a,s+r)),e.addPoint(pe(n+t,s,n+t,s+l,n+t,s-l)),e.addPoint(pe(n,s-r,n+a,s-r,n-a,s-r)),i>0&&me(e,t,r,i)}(e,t,r,s),Math.round(n/4)):ue(e,i,n,t,r,s);const o={x:0,y:r},a=i+.5*Math.PI,l={x:Math.cos(a)*t,y:Math.sin(a)*r},c=G({px:o.x,py:o.y,cx:l.x,cy:l.y,rx:t,ry:r,largeArcFlag:i>Math.PI,sweepFlag:!0});return n>30||n%c.length==0?function(e,t,r,i,n,s,o,a){const l=Math.round(n/i.length);e.addPoint(de(t,r));for(let t=0,r=i.length;t<r;t++){const r=i[t],n=e.points[t],s=de(r.x,r.y);n.controls[1].position.set(r.x1,r.y1),s.controls[0].position.set(r.x2,r.y2),e.addPoint(s)}a>0?fe(e,s,o,a):e.addPoint(de(0,0));return l}(e,o.x,o.y,c,n,t,r,s):ue(e,i,n,t,r,s)}(h,.5*t,.5*r,n*Math.PI/180,i,s);h.isClosed=!0,h.update();const d=ce.create({shape:h,parameters:{subdivisions:u,surfaceMaxCount:c,extrudeDepth:o,extrudeBevelSize:a,extrudeBevelSegments:l}});return Object.assign(d,{userData:Object.assign(Object.assign({},e),{type:"EllipseGeometry"})})}},HelixGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,revolutions:2,segments:40,pathRadius:10,pathType:0,pathSegments:30,cornerRadius:30,cornerSegments:4},e.parameters),o=Math.abs(s.width),a=Math.abs(null!==(i=s.height)&&void 0!==i?i:o),l=Math.abs(null!==(n=s.depth)&&void 0!==n?n:o),c=Math.abs(Math.min(o,l))/2;return{parameters:Object.assign(s,{width:o,height:a,depth:l,radius:c,segments:Math.round(s.segments),pathSegments:Math.round(s.pathSegments),cornerSegments:Math.round(s.cornerSegments)})}}static build(e){const{width:t,height:r,depth:i,radius:n,revolutions:s,segments:o,pathRadius:a,pathType:l,pathSegments:c,cornerRadius:h,cornerSegments:u}=e.parameters,d=new ve(!1,t,r,i,n,s,o,a,l,c,h,u);return Object.assign(d,{userData:Object.assign(Object.assign({},e),{type:"HelixGeometry"})})}},IcosahedronGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,detail:0},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{width:r,height:i,depth:n,detail:s}=e.parameters,o=new t.IcosahedronBufferGeometry(.5*r,s);return o.scale(1,i/r,n/r),Object.assign(o,{userData:Object.assign(Object.assign({},e),{type:"IcosahedronGeometry"})})}},LatheGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,segments:64,verticalSegments:64,points:[{x:0,y:-50,id:0},{x:50,y:-50,id:1},{x:50,y:50,id:2},{x:0,y:50,id:3}]},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{points:r,segments:i,verticalSegments:n}=e.parameters,s=new t.Shape;s.moveTo(r[0].x,r[0].y),s.bezierCurveTo(r[1].x,r[1].y,r[2].x,r[2].y,r[3].x,r[3].y);const o=new t.LatheBufferGeometry(s.extractPoints(n).shape,i);return o.rotateZ(Math.PI),Object.assign(o,{userData:Object.assign(Object.assign({},e),{type:"LatheGeometry"})})}},NonParametricGeometry:Be,PolygonGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:3},e.parameters);return{shape:new R,parameters:Object.assign(s,{surfaceMaxCount:(null!==(i=s.surfaceMaxCount)&&void 0!==i?i:s.cornerRadius>0)?1e3:100,width:Math.abs(s.width),height:Math.abs(null!==(n=s.height)&&void 0!==n?n:s.width)})}}static build(e){const{width:t,height:r,spikes:i,cornerRadius:n,extrudeDepth:s,extrudeBevelSize:o,extrudeBevelSegments:a,surfaceMaxCount:l}=e.parameters,c=e.shape,h=.5*t,u=.5*r,d=2*Math.PI/i;for(let e=0;e<i;e++){const t=d*e,r=0+Math.sin(t)*h,i=0+Math.cos(t)*u;c.addPoint(c.createPoint(r,i))}c.isClosed=!0;for(let e=0,t=c.points.length;e<t;e++)c.points[e].roundness=n;c.roundness=n,c.update();const p=ce.create({shape:c,parameters:{surfaceMaxCount:l,roundness:n,extrudeDepth:s,extrudeBevelSize:o,extrudeBevelSegments:a}});return Object.assign(p,{userData:Object.assign(Object.assign({},e),{type:"PolygonGeometry"})})}},PyramidGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,radialSegments:4,heightSegments:1,cornerRadius:0,cornerSegments:8,openEnded:!1},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{width:t,height:r,depth:i,radialSegments:n,heightSegments:s,openEnded:o,cornerRadius:a,cornerSegments:l}=e.parameters,c=new Fe(.5*t,r,n,s,o,a,l);return c.scale(1,1,i/t),Object.assign(c,{userData:Object.assign(Object.assign({},e),{type:"PyramidGeometry"})})}},RectangleGeometry:Ue,SphereGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,widthSegments:64,heightSegments:64,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:s.width)})}}static build(e){const{width:r=100,height:i=r,depth:n=r,widthSegments:s=64,heightSegments:o=64,phiStart:a,phiLength:l,thetaStart:c,thetaLength:h}=e.parameters,u=new t.SphereBufferGeometry(.5*r,s,o,a,l,c,h);return u.scale(1,i/r,n/r),Object.assign(u,{userData:Object.assign(Object.assign({},e),{type:"SphereGeometry"})})}},StarGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0,innerRadiusPercent:38.19,spikes:5,cornerRadius:0,angle:360,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1},e.parameters);return{shape:new R,parameters:Object.assign(s,{surfaceMaxCount:(null!==(i=s.surfaceMaxCount)&&void 0!==i?i:s.cornerRadius>0)?1e3:100,width:Math.abs(s.width),height:Math.abs(null!==(n=s.height)&&void 0!==n?n:s.width)})}}static build(e){const{width:t,height:r,innerRadiusPercent:i,spikes:n,cornerRadius:s,angle:o,extrudeDepth:a,extrudeBevelSize:l,extrudeBevelSegments:c,surfaceMaxCount:h}=e.parameters,u=e.shape,d=.5*t,p=.5*r;let f=o*Math.PI/360/n,m=Math.PI/2*3*-1;const g=d*i/100,v=p*i/100;if(3==n&&50==i){f=2*Math.PI/n;for(let e=0;e<n;e++){const t=f*e,r=0+Math.sin(t)*d,i=0+Math.cos(t)*p;u.addPoint(u.createPoint(r,i))}}else for(let e=0;e<n;e++){let e=0+Math.cos(m)*d,t=0+Math.sin(m)*p;u.addPoint(u.createPoint(e,t)),m+=f,e=0+Math.cos(m)*g,t=0+Math.sin(m)*v,u.addPoint(u.createPoint(e,t)),m+=f}u.isClosed=!0;for(let e=0,t=u.points.length;e<t;e++)u.points[e].roundness=s;u.roundness=s,u.update();const y=ce.create({shape:u,parameters:{surfaceMaxCount:h,roundness:s,extrudeDepth:a,extrudeBevelSize:l,extrudeBevelSegments:c}});return Object.assign(y,{userData:Object.assign(Object.assign({},e),{type:"StarGeometry"})})}},TextFrameGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:0)})}}static build(e){const{width:r,height:i}=e.parameters,n=new t.PlaneBufferGeometry(r,i);return Object.assign(n,{userData:Object.assign(Object.assign({},e),{type:"TextFrameGeometry"})})}},TorusGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,radialSegments:64,tubularSegments:64,arc:2*Math.PI,cornerRadius:30,cornerSegments:8},e.parameters),o=Math.abs(s.width),a=Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),l=Math.abs(null!==(n=s.depth)&&void 0!==n?n:.25*s.width);return{parameters:Object.assign(s,{width:o,height:a,depth:l})}}static build(e){const{width:t,height:r,depth:i,radialSegments:n,tubularSegments:s,arc:o,cornerRadius:a,cornerSegments:l}=e.parameters,c=function(e,t,r,i,n,s,o,a,l,c,h){[t,r]=[r,t],o=t/2,1==(n/=2*Math.PI)&&(c=0);return new ve(!0,e,t,r,i,n,s,o,a,l,c,h)}(t,r,i,.5*t,o,s,0,0,n,a,l);return c.scale(1,r/t,1),Object.assign(c,{userData:Object.assign(Object.assign({},e),{type:"TorusGeometry"})})}},TorusKnotGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:1,tube:50,tubularSegments:64,radialSegments:32,p:2,q:3},e.parameters);return{parameters:Object.assign(s,{width:Math.abs(s.width),height:Math.abs(null!==(i=s.height)&&void 0!==i?i:s.width),depth:Math.abs(null!==(n=s.depth)&&void 0!==n?n:1)})}}static build(e){const{width:r,tube:i,tubularSegments:n,radialSegments:s,p:o,q:a}=e.parameters,l=.5*r-i,c=new t.TorusKnotBufferGeometry(l,i,n,s,o,a);return Object.assign(c,{userData:Object.assign(Object.assign({},e),{type:"TorusKnotGeometry"})})}},TriangleGeometry:class{static create(e){return this.build(this.normalizeInputs(e))}static normalizeInputs(e,t){var r,i,n;const s=Object.assign({},null!==(r=null==t?void 0:t.parameters)&&void 0!==r?r:{width:100,depth:0,spikes:5,cornerRadius:0,extrudeDepth:0,extrudeBevelSize:0,extrudeBevelSegments:1,isRect:!1},e.parameters);return{shape:new R,parameters:Object.assign(s,{surfaceMaxCount:(null!==(i=s.surfaceMaxCount)&&void 0!==i?i:s.cornerRadius>0)?1e3:100,width:Math.abs(s.width),height:Math.abs(null!==(n=s.height)&&void 0!==n?n:s.width*(s.isRect?1:Math.sqrt(3)/2))})}}static build(e){const{width:t=100,height:r,cornerRadius:i,extrudeDepth:n,extrudeBevelSize:s,extrudeBevelSegments:o,isRect:a,surfaceMaxCount:l}=e.parameters,c=e.shape,h=.5*t,u=.5*r;a?(c.addPoint(c.createPoint(-h,u)),c.addPoint(c.createPoint(h,-u)),c.addPoint(c.createPoint(-h,-u))):(c.addPoint(c.createPoint(0,u)),c.addPoint(c.createPoint(h,-u)),c.addPoint(c.createPoint(-h,-u))),c.isClosed=!0;for(let e=0,t=c.points.length;e<t;e++)c.points[e].roundness=i;c.roundness=i,c.update();const d=ce.create({shape:c,parameters:{surfaceMaxCount:l,roundness:i,extrudeDepth:n,extrudeBevelSize:s,extrudeBevelSegments:o}});return Object.assign(d,{userData:Object.assign(Object.assign({},e),{type:"TriangleGeometry"})})}},VectorGeometry:ce,SubdivGeometry:We}),Ke=e=>Xe[e.type].create(e),qe=e=>"isEntity"in e,Ze=e=>"isAbstractMesh"in e,$e=e=>"objectHelper"in e,et=new t.Box3,tt=new t.Vector3,rt=new t.Vector3,it=new t.Matrix4;const nt=(e,r,i,n)=>{var s,o;if(Ze(e)){const t=e.geometry.userData.parameters,r=e.geometry.getAttribute("position");"SubdivGeometry"===e.geometry.userData.type?tt.copy((null!==(s=e.geometry.originalGeometry)&&void 0!==s?s:e.geometry).boundingSphere.center):(!function(e,t,r=0,i=t.count){let n=1/0,s=1/0,o=1/0,a=-1/0,l=-1/0,c=-1/0;for(let e=r;e<i;e++){const r=t.getX(e),i=t.getY(e),h=t.getZ(e);r<n&&(n=r),i<s&&(s=i),h<o&&(o=h),r>a&&(a=r),i>l&&(l=i),h>c&&(c=h)}e.min.set(n,s,o),e.max.set(a,l,c)}(et,r,e.geometry.drawRange.start,e.geometry.drawRange.count<1/0?e.geometry.drawRange.count:r.count),et.getCenter(tt)),e.forceComputeSize?et.getSize(rt).multiplyScalar(.5):rt.set(t.width,t.height,null!==(o=t.depth)&&void 0!==o?o:0).multiplyScalar(.5)}else if($e(e)&&!0===n){const t=e.geometryHelper.getAttribute("position");et.setFromArray(t.array),et.getCenter(tt),et.getSize(rt).multiplyScalar(.5)}else tt.setScalar(0),rt.setScalar(0);it.copy(r).multiply(e.matrixWorld),0===rt.x&&0===rt.y&&0===rt.z?i.push(new t.Vector3(tt.x,tt.y,tt.z).applyMatrix4(it)):i.push(new t.Vector3(-rt.x,rt.y,rt.z).add(tt).applyMatrix4(it),new t.Vector3(-rt.x,-rt.y,rt.z).add(tt).applyMatrix4(it),new t.Vector3(rt.x,-rt.y,rt.z).add(tt).applyMatrix4(it),new t.Vector3(rt.x,rt.y,rt.z).add(tt).applyMatrix4(it),new t.Vector3(-rt.x,rt.y,-rt.z).add(tt).applyMatrix4(it),new t.Vector3(-rt.x,-rt.y,-rt.z).add(tt).applyMatrix4(it),new t.Vector3(rt.x,-rt.y,-rt.z).add(tt).applyMatrix4(it),new t.Vector3(rt.x,rt.y,-rt.z).add(tt).applyMatrix4(it))};class st extends t.Box3{constructor(e,r){super(e,r),this.transform=new t.Matrix4,this.vertices=[],this.faces=[],this.edges=[],this.centerEdges=[]}setFromObjectSize(e,r=!1){e.updateWorldMatrix(!1,!1),this.makeEmpty(),this.transform=e.matrixWorld;const i=(new t.Matrix4).copy(e.matrixWorld).invert();return this.expandByObjectSize(e,i,r)}expandByObjectSize(e,t,r=!1){const i=[];return!0===r?e.traverseEntity((r=>nt(r,t,i,"enableHelper"in e&&e.enableHelper))):nt(e,t,i,"enableHelper"in e&&e.enableHelper),this.setFromPoints(i)}getCenter(e){return(e=super.getCenter(e)).applyMatrix4(this.transform),e}getPositionToCenter(e){return e=super.getCenter(e)}computeVertices(){this.getSize(rt).multiplyScalar(.5),this.getCenter(tt),it.copy(this.transform).setPosition(tt),this.vertices=[new t.Vector3(-rt.x,rt.y,rt.z).applyMatrix4(it),new t.Vector3(-rt.x,-rt.y,rt.z).applyMatrix4(it),new t.Vector3(rt.x,-rt.y,rt.z).applyMatrix4(it),new t.Vector3(rt.x,rt.y,rt.z).applyMatrix4(it),new t.Vector3(-rt.x,rt.y,-rt.z).applyMatrix4(it),new t.Vector3(-rt.x,-rt.y,-rt.z).applyMatrix4(it),new t.Vector3(rt.x,-rt.y,-rt.z).applyMatrix4(it),new t.Vector3(rt.x,rt.y,-rt.z).applyMatrix4(it)]}computeEdges(){this.vertices.length>0&&this.computeVertices(),this.edges=[new t.Line3(this.vertices[0],this.vertices[3]),new t.Line3(this.vertices[1],this.vertices[2]),new t.Line3(this.vertices[5],this.vertices[6]),new t.Line3(this.vertices[4],this.vertices[7]),new t.Line3(this.vertices[0],this.vertices[1]),new t.Line3(this.vertices[3],this.vertices[2]),new t.Line3(this.vertices[7],this.vertices[6]),new t.Line3(this.vertices[4],this.vertices[5]),new t.Line3(this.vertices[0],this.vertices[4]),new t.Line3(this.vertices[1],this.vertices[5]),new t.Line3(this.vertices[2],this.vertices[6]),new t.Line3(this.vertices[3],this.vertices[7])],this.centerEdges=this.edges.map((e=>e.getCenter(new t.Vector3)))}computeFaces(){this.vertices.length>0&&this.computeVertices(),this.faces=[(new t.Vector3).copy(this.vertices[0]).sub(this.vertices[2]).multiplyScalar(.5).add(this.vertices[2]),(new t.Vector3).copy(this.vertices[7]).sub(this.vertices[5]).multiplyScalar(.5).add(this.vertices[5]),(new t.Vector3).copy(this.vertices[4]).sub(this.vertices[1]).multiplyScalar(.5).add(this.vertices[1]),(new t.Vector3).copy(this.vertices[3]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6]),(new t.Vector3).copy(this.vertices[4]).sub(this.vertices[3]).multiplyScalar(.5).add(this.vertices[3]),(new t.Vector3).copy(this.vertices[1]).sub(this.vertices[6]).multiplyScalar(.5).add(this.vertices[6])]}}var ot,at;!function(e){e.POSITION="position",e.LIGHTING="light",e.COLOR="color",e.GRADIENT="gradient",e.NORMAL="normal",e.DEPTH="depth",e.TEXTURE="texture",e.NOISE="noise",e.FRESNEL="fresnel",e.RAINBOW="rainbow",e.POINTS="points",e.MATCAP="matcap",e.LINES="lines",e.DISPLACE="displace"}(ot||(ot={})),function(e){e.POSITION="position",e.LIGHTING="light",e.COLOR="color"}(at||(at={}));class lt{constructor(e,t,r){if(this.next=void 0,this.uniforms={},this.textures={},this.defines={},this.backLayer=void 0,this.isBack=!1,this.id=e,t){this.type=t.type;for(const e in t)"type"!==e&&"calpha"!==e&&(this.uniforms[`f${this.id}_${e}`]=t[e]);for(const e in r)this.defines[e]=r[e]}}copy(e){this.id=e.id,this.type=e.type,this.defines=Object.assign({},e.defines);for(const t in e.uniforms)this.uniforms[t]?this.uniforms[t].copy(e.uniforms[t]):this.uniforms[t]=e.uniforms[t].clone();return this}clone(){return new lt(this.id).copy(this)}fromJSON(e,t){this.id=e.id,this.defines=Object.assign({},e.defines);for(const r in e.uniforms)this.uniforms[r]=t.getNode(e.uniforms[r]);return this}toJSON(e){const t={};for(const r in this.uniforms)t[r]=this.uniforms[r].toJSON(e).uuid;return{id:this.id,type:this.type,defines:JSON.parse(JSON.stringify(this.defines)),uniforms:t,next:null==this.next?void 0:this.next.toJSON(e)}}copyUniforms(e){for(const t in this.uniforms){const r=this.getName(t);void 0!==r&&this.uniforms[t].copy(e.uniforms[`f${e.id}_${r}`])}return this}hasValueByKey(e){return void 0!==this.uniforms[e]}hasValue(e){return this.hasValueByKey(`f${this.id}_${e}`)}setValue(e,t){const r=`f${this.id}_${e}`;this.hasValueByKey(r)&&void 0!==t&&(this.uniforms[r].value=t)}getValue(e){const t=`f${this.id}_${e}`;if(this.hasValueByKey(t))return this.uniforms[t].value}getValues(){const e={type:this.type};for(const t in this.uniforms){const r=this.getName(t);if(void 0===r)continue;const i=this.uniforms[`f${this.id}_${r}`].value;void 0!==i&&(e[r]=i.clone?i.clone():i)}return e}getName(e){const t=/f\d+_(.*)/.exec(e);if(t&&t.length>1)return t[1];console.log(`Layer.getName: error ${e}`)}getNames(){const e=[];for(const t in this.uniforms){const r=this.getName(t);r&&e.push(r)}return e}isEqual(e){for(const r in e.uniforms){const i=e.getName(r);if(!i)return!1;const n=this.getValue(i),s=e.uniforms[r].value;if(s.value instanceof t.Texture){if(n.image!==s.image)return!1}else if(Array.isArray(s)){const e=n;for(let t=0,r=e.length;t<r;++t)if(e[t]!==s[t])return!1}else{const e=n;if(e.equals){if(!e.equals(s))return!1}else if(n!==s)return!1}}return!0}dispose(){}}const ct=function(e,t){const r=e.id,i=e.type;return new lt(r,{type:i}).fromJSON(e,t)};function ht(e){const t=e instanceof lt?e.type:e;return"texture"===t||"displace_map"===t||"matcap"===t}class ut{constructor(e){this.hashProperties=void 0,this.isNode=!0,this.shortcuts={},this.uuid=t.MathUtils.generateUUID(),this.type=e,this.name="",this.userData={}}analyze(e,t){t=null!=t?t:{},e.analyzing=!0,this.build(e.addFlow(t.slot,t.cache,t.context),"v4"),e.clearVertexNodeCode(),e.clearFragmentNodeCode(),e.removeFlow(),e.analyzing=!1}analyzeAndFlow(e,t,r){return r=null!=r?r:{},this.analyze(e,r),this.flow(e,t,r)}flow(e,t,r){r=null!=r?r:{},e.addFlow(r.slot,r.cache,r.context);const i={result:this.build(e,t),code:e.clearNodeCode(),extra:e.context.extra};return e.removeFlow(),i}build(e,t,r){t=null!=t?t:this.getType(e,t);const i=e.getNodeData(null!=r?r:this);return e.analyzing&&this.appendDepsNode(e,i,t),-1===e.nodes.indexOf(this)&&e.nodes.push(this),void 0!==this.updateFrame&&-1===e.updaters.indexOf(this)&&e.updaters.push(this),this.generate(e,t,r)}updateFrame(e){}generateReadonly(e,t,r,i,n,s){return""}generate(e,t,r,i,n){return""}parse(e,t,r,i){}appendDepsNode(e,t,r){t.deps=(t.deps||0)+1;const i=e.getTypeLength(r);(i>(t.outputMax||0)||this.getType(e,r))&&(t.outputMax=i,t.output=r)}setName(e){this.name=e}getName(){return this.name}getType(e,t){return"sampler2D"===t||"samplerCube"===t?t:this.type}getJSONNode(e){if((null==e?void 0:e.materials)&&void 0!==(null==e?void 0:e.materials[this.uuid]))return e.materials[this.uuid]}getHash(){let e,t,r="{";for(e in this)t=this[e],t instanceof ut&&(r+='"'+e+'":'+t.getHash()+",");if(this.hashProperties)for(let i=0;i<this.hashProperties.length;i++)e=this.hashProperties[i],t=this[e],r+='"'+e+'":"'+String(t)+'",';return r+='"id":"'+this.uuid+'"}',r}copy(e){return this.name=e.name,e.type&&(this.type=e.type),e.frameId&&(this.frameId=e.frameId),e.hashProperties&&(this.hashProperties=e.hashProperties.map((e=>e))),this.userData=JSON.parse(JSON.stringify(e.userData)),this.shortcuts=JSON.parse(JSON.stringify(e.shortcuts)),this}clone(){return(new this.constructor).copy(this)}createJSONNode(e){const t=void 0===e||"string"==typeof e;if("string"!=typeof this.type)throw new Error("Node does not allow serialization.");const r={};return r.uuid=this.uuid,r.type=this.type,""!==this.name&&(r.name=this.name),"{}"!==JSON.stringify(this.userData)&&(r.userData=this.userData),!t&&e&&(e.nodes[this.uuid]=r),r}toJSON(e){var t;return null!==(t=this.getJSONNode(e))&&void 0!==t?t:this.createJSONNode(e)}fromJSON(e,t){return this.uuid=e.uuid,this.type=e.type,e.name&&(this.name=e.name),e.userData&&(this.userData=e.userData),this}}class dt extends ut{constructor(e,t){super(e),this.scope="",t=null!=t?t:{},this.shared=void 0===t.shared||t.shared,this.unique=void 0!==t.unique&&t.unique}build(e,r,i,n){if(r=null!=r?r:this.getType(e),this.getShared(e,r)){const s=this.getUnique(e,r);s&&void 0===this.uuid&&(this.uuid=t.MathUtils.generateUUID()),i=e.getUUID(null!=i?i:this.getUUID(),!s);const o=e.getNodeData(i),a=o.output||this.getType(e);if(e.analyzing)return(o.deps||0)>0||this.getLabel()?(this.appendDepsNode(e,o,r),this.generate(e,r,i)):super.build(e,r,i);if(s)return o.name=o.name||super.build(e,r,i),o.name;if(!this.getLabel()&&(!this.getShared(e,a)||e.context.ignoreCache||1===o.deps))return super.build(e,r,i);i=this.getUUID(!1);let l=this.getTemp(e,i);if(l)return e.format(l,a,r);{l=super.generate(e,r,i,o.output,n);const t=this.generate(e,a,i);return e.addNodeCode(l+" = "+t+";"),e.format(l,a,r)}}return super.build(e,r,i)}getShared(e,t){return"sampler2D"!==t&&"samplerCube"!==t&&this.shared}getUnique(e,t){return this.unique}setLabel(e){return this.label=e,this}getLabel(){return this.label}getUUID(e){let t=this.uuid;return"string"==typeof this.scope&&(t=this.scope+"-"+t),t}getTemp(e,t){t=t||this.uuid;const r=e.getVars()[t];return r?r.name:void 0}generate(e,t,r,i,n){return this.getShared(e,t)||console.error("TempNode is not shared"),r=null!=r?r:this.uuid,e.getTempVar(r,null!=i?i:this.getType(e),n,this.getLabel()).name}}class pt extends dt{constructor(e,t){(t=null!=t?t:{}).shared=void 0!==t.shared&&t.shared,super(e,t),this.readonly=!1}setReadonly(e){return this.readonly=e,this.hashProperties=this.readonly?["value"]:void 0,this}getReadonly(){return this.readonly}createJSONNode(e){const t=super.createJSONNode(e);return!0===this.readonly&&(t.readonly=this.readonly),t}fromJSON(e,t){return super.fromJSON(e,t),void 0!==e.readonly&&this.setReadonly(e.readonly),this}generate(e,t,r,i,n,s){r=e.getUUID(null!=r?r:this.getUUID()),i=null!=i?i:this.getType(e);const o=e.getNodeData(r);return this.getReadonly()&&void 0!==this.generateReadonly?this.generateReadonly(e,t,r,i,n,s):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,n,s,this.getLabel())),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,n,s,this.getLabel())),e.format(o.fragment.name,i,t))}copy(e){return super.copy(e),this.readonly=e.readonly,this}}const ft={elements:["x","y","z","w"],addShortcuts:function(){function e(e,t,r){return r?{get:function(){return this[e][t][r]},set:function(i){this[e][t][r]=i}}:{get:function(){return this[e][t]},set:function(r){this[e][t]=r}}}return function(t,r,i){const n={};for(let t=0;t<i.length;++t){const s=i[t].split("."),o=s[0],a=s[1];n[o]=e(r,o,a)}Object.defineProperties(t,n)}}()};class mt extends pt{constructor(e=0,r,i){super("c"),this.nodeType="Color",this.value=e instanceof t.Color?e:new t.Color(e||0,r,i)}generate(e,t,r,i,n,s){r=e.getUUID(null!=r?r:this.getUUID()),i=null!=i?i:this.getType(e);const o=e.getNodeData(r),a=this.getReadonly()&&void 0!==this.generateReadonly;if(this.alpha){const t=this.alpha.build(e,"f");e.addFragmentNodeCode(`accumAlpha += ( 1.0 - accumAlpha ) * ${t};`)}return a?this.generateReadonly(e,t,r,i,n,s):e.isShader("vertex")?(o.vertex||(o.vertex=e.createVertexUniform(i,this,n,s,this.getLabel())),e.format(o.vertex.name,i,t)):(o.fragment||(o.fragment=e.createFragmentUniform(i,this,n,s,this.getLabel())),e.format(o.fragment.name,i,t))}generateReadonly(e,t,r,i,n,s){return e.format("vec3("+this.value.r+", "+this.value.g+", "+this.value.b+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.alpha?this.alpha?this.alpha.copy(e.alpha):this.alpha=e.alpha.clone():this.alpha=void 0,this}toJSON(e){var t;let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),r.r=this.value.r,r.g=this.value.g,r.b=this.value.b,r.value=this.value.getHex(),r.alpha=null===(t=this.alpha)||void 0===t?void 0:t.toJSON(e),!0===this.readonly&&(r.readonly=!0)),r.nodeType=this.nodeType,this.alpha&&(r.alpha=this.alpha.uuid),r}fromJSON(e,r){return super.fromJSON(e,r),e.value&&(this.value=new t.Color(e.value)),e.alpha&&(this.alpha=r.getNode(e.alpha)),this}}ft.addShortcuts(mt.prototype,"value",["r","g","b"]);class gt extends pt{constructor(e){super("f"),this.nodeType="Float",this.value=null!=e?e:0}generateReadonly(e,t,r,i,n,s){return e.format(this.value+(this.value%1?"":".0"),i,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,!0===this.getReadonly()&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}}class vt extends pt{constructor(e){super("i"),this.nodeType="Int",this.value=Math.floor(null!=e?e:0)}generateReadonly(e,t,r,i,n,s){return e.format(this.value.toString(),i,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,!0===this.getReadonly()&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}}class yt extends pt{constructor(e){super("b"),this.nodeType="Bool",this.value=null!=e&&e}generateReadonly(e,t,r,i){return e.format(this.value?"true":"false",i,t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value,!0===this.getReadonly()&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}}class At extends pt{constructor(e=0,r){super("v2"),this.nodeType="Vector2",this.value=e instanceof t.Vector2?e:new t.Vector2(e,r)}generateReadonly(e,t,r,i,n,s){return e.format("vec2("+this.value.x+", "+this.value.y+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,!0===this.getReadonly()&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),this}}ft.addShortcuts(At.prototype,"value",["x","y"]);class wt extends pt{constructor(e=0,r,i){super("v3"),this.nodeType="Vector3",this.value=e instanceof t.Vector3?e:new t.Vector3(e,r,i)}generateReadonly(e,t,r,i,n,s){return e.format("vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,t.z=this.value.z,!0===this.getReadonly()&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),e.z&&(this.value.z=e.z),this}}ft.addShortcuts(wt.prototype,"value",["x","y","z"]);class xt extends pt{constructor(e=1,r){super("v4[]"),this.nodeType="Vector4Array",this.size=e,this.value=Array.isArray(r)?r:r instanceof t.Vector4?new Array(e).fill(r):new Array(e).fill(new t.Vector4(0))}copy(e){return super.copy(e),this.value=e.value.map((e=>e.clone())),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.map((e=>({x:e.x,y:e.y,z:e.z,w:e.w})))),t.nodeType=this.nodeType,t}fromJSON(e,r){return super.fromJSON(e,r),e.value&&(this.value=e.value.map((e=>new t.Vector4(e.x,e.y,e.z,e.w))),this.size=this.value.length),this}}class bt extends pt{constructor(e=1,t){super("f[]"),this.nodeType="FloatArray",this.size=e,this.value=Array.isArray(t)?t:"number"==typeof t?new Array(e).fill(t):new Array(e).fill(0)}copy(e){return super.copy(e),this.size=e.size,this.value=[...e.value],this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.size=this.size,t.value=[...this.value]),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=[...e.value]),e.size?this.size=e.size:e.value&&(this.size=this.value.length),this}}const St=new class{constructor(){this.nodes={},this.keywords={}}add(e){this.nodes[e.name]=e}addKeyword(e,t,r){r=void 0===r||r,this.keywords[e]={callback:t,cache:r}}remove(e){delete this.nodes[e.name]}removeKeyword(e){delete this.keywords[e]}get(e){return this.nodes[e]}getKeyword(e,t){return this.keywords[e].callback(t)}getKeywordData(e){return this.keywords[e]}contains(e){return void 0!==this.nodes[e]}containsKeyword(e){return void 0!==this.keywords[e]}};class Et extends dt{constructor(e){super("v2",{shared:!1}),this.nodeType="UV",this.index=null!=e?e:0}generate(e,t){e.requires.uv[this.index]=!0;const r=this.index>0?this.index+1:"",i=e.isShader("vertex")?"uv"+r:"vUv"+r;return e.format(i,this.getType(e),t)}copy(e){return super.copy(e),this.index=e.index,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.index=this.index),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.index&&(this.index=e.index),this}}St.addKeyword("uv",(function(){return new Et})),St.addKeyword("uv2",(function(){return new Et(1)}));const Ct=/^\s*([a-z_0-9]+)\s([a-z_0-9]+)\s*\((.*?)\)/i,Tt=/[a-z_0-9]+/gi;class Ot extends dt{constructor(e,t,r,i,n){super(n),this.src="",this.nodeType="Function",this.useKeywords=!0,this.includes=[],this.extensions={},this.keywords={},this.isMethod=void 0===n,this.isInterface=!1,this.parse(e,t,r,i)}getShared(e,t){return!this.isMethod}getType(e){return e.getTypeByFormat(this.type)}getInputByName(e){if(this.inputs){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}}getIncludeByName(e){if(this.includes){let t=this.includes.length;for(;t--;)if(this.includes[t].name===e)return this.includes[t]}}generate(e,t,r,i,n){let s,o=0,a=this.src;if(this.includes)for(let t=0;t<this.includes.length;t++)e.include(this.includes[t],this);for(const t in this.extensions)e.extensions[t]=!0;const l=[];for(;s=Tt.exec(this.src);)l.push(s);for(let t=0;t<l.length;t++){const r=l[t],i=r[0],n=!this.isMethod||!this.getInputByName(i);let s=i;if(this.keywords[i]||this.useKeywords&&n&&St.containsKeyword(i)){let t=this.keywords[i];if(!t){const r=St.getKeywordData(i);r.cache&&(t=e.keywords[i]),t=t||St.getKeyword(i,e),r.cache&&(e.keywords[i]=t)}s=t.build(e)}i!==s&&(a=a.substring(0,r.index+o)+s+a.substring(r.index+i.length+o),o+=s.length-i.length),void 0===this.getIncludeByName(s)&&St.contains(s)&&e.include(St.get(s))}return"source"===t?a:this.isMethod?(this.isInterface||e.include(this,void 0,a),this.name):e.format("( "+a+" )",this.getType(e),t)}parse(e,t,r,i){if(this.src=e||"",this.includes=null!=t?t:[],this.extensions=null!=r?r:{},this.keywords=null!=i?i:{},this.isMethod){const e=Ct.exec(this.src);if(this.inputs=[],e&&4==e.length){this.type=e[1],this.name=e[2];const t=e[3].match(Tt);if(t){let e=0;for(;e<t.length;){let r,i=t[e++];"in"===i||"out"===i||"inout"===i?r=t[e++]:(r=i,i="");const n=t[e++];this.inputs.push({name:n,type:r,qualifier:i})}}this.isInterface=-1===this.src.indexOf("{")}else this.type="",this.name=""}}copy(e){return super.copy(e),this.isMethod=e.isMethod,this.useKeywords=e.useKeywords,void 0!==e.type&&(this.type=e.type),this.parse(e.src,e.includes,e.extensions,e.keywords),this}toJSON(e){var t;let r=this.getJSONNode(e);if(!r){r=this.createJSONNode(e),r.src=this.src,r.isMethod=this.isMethod,r.useKeywords=this.useKeywords,this.isMethod||(r.type=this.type),r.extensions=JSON.parse(JSON.stringify(this.extensions));const i={};for(const t in this.keywords)i[t]=this.keywords[t].toJSON(e).uuid;if(r.keywords=i,null===(t=this.includes)||void 0===t?void 0:t.length){const t=[];for(let r=0;r<this.includes.length;r++)t.push(this.includes[r].toJSON(e).uuid);r.includes=t}r.isMethod=this.isMethod,r.inputs=this.inputs}return r.nodeType=this.nodeType,r}fromJSON(e,t){if(super.fromJSON(e,t),void 0!==e.inputs&&(this.inputs=e.inputs),void 0!==e.isMethod&&(this.isMethod=e.isMethod),e.src&&(this.src=e.src),e.isMethod&&(this.isMethod=e.isMethod),e.useKeywords&&(this.useKeywords=e.useKeywords),e.type&&(this.type=e.type),e.extensions&&(this.extensions=e.extensions),e.keywords&&t){this.keywords={};for(const r in e.keywords)this.keywords[r]=t.getNode(e.keywords[r])}return e.includes&&t&&(this.includes=e.includes.map((e=>t.getNode(e)))),this}}const Dt=/^([a-z_0-9]+)\s([a-z_0-9]+)\s?\=?\s?(.*?)(\;|$)/i;class Mt extends dt{constructor(e="",t){super(),this.src="",this.useDefine=!1,this.nodeType="Const",this.parse(e||Mt.PI,void 0,void 0,void 0,t)}getType(e){return e.getTypeByFormat(this.type)}parse(e,t,r,i,n){this.src=e||"";let s,o,a="";const l=Dt.exec(e);this.useDefine=null!=n?n:"#"===this.src.charAt(0),l&&l.length>1?(o=l[1],s=l[2],a=l[3]):(s=this.src,o="f"),this.name=s,this.type=o,this.value=a}build(e,t){if("source"===t){if(this.value)return this.useDefine?"#define "+this.name+" "+this.value:"const "+this.type+" "+this.name+" = "+this.value+";";if(this.useDefine)return this.src}return e.include(this),e.format(this.name,this.getType(e),t)}generate(e,t,r,i,n){return e.format(this.name,this.getType(e),t)}copy(e){return super.copy(e),this.parse(e.src,void 0,void 0,void 0,e.useDefine),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src,t.useDefine=this.useDefine,t.value=this.value,t.name=this.name),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.src&&(this.src=e.src),e.value&&(this.value=e.value),e.name&&(this.name=e.name),void 0!==e.useDefine&&(this.useDefine=e.useDefine),this}}Mt.PI="PI",Mt.PI2="PI2",Mt.RECIPROCAL_PI="RECIPROCAL_PI",Mt.RECIPROCAL_PI2="RECIPROCAL_PI2",Mt.LOG2="LOG2",Mt.EPSILON="EPSILON";class _t extends Ot{constructor(e="",t,r,i,n){super(e,n,i,r,t),this.nodeType="Expression"}}class Nt extends dt{constructor(e=new ut,t){super("v4"),this.nodeType="ColorSpace",this.factor=new ut,this.input=e,this.method=null!=t?t:Nt.LINEAR_TO_LINEAR,this.hashProperties=["method"]}static getEncodingComponents(e){switch(e){case t.LinearEncoding:return["Linear"];case t.sRGBEncoding:return["sRGB"];case t.RGBEEncoding:return["RGBE"];case t.RGBM7Encoding:return["RGBM",new gt(7).setReadonly(!0)];case t.RGBM16Encoding:return["RGBM",new gt(16).setReadonly(!0)];case t.RGBDEncoding:return["RGBD",new gt(256).setReadonly(!0)];case t.GammaEncoding:return["Gamma",new _t("float( GAMMA_FACTOR )","f")];default:return[]}}generate(e,t){const r=this.input.build(e,"v4"),i=this.getType(e),n=Nt.Nodes[this.method],s=e.include(n);if(s===Nt.LINEAR_TO_LINEAR)return e.format(r,i,t);if(2===n.inputs.length){const n=this.factor.build(e,"f");return e.format(s+"( "+r+", "+n+" )",i,t)}return e.format(s+"( "+r+" )",i,t)}fromEncoding(e){const t=Nt.getEncodingComponents(e);this.method="LinearTo"+t[0],this.factor=t[1]}fromDecoding(e){const t=Nt.getEncodingComponents(e);this.method=t[0]+"ToLinear",this.factor=t[1]}copy(e){return super.copy(e),this.input.copy(e.input),this.method=e.method,this.factor.copy(e.factor),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.input=this.input.toJSON(e).uuid,t.factor=this.factor.toJSON(e).uuid,t.method=this.method),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.input&&(this.input=t.getNode(e.input)),e.factor&&(this.factor=t.getNode(e.factor)),e.method&&(this.method=e.method),this}}Nt.Nodes={LinearToLinear:new Ot(["vec4 LinearToLinear( in vec4 value ) {","\treturn value;","}"].join("\n")),GammaToLinear:new Ot(["vec4 GammaToLinear( in vec4 value, in float gammaFactor ) {","\treturn vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );","}"].join("\n")),LinearToGamma:new Ot(["vec4 LinearToGamma( in vec4 value, in float gammaFactor ) {","\treturn vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );","}"].join("\n")),sRGBToLinear:new Ot(["vec4 sRGBToLinear( in vec4 value ) {","\treturn 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.w );","}"].join("\n")),LinearTosRGB:new Ot(["vec4 LinearTosRGB( in vec4 value ) {","\treturn 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.w );","}"].join("\n")),RGBEToLinear:new Ot(["vec4 RGBEToLinear( in vec4 value ) {","\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );","}"].join("\n")),LinearToRGBE:new Ot(["vec4 LinearToRGBE( in vec4 value ) {","\tfloat maxComponent = max( max( value.r, value.g ), value.b );","\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );","\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );","}"].join("\n")),RGBMToLinear:new Ot(["vec3 RGBMToLinear( in vec4 value, in float maxRange ) {","\treturn vec4( value.xyz * value.w * maxRange, 1.0 );","}"].join("\n")),LinearToRGBM:new Ot(["vec3 LinearToRGBM( in vec4 value, in float maxRange ) {","\tfloat maxRGB = max( value.x, max( value.g, value.b ) );","\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );","\tM = ceil( M * 255.0 ) / 255.0;","\treturn vec4( value.rgb / ( M * maxRange ), M );","}"].join("\n")),RGBDToLinear:new Ot(["vec3 RGBDToLinear( in vec4 value, in float maxRange ) {","\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );","}"].join("\n")),LinearToRGBD:new Ot(["vec3 LinearToRGBD( in vec4 value, in float maxRange ) {","\tfloat maxRGB = max( value.x, max( value.g, value.b ) );","\tfloat D = max( maxRange / maxRGB, 1.0 );","\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );","\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );","}"].join("\n")),cLogLuvM:new Mt("const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );"),LinearToLogLuv:new Ot(["vec4 LinearToLogLuv( in vec4 value ) {","\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;","\tXp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));","\tvec4 vResult;","\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;","\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;","\tvResult.w = fract(Le);","\tvResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;","\treturn vResult;","}"].join("\n"),[new Mt("const mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );")]),cLogLuvInverseM:new Mt("const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );"),LogLuvToLinear:new Ot(["vec4 LogLuvToLinear( in vec4 value ) {","\tfloat Le = value.z * 255.0 + value.w;","\tvec3 Xp_Y_XYZp;","\tXp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);","\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;","\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;","\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;","\treturn vec4( max(vRGB, 0.0), 1.0 );","}"].join("\n"),[new Mt("const mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );")])},Nt.LINEAR_TO_LINEAR="LinearToLinear",Nt.GAMMA_TO_LINEAR="GammaToLinear",Nt.LINEAR_TO_GAMMA="LinearToGamma",Nt.SRGB_TO_LINEAR="sRGBToLinear",Nt.LINEAR_TO_SRGB="LinearTosRGB",Nt.RGBE_TO_LINEAR="RGBEToLinear",Nt.LINEAR_TO_RGBE="LinearToRGBE",Nt.RGBM_TO_LINEAR="RGBMToLinear",Nt.LINEAR_TO_RGBM="LinearToRGBM",Nt.RGBD_TO_LINEAR="RGBDToLinear",Nt.LINEAR_TO_RGBD="LinearToRGBD",Nt.LINEAR_TO_LOG_LUV="LinearToLogLuv",Nt.LOG_LUV_TO_LINEAR="LogLuvToLinear";class Lt extends t.Texture{toJSON(e){const t=super.toJSON(e),r=void 0===e||"string"==typeof e;if(void 0!==this.image&&!r){const t=this.image;if(Array.isArray(t)){e.images[t.uuid].url=[];for(let r=0;r<t.length;r++)e.images[t.uuid].url[r]=Bt(t[r])}else e.images[t.uuid].url=Bt(t)}return t}}function Bt(e){return"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?function(e){if(/^data:/i.test(e.src))return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===It&&(It=document.createElement("canvas")),It.width=e.width,It.height=e.height;const r=It.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=It}return/\.jpe?g$/i.test(e.src)?t.toDataURL("image/jpeg",.6):t.toDataURL("image/png")}(e):(console.warn("THREE.Texture: Unable to serialize Texture."),"")}let It;class Pt extends pt{constructor(e=new Lt,t,r,i){super("v4",{shared:!0}),this.nodeType="Texture",this.value=e,this.uv=null!=t?t:new Et,this.bias=r,this.project=void 0!==i&&i}getTexture(e,t){return super.generate(e,t,this.value.uuid,"t")}generate(e,t){var r;if("sampler2D"===t)return this.getTexture(e,t);const i=this.getTexture(e,t),n=this.uv.build(e,this.project?"v4":"v2");let s,o,a=this.bias?this.bias.build(e,"f"):void 0;void 0===a&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f")),s=this.project?"texture2DProj":a?"tex2DBias":"tex2D",o=a?s+"( "+i+", "+n+", "+a+" )":s+"( "+i+", "+n+" )";const l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=null!==(r=this.colorSpace)&&void 0!==r?r:new Nt(new _t("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(o),o=this.colorSpace.build(e,c),e.removeContext(),e.format(o,c,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.uv.copy(e.uv),e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,e.colorSpace?this.colorSpace?this.colorSpace.copy(e.colorSpace):this.colorSpace=e.colorSpace.clone():this.colorSpace=void 0,this.project=e.project,this.value.updateMatrix(),this.value.needsUpdate=!0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value.toJSON(e).uuid),t.uv=this.uv.toJSON(e).uuid,t.project=this.project,this.bias&&(t.bias=this.bias.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),this.project=e.project,e.value&&(this.value=t.getTexture(e.value),this.value.updateMatrix()),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),this}}class Rt extends pt{constructor(e){super("m3"),this.nodeType="Matrix3",this.value=null!=e?e:new t.Matrix3}generateReadonly(e,t,r,i,n,s){return e.format("mat3("+this.value.elements.join(", ")+")",i,t)}copy(e){return super.copy(e),this.elements=e.elements,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.elements&&(this.elements=e.elements),this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}}var Ft,Ut;!function(e){e[e.UV=0]="UV",e[e.PLANAR=1]="PLANAR",e[e.SPHERICAL=2]="SPHERICAL",e[e.CYLINDRICAL=3]="CYLINDRICAL"}(Ft||(Ft={}));class zt extends dt{constructor(e=new Pt,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut,o=new ut){super("v3"),this.nodeType="CustomTexture",this.firstTime=!0,this.texture=e,this.textureSize=t,this.crop=r,this.projection=i,this.axis=n,this.mat=new Rt(this.texture.value.matrix),this.alpha=s,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){let r;switch(e.require("position"),e.require("uv"),e.requires.uv=[!0],this.projection.value){case Ft.CYLINDRICAL:r=e.include(zt.Nodes.cylindrical);break;case Ft.SPHERICAL:r=e.include(zt.Nodes.spherical);break;case Ft.PLANAR:const t=new Ot(`\n\t\tvec3 g${this.uuid.toString().replace(/-/g,"")}_planarTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, float alpha, int mode, out float calpha) {\n\n\t\t\t\tvec2 uvs = ( mat * vec3( g${this.uuid.toString().replace(/-/g,"")}_vCustomUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\tvec4 tmp = texture2D( tex, uvs );\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\t\t\t\treturn col;\n\t\t\t}`);r=e.include(t);break;default:r=e.include(zt.Nodes.uv)}if(this.projection.value===Ft.PLANAR&&this.firstTime){const t=`g${this.uuid.toString().replace(/-/g,"")}`;e.addVertexParsCode(`varying vec2 ${t}_vCustomUv;`),e.addFragmentParsCode(`varying vec2 ${t}_vCustomUv;`),e.addVertexFinalCode(`\n vec3 ${t}_posN = normalize(transformed);\n${0===this.axis.value?`\n\t\t\t\t\t\t\t\t\t float ${t}_u = (1. + (${t}_posN.z)) / 2.;\n\t\t\t\t\t\t\t\t\t float ${t}_v = (1. + (${t}_posN.y)) / 2.;\n\t\t\t\t\t\t\t\t\t `:""}\n\n${1===this.axis.value?`\n\t\t\t\t\t\t\t\t\t float ${t}_u = (1. + (${t}_posN.x)) / 2.;\n\t\t\t\t\t\t\t\t\t float ${t}_v = (1. - (${t}_posN.z)) / 2.;\n\t\t\t\t\t\t\t\t\t `:""}\n\n${2===this.axis.value?`\n\t\t\t\t\t\t\t\t\t float ${t}_u = (1. + (${t}_posN.x)) / 2.;\n\t\t\t\t\t\t\t\t\t float ${t}_v = (1. + (${t}_posN.y)) / 2.;\n\t\t\t\t\t\t\t\t\t `:""}\n\n ${t}_vCustomUv = vec2(${t}_u, ${t}_v);\n `)}e.addFragmentVariable(this.calpha,"float");const i=[];return i.push(this.texture.getTexture(e,"t")),i.push(this.textureSize.build(e,"v2")),i.push(this.crop.build(e,"f")),i.push(this.mat.build(e,"mat3")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),this.firstTime=!this.firstTime,e.format(r+"("+i.join(",")+")",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.toJSON(e).uuid,t.textureSize=this.textureSize.toJSON(e).uuid,t.crop=this.crop.toJSON(e).uuid,t.projection=this.projection.toJSON(e).uuid,t.axis=this.axis.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture),this.texture.value.updateMatrix(),this.mat=new Rt(this.texture.value.matrix)),e.textureSize&&(this.textureSize=t.getNode(e.textureSize)),e.crop&&(this.crop=t.getNode(e.crop)),e.projection&&(this.projection=t.getNode(e.projection)),e.axis&&(this.axis=t.getNode(e.axis)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.texture.copy(e.texture),this.textureSize.copy(e.textureSize),this.crop.copy(e.crop),this.projection.copy(e.projection),this.axis.copy(e.axis),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}}zt.Nodes={cylindrical:new Ot("\nvec3 cylindricalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, float alpha, int mode, out float calpha) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float v = (posN.y / 2.) + .5;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\n vec2 df = fwidth(uvs);\n \tif(df.x > 0.5) df.x = 0.;\n vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\t\t\t\treturn col;\n\t\t\t}\n"),spherical:new Ot("\nvec3 sphericalTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, float alpha, int mode, out float calpha) {\n vec3 posN = normalize(vPosition);\n float u = 0.5 + atan(posN.z, posN.x) / (2.*3.1415);\n float v = 0.5 + asin(posN.y) / 3.1415;\n\n vec2 calculatedUv = vec2(u,v);\n\t\t\t\tvec2 uvs = ( mat * vec3( calculatedUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\n vec2 df = fwidth(uvs);\n \tif(df.x > 0.5) df.x = 0.;\n vec4 tmp = textureLod(tex, uvs, log2(max(df.x, df.y)*min(textureSize.x, textureSize.y)));\n\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\t\t\t\treturn col;\n\t\t\t}\n"),uv:new Ot("vec3 uvTexture(sampler2D tex, vec2 textureSize, float crop, mat3 mat, float alpha, int mode, out float calpha) {\n\n\t\t\t\tvec2 uvs = ( mat * vec3( vUv * 2. - 1., 1. ) / 2. + 0.5 ).xy;\n\t\t\t\tvec4 tmp = texture2D( tex, uvs );\n\n\t\t\t\tvec3 col = tmp.rgb;\n\n\t\t\t\tfloat lalpha = alpha * tmp.a;\n\t\t\t\tif ( crop > 0.5 ) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\tlalpha = 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\t\t\t\treturn col;\n\t\t\t}")};class kt extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut,o=new ut){super("v3"),this.nodeType="Fresnel",this.color=e,this.bias=t,this.scale=r,this.intensity=i,this.factor=n,this.alpha=s,this.mode=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.require("vWorldViewDir"),e.require("vWorldNormal"),e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");const r=e.include(kt.Nodes.fresnel),i=[];return i.push(this.color.build(e,"c")),i.push(this.bias.build(e,"f")),i.push(this.scale.build(e,"f")),i.push(this.intensity.build(e,"f")),i.push(this.factor.build(e,"f")),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("FresnelNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.color=this.color.toJSON(e).uuid,t.bias=this.bias.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid,t.intensity=this.intensity.toJSON(e).uuid,t.factor=this.factor.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.color&&(this.color=t.getNode(e.color)),e.bias&&(this.bias=t.getNode(e.bias)),e.scale&&(this.scale=t.getNode(e.scale)),e.intensity&&(this.intensity=t.getNode(e.intensity)),e.factor&&(this.factor=t.getNode(e.factor)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.color.copy(e.color),this.bias.copy(e.bias),this.scale.copy(e.scale),this.intensity.copy(e.intensity),this.factor.copy(e.factor),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this.calpha=e.calpha,this}}kt.Nodes={fresnel:new Ot("vec3 fresnel(vec3 color, float bias, float scale, float intensity, float factor, float alpha, int mode, out float calpha) {\n\t\t\t\tfloat fresnel = bias + scale * pow( abs( factor + dot( normalize( vWorldViewDir ), normalize( vWorldNormal ) ) ), intensity );\n\n\t\t\t\tfloat lalpha = clamp( fresnel, 0.0, 1.0 ) * alpha;\n\t\t\t\tcalpha = lalpha / clamp(lalpha + accumAlpha, 0.001, 1.0);\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * lalpha;\n\t\t\t\treturn color;\n\t\t\t}")},function(e){e.SIMPLEX="simplex3d",e.SIMPLEX_FRACTAL="simplex3dFractal",e.ASHIMA="simplexAshima",e.FBM="fbm",e.PERLIN="perlin"}(Ut||(Ut={}));const Gt=function(){const e=new Ot("vec3 random3(vec3 c) {\n\t\t\tfloat j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0)));\n\t\t\tvec3 r;\n\t\t\tr.z = fract(512.0*j);\n\t\t\tj *= .125;\n\t\t\tr.x = fract(512.0*j);\n\t\t\tj *= .125;\n\t\t\tr.y = fract(512.0*j);\n\t\t\treturn r-0.5;\n\t\t}"),t=new Ot("float simplex3d(vec3 p) {\n\t\t\t vec3 s = floor(p + dot(p, vec3(F3)));\n\t\t\t vec3 x = p - s + dot(s, vec3(G3));\n\t\t\t \n\t\t\t vec3 e = step(vec3(0.0), x - x.yzx);\n\t\t\t vec3 i1 = e*(1.0 - e.zxy);\n\t\t\t vec3 i2 = 1.0 - e.zxy*(1.0 - e);\n\t\t\t\t\n\t\t\t vec3 x1 = x - i1 + G3;\n\t\t\t vec3 x2 = x - i2 + 2.0*G3;\n\t\t\t vec3 x3 = x - 1.0 + 3.0*G3;\n\t\t\t \n\t\t\t vec4 w, d;\n\t\t\t \n\t\t\t w.x = dot(x, x);\n\t\t\t w.y = dot(x1, x1);\n\t\t\t w.z = dot(x2, x2);\n\t\t\t w.w = dot(x3, x3);\n\t\t\t \n\t\t\t w = max(0.6 - w, 0.0);\n\t\t\t \n\t\t\t d.x = dot(random3(s), x);\n\t\t\t d.y = dot(random3(s + i1), x1);\n\t\t\t d.z = dot(random3(s + i2), x2);\n\t\t\t d.w = dot(random3(s + 1.0), x3);\n\t\t\t \n\t\t\t w *= w;\n\t\t\t w *= w;\n\t\t\t d *= w;\n\t\t\t \n\t\t\t return dot(d, vec4(52.0));\n\t\t}",[e]);t.keywords.F3=new Mt("float F3 0.3333333"),t.keywords.G3=new Mt("float G3 0.1666667");const r=new Ot("float simplex3dFractal(vec3 m) {\n\t\t\tmat3 rot1 = mat3(-0.37, 0.36, 0.85,-0.14,-0.93, 0.34,0.92, 0.01,0.4);\n\t\t\tmat3 rot2 = mat3(-0.55,-0.39, 0.74, 0.33,-0.91,-0.24,0.77, 0.12,0.63);\n\t\t\tmat3 rot3 = mat3(-0.71, 0.52,-0.47,-0.08,-0.72,-0.68,-0.7,-0.45,0.56);\n\t\t\treturn 0.5333333 * simplex3d(m * rot1)\n\t\t\t\t + 0.2666667 * simplex3d(2.0 * m * rot2)\n\t\t\t\t + 0.1333333 * simplex3d(4.0 * m * rot3)\n\t\t\t\t + 0.0666667 * simplex3d(8.0 * m);\n\t\t}",[t]),i=new Ot("vec4 permute(vec4 x){return mod(((x*34.0)+1.0)*x, 289.0);}"),n=new Ot("vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}"),s=new Ot("float simplexAshima(vec3 v) {\n\t\t const vec2 C = vec2(1.0/6.0, 1.0/3.0) ;\n\t\t const vec4 D = vec4(0.0, 0.5, 1.0, 2.0);\n\t\t vec3 i = floor(v + dot(v, C.yyy) );\n\t\t vec3 x0 = v - i + dot(i, C.xxx) ;\n\t\t vec3 g = step(x0.yzx, x0.xyz);\n\t\t vec3 l = 1.0 - g;\n\t\t vec3 i1 = min( g.xyz, l.zxy );\n\t\t vec3 i2 = max( g.xyz, l.zxy );\n\t\t vec3 x1 = x0 - i1 + 1.0 * C.xxx;\n\t\t vec3 x2 = x0 - i2 + 2.0 * C.xxx;\n\t\t vec3 x3 = x0 - 1. + 3.0 * C.xxx;\n\t\t i = mod(i, 289.0 ); \n\t\t vec4 p = permute( permute( permute( \n\t\t\t\t\t i.z + vec4(0.0, i1.z, i2.z, 1.0 ))\n\t\t\t\t + i.y + vec4(0.0, i1.y, i2.y, 1.0 )) \n\t\t\t\t + i.x + vec4(0.0, i1.x, i2.x, 1.0 ));\n\t\t float n_ = 1.0/7.0; // N=7\n\t\t vec3 ns = n_ * D.wyz - D.xzx;\n\t\t vec4 j = p - 49.0 * floor(p * ns.z *ns.z); // mod(p,N*N)\n\t\t vec4 x_ = floor(j * ns.z);\n\t\t vec4 y_ = floor(j - 7.0 * x_ ); // mod(j,N)\n\t\t vec4 x = x_ *ns.x + ns.yyyy;\n\t\t vec4 y = y_ *ns.x + ns.yyyy;\n\t\t vec4 h = 1.0 - abs(x) - abs(y);\n\t\t vec4 b0 = vec4( x.xy, y.xy );\n\t\t vec4 b1 = vec4( x.zw, y.zw );\n\t\t vec4 s0 = floor(b0)*2.0 + 1.0;\n\t\t vec4 s1 = floor(b1)*2.0 + 1.0;\n\t\t vec4 sh = -step(h, vec4(0.0));\n\t\t vec4 a0 = b0.xzyw + s0.xzyw*sh.xxyy ;\n\t\t vec4 a1 = b1.xzyw + s1.xzyw*sh.zzww ;\n\t\t vec3 p0 = vec3(a0.xy,h.x);\n\t\t vec3 p1 = vec3(a0.zw,h.y);\n\t\t vec3 p2 = vec3(a1.xy,h.z);\n\t\t vec3 p3 = vec3(a1.zw,h.w);\n\t\t vec4 norm = taylorInvSqrt(vec4(dot(p0,p0), dot(p1,p1), dot(p2, p2), dot(p3,p3)));\n\t\t p0 *= norm.x;\n\t\t p1 *= norm.y;\n\t\t p2 *= norm.z;\n\t\t p3 *= norm.w;\n\t\t vec4 m = max(0.6 - vec4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);\n\t\t m = m * m;\n\t\t return 42.0 * dot( m*m, vec4( dot(p0,x0), dot(p1,x1), \n\t\t\t\t\t\t\t\t\t\tdot(p2,x2), dot(p3,x3) ) );\n\t\t}",[i,n]),o=new Ot("vec4 mod289(vec4 x){return x - floor(x * (1.0 / 289.0)) * 289.0;}"),a=new Ot("vec4 perm(vec4 x){return mod289(((x * 34.0) + 1.0) * x);}",[o]),l=new Ot("float noise(vec3 p){\n\t\t\tvec3 a = floor(p);\n\t\t\tvec3 d = p - a;\n\t\t\td = d * d * (3.0 - 2.0 * d);\n\t\t\tvec4 b = a.xxyy + vec4(0.0, 1.0, 0.0, 1.0);\n\t\t\tvec4 k1 = perm(b.xyxy);\n\t\t\tvec4 k2 = perm(k1.xyxy + b.zzww);\n\t\t\tvec4 c = k2 + a.zzzz;\n\t\t\tvec4 k3 = perm(c);\n\t\t\tvec4 k4 = perm(c + 1.0);\n\t\t\tvec4 o1 = fract(k3 * (1.0 / 41.0));\n\t\t\tvec4 o2 = fract(k4 * (1.0 / 41.0));\n\t\t\tvec4 o3 = o2 * d.z + o1 * (1.0 - d.z);\n\t\t\tvec2 o4 = o3.yw * d.x + o3.xz * (1.0 - d.x);\n\t\t\treturn o4.y * d.y + o4.x * (1.0 - d.y);\n\t\t}",[a]),c=new Ot("float fbm(vec3 x) {\n\t\t\tfloat v = 0.0;\n\t\t\tfloat a = 0.5;\n\t\t\tvec3 shift = vec3(100);\n\t\t\tfor (int i = 0; i < NUM_OCTAVES; ++i) {\n\t\t\t\tv += a * noise(x);\n\t\t\t\tx = x * 2.0 + shift;\n\t\t\t\ta *= 0.5;\n\t\t\t}\n\t\t\treturn v;\n\t\t}",[l]);c.keywords.NUM_OCTAVES=new Mt("int NUM_OCTAVES 5");const h=new Ot("vec3 fade(vec3 t) {return t*t*t*(t*(t*6.0-15.0)+10.0);}");return{simplex:t,simplexFractal:r,simplexAshima:s,fbm:c,perlin:new Ot("float perlin(vec3 P){\n\t\t vec3 Pi0 = floor(P);\n\t\t vec3 Pi1 = Pi0 + vec3(1.0);\n\t\t Pi0 = mod(Pi0, 289.0);\n\t\t Pi1 = mod(Pi1, 289.0);\n\t\t vec3 Pf0 = fract(P);\n\t\t vec3 Pf1 = Pf0 - vec3(1.0);\n\t\t vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);\n\t\t vec4 iy = vec4(Pi0.yy, Pi1.yy);\n\t\t vec4 iz0 = Pi0.zzzz;\n\t\t vec4 iz1 = Pi1.zzzz;\n\t\t vec4 ixy = permute(permute(ix) + iy);\n\t\t vec4 ixy0 = permute(ixy + iz0);\n\t\t vec4 ixy1 = permute(ixy + iz1);\n\t\t vec4 gx0 = ixy0 / 7.0;\n\t\t vec4 gy0 = fract(floor(gx0) / 7.0) - 0.5;\n\t\t gx0 = fract(gx0);\n\t\t vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);\n\t\t vec4 sz0 = step(gz0, vec4(0.0));\n\t\t gx0 -= sz0 * (step(0.0, gx0) - 0.5);\n\t\t gy0 -= sz0 * (step(0.0, gy0) - 0.5);\n\t\t vec4 gx1 = ixy1 / 7.0;\n\t\t vec4 gy1 = fract(floor(gx1) / 7.0) - 0.5;\n\t\t gx1 = fract(gx1);\n\t\t vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);\n\t\t vec4 sz1 = step(gz1, vec4(0.0));\n\t\t gx1 -= sz1 * (step(0.0, gx1) - 0.5);\n\t\t gy1 -= sz1 * (step(0.0, gy1) - 0.5);\n\t\t vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);\n\t\t vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);\n\t\t vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);\n\t\t vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);\n\t\t vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);\n\t\t vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);\n\t\t vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);\n\t\t vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);\n\t\t vec4 norm0 = taylorInvSqrt(vec4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110)));\n\t\t g000 *= norm0.x;\n\t\t g010 *= norm0.y;\n\t\t g100 *= norm0.z;\n\t\t g110 *= norm0.w;\n\t\t vec4 norm1 = taylorInvSqrt(vec4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111)));\n\t\t g001 *= norm1.x;\n\t\t g011 *= norm1.y;\n\t\t g101 *= norm1.z;\n\t\t g111 *= norm1.w;\n\t\t float n000 = dot(g000, Pf0);\n\t\t float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));\n\t\t float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));\n\t\t float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));\n\t\t float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));\n\t\t float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));\n\t\t float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));\n\t\t float n111 = dot(g111, Pf1);\n\t\t vec3 fade_xyz = fade(Pf0);\n\t\t vec4 n_z = mix(vec4(n000, n100, n010, n110), vec4(n001, n101, n011, n111), fade_xyz.z);\n\t\t vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);\n\t\t float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x); \n\t\t return 2.2 * n_xyz;\n\t\t}",[i,n,h])}}();class jt extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut,o=new ut){super("v3"),this.nodeType="Rainbow",this.filmThickness=e,this.movement=t,this.wavelengths=r,this.noiseStrength=i,this.noiseScale=n,this.offset=s,this.alpha=o,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.require("normal"),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");const r=e.include(jt.Nodes.rainbow),i=[];return i.push(this.filmThickness.build(e,"f")),i.push(this.movement.build(e,"f")),i.push(this.wavelengths.build(e,"v3")),i.push(this.noiseStrength.build(e,"f")),i.push(this.noiseScale.build(e,"f")),i.push(this.offset.build(e,"v3")),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("RainbowNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.filmThickness=this.filmThickness.toJSON(e).uuid,t.movement=this.movement.toJSON(e).uuid,t.wavelengths=this.wavelengths.toJSON(e).uuid,t.noiseStrength=this.noiseStrength.toJSON(e).uuid,t.noiseScale=this.noiseScale.toJSON(e).uuid,t.offset=this.offset.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.filmThickness&&(this.filmThickness=t.getNode(e.filmThickness)),e.movement&&(this.movement=t.getNode(e.movement)),e.wavelengths&&(this.wavelengths=t.getNode(e.wavelengths)),e.noiseStrength&&(this.noiseStrength=t.getNode(e.noiseStrength)),e.noiseScale&&(this.noiseScale=t.getNode(e.noiseScale)),e.offset&&(this.offset=t.getNode(e.offset)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.calpha&&(this.calpha=e.calpha),this}copy(e){return super.copy(e),this.filmThickness.copy(e.filmThickness),this.movement.copy(e.movement),this.wavelengths.copy(e.wavelengths),this.noiseStrength.copy(e.noiseStrength),this.noiseScale.copy(e.noiseScale),this.offset.copy(e.offset),this.alpha.copy(e.alpha),this.calpha=e.calpha,this}}jt.Nodes=function(){const e=new Ot("vec3 attenuation(vec3 wavelengths, float filmThickness, float movement, float noiseStrength, float noiseScale, vec3 offset) {\n vec3 viewDir = normalize(-(cameraPosition + offset));\n vec3 st = normalize(position) * noiseScale;\n\t\t\t\t vec3 q = vec3(simplex3d(st),\n\t\t\t\t\t\t\t simplex3d(st + vec3(1.0)),\n\t\t\t\t\t\t\t simplex3d(st + vec3(1.0)));\n\n\t\t\t\t vec3 r = vec3(simplex3d(st + vec3(1.4, 1.3, 1.0) * q + vec3(1.7, 9.2, 1.0)),\n\t\t\t\t\t\t\t simplex3d(st + vec3(2.0, 1.2, 1.0) * q + vec3(8.3, 2.8, 1.0)),\n\t\t\t\t\t\t\t simplex3d(st * q));\n\n float noise = simplex3d(st + r);\n\n return .5 + .5 * cos((((filmThickness + (noise * noiseStrength)) / (vec3(wavelengths.r * 1.0, wavelengths.g * 0.8, wavelengths.b * 0.6) + 1.0)) * dot(normalize(vObjectNormal), viewDir)) + movement);\n }",[Gt.simplex]);return{rainbow:new Ot("vec3 rainbow(float filmThickness, float movement, vec3 wavelengths, float noiseStrength, float noiseScale, vec3 offset, float alpha, out float calpha) {\n vec3 res = clamp(attenuation(wavelengths, filmThickness, movement, noiseStrength, noiseScale, offset), 0.0, 2.0);\n\n float rainbowContribution = clamp(res.r + res.g + res.b, 0.0, 1.0);\n float lalpha = alpha * rainbowContribution;\n calpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n accumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\n return res;\n }",[e])}}();class Vt extends dt{constructor(e=new ut,t=new ut){super("v3"),this.nodeType="CustomNormal",this.cnormal=e,this.alpha=t}generate(e,t){if(e.isShader("fragment")){const r=e.include(Vt.Nodes.customNormal),i=[];return i.push(this.cnormal.build(e,"v3")),i.push("normal"),i.push(this.alpha.build(e,"f")),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("CustomNormalNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.cnormal=this.cnormal.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.cnormal&&(this.cnormal=t.getNode(e.cnormal)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}copy(e){return super.copy(e),this.cnormal.copy(e.cnormal),this.alpha.copy(e.alpha),this}}Vt.Nodes={customNormal:new Ot("vec3 customNormal(vec3 cnormal, vec3 norm, float alpha) {\n\t\t\t\tvec3 normal = packNormalToRGB( norm ).rgb;\n\t\t\t\tnormal *= step( vec3(0.5), cnormal );\n\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * alpha;\n\n\t\t\t\treturn normal;\n\t\t\t}")};class Ht extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut,o=new ut,a=new ut,l=new ut){super("v3"),this.nodeType="Gradient",this.glType=e,this.num=t,this.smooth=r,this.colors=i,this.steps=n,this.offset=s,this.morph=o,this.angle=a,this.alpha=l,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.define("GRAD_MAX",10),e.require("uv"),e.requires.uv=[!0],e.addFragmentVariable(this.calpha,"float");const r=e.include(Ht.Nodes.gradient),i=[];return i.push(this.glType.build(e,"i")),i.push(this.num.build(e,"i")),i.push(this.smooth.build(e,"b")),i.push(this.colors.build(e,"v4[]")),i.push(this.steps.build(e,"f[]")),i.push(this.offset.build(e,"v2")),i.push(this.morph.build(e,"v2")),i.push(this.angle.build(e,"f")),i.push(this.alpha.build(e,"f")),i.push(this.calpha),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("GradientNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.glType=this.glType.toJSON(e).uuid,t.num=this.num.toJSON(e).uuid,t.smooth=this.smooth.toJSON(e).uuid,t.colors=this.colors.toJSON(e).uuid,t.steps=this.steps.toJSON(e).uuid,t.offset=this.offset.toJSON(e).uuid,t.morph=this.morph.toJSON(e).uuid,t.angle=this.angle.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}copy(e){return super.copy(e),this.glType.copy(e.glType),this.num.copy(e.num),this.smooth.copy(e.smooth),this.colors.copy(e.colors),this.steps.copy(e.steps),this.offset.copy(e.offset),this.morph.copy(e.morph),this.angle.copy(e.angle),this.alpha.copy(e.alpha),this.calpha=e.calpha,this}fromJSON(e,t){return super.fromJSON(e,t),e.calpha&&(this.calpha=e.calpha),e.glType&&(this.glType=t.getNode(e.glType)),e.num&&(this.num=t.getNode(e.num)),e.smooth&&(this.smooth=t.getNode(e.smooth)),e.colors&&(this.colors=t.getNode(e.colors)),e.steps&&(this.steps=t.getNode(e.steps)),e.offset&&(this.offset=t.getNode(e.offset)),e.morph&&(this.morph=t.getNode(e.morph)),e.angle&&(this.angle=t.getNode(e.angle)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}}var Jt,Qt;Ht.Nodes={gradient:new Ot("vec3 gradient(int glType, int num, bool smoothed, vec4 colors[GRAD_MAX], float steps[GRAD_MAX], vec2 offset, vec2 morph, float angle, float alpha, out float calpha) {\n\t\t\t\tvec4 color = colors[0];\n\t\t\t\tvec2 m = morph / vUv.xy;\n\t\t\t\tvec2 rot = vec2( 0.5 + m.x, m.y );\n\t\t\t\tvec2 dt = vec2(\n\t\t\t\t\tcos( angle ) * rot.x - sin( angle ) * rot.y,\n\t\t\t\t\tsin( angle ) * rot.x + cos( angle ) * rot.y\n\t\t\t\t);\n\t\t\t\tvec2 pt = ( vUv - 0.5 + offset ) / 2.0 + dt / 2.0;\n\t\t\t\tfloat t = dot( pt, dt ) / dot( dt, dt );\n\t\t\t\tif ( glType == 1 ) {\n\t\t\t\t\tt = distance (\n\t\t\t\t\t\t( vUv + morph ) * 3.0,\n\t\t\t\t\t\t( vUv + offset ) + 1.0\n\t\t\t\t\t) + angle;\n\t\t\t\t} else if ( glType == 2 ) {\n\t\t\t\t\tfloat polar = atan(\n\t\t\t\t\t\tvUv.x + morph.x - 0.5 + offset.x,\n\t\t\t\t\t\tvUv.y + morph.y - 0.5 + offset.y\n\t\t\t\t\t) * -1.0;\n\t\t\t\t\tt = fract( ( angle / PI / -2.0 ) + 0.5 * ( polar / PI ) );\n\t\t\t\t}\n\t\t\t\tfloat p;\n\t\t\t\tfor ( int i = 1; i < num; i++ ) {\n\t\t\t\t\t\tp = clamp( ( t - steps[i-1] ) / ( steps[i] - steps[i-1] ), 0.0, 1.0 );\n\t\t\t\t\t\tcolor = mix( color, colors[i],\n\t\t\t\t\t\t\t\t\t( smoothed ) ? smoothstep( 0.0, 1.0, p ) : p\n\t\t\t\t\t\t\t\t );\n\t\t\t\t}\n\t\t\t\tfloat lalpha = alpha * color.a;\n\t\t\t\tcalpha = lalpha / clamp( lalpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * lalpha;\n\n\t\t\t\treturn color.xyz;\n\t\t\t}")},function(e){e.NOISE="noise",e.MAP="map"}(Jt||(Jt={}));class Yt extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut){super("v3"),this.nodeType="VertexDisplacement",this.displacementTypeIndex=e,this.intensity=t,this.movementOrTexture=r,Object.values(Jt)[this.displacementTypeIndex.value]===Jt.MAP&&(this.mat=new Rt(this.movementOrTexture.value.matrix)),this.cropOrOffset=i,this.scale=n,this.noiseFunctionIndex=s}generate(e,t){if(e.isShader("vertex")){let r;e.define("USE_LAYER_DISPLACE");const i=[];i.push("displaced_position"),i.push("displaced_normal");switch(Object.values(Jt)[this.displacementTypeIndex.value]){case Jt.MAP:r=e.include(Yt.Nodes.map),i.push(this.movementOrTexture.getTexture(e,"t")),i.push("uv"),i.push(this.cropOrOffset.build(e,"f")),i.push(this.mat.build(e,"mat3"));break;case Jt.NOISE:{const t=Object.values(Ut)[this.noiseFunctionIndex.value],n=new Ot("vec3 orthogonal(vec3 v) {\n\t\t\t\t\t\t\treturn normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n\t\t\t\t\t\t}"),s=new Ot(`vec3 distorted(vec3 p, vec3 n, float scale, float intensity, vec3 offset, float neighbour_offset, float movement) {\n\t\t\t\t\t\t\treturn p + n * ${t}((p + offset) * scale * 0.001 + neighbour_offset + (movement * 0.1)) * intensity;\n\t\t\t\t\t\t}`,[Gt.simplex,Gt.simplexFractal,Gt.simplexAshima,Gt.fbm,Gt.perlin]),o=new Ot("vec3 vertexDisplacementNoise(vec3 position, vec3 normal, float scale, vec3 offset, float movement, float intensity, out vec3 displaced_normal) {\n\t\t\t\t\t\t\tvec3 displaced_position = distorted(position, normal, scale, intensity, offset, neighbor_offset, movement);\n\t\t\t\t\t\t\tvec3 tangent1 = orthogonal(normal);\n\t\t\t\t\t\t\tvec3 tangent2 = normalize(cross(normal, tangent1));\n\t\t\t\t\t\t\tvec3 nearby1 = position + tangent1 * 0.1;\n\t\t\t\t\t\t\tvec3 nearby2 = position + tangent2 * 0.1;\n\t\t\t\t\t\t\tvec3 distorted1 = distorted(nearby1, normal, scale, intensity, offset, neighbor_offset, movement);\n\t\t\t\t\t\t\tvec3 distorted2 = distorted(nearby2, normal, scale, intensity, offset, neighbor_offset, movement);\n\t\t\t\t\t\t\tdisplaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n\t\t\t\t\t\t\treturn displaced_position;\n\t\t\t\t\t\t}",[s,n]);r=e.include(o),i.push(this.scale.build(e,"f")),i.push(this.cropOrOffset.build(e,"v3")),i.push(this.movementOrTexture.build(e,"f"));break}}return i.push(this.intensity.build(e,"f")),i.push("displaced_normal"),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("VertexDisplacementNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.intensity=this.intensity.toJSON(e).uuid,t.scale=this.scale.toJSON(e).uuid,t.movementOrTexture=this.movementOrTexture.toJSON(e).uuid,t.cropOrOffset=this.cropOrOffset.toJSON(e).uuid),t.displacementTypeIndex=this.displacementTypeIndex,t.noiseFunctionIndex=this.noiseFunctionIndex,t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),this.displacementTypeIndex=e.displacementTypeIndex,this.noiseFunctionIndex=e.noiseFunctionIndex,e.cropOrOffset&&(this.cropOrOffset=t.getNode(e.cropOrOffset)),e.intensity&&(this.intensity=t.getNode(e.intensity)),e.movementOrTexture&&(1===e.displacementTypeIndex.value?(this.movementOrTexture=t.getNode(e.movementOrTexture),this.movementOrTexture.value.updateMatrix(),this.mat=new Rt(this.movementOrTexture.value.matrix)):0===e.displacementTypeIndex.value&&(this.movementOrTexture=t.getNode(e.movementOrTexture))),e.scale&&(this.scale=t.getNode(e.scale)),this}copy(e){return super.copy(e),this.noiseFunctionIndex=e.noiseFunctionIndex,this.scale.copy(e.scale),this.cropOrOffset.copy(e.cropOrOffset),this.intensity.copy(e.intensity),this.movementOrTexture.copy(e.movementOrTexture),this}}Yt.Nodes=function(){const e=new Ot("vec3 orthogonal(vec3 v) {\n\t\t\t\treturn normalize(abs(v.x) > abs(v.z) ? vec3(-v.y, v.x, 0.0) : vec3(0.0, -v.z, v.y));\n\t\t\t}"),t=new Ot("float displacementMapTexture(sampler2D tex, float crop, vec2 uv, mat3 mat, vec2 offset) {\n\t\t\t\tvec2 uvs = (mat * vec3(uv * 2.0 - 1.0, 1.0) / 2.0 + 0.5).xy + offset;\n\t\t\t\tvec4 tmp = texture2D(tex, uvs);\n\t\t\t\tvec3 col = tmp.rgb;\n\t\t\t\tif (crop > 0.5) {\n\t\t\t\t\tif ( uvs.x < 0.0 || uvs.x > 1.0 || uvs.y < 0.0 || uvs.y > 1.0 ) {\n\t\t\t\t\t\treturn 0.0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn col.r;\n\t\t\t}");return{map:new Ot("vec3 vertexDisplacementMap(vec3 position, vec3 normal, sampler2D tex, vec2 uv, float crop, mat3 mat, float intensity, out vec3 displaced_normal) {\n\t\t\t\tvec3 displaced_position = position + normal * displacementMapTexture(tex, crop, uv, mat, vec2(0.0)) * intensity;\n\t\t\t\tvec3 tangent1 = normalize(orthogonal(normal));\n\t\t\t\tvec3 tangent2 = normalize(cross(normal, tangent1));\n\t\t\t\tvec3 nearby1 = position + tangent1 * 0.1;\n\t\t\t\tvec3 nearby2 = position + tangent2 * 0.1;\n\t\t\t\tvec3 distorted1 = nearby1 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n\t\t\t\tvec3 distorted2 = nearby2 + normal * displacementMapTexture(tex, crop, uv, mat, vec2(neighbor_offset)) * intensity;\n\t\t\t\tdisplaced_normal = normalize(cross(distorted1 - displaced_position, distorted2 - displaced_position));\n\t\t\t\treturn displaced_position;\n\t\t\t}",[e,t])}}();class Wt extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut,o=new ut,a=new ut,l=new ut,c=new ut,h=new ut,u=new ut,d=new ut,p=new ut,f=new ut){super("v3"),this.nodeType="Noise",this.scale=e,this.move=t,this.fA=r,this.fB=i,this.distortion=n,this.colorA=s,this.colorB=o,this.colorC=a,this.colorD=l,this.intA=c,this.intB=h,this.intC=u,this.intD=d,this.alpha=p,this.noiseFunctionIndex=f}generate(e,t,r,i,n){e.require("uv"),e.requires.uv=[!0];const s=Object.values(Ut)[this.noiseFunctionIndex.value],o=new Ot(`vec3 ${s}customNoise(float scale, float move, vec2 fA, vec2 fB, vec2 distortion, vec3 colorA, vec3 colorB, vec3 colorC, vec3 colorD, float intA, float intB, float intC, float intD, float alpha) {\n\t\t\t\tvec3 st = normalize(position) * scale;\n\t\t\t\tvec3 q = vec3(${s}(st),\n\t\t\t\t\t\t\t ${s}(st + vec3(1.0)),\n\t\t\t\t\t\t\t ${s}(st + vec3(1.0)));\n\t\t\t\tvec3 r = vec3(${s}(st + vec3(distortion, 1.0) * q + vec3(fA, 1.0) + move),\n\t\t\t\t\t\t\t ${s}(st + vec3(distortion, 1.0) * q + vec3(fB, 1.0) + move), \n\t\t\t\t\t\t\t ${s}(st * q));\n\t\t\t\tfloat f = ${s}(st + r);\n\t\t\t\tvec3 color;\n\t\t\t\tcolor = mix(colorA * intA, colorB * intB, clamp((f * f) * 4.0, 0.0, 1.0));\n\t\t\t\tcolor = mix(color, colorC * intC, clamp(length(q), 0.0, 1.0));\n\t\t\t\tcolor = mix(color, colorD * intD, clamp(length(r.x), 0.0, 1.0));\n\t\t\t\taccumAlpha += (1.0 - accumAlpha) * alpha;\n\t\t\t\treturn clamp(color, 0.0, 1.0);\n\t\t\t}`,[Gt.simplex,Gt.simplexFractal,Gt.simplexAshima,Gt.fbm,Gt.perlin]),a=e.include(o),l=[];l.push(this.scale.build(e,"f")),l.push(this.move.build(e,"f")),l.push(this.fA.build(e,"v2")),l.push(this.fB.build(e,"v2")),l.push(this.distortion.build(e,"v2")),l.push(this.colorA.build(e,"c")),l.push(this.colorB.build(e,"c")),l.push(this.colorC.build(e,"c")),l.push(this.colorD.build(e,"c")),l.push(this.intA.build(e,"f")),l.push(this.intB.build(e,"f")),l.push(this.intC.build(e,"f")),l.push(this.intD.build(e,"f")),l.push(this.alpha.build(e,"f"));return e.format(a+"("+l.join(",")+")",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scale=this.scale.toJSON(e).uuid,t.move=this.move.toJSON(e).uuid,t.fA=this.fA.toJSON(e).uuid,t.fB=this.fB.toJSON(e).uuid,t.distortion=this.distortion.toJSON(e).uuid,t.colorA=this.colorA.toJSON(e).uuid,t.colorB=this.colorB.toJSON(e).uuid,t.colorC=this.colorC.toJSON(e).uuid,t.colorD=this.colorD.toJSON(e).uuid,t.intA=this.intA.toJSON(e).uuid,t.intB=this.intB.toJSON(e).uuid,t.intC=this.intC.toJSON(e).uuid,t.intD=this.intD.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.noiseFunction=this.noiseFunctionIndex,t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scale&&(this.scale=t.getNode(e.scale)),e.move&&(this.move=t.getNode(e.move)),e.fA&&(this.fA=t.getNode(e.fA)),e.fB&&(this.fB=t.getNode(e.fB)),e.distortion&&(this.distortion=t.getNode(e.distortion)),e.colorA&&(this.colorA=t.getNode(e.colorA)),e.colorB&&(this.colorB=t.getNode(e.colorB)),e.colorC&&(this.colorC=t.getNode(e.colorC)),e.colorD&&(this.colorD=t.getNode(e.colorD)),e.intA&&(this.intA=t.getNode(e.intA)),e.intB&&(this.intB=t.getNode(e.intB)),e.intC&&(this.intC=t.getNode(e.intC)),e.intD&&(this.intD=t.getNode(e.intD)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.noiseFunctionIndex&&(this.noiseFunctionIndex=t.getNode(e.noiseFunctionIndex)),this}copy(e){return super.copy(e),this.scale.copy(e.scale),this.move.copy(e.move),this.fA.copy(e.fA),this.fB.copy(e.fB),this.distortion.copy(e.distortion),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.colorC.copy(e.colorC),this.colorD.copy(e.colorD),this.intA.copy(e.intA),this.intB.copy(e.intB),this.intC.copy(e.intC),this.intD.copy(e.intD),this.alpha.copy(e.alpha),this.noiseFunctionIndex.copy(e.noiseFunctionIndex),this}}Wt.numOctaves=5,function(e){e.ADD="+",e.SUB="-",e.MUL="*",e.DIV="/"}(Qt||(Qt={}));class Xt extends dt{constructor(e=new ut,t=new ut,r=Xt.ADD){super(),this.nodeType="Operator",this.a=e,this.b=t,this.op=r}getType(e){const t=this.a.getType(e),r=this.b.getType(e);return e.isTypeMatrix(t)?"v4":e.getTypeLength(r)>e.getTypeLength(t)?r:t}generate(e,t){const r=this.getType(e);this.type=r;const i=this.a.build(e,r),n=this.b.build(e,r);return e.format("( "+i+" "+this.op+" "+n+" )",r,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),this}}Xt.ADD=Qt.ADD,Xt.SUB=Qt.SUB,Xt.MUL=Qt.MUL,Xt.DIV=Qt.DIV;class Kt extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut){super("v3"),this.nodeType="Blend",this.a=e,this.b=t,this.alpha=r,this.mode=i}generate(e,t){if(e.isShader("fragment")){const r=[];return r.push(this.a.build(e,"c")),r.push(this.b.build(e,"c")),r.push(this.alpha.build(e,"f")),r.push(this.mode.build(e,"i")),e.format("spe_blend("+r.join(",")+")",this.getType(e),t)}return console.warn("BlendNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.mode&&(this.mode=t.getNode(e.mode)),this}}class qt extends dt{constructor(e=new ut,t=new ut,r=new ut,i=new ut,n=new ut,s=new ut,o=new ut){super("v3"),this.nodeType="Depth",this.near=e,this.far=t,this.isVector=r,this.origin=i,this.colorA=n,this.colorB=s,this.alpha=o}generate(e,t){if(e.isShader("fragment")){e.require("worldPosition");const r=e.include(qt.Nodes.sdepth),i=[];return i.push(this.near.build(e,"f")),i.push(this.far.build(e,"f")),i.push(this.isVector.build(e,"f")),i.push(this.origin.build(e,"v3")),i.push(this.colorA.build(e,"v3")),i.push(this.colorB.build(e,"v3")),i.push(this.alpha.build(e,"f")),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("DepthNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.near=this.near.toJSON(e).uuid,t.far=this.far.toJSON(e).uuid,t.isVector=this.isVector.toJSON(e).uuid,t.origin=this.origin.toJSON(e).uuid,t.colorA=this.colorA.toJSON(e).uuid,t.colorB=this.colorB.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.near&&(this.near=t.getNode(e.near)),e.far&&(this.far=t.getNode(e.far)),e.isVector&&(this.isVector=t.getNode(e.isVector)),e.origin&&(this.origin=t.getNode(e.origin)),e.colorA&&(this.colorA=t.getNode(e.colorA)),e.colorB&&(this.colorB=t.getNode(e.colorB)),e.alpha&&(this.alpha=t.getNode(e.alpha)),this}copy(e){return super.copy(e),this.near.copy(e.near),this.far.copy(e.far),this.isVector.copy(e.isVector),this.origin.copy(e.origin),this.colorA.copy(e.colorA),this.colorB.copy(e.colorB),this.alpha.copy(e.alpha),this}}qt.Nodes={sdepth:new Ot("vec3 sdepth(float near, float far, float isVector, vec3 origin, vec3 colorA, vec3 colorB, float alpha) {\n\t\t\t\tvec3 base = ( isVector > 0.5 ) ? origin : cameraPosition;\n\t\t\t\tfloat dist = length( vWPosition - base );\n\t\t\t\tfloat dep = ( dist - near ) / ( far - near );\n\t\t\t\tvec3 depth = mix( colorB, colorA, 1.0 - clamp( dep, 0., 1. ) );\n\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * alpha;\n\n\t\t\t\treturn depth;\n\t\t\t}")};class Zt extends dt{constructor(e=new ut,t=new Pt,r=new ut,i=new ut){super("v3"),this.nodeType="Matcap",this.color=e,this.texture=t,this.alpha=r,this.mode=i,this.calpha=`g${this.uuid.toString().replace(/-/g,"")}_calpha`}generate(e,t){if(e.isShader("fragment")){e.addFragmentVariable(this.calpha,"float");const r=e.include(Zt.Nodes.matcap);e.require("normal"),e.requires.normal=!0;const i=[];return i.push(this.color.build(e,"v3")),i.push(this.texture.getTexture(e,"t")),i.push("normal"),i.push(this.alpha.build(e,"f")),i.push(this.mode.build(e,"i")),i.push(this.calpha),e.format(r+"("+i.join(",")+")",this.getType(e),t)}return console.warn("MatcapNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.texture.copy(e.texture),this.color.copy(e.color),this.alpha.copy(e.alpha),this.mode.copy(e.mode),this.calpha=e.calpha,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.texture=this.texture.toJSON(e).uuid,t.color=this.color.toJSON(e).uuid,t.alpha=this.alpha.toJSON(e).uuid,t.mode=this.mode.toJSON(e).uuid,t.calpha=this.calpha),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.calpha&&(this.calpha=e.calpha),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.texture&&(this.texture=t.getNode(e.texture)),e.color&&(this.color=t.getNode(e.color)),e.mode&&(this.mode=t.getNode(e.mode)),this}}Zt.Nodes={matcap:new Ot("vec3 matcap(vec3 color, sampler2D matcapTex, vec3 normal, float alpha, int mode, out float calpha) {\n vec3 viewDir = normalize( vViewPosition );\n vec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n vec3 y = cross( viewDir, x );\n vec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n vec4 matcapColor = texture2D( matcapTex, uv );\n // matcapColor = matcapTexelToLinear( matcapColor );\n matcapColor.rgb *= color;\n \n calpha = alpha / clamp( alpha + accumAlpha, 0.00001, 1.0 );\n\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * alpha;\n \n return matcapColor.rgb;\n }\n ")};class $t{constructor(e){this.id=2,this.layerCount=2,this.uuid=t.MathUtils.generateUUID(),this.needsUpdate=!1,this._material=e,this._layerNodes=[];const r=this._createLayer({id:0,type:ot.COLOR});this._material.color=r.color,void 0===this._material.alpha&&(this._material.alpha=new gt(1));const i=new gt(1),n=new vt(0);"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=i,this._material.shadingBlend=n),this._layerNodes.push({id:0,type:at.COLOR,color:r.color,alpha:r.alpha,mode:r.mode}),this._layerNodes.push({id:1,type:at.LIGHTING,alpha:i,mode:n}),this.head=r.layer,this.head.next=new lt(1,{type:ot.LIGHTING,alpha:i,mode:n})}get material(){return this._material}set material(e){let t,r;this._material=e;let i=this.head;for(;void 0!==i;){if(i.type===ot.LIGHTING){t=i.uniforms[`f${i.id}_alpha`],r=i.uniforms[`f${i.id}_mode`];break}i=i.next}"shadingAlpha"in this._material&&"shadingBlend"in this._material&&(this._material.shadingAlpha=t,this._material.shadingBlend=r),this.blendColors(),this.blendAfterColors(),this.blendPositions()}addLayer(e){var r;if(e.id=null!==(r=e.id)&&void 0!==r?r:++this.id,this.layerCount++,e.type===ot.LIGHTING){const r=this.createLightLayer(e);return this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),r}const i=this._createLayer(e),n=i.layer;if(void 0===this.head)this.head=n;else{let e=this.head;for(;null!=e.next;)e=e.next;e.next=n}return i.color&&this._layerNodes.push({id:n.id,type:at.COLOR,color:i.color,alpha:i.alpha,mode:i.mode}),i.position&&this._layerNodes.push({id:n.id,type:at.POSITION,position:i.position}),this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}addLayerBeforeAt(e,r){var i;let n=this.head;e.id=null!==(i=e.id)&&void 0!==i?i:++this.id,this.layerCount++;const s=this._createLayer(e),o=s.layer;o.next=r;let a=0;if(n===r)this.head=o,s.color&&this._layerNodes.splice(0,0,{id:o.id,type:at.COLOR,color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&this._layerNodes.splice(0,0,{id:o.id,type:at.POSITION,position:s.position});else{for(a=1;(null==n?void 0:n.next)!==r;)n=null==n?void 0:n.next,a++;n.next=o,s.color&&this._layerNodes.splice(a,0,{id:o.id,type:at.COLOR,color:s.color,alpha:s.alpha,mode:s.mode}),s.position&&this._layerNodes.splice(a,0,{id:o.id,type:at.POSITION,position:s.position})}return this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),o}addLayerAt(e,r){var i;r.id=null!==(i=r.id)&&void 0!==i?i:++this.id,this.layerCount++;const n=this._createLayer(r),s=n.layer;if(n.color&&this._layerNodes.splice(e,0,{id:s.id,type:at.COLOR,color:n.color,alpha:n.alpha,mode:n.mode}),n.position&&this._layerNodes.splice(e,0,{id:s.id,type:at.POSITION,position:n.position}),0==e)s.next=this.head,this.head=s;else{let t=this.head,r=this.head.next;for(let i=0;i<e-1;i++)t=r,r=r.next;s.next=r,t.next=s}return this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),s}removeLayer(e){let r,i=this.head,n=0;if((null==i?void 0:i.id)==e)this.head=i.next;else for(n=1,r=i,i=null==i?void 0:i.next;null!=i;){if(i.id==e){r.next=i.next;break}n++,r=i,i=i.next}return this.cleanupChangedLayer(i),this.blendColors(),this.blendAfterColors(),this.blendPositions(),this.uuid=t.MathUtils.generateUUID(),this.layerCount--,n}changeLayer(e,r){let i,n,s=this.head;if((null==s?void 0:s.id)==e){const t=this._createLayer(Object.assign({id:e},r));n=t.layer,n.next=s.next,this.head=n,t.color&&(this._layerNodes[0]={id:n.id,type:at.COLOR,color:t.color,alpha:t.alpha,mode:t.mode}),t.position&&(this._layerNodes[0]={id:n.id,type:at.POSITION,position:t.position}),n.uniforms[`f${e}_mode`].value=s.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=s.uniforms[`f${e}_alpha`].value}else{i=s,s=s.next;let t=1;for(;null!=s;){if(s.id==e){const o=this._createLayer(Object.assign({id:e},r));n=o.layer,i.next=n,n.next=s.next,o.color&&(this._layerNodes[t]={id:n.id,type:at.COLOR,color:o.color,alpha:o.alpha,mode:o.mode}),o.position&&(this._layerNodes[t]={id:n.id,type:at.POSITION,position:o.position}),n.uniforms[`f${e}_mode`].value=s.uniforms[`f${e}_mode`].value,n.uniforms[`f${e}_alpha`].value=s.uniforms[`f${e}_alpha`].value;break}i=s,s=s.next,t++}}return this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors(),this.blendPositions(),n}getLayer(e){let t=this.head;for(;null!=t&&t.id!=e;)t=t.next;return t}getLayers(){const e=[];let t=this.head;for(;null!=t;)e.push(t),t=t.next;return e}getLayerPosition(e){let t=this.head,r=0;for(;void 0!==t&&t.id!=e;)r++,t=t.next;return r}getDefines(){}getBeforeProgram(){}getLightingProgram(){}getAfterProgram(){}getVarPrograms(){}getUniforms(){}moveLayer(e,r){let i,n,s=this.head;if(0==e)i=this.head,this.head=i.next;else{for(let t=0;t<e;t++)n=s,s=s.next;n.next=s.next,i=s}if(s=this.head,n=void 0,0==r)i.next=this.head,this.head=i;else{for(let e=0;e<r-1;e++)s=s.next;i.next=null==s?void 0:s.next,s.next=i}const o=this._layerNodes.splice(e,1)[0];this._layerNodes.splice(r,0,o),this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors()}updateLayerUniform(){this.uuid=t.MathUtils.generateUUID(),this.blendColors(),this.blendAfterColors()}copy(e){this.needsUpdate=!1,this.layerCount=e.layerCount,this._layerNodes=[],this.layerCount=0,this.head=void 0,this.rebuildLayerNodes(this.head,e.head);let t=e.head,r=this.head;for(;null!=t.next;)this.rebuildLayerNodes(r,t.next),r=r.next,t=t.next;return this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}createLightLayer(e){const t=new gt(e.alpha),r=new vt(e.mode);this._material.shadingAlpha=t,this._material.shadingBlend=r,this._layerNodes.push({id:e.id,type:at.LIGHTING,alpha:t,mode:r});const i=new lt(e.id,{type:ot.LIGHTING,alpha:t,mode:r});if(void 0===this.head)this.head=i;else{let e=this.head;for(;null!=e.next;)e=e.next;e.next=i}return i}rebuildLayerNodes(e,t,r=!1){if(t.type===ot.LIGHTING){const i=r?t.uniforms[`f${t.id}_alpha`]:new gt(t.uniforms[`f${t.id}_alpha`].value),n=r?t.uniforms[`f${t.id}_mode`]:new vt(t.uniforms[`f${t.id}_mode`].value);this._material.shadingAlpha=i,this._material.shadingBlend=n,this._layerNodes.push({id:t.id,type:at.LIGHTING,alpha:i,mode:n}),void 0===this.head?this.head=new lt(t.id,{type:ot.LIGHTING,alpha:i,mode:n}):e&&(e.next=new lt(t.id,{type:ot.LIGHTING,alpha:i,mode:n}))}else{const e={type:t.type,id:t.id};for(const i in t.uniforms){const n=t.getName(i);if(!n)continue;const s=`f${t.id}_${n}`;if(Array.isArray(t.uniforms[s].value))e[n]=t.uniforms[s].value.map((e=>e.clone&&!r?e.clone():e));else{const i=t.uniforms[s].value;null!=i&&(e[n]=i.clone&&!r?i.clone():i)}}this.addLayer(e)}}clone(){return new $t(this._material).copy(this)}toJSON(e){return{id:this.id,uuid:this.uuid,head:this.head.toJSON(e)}}fromJSON(e,t,r){const i=new lt(e.head.id,{type:e.head.type}).fromJSON(e.head,t);let n=e.head.next,s=i;for(;null!=n;)s.next=new lt(n.id,{type:n.type}).fromJSON(n,t),n=n.next,s=s.next;this._layerNodes=[],this.head=void 0,this.rebuildLayerNodes(this.head,i,!0);let o=i;for(s=this.head;null!=o.next;)this.rebuildLayerNodes(s,o.next,!0),s=s.next,o=o.next;return this._material=r,this.id=e.id,this.uuid=e.uuid,this.blendColors(),this.blendAfterColors(),this.blendPositions(),this}dispose(){let e=this.head;for(this._layerNodes=[],this.layerCount=0;void 0!==e;)!0===e.hasOwnProperty("dispose")&&e.dispose(),e=e.next;this.head=void 0}_createLayer(e){var r,i,n,s,o,a,l,c,h,u,d,p,f,m,g,v,y,A,w,x,b,S,E,C,T,O,D,M,_,N,L,B,I,P,R,F,U,z,k,G,j,V,H,J,Q,Y,W,X,K,q,Z,$,ee,te,re,ie,ne,se,oe,ae,le,ce,he,ue,de,pe,fe,me,ge,ve,ye,Ae,we,xe,be,Se,Ee;const Ce=e.type;switch(Ce){case ot.COLOR:{const t=new mt(null!==(r=e.color)&&void 0!==r?r:5855577),s=new gt(null!==(i=e.alpha)&&void 0!==i?i:1),o=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=s;const a=new vt(null!==(n=e.mode)&&void 0!==n?n:0);t.alpha=s;return{layer:new lt(e.id,{type:Ce,color:t,alpha:s,calpha:o,mode:a}),color:t,alpha:o,mode:a}}case ot.TEXTURE:{const r=null!==(s=e.texture)&&void 0!==s?s:new Lt,i=r.matrix;e.mat&&i.copy(e.mat),r.needsUpdate=!0;const n=new gt(null!==(o=e.crop)&&void 0!==o?o:0),d=new vt(null!==(a=e.projection)&&void 0!==a?a:0),p=new vt(null!==(l=e.axis)&&void 0!==l?l:0),f=new gt(null!==(c=e.alpha)&&void 0!==c?c:1),m=new vt(null!==(h=e.mode)&&void 0!==h?h:0),g=new Pt(r),v=new wt(null!==(u=e.textureSize)&&void 0!==u?u:new t.Vector3(r.image.width,r.image.height)),y=new zt(g,v,n,d,p,f,m),A=new _t(y.calpha,"f");return{layer:new lt(e.id,{type:Ce,texture:g,textureSize:v,crop:n,projection:d,axis:p,mat:y.mat,alpha:f,calpha:A,mode:m}),color:y,alpha:A,mode:m}}case ot.MATCAP:{const t=new mt(null!==(d=e.color)&&void 0!==d?d:16777215),r=null!==(p=e.texture)&&void 0!==p?p:new Lt;r.needsUpdate=!0;const i=new gt(null!==(f=e.alpha)&&void 0!==f?f:1),n=new Pt(r),s=new vt(null!==(m=e.mode)&&void 0!==m?m:0),o=new Zt(t,n,i,s),a=new _t(o.calpha,"f");return{layer:new lt(e.id,{type:Ce,texture:n,color:t,alpha:i,calpha:a,mode:s}),color:o,alpha:a,mode:s}}case ot.FRESNEL:{const t=new mt(null!==(g=e.color)&&void 0!==g?g:16777215),r=new gt(null!==(v=e.bias)&&void 0!==v?v:.1),i=new gt(null!==(y=e.scale)&&void 0!==y?y:1),n=new gt(null!==(A=e.intensity)&&void 0!==A?A:2),s=new gt(null!==(w=e.factor)&&void 0!==w?w:1),o=new gt(null!==(x=e.alpha)&&void 0!==x?x:1),a=new vt(null!==(b=e.mode)&&void 0!==b?b:0),l=new kt(t,r,i,n,s,o,a),c=new _t(l.calpha,"f");return{layer:new lt(e.id,{type:Ce,color:t,bias:r,scale:i,intensity:n,factor:s,alpha:o,calpha:c,mode:a}),color:l,alpha:c,mode:a}}case ot.RAINBOW:{const r=new gt(null!==(S=e.filmThickness)&&void 0!==S?S:30),i=new gt(null!==(E=e.movement)&&void 0!==E?E:0),n=new wt(null!==(C=e.wavelengths)&&void 0!==C?C:new t.Vector3(0,0,0)),s=new gt(null!==(T=e.noiseStrength)&&void 0!==T?T:0),o=new gt(null!==(O=e.noiseScale)&&void 0!==O?O:1),a=new wt(null!==(D=e.offset)&&void 0!==D?D:new t.Vector3(0,0,0)),l=new gt(null!==(M=e.alpha)&&void 0!==M?M:1),c=new jt(r,i,n,s,o,a,l),h=new _t(c.calpha,"f"),u=new vt(null!==(_=e.mode)&&void 0!==_?_:0);return{layer:new lt(e.id,{type:Ce,filmThickness:r,movement:i,wavelengths:n,noiseStrength:s,noiseScale:o,offset:a,alpha:l,calpha:h,mode:u}),color:c,alpha:h,mode:u}}case ot.DEPTH:{const r=new gt(null!==(N=e.near)&&void 0!==N?N:700),i=new gt(null!==(L=e.far)&&void 0!==L?L:1e3),n=new gt(null!==(B=e.isVector)&&void 0!==B?B:0),s=new wt(null!==(I=e.origin)&&void 0!==I?I:new t.Vector3),o=new mt(null!==(P=e.colorA)&&void 0!==P?P:new t.Color),a=new mt(null!==(R=e.colorB)&&void 0!==R?R:new t.Color(0,0,0)),l=new gt(null!==(F=e.alpha)&&void 0!==F?F:1),c=new vt(null!==(U=e.mode)&&void 0!==U?U:0),h=new _t("alpha / clamp(alpha + accumAlpha, 0.001, 1.0 )","f");h.keywords.alpha=l;const u=new qt(r,i,n,s,o,a,l);return{layer:new lt(e.id,{type:Ce,near:r,far:i,isVector:n,origin:s,colorA:o,colorB:a,alpha:l,calpha:h,mode:c}),color:u,alpha:h,mode:c}}case ot.NOISE:{const r=new gt(null!==(z=e.scale)&&void 0!==z?z:2),i=new gt(null!==(k=e.move)&&void 0!==k?k:1),n=new At(null!==(G=e.fA)&&void 0!==G?G:new t.Vector2(1.7,9.2)),s=new At(null!==(j=e.fB)&&void 0!==j?j:new t.Vector2(8.3,2.8)),o=new At(null!==(V=e.distortion)&&void 0!==V?V:new t.Vector2(1,1)),a=new mt(null!==(H=e.colorA)&&void 0!==H?H:new t.Color(.4,.4,.4)),l=new mt(null!==(J=e.colorB)&&void 0!==J?J:new t.Color(.4,.4,.4)),c=new mt(null!==(Q=e.colorC)&&void 0!==Q?Q:new t.Color(1,1,1)),h=new mt(null!==(Y=e.colorD)&&void 0!==Y?Y:new t.Color(1,1,1)),u=new gt(null!==(W=e.intA)&&void 0!==W?W:1),d=new gt(null!==(X=e.intB)&&void 0!==X?X:1),p=new gt(null!==(K=e.intC)&&void 0!==K?K:1),f=new gt(null!==(q=e.intD)&&void 0!==q?q:1),m=new gt(null!==(Z=e.alpha)&&void 0!==Z?Z:1),g=new vt(null!==($=e.mode)&&void 0!==$?$:0),v=new vt(null!==(ee=e.noiseType)&&void 0!==ee?ee:0),y=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");y.keywords.alpha=m;const A=new Wt(r,i,n,s,o,a,l,c,h,u,d,p,f,m,v);return{layer:new lt(e.id,{type:Ce,scale:r,move:i,fA:n,fB:s,distortion:o,colorA:a,colorB:l,colorC:c,colorD:h,intA:u,intB:d,intC:p,intD:f,alpha:m,calpha:y,mode:g,noiseType:v}),color:A,alpha:y,mode:g}}case ot.NORMAL:{const r=new wt(null!==(te=e.cnormal)&&void 0!==te?te:new t.Vector3(1,1,1)),i=new gt(null!==(re=e.alpha)&&void 0!==re?re:1),n=new vt(null!==(ie=e.mode)&&void 0!==ie?ie:0),s=new Vt(r,i),o=new _t("alpha / clamp(alpha + accumAlpha, 0.00001, 1.0 )","f");o.keywords.alpha=i;return{layer:new lt(e.id,{type:Ce,cnormal:r,alpha:i,calpha:o,mode:n}),color:s,alpha:o,mode:n}}case ot.GRADIENT:{const r=new vt(null!==(ne=e.gl_type)&&void 0!==ne?ne:0),i=new vt(null!==(se=e.num)&&void 0!==se?se:2),n=new yt(null!==(oe=e.smooth)&&void 0!==oe&&oe);let s,o;e.colors?s=new xt(e.colors.length,e.colors):(s=new xt(10,new t.Vector4(0,0,0,1)),s.value[1]=new t.Vector4(1,1,1,1)),e.steps?o=new bt(e.steps.length,e.steps):(o=new bt(10,1),o.value[0]=0);const a=new At(null!==(ae=e.offset)&&void 0!==ae?ae:new t.Vector2(0,0)),l=new At(null!==(le=e.morph)&&void 0!==le?le:new t.Vector2(0,0)),c=new gt(null!==(ce=e.angle)&&void 0!==ce?ce:0),h=new gt(null!==(he=e.alpha)&&void 0!==he?he:1),u=new vt(null!==(ue=e.mode)&&void 0!==ue?ue:0),d=new Ht(r,i,n,s,o,a,l,c,h),p=new _t(d.calpha,"f");return{layer:new lt(e.id,{type:Ce,gl_type:r,num:i,smooth:n,colors:s,steps:o,offset:a,morph:l,angle:c,alpha:h,calpha:p,mode:u}),color:d,alpha:p,mode:u}}case ot.DISPLACE:{const r=new vt(null!==(de=e.displacementType)&&void 0!==de?de:0);if(0===r.value){const i=new wt(null!==(pe=e.offset)&&void 0!==pe?pe:new t.Vector3(0,0,0)),n=new gt(null!==(fe=e.scale)&&void 0!==fe?fe:10),s=new gt(null!==(me=e.intensity)&&void 0!==me?me:8),o=new gt(null!==(ge=e.movement)&&void 0!==ge?ge:1),a=new gt(null!==(ve=e.alpha)&&void 0!==ve?ve:1),l=new vt(null!==(ye=e.mode)&&void 0!==ye?ye:0),c=new vt(null!==(Ae=e.noiseType)&&void 0!==Ae?Ae:0),h=new Yt(r,s,o,i,n,c);return{layer:new lt(e.id,{displacementType:r,type:Ce,offset:i,scale:n,intensity:s,movement:o,alpha:a,mode:l,noiseType:c}),position:h}}if(1===r.value){const t=null!==(we=e.texture)&&void 0!==we?we:new Lt,i=t.matrix;e.mat&&i.copy(e.mat),t.needsUpdate=!0;const n=new gt(null!==(xe=e.intensity)&&void 0!==xe?xe:8),s=new Pt(t),o=new gt(null!==(be=e.crop)&&void 0!==be?be:0),a=new gt(null!==(Se=e.alpha)&&void 0!==Se?Se:1),l=new vt(null!==(Ee=e.mode)&&void 0!==Ee?Ee:0),c=new Yt(r,n,s,o);return{layer:new lt(e.id,{displacementType:r,type:Ce,intensity:n,texture:s,crop:o,mat:c.mat,alpha:a,mode:l}),position:c}}return{}}}return{}}blendColors(){const e=this._layerNodes.findIndex((e=>e.type===at.COLOR)),t=this._layerNodes.findIndex((e=>e.type===at.LIGHTING));if(-1!==e&&e<t){let r=this._layerNodes[e].color;for(let i=e+1;i<t;++i){const e=this._layerNodes[i];e.type===at.COLOR&&(r=new Kt(r,e.color,e.alpha,e.mode))}this._material.color=r}else this._material.color=void 0}blendAfterColors(){let e=new _t("outgoingLight","f");const t=this._layerNodes.findIndex((e=>e.type===at.LIGHTING));if(this._layerNodes.length>t+1){for(let r=t+1;r<this._layerNodes.length;++r){const t=this._layerNodes[r];t.type===at.COLOR&&(e=new Kt(e,t.color,t.alpha,t.mode))}"afterColor"in this._material&&(this._material.afterColor=e)}else"afterColor"in this._material&&(this._material.afterColor=void 0)}blendPositions(){const e=this._layerNodes.filter((e=>e.type===at.POSITION));if(e.length>0){let t=e[0].position;for(let r=1;r<e.length;++r)e[r]&&(t=new Xt(t,e[r].position,Xt.ADD),t=new Xt(t,new gt(.5).setReadonly(!0),Xt.MUL));this._material.position=t}else this._material.position=void 0}cleanupChangedLayer(e){switch(this._layerNodes=this._layerNodes.filter((t=>t.id!==e.id)),e.type){case ot.DISPLACE:this.blendPositions();break;default:this.blendColors(),this.blendAfterColors()}}}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function er(e,t,r,i){return new(r||(r=Promise))((function(n,s){function o(e){try{l(i.next(e))}catch(e){s(e)}}function a(e){try{l(i.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,a)}l((i=i.apply(e,t||[])).next())}))}class tr{constructor(e){e=null!=e?e:{},this.name=e.name,this.type=e.type,this.node=e.node,this.size=e.size,this.needsUpdate=e.needsUpdate}get value(){return this.node.value}set value(e){this.node.value=e}}class rr extends pt{constructor(e=0,r,i,n){super("v4"),this.nodeType="Vector4",this.value=e instanceof t.Vector4?e:new t.Vector4(e,r,i,n)}generateReadonly(e,t,r,i,n,s){return e.format("vec4("+this.value.x+", "+this.value.y+", "+this.value.z+", "+this.value.w+")",i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.x=this.value.x,t.y=this.value.y,t.z=this.value.z,t.w=this.value.w,!0===this.getReadonly()&&(t.readonly=!0)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.x&&(this.value.x=e.x),e.y&&(this.value.y=e.y),e.z&&(this.value.z=e.z),e.w&&(this.value.w=e.w),void 0!==e.readonly&&(this.readonly=e.readonly),this}}ft.addShortcuts(rr.prototype,"value",["x","y","z","w"]);const ir=new RegExp("^structs*([a-z_0-9]+)s*{s*((.|\n)*?)}","gim"),nr=new RegExp("s*(w*?)s*(w*?)(=|;)","gim");class sr extends dt{constructor(e=""){super(),this.inputs=[],this.src="",this.nodeType="Struct",this.parse(e)}getType(e){return e.getTypeByFormat(this.name)}getInputByName(e){let t=this.inputs.length;for(;t--;)if(this.inputs[t].name===e)return this.inputs[t]}generate(e,t,r,i,n){return"source"===t?this.src+";":e.format("( "+this.src+" )",this.getType(e),t)}parse(e=""){this.src=e,this.inputs=[];const t=ir.exec(e);if(t){const e=t[2];let r;for(;r=nr.exec(e);)this.inputs.push({type:r[1],name:r[2]});this.name=t[1]}else this.name="";this.type=this.name}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.src=this.src),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.src&&(this.src=e.src,this.parse(this.src)),this}}class or extends dt{constructor(e,t){super(),this.inputs=[],this.nodeType="FunctionCall",this.value=e,this.inputs=null!=t?t:[]}getFunction(){return this.value}getType(e){return this.value.getType(e)}generate(e,t,r,i,n){i=this.getType(e);const s=this.value;let o=s.build(e,t)+"( ";const a=[];if(s.inputs){for(let t=0;t<s.inputs.length;t++){const r=s.inputs[t],i=this.inputs[t]||this.inputs[r.name];a.push(i.build(e,e.getTypeByFormat(r.type)))}o+=a.join(", ")+" )"}return e.format(o,i,t)}copy(e){return super.copy(e),this.value.copy(e.value),this.inputs=e.inputs.map((e=>e.clone())),this}toJSON(e){var t;let r=this.getJSONNode(e);if(!r){const i=this.value;if(r=this.createJSONNode(e),r.value=this.value.toJSON(e).uuid,null===(t=i.inputs)||void 0===t?void 0:t.length){r.inputs={};for(let t=0;t<i.inputs.length;t++){const n=i.inputs[t],s=this.inputs[t];r.inputs[n.name]=s.toJSON(e).uuid}}}return r}}var ar;!function(e){e.RAD="radians",e.DEG="degrees",e.EXP="exp",e.EXP2="exp2",e.LOG="log",e.LOG2="log2",e.SQRT="sqrt",e.INV_SQRT="inversesqrt",e.FLOOR="floor",e.CEIL="ceil",e.NORMALIZE="normalize",e.FRACT="fract",e.SATURATE="saturate",e.SIN="sin",e.COS="cos",e.TAN="tan",e.ASIN="asin",e.ACOS="acos",e.ARCTAN="atan",e.ABS="abs",e.SIGN="sign",e.LENGTH="length",e.NEGATE="negate",e.INVERT="invert",e.MIN="min",e.MAX="max",e.MOD="mod",e.STEP="step",e.REFLECT="reflect",e.DISTANCE="distance",e.DOT="dot",e.CROSS="cross",e.POW="pow",e.MIX="mix",e.CLAMP="clamp",e.REFRACT="refract",e.SMOOTHSTEP="smoothstep",e.FACEFORWARD="faceforward"}(ar||(ar={}));class lr extends dt{constructor(e=new ut,t=lr.ABS,r,i){super(),this.nodeType="Math",this.a=e,"string"!=typeof t?this.b=t:i=t,"string"!=typeof r?this.c=r:i=r,this.method=i,this.hashProperties=["method"]}getNumInputs(e){switch(this.method){case lr.MIX:case lr.CLAMP:case lr.REFRACT:case lr.SMOOTHSTEP:case lr.FACEFORWARD:return 3;case lr.MIN:case lr.MAX:case lr.MOD:case lr.STEP:case lr.REFLECT:case lr.DISTANCE:case lr.DOT:case lr.CROSS:case lr.POW:return 2;default:return 1}}getInputType(e){const t=e.getTypeLength(this.a.getType(e)),r=this.b?e.getTypeLength(this.b.getType(e)):0,i=this.c?e.getTypeLength(this.c.getType(e)):0;return t>r&&t>i?this.a.getType(e):r>i?this.b.getType(e):this.c.getType(e)}getType(e){switch(this.method){case lr.LENGTH:case lr.DISTANCE:case lr.DOT:return"f";case lr.CROSS:return"v3"}return this.getInputType(e)}generate(e,t){let r,i,n;const s=this.a?e.getTypeLength(this.a.getType(e)):0,o=this.b?e.getTypeLength(this.b.getType(e)):0,a=this.c?e.getTypeLength(this.c.getType(e)):0,l=this.getInputType(e),c=this.getType(e);switch(this.type=c,this.method){case lr.NEGATE:return e.format("( -"+this.a.build(e,l)+" )",l,t);case lr.INVERT:return e.format("( 1.0 - "+this.a.build(e,l)+" )",l,t);case lr.CROSS:r=this.a.build(e,"v3"),i=this.b.build(e,"v3");break;case lr.STEP:r=this.a.build(e,1===s?"f":l),i=this.b.build(e,l);break;case lr.MIN:case lr.MAX:case lr.MOD:r=this.a.build(e,l),i=this.b.build(e,1===o?"f":l);break;case lr.REFRACT:r=this.a.build(e,l),i=this.b.build(e,l),n=this.c.build(e,"f");break;case lr.MIX:r=this.a.build(e,l),i=this.b.build(e,l),n=this.c.build(e,1===a?"f":l);break;default:r=this.a.build(e,l),this.b&&(i=this.b.build(e,l)),this.c&&(n=this.c.build(e,l))}const h=[];h.push(r),i&&h.push(i),n&&h.push(n);const u=this.getNumInputs(e);if(h.length!==u)throw Error(`Arguments not match used in "${this.method}". Require ${u}, currently ${h.length}.`);return e.format(this.method+"( "+h.join(", ")+" )",c,t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b=e.b instanceof ut?e.b.clone():e.b,this.c=e.c instanceof ut?e.c.clone():e.c,this.method=e.method,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,this.b&&(t.b=this.b.toJSON(e).uuid),this.c&&(t.c=this.c.toJSON(e).uuid),t.method=this.method),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.c&&(this.c=t.getNode(e.c)),e.method&&(this.method=e.method),this}}lr.RAD=ar.RAD,lr.DEG=ar.DEG,lr.EXP=ar.EXP,lr.EXP2=ar.EXP2,lr.LOG=ar.LOG,lr.LOG2=ar.LOG2,lr.SQRT=ar.SQRT,lr.INV_SQRT=ar.INV_SQRT,lr.FLOOR=ar.FLOOR,lr.CEIL=ar.CEIL,lr.NORMALIZE=ar.NORMALIZE,lr.FRACT=ar.FRACT,lr.SATURATE=ar.SATURATE,lr.SIN=ar.SIN,lr.COS=ar.COS,lr.TAN=ar.TAN,lr.ASIN=ar.ASIN,lr.ACOS=ar.ACOS,lr.ARCTAN=ar.ARCTAN,lr.ABS=ar.ABS,lr.SIGN=ar.SIGN,lr.LENGTH=ar.LENGTH,lr.NEGATE=ar.NEGATE,lr.INVERT=ar.INVERT,lr.MIN=ar.MIN,lr.MAX=ar.MAX,lr.MOD=ar.MOD,lr.STEP=ar.STEP,lr.REFLECT=ar.REFLECT,lr.DISTANCE=ar.DISTANCE,lr.DOT=ar.DOT,lr.CROSS=ar.CROSS,lr.POW=ar.POW,lr.MIX=ar.MIX,lr.CLAMP=ar.CLAMP,lr.REFRACT=ar.REFRACT,lr.SMOOTHSTEP=ar.SMOOTHSTEP,lr.FACEFORWARD=ar.FACEFORWARD;class cr extends dt{constructor(e=new ut,t=new ut,r=new ut){super("v4"),this.nodeType="TextureCubeUV",this.value=e,this.uv=t,this.bias=r}bilinearCubeUV(e,t,r,i){var n,s,o,a;const l=new or(cr.Nodes.bilinearCubeUV,[t,r,i]);this.colorSpaceTL=null!==(n=this.colorSpaceTL)&&void 0!==n?n:new Nt(new _t("","v4")),this.colorSpaceTL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTL.input.parse(l.build(e)+".tl"),this.colorSpaceTR=null!==(s=this.colorSpaceTR)&&void 0!==s?s:new Nt(new _t("","v4")),this.colorSpaceTR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceTR.input.parse(l.build(e)+".tr"),this.colorSpaceBL=null!==(o=this.colorSpaceBL)&&void 0!==o?o:new Nt(new _t("","v4")),this.colorSpaceBL.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBL.input.parse(l.build(e)+".bl"),this.colorSpaceBR=null!==(a=this.colorSpaceBR)&&void 0!==a?a:new Nt(new _t("","v4")),this.colorSpaceBR.fromDecoding(e.getTextureEncodingFromMap(this.value.value)),this.colorSpaceBR.input.parse(l.build(e)+".br");const c={include:e.isShader("vertex"),ignoreCache:!0};e.addContext(c),this.colorSpaceTLExp=new _t(this.colorSpaceTL.build(e,"v4"),"v4"),this.colorSpaceTRExp=new _t(this.colorSpaceTR.build(e,"v4"),"v4"),this.colorSpaceBLExp=new _t(this.colorSpaceBL.build(e,"v4"),"v4"),this.colorSpaceBRExp=new _t(this.colorSpaceBR.build(e,"v4"),"v4"),e.removeContext();const h=new _t("mix( mix( cubeUV_TL, cubeUV_TR, cubeUV.f.x ), mix( cubeUV_BL, cubeUV_BR, cubeUV.f.x ), cubeUV.f.y )","v4");return h.keywords.cubeUV_TL=this.colorSpaceTLExp,h.keywords.cubeUV_TR=this.colorSpaceTRExp,h.keywords.cubeUV_BL=this.colorSpaceBLExp,h.keywords.cubeUV_BR=this.colorSpaceBRExp,h.keywords.cubeUV=l,h}generate(e,t){if(e.isShader("fragment")){const r=this.uv,i=this.bias||e.context.roughness,n=new or(cr.Nodes.roughnessToMip,[i]),s=new lr(n,cr.Nodes.m0,cr.Nodes.cubeUV_maxMipLevel,lr.CLAMP),o=new lr(s,lr.FLOOR),a=new lr(s,lr.FRACT),l=this.bilinearCubeUV(e,this.value,r,o),c=this.bilinearCubeUV(e,this.value,r,new Xt(o,new gt(1).setReadonly(!0),Xt.ADD)),h=new lr(l,c,a,lr.MIX);return e.format(h.build(e),"v4",t)}return console.warn("TextureCubeUVNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.uv.copy(e.uv),this.bias.copy(e.bias),this.value.copy(e.value),e.colorSpaceTL?this.colorSpaceTL?this.colorSpaceTL.copy(e.colorSpaceTL):this.colorSpaceTL=e.colorSpaceTL.clone():this.colorSpaceTL=void 0,e.colorSpaceTR?this.colorSpaceTR?this.colorSpaceTR.copy(e.colorSpaceTR):this.colorSpaceTR=e.colorSpaceTR.clone():this.colorSpaceTR=void 0,e.colorSpaceBL?this.colorSpaceBL?this.colorSpaceBL.copy(e.colorSpaceBL):this.colorSpaceBL=e.colorSpaceBL.clone():this.colorSpaceBL=void 0,e.colorSpaceBR?this.colorSpaceBR?this.colorSpaceBR.copy(e.colorSpaceBR):this.colorSpaceBR=e.colorSpaceBR.clone():this.colorSpaceBR=void 0,e.colorSpaceTLExp?this.colorSpaceTLExp?this.colorSpaceTLExp.copy(e.colorSpaceTLExp):this.colorSpaceTLExp=e.colorSpaceTLExp.clone():this.colorSpaceTLExp=void 0,e.colorSpaceTRExp?this.colorSpaceTRExp?this.colorSpaceTRExp.copy(e.colorSpaceTRExp):this.colorSpaceTRExp=e.colorSpaceTRExp.clone():this.colorSpaceTRExp=void 0,e.colorSpaceBLExp?this.colorSpaceBLExp?this.colorSpaceBLExp.copy(e.colorSpaceBLExp):this.colorSpaceBLExp=e.colorSpaceBLExp.clone():this.colorSpaceBLExp=void 0,e.colorSpaceBRExp?this.colorSpaceBRExp?this.colorSpaceBRExp.copy(e.colorSpaceBRExp):this.colorSpaceBRExp=e.colorSpaceBRExp.clone():this.colorSpaceBRExp=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,t.uv=this.uv.toJSON(e).uuid,t.bias=this.bias.toJSON(e).uuid,this.colorSpaceTL&&this.colorSpaceTL.toJSON(e).uuid,this.colorSpaceTR&&this.colorSpaceTR.toJSON(e).uuid,this.colorSpaceBL&&this.colorSpaceBL.toJSON(e).uuid,this.colorSpaceBR&&this.colorSpaceBR.toJSON(e).uuid,this.colorSpaceTLExp&&this.colorSpaceTLExp.toJSON(e).uuid,this.colorSpaceTRExp&&this.colorSpaceTRExp.toJSON(e).uuid,this.colorSpaceBLExp&&this.colorSpaceBLExp.toJSON(e).uuid,this.colorSpaceBRExp&&this.colorSpaceBRExp.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),e.colorSpaceTL&&(this.colorSpaceTL=t.getNode(e.colorSpaceTL)),e.colorSpaceTR&&(this.colorSpaceTR=t.getNode(e.colorSpaceTR)),e.colorSpaceBL&&(this.colorSpaceBL=t.getNode(e.colorSpaceBL)),e.colorSpaceBR&&(this.colorSpaceBR=t.getNode(e.colorSpaceBR)),e.colorSpaceTLExp&&(this.colorSpaceTLExp=t.getNode(e.colorSpaceTLExp)),e.colorSpaceTRExp&&(this.colorSpaceTRExp=t.getNode(e.colorSpaceTRExp)),e.colorSpaceBLExp&&(this.colorSpaceBLExp=t.getNode(e.colorSpaceBLExp)),e.colorSpaceBRExp&&(this.colorSpaceBRExp=t.getNode(e.colorSpaceBRExp)),this}}cr.Nodes=function(){const e=new sr("struct TextureCubeUVData {\n\t\t\tvec4 tl;\n\t\t\tvec4 tr;\n\t\t\tvec4 br;\n\t\t\tvec4 bl;\n\t\t\tvec2 f;\n\t\t}"),t=new Mt("float cubeUV_maxMipLevel 8.0",!0),r=new Mt("float cubeUV_minMipLevel 4.0",!0),i=new Mt("float cubeUV_maxTileSize 256.0",!0),n=new Mt("float cubeUV_minTileSize 16.0",!0),s=new Ot("float getFace(vec3 direction) {\n\t\t\t\tvec3 absDirection = abs(direction);\n\t\t\t\tfloat face = -1.0;\n\t\t\t\tif (absDirection.x > absDirection.z) {\n\t\t\t\t\tif (absDirection.x > absDirection.y)\n\t\t\t\t\t\tface = direction.x > 0.0 ? 0.0 : 3.0;\n\t\t\t\t\telse\n\t\t\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t\t\t} else {\n\t\t\t\t\tif (absDirection.z > absDirection.y)\n\t\t\t\t\t\tface = direction.z > 0.0 ? 2.0 : 5.0;\n\t\t\t\t\telse\n\t\t\t\t\t\tface = direction.y > 0.0 ? 1.0 : 4.0;\n\t\t\t\t}\n\t\t\t\treturn face;\n\t\t}");s.useKeywords=!1;const o=new Ot("vec2 getUV(vec3 direction, float face) {\n\t\t\t\tvec2 uv;\n\t\t\t\tif (face == 0.0) {\n\t\t\t\t\tuv = vec2(direction.z, direction.y) / abs(direction.x); // pos x\n\t\t\t\t} else if (face == 1.0) {\n\t\t\t\t\tuv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y\n\t\t\t\t} else if (face == 2.0) {\n\t\t\t\t\tuv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z\n\t\t\t\t} else if (face == 3.0) {\n\t\t\t\t\tuv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x\n\t\t\t\t} else if (face == 4.0) {\n\t\t\t\t\tuv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y\n\t\t\t\t} else {\n\t\t\t\t\tuv = vec2(direction.x, direction.y) / abs(direction.z); // neg z\n\t\t\t\t}\n\t\t\t\treturn 0.5 * (uv + 1.0);\n\t\t}");o.useKeywords=!1;const a=new Ot("TextureCubeUVData bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n\t\t\tfloat face = getFace(direction);\n\t\t\tfloat filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n\t\t\tmipInt = max(mipInt, cubeUV_minMipLevel);\n\t\t\tfloat faceSize = exp2(mipInt);\n\t\t\tfloat texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\t\t\tvec2 uv = getUV(direction, face) * (faceSize - 1.0);\n\t\t\tvec2 f = fract(uv);\n\t\t\tuv += 0.5 - f;\n\t\t\tif (face > 2.0) {\n\t\t\t\tuv.y += faceSize;\n\t\t\t\tface -= 3.0;\n\t\t\t}\n\t\t\tuv.x += face * faceSize;\n\t\t\tif(mipInt < cubeUV_maxMipLevel){\n\t\t\t\tuv.y += 2.0 * cubeUV_maxTileSize;\n\t\t\t}\n\t\t\tuv.y += filterInt * 2.0 * cubeUV_minTileSize;\n\t\t\tuv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n\t\t\tuv *= texelSize;\n\t\t\tvec4 tl = texture2D(envMap, uv);\n\t\t\tuv.x += texelSize;\n\t\t\tvec4 tr = texture2D(envMap, uv);\n\t\t\tuv.y += texelSize;\n\t\t\tvec4 br = texture2D(envMap, uv);\n\t\t\tuv.x -= texelSize;\n\t\t\tvec4 bl = texture2D(envMap, uv);\n\t\t\treturn TextureCubeUVData( tl, tr, br, bl, f );\n\t\t}",[e,s,o,t,r,i,n]);a.useKeywords=!1;const l=new Mt("float r0 1.0",!0),c=new Mt("float v0 0.339",!0),h=new Mt("float m0 -2.0",!0),u=new Mt("float r1 0.8",!0),d=new Mt("float v1 0.276",!0),p=new Mt("float m1 -1.0",!0),f=new Mt("float r4 0.4",!0),m=new Mt("float v4 0.046",!0),g=new Mt("float m4 2.0",!0),v=new Mt("float r5 0.305",!0),y=new Mt("float v5 0.016",!0),A=new Mt("float m5 3.0",!0),w=new Mt("float r6 0.21",!0),x=new Mt("float v6 0.0038",!0),b=new Mt("float m6 4.0",!0);return{bilinearCubeUV:a,roughnessToMip:new Ot("float roughnessToMip(float roughness) {\n\t\t\tfloat mip = 0.0;\n\t\t\tif (roughness >= r1) {\n\t\t\t\tmip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n\t\t\t} else if (roughness >= r4) {\n\t\t\t\tmip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n\t\t\t} else if (roughness >= r5) {\n\t\t\t\tmip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n\t\t\t} else if (roughness >= r6) {\n\t\t\t\tmip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n\t\t\t} else {\n\t\t\t\tmip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n\t\t\t}\n\t\t\treturn mip;\n\t\t}",[l,c,h,u,d,p,f,m,g,v,y,A,w,x,b]),m0:h,cubeUV_maxMipLevel:t}}();class hr extends dt{constructor(e){super("v3"),this.nodeType="Normal",this.scope=null!=e?e:hr.VIEW}getShared(){return this.scope===hr.WORLD}build(e,t,r,i){const n=e.context[this.scope+"Normal"];return n?n.build(e,t,r,i):super.build(e,t,r)}generate(e,t,r,i,n){let s;switch(this.scope){case hr.VIEW:s=e.isShader("vertex")?"transformedNormal":"geometryNormal";break;case hr.LOCAL:e.isShader("vertex")?s="objectNormal":(e.requires.normal=!0,s="vObjectNormal");break;case hr.WORLD:e.isShader("vertex")?s="inverseTransformDirection( transformedNormal, viewMatrix ).xyz":(e.requires.worldNormal=!0,s="vWNormal")}return e.format(s,this.getType(e),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}}hr.LOCAL="local",hr.WORLD="world",hr.VIEW="view",hr.NORMAL="normal",St.addKeyword("viewNormal",(function(){return new hr(hr.VIEW)})),St.addKeyword("localNormal",(function(){return new hr(hr.NORMAL)})),St.addKeyword("worldNormal",(function(){return new hr(hr.WORLD)}));class ur extends dt{constructor(e){super("v3"),this.nodeType="Position",this.scope=null!=e?e:ur.LOCAL}getType(){switch(this.scope){case ur.PROJECTION:return"v4"}return this.type}getShader(){switch(this.scope){case ur.LOCAL:case ur.WORLD:return!1}return!0}generate(e,t,r,i,n){let s;switch(this.scope){case ur.LOCAL:e.isShader("vertex")?s="transformed":(e.requires.position=!0,s="vPosition");break;case ur.WORLD:if(e.isShader("vertex"))return"( modelMatrix * vec4( transformed, 1.0 ) ).xyz";e.requires.worldPosition=!0,s="vWPosition";break;case ur.VIEW:s=e.isShader("vertex")?"-mvPosition.xyz":"vViewPosition";break;case ur.PROJECTION:s=e.isShader("vertex")?"( projectionMatrix * modelViewMatrix * vec4( position, 1.0 ) )":"vec4( 0.0 )"}return e.format(s,this.getType(),t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}}ur.LOCAL="local",ur.WORLD="world",ur.VIEW="view",ur.PROJECTION="projection",St.addKeyword("position",(function(){return new ur})),St.addKeyword("worldPosition",(function(){return new ur(ur.WORLD)})),St.addKeyword("viewPosition",(function(){return new ur(ur.VIEW)}));class dr extends dt{constructor(e){super("v3"),this.nodeType="Reflect",this.scope=null!=e?e:dr.CUBE}getUnique(e){return!e.context.viewNormal}getType(){switch(this.scope){case dr.SPHERE:return"v2"}return this.type}generate(e,t){const r=this.getUnique(e);if(e.isShader("fragment")){let i;switch(this.scope){case dr.VECTOR:{const t=new hr(hr.VIEW),n=e.context.roughness,s=t.build(e,"v3"),o=new ur(ur.VIEW).build(e,"v3"),a=n?n.build(e,"f"):void 0;let l=`reflect( -normalize( ${o} ), ${s} )`;a&&(l=`normalize( mix( ${l}, ${s}, ${a} * ${a} ) )`);const c=`inverseTransformDirection( ${l}, viewMatrix )`;r?(e.addNodeCode(`vec3 reflectVec = ${c};`),i="reflectVec"):i=c;break}case dr.CUBE:{const t=new dr(dr.VECTOR).build(e,"v3"),n="vec3( -"+t+".x, "+t+".yz )";r?(e.addNodeCode(`vec3 reflectCubeVec = ${n};`),i="reflectCubeVec"):i=n;break}case dr.SPHERE:{const t="normalize( ( viewMatrix * vec4( "+new dr(dr.VECTOR).build(e,"v3")+", 0.0 ) ).xyz + vec3( 0.0, 0.0, 1.0 ) ).xy * 0.5 + 0.5";r?(e.addNodeCode(`vec2 reflectSphereVec = ${t};`),i="reflectSphereVec"):i=t;break}}return e.format(i,this.getType(),t)}return console.warn("ReflectNode is not compatible with "+e.shader+" shader."),e.format("vec3( 0.0 )",this.type,t)}copy(e){return super.copy(e),this.scope=e.scope,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.scope=this.scope),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),this}}dr.CUBE="cube",dr.SPHERE="sphere",dr.VECTOR="vector";class pr extends dt{constructor(e=new Pt,t,r){super("v4"),this.nodeType="TextureCube",this.value=e,this.radianceNode=new cr(this.value,null!=t?t:new dr(dr.VECTOR),r),this.irradianceNode=new cr(this.value,new hr(hr.WORLD),new gt(1).setReadonly(!0))}generate(e,t){if(e.isShader("fragment")){e.require("irradiance"),e.context.bias&&e.context.bias.setTexture(this.value);return("irradiance"===e.slot?this.irradianceNode:this.radianceNode).build(e,t)}return console.warn("TextureCubeNode is not compatible with "+e.shader+" shader."),e.format("vec4( 0.0 )",this.getType(e),t)}copy(e){return super.copy(e),this.value.copy(e.value),this.radianceNode.copy(e.radianceNode),this.irradianceNode.copy(e.irradianceNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid,this.radianceNode&&(t.radianceNode=this.radianceNode.toJSON(e).uuid),this.irradianceNode&&(t.irradianceNode=this.irradianceNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),e.radianceNode&&(this.radianceNode=t.getNode(e.radianceNode)),e.irradianceNode&&(this.irradianceNode=t.getNode(e.irradianceNode)),this}}class fr extends pt{constructor(e=new t.CubeTexture,r,i){super("v4",{shared:!0}),this.nodeType="CubeTexture",this.value=e,this.uv=null!=r?r:new dr,this.bias=i}getTexture(e,t){return super.generate(e,t,this.value.uuid,"tc")}generate(e,t){var r,i;if("samplerCube"===t)return this.getTexture(e,t);const n=this.getTexture(e,t),s=null===(r=this.uv)||void 0===r?void 0:r.build(e,"v3");let o,a=this.bias?this.bias.build(e,"f"):void 0;void 0===a&&e.context.bias&&(a=e.context.bias.setTexture(this).build(e,"f")),o=a?"texCubeBias( "+n+", "+s+", "+a+" )":"texCube( "+n+", "+s+" )";const l={include:e.isShader("vertex"),ignoreCache:!0},c=this.getType(e);return e.addContext(l),this.colorSpace=null!==(i=this.colorSpace)&&void 0!==i?i:new Nt(new _t("",c)),this.colorSpace.fromDecoding(e.getTextureEncodingFromMap(this.value)),this.colorSpace.input.parse(o),o=this.colorSpace.build(e,c),e.removeContext(),e.format(o,c,t)}copy(e){return super.copy(e),this.value.copy(e.value),e.uv?this.uv?this.uv.copy(e.uv):this.uv=e.uv.clone():this.uv=void 0,e.bias?this.bias?this.bias.copy(e.bias):this.bias=e.bias.clone():this.bias=void 0,this}toJSON(e){var t;let r=this.getJSONNode(e);return r||(r=this.createJSONNode(e),this.value&&(r.value=this.value.uuid),r.uv=null===(t=this.uv)||void 0===t?void 0:t.toJSON(e).uuid,this.bias&&(r.bias=this.bias.toJSON(e).uuid)),r.nodeType=this.nodeType,r}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getTexture(e.value)),e.uv&&(this.uv=t.getNode(e.uv)),e.bias&&(this.bias=t.getNode(e.bias)),this}}const mr=ft.elements,gr=["float","vec2","vec3","vec4"],vr={float:"f",vec2:"v2",vec3:"v3",vec4:"v4",mat4:"v4",int:"i",bool:"b","float[]":"f[]","vec4[]":"v4[]"},yr={t:"sampler2D",tc:"samplerCube",b:"bool",i:"int",f:"float",c:"vec3",v2:"vec2",v3:"vec3",v4:"vec4",m3:"mat3",m4:"mat4","f[]":"float[]","v4[]":"vec4[]"};class Ar{constructor(){this.includes={consts:{},functions:{},structs:{}},this.cache="",this.slot="",this.shader="",this.context={},this.getIncludesCode=function(){function e(e,t){return e.deps.length-t.deps.length}return function(t,r){let i=this.getIncludes(t,r);if(!i)return"";let n="";i=i.sort(e);for(let e=0;e<i.length;e++)i[e].src&&(n+=i[e].src+"\n");return n}}(),this.slots=[],this.caches=[],this.contexts=[],this.keywords={},this.nodeData={},this.fragmentVariables={},this.requires={uv:[],color:[],lights:!1,fog:!1,transparent:!1,irradiance:!1,position:!1,worldPosition:!1,normal:!1,worldNormal:!1,vWorldViewDir:!1,vWorldNormal:!1},this.includes={consts:[],functions:[],structs:[]},this.attributes={},this.prefixCode=["#ifdef TEXTURE_LOD_EXT","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCubeLodEXT(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2DLodEXT(a, b, c)","#else","\t#define texCube(a, b) textureCube(a, b)","\t#define texCubeBias(a, b, c) textureCube(a, b, c)","\t#define tex2D(a, b) texture2D(a, b)","\t#define tex2DBias(a, b, c) texture2D(a, b, c)","#endif","\n\t\t\t// NOTE: Include Spline's blending modes. This could be part of BlendNode\n\t\t\t#define SPE_BLENDING_NORMAL 0\n\t\t\t#define SPE_BLENDING_MULTIPLY 1\n\t\t\t#define SPE_BLENDING_SCREEN 2\n\t\t\t#define SPE_BLENDING_OVERLAY 3\n\n\t\t\tvec3 spe_normalBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\treturn mix( a, b, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_multiplyBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\treturn mix( a, a * b, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_screenBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\tvec3 tmp = 1.0 - ( 1.0 - a ) * ( 1.0 - b );\n\t\t\t\treturn mix( a, tmp, alpha );\n\t\t\t}\n\n\t\t\tvec3 spe_overlayBlend( vec3 a, vec3 b, float alpha ) {\n\t\t\t\tvec3 tmp = mix( 1. - 2. * (1. - a) * (1. - b), 2. * a * b, step( a, vec3(.5) ) );\n\t\t\t\treturn clamp( mix( a, tmp, alpha ), 0.0, 1.0 );\n\t\t\t}\n\n\t\t\tvec3 spe_blend( vec3 a, vec3 b, float alpha, int mode ) {\n\t\t\t\tif ( mode == SPE_BLENDING_NORMAL ) return spe_normalBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_MULTIPLY ) return spe_multiplyBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_SCREEN ) return spe_screenBlend( a, b, alpha );\n\t\t\t\telse if ( mode == SPE_BLENDING_OVERLAY ) return spe_overlayBlend( a, b, alpha );\n\t\t\t\treturn vec3( 1.0 );\n\t\t\t}\n\t\t\t","#include <packing>","#include <common>"].join("\n"),this.parsCode={vertex:["float neighbor_offset = 0.0001;",""].join("\n"),fragment:["float accumAlpha = 0.0;","void accumulateAlpha(float alpha) {\n\t\t\t\t\taccumAlpha += (1.0 - accumAlpha) * alpha;\n\t\t\t\t}",""].join("\n")},this.code={vertex:"",fragment:""},this.nodeCode={vertex:"",fragment:""},this.resultCode={vertex:"",fragment:""},this.finalCode={vertex:"",fragment:""},this.inputs={uniforms:{list:[],vertex:[],fragment:[]},arrayUniforms:{list:[],vertex:[],fragment:[]},vars:{varying:[],vertex:[],fragment:[]}},this.defines={},this.uniforms={},this.extensions={derivatives:!1,fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1},this.updaters=[],this.nodes=[],this.analyzing=!1}build(e,t){this.buildShader("vertex",e),this.buildShader("fragment",t);for(let e=0;e<this.requires.uv.length;e++)if(this.requires.uv[e]){const t=e>0?e+1:"";this.addVaryCode("varying vec2 vUv"+t+";"),e>0&&this.addVertexParsCode("attribute vec2 uv"+t+";"),this.addVertexFinalCode("vUv"+t+" = uv"+t+";")}return this.requires.color[0]&&(this.addVaryCode("varying vec4 vColor;"),this.addVertexParsCode("attribute vec4 color;"),this.addVertexFinalCode("vColor = color;")),this.requires.color[1]&&(this.addVaryCode("varying vec4 vColor2;"),this.addVertexParsCode("attribute vec4 color2;"),this.addVertexFinalCode("vColor2 = color2;")),this.requires.position&&(this.addVaryCode("varying vec3 vPosition;"),this.addVertexFinalCode("vPosition = transformed;")),this.requires.worldPosition&&(this.addVaryCode("varying vec3 vWPosition;"),this.addVertexFinalCode("vWPosition = ( modelMatrix * vec4( transformed, 1.0 ) ).xyz;")),this.requires.normal&&(this.addVaryCode("varying vec3 vObjectNormal;"),this.addVertexFinalCode("vObjectNormal = normal;")),this.requires.worldNormal&&(this.addVaryCode("varying vec3 vWNormal;"),this.addVertexFinalCode("vWNormal = inverseTransformDirection( transformedNormal, viewMatrix ).xyz;")),this.requires.vWorldViewDir&&(this.addVaryCode("varying vec3 vWorldViewDir;"),this.addVertexFinalCode("vWorldViewDir = isPerspectiveMatrix( projectionMatrix ) ? ( (modelMatrix * vec4(position, 1.0)).xyz - cameraPosition ) : vec3( -viewMatrix[0][2], -viewMatrix[1][2], -viewMatrix[2][2] );")),this.requires.vWorldNormal&&(this.addVaryCode("varying vec3 vWorldNormal;"),this.addVertexFinalCode("vWorldNormal = normalize( mat3( modelMatrix[0].xyz, modelMatrix[1].xyz, modelMatrix[2].xyz ) * normal );")),this}buildShader(e,t){this.resultCode[e]=t.build(this.setShader(e),"v4")}setMaterial(e,t){return this.material=e,this.renderer=t,this.requires.lights=e.lights,this.requires.fog=e.fog,this.mergeDefines(e.defines),this}addFlow(e,t,r){return this.addSlot(e).addCache(t).addContext(r)}removeFlow(){return this.removeSlot().removeCache().removeContext()}addCache(e){return this.cache=null!=e?e:"",this.caches.push(this.cache),this}removeCache(){return this.caches.pop(),this.cache=this.caches[this.caches.length-1]||"",this}addContext(e){return this.context=Object.assign({},this.context,e),this.context.extra=this.context.extra||{},this.contexts.push(this.context),this}removeContext(){return this.contexts.pop(),this.context=this.contexts[this.contexts.length-1]||{},this}addSlot(e){return this.slot=e||"",this.slots.push(this.slot),this}removeSlot(){return this.slots.pop(),this.slot=this.slots[this.slots.length-1]||"",this}addFragmentVariable(e,t){void 0===this.fragmentVariables[e]&&(this.addFragmentCode(`${t} ${e};`),this.fragmentVariables[e]="")}addVertexCode(e){this.addCode(e,"vertex")}addFragmentCode(e){this.addCode(e,"fragment")}addCode(e,t){this.code[null!=t?t:this.shader]+=e+"\n"}addVertexNodeCode(e){this.addNodeCode(e,"vertex")}addFragmentNodeCode(e){this.addNodeCode(e,"fragment")}addNodeCode(e,t){this.nodeCode[null!=t?t:this.shader]+=e+"\n"}clearNodeCode(e){e=null!=e?e:this.shader;const t=this.nodeCode[e];return this.nodeCode[e]="",t}clearVertexNodeCode(){return this.clearNodeCode("vertex")}clearFragmentNodeCode(){return this.clearNodeCode("fragment")}addVertexFinalCode(e){this.addFinalCode(e,"vertex")}addFragmentFinalCode(e){this.addFinalCode(e,"fragment")}addFinalCode(e,t){this.finalCode[null!=t?t:this.shader]+=e+"\n"}addVertexParsCode(e){this.addParsCode(e,"vertex")}addFragmentParsCode(e){this.addParsCode(e,"fragment")}addParsCode(e,t){this.parsCode[null!=t?t:this.shader]+=e+"\n"}addVaryCode(e){this.addVertexParsCode(e),this.addFragmentParsCode(e)}isCache(e){return-1!==this.caches.indexOf(e)}isSlot(e){return-1!==this.slots.indexOf(e)}define(e,t){this.defines[e]=void 0===t?1:t}require(e){this.requires[e]=!0}isDefined(e){return void 0!==this.defines[e]}getVar(e,t,r,i="varying",n="V",s=""){const o=this.getVars(i);let a=o[e];if(!a){const i=o.length;a={name:r||"node"+n+i+(s?"_"+s:""),type:t},o.push(a),o[e]=a}return a}getTempVar(e,t,r,i){return this.getVar(e,t,r,this.shader,"T",i)}getAttribute(e,t){if(!this.attributes[e]){const r=this.getVar(e,t);this.addVertexParsCode("attribute "+t+" "+e+";"),this.addVertexFinalCode(r.name+" = "+e+";"),this.attributes[e]={varying:r,name:e,type:t}}return this.attributes[e]}getCode(e){return[this.prefixCode,this.parsCode[e],this.getVarListCode(this.getVars("varying"),"varying"),this.getVarListCode(this.inputs.uniforms[e],"uniform"),this.getVarListCode(this.inputs.arrayUniforms[e],"uniform"),this.getIncludesCode("consts",e),this.getIncludesCode("structs",e),this.getIncludesCode("functions",e),"void main() {",this.getVarListCode(this.getVars(e)),this.code[e],this.resultCode[e],this.finalCode[e],"}"].join("\n")}getVarListCode(e,t){t=null!=t?t:"";let r="";for(let i=0,n=e.length;i<n;++i){const n=e[i],s=n.type,o=n.name,a=n.size,l=this.getFormatByType(s);if(void 0===l)throw new Error("Node pars "+l+" not found.");l.includes("[]")?r+=t+" "+l.substring(0,l.length-2)+" "+o+`[${a}];\n`:r+=t+" "+l+" "+o+";\n"}return r}getVars(e){return this.inputs.vars[null!=e?e:this.shader]}getNodeData(e){const t=e instanceof ut?e.uuid:e;return this.nodeData[t]=this.nodeData[t]||{}}createUniform(e,t,r,i,n,s){if(t.includes("[]")){const o=this.inputs.arrayUniforms,a=o.list.length,l=new tr({type:t,size:r.size,name:i||"nodeUA"+a+(s?"_"+s:""),node:r,needsUpdate:n});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}{const o=this.inputs.uniforms,a=o.list.length,l=new tr({type:t,name:i||"nodeU"+a+(s?"_"+s:""),node:r,needsUpdate:n});return o.list.push(l),o[e].push(l),o[e][l.name]=l,this.uniforms[l.name]=l,l}}createVertexUniform(e,t,r,i,n){return this.createUniform("vertex",e,t,r,i,n)}createFragmentUniform(e,t,r,i,n){return this.createUniform("fragment",e,t,r,i,n)}include(e,t,r){var i;let n;if(e="string"==typeof e?St.get(e):e,!1===this.context.include)return e.name;e instanceof Ot?n=this.includes.functions:e instanceof Mt?n=this.includes.consts:e instanceof sr&&(n=this.includes.structs);const s=n[this.shader]=n[this.shader]||[];if(e){let n=s[e.name];if(n||(n=s[e.name]={node:e,deps:[]},s.push(n),n.src=e.build(this,"source")),e instanceof Ot&&t&&s[t.name]&&-1==s[t.name].deps.indexOf(e)&&(s[t.name].deps.push(e),null===(i=e.includes)||void 0===i?void 0:i.length)){let r=0;do{this.include(e.includes[r++],t)}while(r<e.includes.length)}return r&&(n.src=r),e.name}throw new Error("Include not found.")}colorToVectorProperties(e){return e.replace("r","x").replace("g","y").replace("b","z").replace("a","w")}colorToVector(e){return e.replace(/c/g,"v3")}getIncludes(e,t){return this.includes[e][t||this.shader]}getConstructorFromLength(e){return gr[e-1]}isTypeMatrix(e){return/^m/.test(e)}getTypeLength(e){return"f"===e?1:parseInt(this.colorToVector(e).substr(1))}getTypeFromLength(e){return 1===e?"f":"v"+e}findNode(...e){for(let t=0;t<arguments.length;t++){const r=e[t];if(null==r?void 0:r.isNode)return r}}resolve(...e){for(let r=0;r<arguments.length;r++){const i=e[r];if(void 0!==i){if(i.isNode)return i;if(i.isTexture)switch(i.mapping){case t.CubeReflectionMapping:case t.CubeRefractionMapping:return new fr(i);case t.CubeUVReflectionMapping:case t.CubeUVRefractionMapping:return new pr(new Pt(i));default:return new Pt(i)}else{if(i.isVector2)return new At(i);if(i.isVector3)return new wt(i);if(i.isVector4)return new rr(i)}}}}format(e,t,r){switch(this.colorToVector(r+" <- "+t)){case"f <- v2":case"f <- v3":case"f <- v4":return e+".x";case"f <- i":case"f <- b":return"float( "+e+" )";case"v2 <- f":return"vec2( "+e+" )";case"v2 <- v3":case"v2 <- v4":return e+".xy";case"v2 <- i":case"v2 <- b":return"vec2( float( "+e+" ) )";case"v3 <- f":return"vec3( "+e+" )";case"v3 <- v2":return"vec3( "+e+", 0.0 )";case"v3 <- v4":return e+".xyz";case"v3 <- i":case"v3 <- b":return"vec2( float( "+e+" ) )";case"v4 <- f":return"vec4( "+e+" )";case"v4 <- v2":return"vec4( "+e+", 0.0, 1.0 )";case"v4 <- v3":return"vec4( "+e+", 1.0 )";case"v4 <- i":case"v4 <- b":return"vec4( float( "+e+" ) )";case"i <- f":case"i <- b":return"int( "+e+" )";case"i <- v2":case"i <- v3":case"i <- v4":return"int( "+e+".x )";case"b <- f":return"( "+e+" != 0.0 )";case"b <- v2":return"( "+e+" != vec2( 0.0 ) )";case"b <- v3":return"( "+e+" != vec3( 0.0 ) )";case"b <- v4":return"( "+e+" != vec4( 0.0 ) )";case"b <- i":return"( "+e+" != 0 )"}return e}getTypeByFormat(e){return vr[e]||e}getFormatByType(e){return yr[e]||e}getUUID(e,t){return(t=void 0===t||t)&&this.cache&&(e=this.cache+"-"+e),e}getElementByIndex(e){return mr[e]}getIndexByElement(e){return mr.indexOf(e)}isShader(e){return this.shader===e}setShader(e){return this.shader=e,this}mergeDefines(e){for(const t in e)this.defines[t]=e[t];return this.defines}mergeUniform(e){for(const t in e)this.uniforms[t]=e[t];return this.uniforms}getTextureEncodingFromMap(e){let r;return e?e.isTexture&&(r=e.encoding):r=t.LinearEncoding,r===t.LinearEncoding&&this.context.gamma&&(r=t.GammaEncoding),r}}class wr extends ut{constructor(e=new ut){super("v4"),this.nodeType="Raw",this.value=e}generate(e){const t=this.value.analyzeAndFlow(e,this.type);let r=t.code+"\n";return e.isShader("vertex")?r+="gl_Position = "+t.result+";":r+="gl_FragColor = "+t.result+";",r}copy(e){return super.copy(e),this.value.copy(e.value),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.value=this.value.toJSON(e).uuid),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=t.getNode(e.value)),this}}class xr extends t.ShaderMaterial{constructor(e,t,r){super(r),this.isNodeMaterial=!0,this.type="NodeMaterial",this.wireframeLinecap="",this.wireframeLinejoin="",this.userData={type:"",category:"",nodeType:""},this.fog=!0,this.vertex=null!=e?e:new wr(new ur(ur.PROJECTION)),this.fragment=null!=t?t:new wr(new mt(5855577)),this.updaters=[],this.isDetached=!0,this.dithering=!0,this.onBeforeCompile=this._onBeforeCompile}getDefines(){return this.defines}getUniforms(){return this.uniforms}getVertexShader(){return this.vertexShader}getFragmentShader(){return this.fragmentShader}_onBeforeCompile(e,t){this.build({renderer:t}),e.defines=this.defines,e.uniforms=this.uniforms,e.vertexShader=this.vertexShader,e.fragmentShader=this.fragmentShader,e.extensionDerivatives=!0===this.extensions.derivatives,e.extensionFragDepth=!0===this.extensions.fragDepth,e.extensionDrawBuffers=!0===this.extensions.drawBuffers,e.extensionShaderTextureLOD=!0===this.extensions.shaderTextureLOD}_getLayerStack(e){const t=new $t(this);return e&&(()=>{er(this,void 0,void 0,(function*(){for(;void 0===e.image;)yield new Promise((e=>requestAnimationFrame(e)));t.addLayerAt(1,{type:ot.TEXTURE,texture:e}),this.dispose()}))})(),t}clampUniformsForPreview(){if(this.userData.layers)for(const i of this.userData.layers.getLayers())i.type!=ot.DISPLACE_MAP&&i.type!=ot.DISPLACE_NOISE||(i.uniforms[`${i.id}_intensity`]=(e=i.uniforms[`${i.id}_intensity`],t=-150,r=150,Math.min(Math.max(e,t),r)));var e,t,r}customProgramCacheKey(){return this.getHash()}updateFrame(e){for(let t=0;t<this.updaters.length;++t)e.updateNode(this.updaters[t])}build(e){var r;const i=null!==(r=(e=null!=e?e:{}).builder)&&void 0!==r?r:new Ar;return i.setMaterial(this,e.renderer),i.build(this.vertex,this.fragment),this.vertexShader=i.getCode("vertex"),this.fragmentShader=i.getCode("fragment"),this.defines=i.defines,this.uniforms=i.uniforms,this.extensions=i.extensions,this.updaters=i.updaters,this.fog=i.requires.fog,this.lights=i.requires.lights,this.transparent=i.requires.transparent||this.blending>t.NormalBlending,this}getHash(){let e="{";return e+='"vertex":'+this.vertex.getHash()+",",e+='"fragment":'+this.fragment.getHash(),e+="}",e}copy(e){const t=this.uuid;for(const t in e)this[t]=e[t];return this.uuid=t,void 0!==e.userData&&(this.userData=JSON.parse(JSON.stringify(e.userData))),this}toJSON(e){const t=this.userData.layers;this.userData.layers=void 0;const r=super.toJSON(e);return r.type="ShaderMaterial",r.userData={type:this.userData.type,category:this.userData.category,nodeType:this.type,layers:t.toJSON(e)},r.vertex=this.vertex.toJSON(e).uuid,r.fragment=this.fragment.toJSON(e).uuid,delete r.vertexShader,delete r.fragmentShader,delete r.color,delete r.shininess,delete r.specular,delete r.roughness,delete r.metalness,delete r.uniforms,e&&!e.materials[this.uuid]&&(e.materials[this.uuid]=r),this.userData.layers=t,r}fromJSON(e,r){var i;this.defines=null!==(i=e.defines)&&void 0!==i?i:{},this.depthFunc=e.depthFunc,this.depthWrite=e.depthWrite,this.side=void 0!==e.side?e.side:t.FrontSide,this.transparent=e.transparent,this.wireframeLinecap=e.wireframeLinecap,this.wireframeLinejoin=e.wireframeLinejoin,this.flatShading=e.flatShading,this.wireframe=e.wireframe,this.userData.layers.fromJSON(e.userData.layers,r,this)}}Object.defineProperties(xr.prototype,{properties:{get:function(){return this.fragment.properties}},needsUpdate:{set:function(e){!0===e&&this.version++,this.needsCompile=e},get:function(){return this.needsCompile}}});class br extends ut{constructor(){super("basic"),this.nodeType="Basic",this.color=new mt(5855577)}generate(e){let r;if(e.isShader("vertex")){const i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(t.UniformsUtils.merge([t.UniformsLib.fog])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif","#include <fog_pars_vertex>"].join("\n"));const n=["#include <beginnormal_vertex>","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#if defined( USE_LAYER_DISPLACE )\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#ifndef FLAT_SHADED"," vNormal = normalize( transformedNormal );","#endif","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif /* !USE_LAYER_DISPLACE */\n\t\t\t\t"];i&&n.push(i.code,i.result?"displaced_position = "+i.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED","\tvNormal = transformedNormal;","#endif"),n.push("#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","#include <fog_vertex>","#include <logdepthbuf_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>"),r=n.join("\n")}else{void 0===this.color&&(this.color=new mt(5855577)),this.color.analyze(e,{slot:"color"}),this.alpha&&this.alpha.analyze(e),this.mask&&this.mask.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"});const t=this.color.flow(e,"c",{slot:"color"}),i=this.alpha?this.alpha.flow(e,"f"):void 0,n=this.mask?this.mask.flow(e,"b"):void 0,s=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0;e.requires.transparent=void 0!==i,e.addParsCode(["#include <fog_pars_fragment>","#include <dithering_pars_fragment>","varying vec3 vViewPosition;","#ifndef FLAT_SHADED"," varying vec3 vNormal;","#endif"].join("\n"));const o=["#include <normal_fragment_begin>",t.code];n&&o.push(n.code,"if ( ! "+n.result+" ) discard;"),i&&o.push(i.code,"#ifdef ALPHATEST"," if ( "+i.result+" <= ALPHATEST ) discard;","#endif"),s?o.push(s.code,`vec3 outgoingLight = ${t.result};`,`vec3 finalColor = spe_blend(outgoingLight, ${s.result}, 1.0, SPE_BLENDING_NORMAL);`):o.push(`vec3 finalColor = ${t.result};`),i?o.push(`gl_FragColor = vec4( finalColor, accumAlpha * ${i.result} );`):o.push("gl_FragColor = vec4("+t.result+", 1.0 );"),o.push("#include <fog_fragment>","#include <dithering_fragment>"),r=o.join("\n")}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),e.position&&(this.position=e.position.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.mask&&(this.mask=e.mask.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.color&&(t.color=this.color.toJSON(e).uuid),this.position&&(t.position=this.position.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.mask&&(t.mask=this.mask.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.mask&&(this.mask=t.getNode(e.mask)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),this}}class Sr extends xr{constructor(e=new br,t){super(e,e,t),this.type="BasicNodeMaterial"}}ft.addShortcuts(Sr.prototype,"fragment",["color","alpha","afterColor","shadingAlpha","shadingBlend","mask","position"]);class Er extends Sr{constructor(e,t,r){super(t,e),this.userData.type="BasicMaterial",this.userData.category="Basic",this.userData.layers=null!=r?r:this._getLayerStack(null==e?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(void 0!==e.userData.layers&&e.userData.layers instanceof $t){const t=e.userData.layers,r=e.fragment;super.copy(e);const i=r.clone();this.fragment=i,this.vertex=i;const n=t.clone();this.userData.layers=n,n.material=this}else super.copy(e);return this}static fromJSON(e,t,r){const i=r.getNode(t.vertex),n=new Er(void 0,i);return n.fromJSON(t,r),n}static fromMaterial(e){const t=new Er(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}}class Cr extends ut{constructor(){super("phong"),this.nodeType="Phong",this.color=new mt(5855577),this.specular=new mt(1118481),this.shininess=new gt(30),this.shadingAlpha=new gt(1),this.shadingBlend=new vt(0)}build(e){let r;if(e.define("PHONG"),e.requires.lights=!0,e.isShader("vertex")){const i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(t.UniformsUtils.merge([t.UniformsLib.fog,t.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include <fog_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","#include <shadowmap_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));const n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];i&&n.push(i.code,i.result?"displaced_position = "+i.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("\t#include <morphtarget_vertex>","\t#include <skinning_vertex>","\t#include <project_vertex>","\t#include <logdepthbuf_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),r=n.join("\n")}else{this.mask&&this.mask.analyze(e),void 0===this.color&&(this.color=new mt(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.normal&&this.normal.analyze(e),this.light&&this.light.analyze(e,{cache:"light"}),this.ao&&this.ao.analyze(e),this.ambient&&this.ambient.analyze(e),this.shadow&&this.shadow.analyze(e),this.emissive&&this.emissive.analyze(e,{slot:"emissive"}),this.environment&&this.environment.analyze(e,{slot:"environment"}),this.environmentAlpha&&this.environment&&this.environmentAlpha.analyze(e);const t=this.mask?this.mask.flow(e,"b"):void 0,i=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.normal?this.normal.flow(e,"v3"):void 0,u=this.light?this.light.flow(e,"v3",{cache:"light"}):void 0,d=this.ao?this.ao.flow(e,"f"):void 0,p=this.ambient?this.ambient.flow(e,"c"):void 0,f=this.shadow?this.shadow.flow(e,"c"):void 0,m=this.emissive?this.emissive.flow(e,"c",{slot:"emissive"}):void 0,g=this.environment?this.environment.flow(e,"c",{slot:"environment"}):void 0,v=this.environmentAlpha&&this.environment?this.environmentAlpha.flow(e,"f"):void 0;e.requires.transparent=void 0!==c,e.addParsCode(["#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_phong_pars_fragment>","#include <shadowmap_pars_fragment>","#include <logdepthbuf_pars_fragment>","#include <dithering_pars_fragment>"].join("\n"));const y=["#include <normal_fragment_begin>","\tBlinnPhongMaterial material;"];t&&y.push(t.code,"if ( ! "+t.result+" ) discard;"),y.push(i.code,"\tvec3 diffuseColor = "+i.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include <logdepthbuf_fragment>",n.code,"\tvec3 specular = "+n.result+";",s.code,"\tfloat shininess = max( 0.0001, "+s.result+" );","\tfloat specularStrength = 1.0;"),c&&y.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),h&&y.push(h.code,"normal = "+h.result+";"),y.push("material.diffuseColor = "+(u?"vec3( 1.0 )":"diffuseColor")+";"),y.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),u&&(y.push(u.code,"reflectedLight.directDiffuse = "+u.result+";"),y.push("reflectedLight.directDiffuse *= diffuseColor;","reflectedLight.indirectDiffuse *= diffuseColor;")),d&&y.push(d.code,"reflectedLight.indirectDiffuse *= "+d.result+";"),p&&y.push(p.code,"reflectedLight.indirectDiffuse += "+p.result+";"),f&&y.push(f.code,"reflectedLight.directDiffuse *= "+f.result+";","reflectedLight.directSpecular += "+f.result+";"),m&&y.push(m.code,"reflectedLight.directDiffuse += "+m.result+";"),y.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),g&&(y.push(g.code),v?y.push(v.code,"outgoingLight = mix( outgoingLight, "+g.result+", "+v.result+" );"):y.push("outgoingLight = "+g.result+";")),y.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result}, ${a.result} );\n\t\t\t\t}\n\t\t\t\t`),l&&y.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?y.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):y.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),y.push("#include <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>","#include <premultiplied_alpha_fragment>","#include <dithering_fragment>"),r=y.join("\n")}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.mask&&(this.mask=e.mask.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.normal&&(this.normal=e.normal.clone()),e.light&&(this.light=e.light.clone()),e.shadow&&(this.shadow=e.shadow.clone()),e.ao&&(this.ao=e.ao.clone()),e.emissive&&(this.emissive=e.emissive.clone()),e.ambient&&(this.ambient=e.ambient.clone()),e.environment&&(this.environment=e.environment.clone()),e.environmentAlpha&&(this.environmentAlpha=e.environmentAlpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid,t.shadingBlend=this.shadingBlend.toJSON(e).uuid,this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.mask&&(t.mask=this.mask.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.normal&&(t.normal=this.normal.toJSON(e).uuid),this.light&&(t.light=this.light.toJSON(e).uuid),this.ao&&(t.ao=this.ao.toJSON(e).uuid),this.ambient&&(t.ambient=this.ambient.toJSON(e).uuid),this.shadow&&(t.shadow=this.shadow.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid),this.environment&&(t.environment=this.environment.toJSON(e).uuid),this.environmentAlpha&&(t.environmentAlpha=this.environmentAlpha.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.specular&&(this.specular=t.getNode(e.specular)),e.shininess&&(this.shininess=t.getNode(e.shininess)),e.mask&&(this.mask=t.getNode(e.mask)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.normal&&(this.normal=t.getNode(e.normal)),e.light&&(this.light=t.getNode(e.light)),e.ao&&(this.ao=t.getNode(e.ao)),e.ambient&&(this.ambient=t.getNode(e.ambient)),e.shadow&&(this.shadow=t.getNode(e.shadow)),e.emissive&&(this.emissive=t.getNode(e.emissive)),e.environment&&(this.environment=t.getNode(e.environment)),e.environmentAlpha&&(this.environmentAlpha=t.getNode(e.environmentAlpha)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}}class Tr extends xr{constructor(e=new Cr,t){super(e,e,t),this.type="PhongNodeMaterial"}}ft.addShortcuts(Tr.prototype,"fragment",["color","afterColor","alpha","shadingAlpha","shadingBlend","specular","shininess","normal","emissive","ambient","light","shadow","ao","environment","environmentAlpha","mask","position"]);class Or extends Tr{constructor(e,t,r){super(t,e),this.userData.type="PhongMaterial",this.userData.category="Phong",this.userData.layers=null!=r?r:this._getLayerStack(null==e?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(void 0!==e.userData.layers&&e.userData.layers instanceof $t){const t=e.userData.layers,r=e.fragment;super.copy(e);const i=r.clone();this.fragment=i,this.vertex=i;const n=t.clone();this.userData.layers=n,n.material=this,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){const i=r.getNode(t.vertex),n=new Or(void 0,i);return n.fromJSON(t,r),n}static fromMaterial(e){const t=new Or(e.map?{map:e.map}:{}),r=t.fragment;return r.color.value.copy(e.color),r.alpha.value=e.opacity,t}dispose(){super.dispose()}}class Dr extends ut{constructor(){super("lambert"),this.nodeType="Lambert",this.color=new mt(5855577),this.emissive=new mt(0),this.emissiveIntensity=new gt(1),this.shadingAlpha=new gt(1),this.shadingBlend=new vt(0)}build(e){let r;if(e.define("LAMBERT"),e.requires.lights=!0,e.isShader("vertex")){const i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(t.UniformsUtils.merge([t.UniformsLib.fog,t.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","\tvarying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <color_pars_vertex>","#include <fog_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","#include <shadowmap_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));const n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];i&&n.push(i.code,i.result?"displaced_position = "+i.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("\t#include <morphtarget_vertex>","\t#include <skinning_vertex>","\t#include <project_vertex>","\t#include <logdepthbuf_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\n\t\t\t\t\tvec3 diffuse = vec3( 1.0 );\n\t\t\t\t\tGeometricContext geometry;\n\t\t\t\t\tgeometry.position = mvPosition.xyz;\n\t\t\t\t\tgeometry.normal = normalize( transformedNormal );\n\t\t\t\t\tgeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\t\t\t\t\tGeometricContext backGeometry;\n\t\t\t\t\tbackGeometry.position = geometry.position;\n\t\t\t\t\tbackGeometry.normal = -geometry.normal;\n\t\t\t\t\tbackGeometry.viewDir = geometry.viewDir;\n\t\t\t\t\tvLightFront = vec3( 0.0 );\n\t\t\t\t\tvIndirectFront = vec3( 0.0 );\n\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\tvLightBack = vec3( 0.0 );\n\t\t\t\t\t\tvIndirectBack = vec3( 0.0 );\n\t\t\t\t\t#endif\n\t\t\t\t\tIncidentLight directLight;\n\t\t\t\t\tfloat dotNL;\n\t\t\t\t\tvec3 directLightColor_Diffuse;\n\t\t\t\t\t#if NUM_POINT_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_SPOT_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_DIR_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\t\t\t\t\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\t\t\t\t\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\t\t\t\t\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t\t#if NUM_HEMI_LIGHTS > 0\n\t\t\t\t\t\t#pragma unroll_loop_start\n\t\t\t\t\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\t\t\t\t\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t\t\t\t\t\t#ifdef DOUBLE_SIDED\n\t\t\t\t\t\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t\t\t\t\t\t#endif\n\t\t\t\t\t\t}\n\t\t\t\t\t\t#pragma unroll_loop_end\n\t\t\t\t\t#endif\n\t\t\t\t","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),r=n.join("\n")}else{this.mask&&this.mask.analyze(e),void 0===this.color&&(this.color=new mt(5855577)),this.color.analyze(e,{slot:"color"}),this.emissive.analyze(e,{slot:"emissive"}),this.emissiveIntensity.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.normal&&this.normal.analyze(e),this.light&&this.light.analyze(e,{cache:"light"}),this.ao&&this.ao.analyze(e),this.ambient&&this.ambient.analyze(e),this.shadow&&this.shadow.analyze(e),this.environment&&this.environment.analyze(e,{slot:"environment"}),this.environmentAlpha&&this.environment&&this.environmentAlpha.analyze(e);const t=this.mask?this.mask.flow(e,"b"):void 0,i=this.color.flow(e,"c",{slot:"color"}),n=this.emissive.flow(e,"c",{slot:"emissive"}),s=this.emissiveIntensity.flow(e,"f",{slot:"emissive"}),o=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.normal?this.normal.flow(e,"v3"):void 0;this.environment&&this.environment.flow(e,"c",{slot:"environment"}),this.environmentAlpha&&this.environment&&this.environmentAlpha.flow(e,"f");e.requires.transparent=void 0!==c,e.addParsCode(["varying vec3 vViewPosition;","varying vec3 vLightFront;","varying vec3 vIndirectFront;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#ifdef DOUBLE_SIDED","\tvarying vec3 vLightBack;","\tvarying vec3 vIndirectBack;","#endif","#include <bsdfs>","#include <lights_pars_begin>","#include <fog_pars_fragment>","#include <shadowmap_pars_fragment>","#include <shadowmask_pars_fragment>","#include <logdepthbuf_pars_fragment>","#include <clipping_planes_pars_fragment>","#include <dithering_pars_fragment>"].join("\n"));const u=["#include <normal_fragment_begin>","#include <clipping_planes_fragment>"];t&&u.push(t.code,"if ( ! "+t.result+" ) discard;"),u.push(i.code,"vec3 diffuseColor = "+i.result+";","ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include <logdepthbuf_fragment>"),c&&u.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),h&&u.push(h.code,"normal = "+h.result+";"),u.push("#ifdef DOUBLE_SIDED","\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;","#else","\treflectedLight.indirectDiffuse += vIndirectFront;","#endif","#include <lightmap_fragment>","reflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor );","#ifdef DOUBLE_SIDED","\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;","#else","\treflectedLight.directDiffuse = vLightFront;","#endif","reflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor ) * getShadowMask();"),n&&u.push(n.code,"reflectedLight.directDiffuse += "+n.result+" * "+s.result+";"),u.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;"),u.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result}, ${a.result} );\n\t\t\t\t}\n\t\t\t\t`),l&&u.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?u.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):u.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),u.push("#include <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>","#include <premultiplied_alpha_fragment>","#include <dithering_fragment>"),r=u.join("\n")}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.emissiveIntensity=e.emissiveIntensity.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.mask&&(this.mask=e.mask.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.normal&&(this.normal=e.normal.clone()),e.light&&(this.light=e.light.clone()),e.shadow&&(this.shadow=e.shadow.clone()),e.ao&&(this.ao=e.ao.clone()),e.emissive&&(this.emissive=e.emissive.clone()),e.ambient&&(this.ambient=e.ambient.clone()),e.environment&&(this.environment=e.environment.clone()),e.environmentAlpha&&(this.environmentAlpha=e.environmentAlpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.emissiveIntensity=this.emissiveIntensity.toJSON(e).uuid,t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid,t.shadingBlend=this.shadingBlend.toJSON(e).uuid,this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid),this.mask&&(t.mask=this.mask.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.normal&&(t.normal=this.normal.toJSON(e).uuid),this.light&&(t.light=this.light.toJSON(e).uuid),this.ao&&(t.ao=this.ao.toJSON(e).uuid),this.ambient&&(t.ambient=this.ambient.toJSON(e).uuid),this.shadow&&(t.shadow=this.shadow.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid),this.environment&&(t.environment=this.environment.toJSON(e).uuid),this.environmentAlpha&&(t.environmentAlpha=this.environmentAlpha.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),e.emissiveIntensity&&(this.emissiveIntensity=t.getNode(e.emissiveIntensity)),e.mask&&(this.mask=t.getNode(e.mask)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.normal&&(this.normal=t.getNode(e.normal)),e.light&&(this.light=t.getNode(e.light)),e.ao&&(this.ao=t.getNode(e.ao)),e.ambient&&(this.ambient=t.getNode(e.ambient)),e.shadow&&(this.shadow=t.getNode(e.shadow)),e.emissive&&(this.emissive=t.getNode(e.emissive)),e.environment&&(this.environment=t.getNode(e.environment)),e.environmentAlpha&&(this.environmentAlpha=t.getNode(e.environmentAlpha)),this}}class Mr extends xr{constructor(e=new Dr,t){super(e,e,t),this.type="LambertNodeMaterial"}}ft.addShortcuts(Mr.prototype,"fragment",["color","afterColor","alpha","shadingAlpha","shadingBlend","normal","emissive","emissiveIntensity","ambient","light","shadow","ao","environment","environmentAlpha","mask","position"]);class _r extends Mr{constructor(e,t,r){super(t,e),this.userData.type="LambertMaterial",this.userData.category="Lambert",this.userData.layers=null!=r?r:this._getLayerStack(null==e?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(void 0!==e.userData.layers&&e.userData.layers instanceof $t){const t=e.userData.layers,r=e.fragment;super.copy(e);const i=r.clone();this.fragment=i,this.vertex=i;const n=t.clone();this.userData.layers=n,n.material=this,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){const i=r.getNode(t.vertex),n=new _r(void 0,i);return n.fromJSON(t,r),n}dispose(){super.dispose()}}class Nr extends ut{constructor(){super("toon"),this.nodeType="Toon",this.color=new mt(5855577),this.specular=new mt(1118481),this.shininess=new gt(30),this.shadingAlpha=new gt(1),this.shadingBlend=new vt(0)}build(e){let r;if(e.define("TOON"),e.requires.lights=!0,e.isShader("vertex")){const i=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(t.UniformsUtils.merge([t.UniformsLib.fog,t.UniformsLib.lights])),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include <fog_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","#include <shadowmap_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));const n=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#ifdef USE_LAYER_DISPLACE\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","\n\t\t\t\t#ifndef USE_LAYER_DISPLACE\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif\n\t\t\t\t"];i&&n.push(i.code,i.result?"displaced_position = "+i.result+";":""),n.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),n.push("\t#include <morphtarget_vertex>","\t#include <skinning_vertex>","\t#include <project_vertex>","\t#include <fog_vertex>","\t#include <logdepthbuf_vertex>","\t#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","\t#include <worldpos_vertex>","\t#include <shadowmap_vertex>","\t#include <fog_vertex>"),r=n.join("\n")}else{this.mask&&this.mask.analyze(e),void 0===this.color&&(this.color=new mt(5855577)),this.color.analyze(e,{slot:"color"}),this.specular.analyze(e),this.shininess.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.normal&&this.normal.analyze(e),this.light&&this.light.analyze(e,{cache:"light"}),this.ao&&this.ao.analyze(e),this.ambient&&this.ambient.analyze(e),this.shadow&&this.shadow.analyze(e),this.emissive&&this.emissive.analyze(e,{slot:"emissive"}),this.environment&&this.environment.analyze(e,{slot:"environment"}),this.environmentAlpha&&this.environment&&this.environmentAlpha.analyze(e);const t=this.mask?this.mask.flow(e,"b"):void 0,i=this.color.flow(e,"c",{slot:"color"}),n=this.specular.flow(e,"c"),s=this.shininess.flow(e,"f"),o=this.shadingAlpha.flow(e,"f"),a=this.shadingBlend.flow(e,"i"),l=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,c=this.alpha?this.alpha.flow(e,"f"):void 0,h=this.normal?this.normal.flow(e,"v3"):void 0,u=this.light?this.light.flow(e,"v3",{cache:"light"}):void 0,d=this.ao?this.ao.flow(e,"f"):void 0,p=this.ambient?this.ambient.flow(e,"c"):void 0,f=this.shadow?this.shadow.flow(e,"c"):void 0,m=this.emissive?this.emissive.flow(e,"c",{slot:"emissive"}):void 0,g=this.environment?this.environment.flow(e,"c",{slot:"environment"}):void 0,v=this.environmentAlpha&&this.environment?this.environmentAlpha.flow(e,"f"):void 0;e.requires.transparent=void 0!==c,e.addParsCode(["#include <gradientmap_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <dithering_pars_fragment>","\n\t\t\t\t\tvarying vec3 vViewPosition;\n\t\t\t\t\t#ifndef FLAT_SHADED\n\t\t\t\t\t\tvarying vec3 vNormal;\n\t\t\t\t\t#endif\n\t\t\t\t\tstruct ToonMaterial {\n\t\t\t\t\t\tvec3\tdiffuseColor;\n\t\t\t\t\t\tvec3\tspecularColor;\n\t\t\t\t\t\tfloat\tspecularShininess;\n\t\t\t\t\t\tfloat\tspecularStrength;\n\t\t\t\t\t};\n\t\t\t\t\tvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\t\t\t\t\t\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\t\t\t\t\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\t\t\t\t\tirradiance *= PI;\n\t\t\t\t\t\t#endif\n\t\t\t\t\t\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t\t\t\t\t\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\t\t\t\t\t}\n\t\t\t\t\tvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\t\t\t\t\t\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\t\t\t\t\t}\n\t\t\t\t\t#define RE_Direct\t\t\t\tRE_Direct_Toon\n\t\t\t\t\t#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\t\t\t\t\t#define Material_LightProbeLOD( material )\t(0)\n\t\t\t\t\t","#include <shadowmap_pars_fragment>","#include <bumpmap_pars_fragment>","#include <normalmap_pars_fragment>","#include <logdepthbuf_pars_fragment>"].join("\n"));const y=["#include <normal_fragment_begin>","\tToonMaterial material;"];t&&y.push(t.code,"if ( ! "+t.result+" ) discard;"),y.push(i.code,"\tvec3 diffuseColor = "+i.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include <logdepthbuf_fragment>",n.code,"\tvec3 specular = "+n.result+";",s.code,"\tfloat shininess = max( 0.0001, "+s.result+" );","\tfloat specularStrength = 1.0;"),c&&y.push(c.code,"#ifdef ALPHATEST","if ( "+c.result+" <= ALPHATEST ) discard;","#endif"),h&&y.push(h.code,"normal = "+h.result+";"),y.push("material.diffuseColor = "+(u?"vec3( 1.0 )":"diffuseColor")+";"),y.push("material.specularColor = specular;","material.specularShininess = shininess;","material.specularStrength = specularStrength;","#include <lights_fragment_begin>","#include <lights_fragment_end>"),u&&(y.push(u.code,"reflectedLight.directDiffuse = "+u.result+";"),y.push("reflectedLight.directDiffuse *= diffuseColor;","reflectedLight.indirectDiffuse *= diffuseColor;")),d&&y.push(d.code,"reflectedLight.indirectDiffuse *= "+d.result+";"),p&&y.push(p.code,"reflectedLight.indirectDiffuse += "+p.result+";"),f&&y.push(f.code,"reflectedLight.directDiffuse *= "+f.result+";","reflectedLight.directSpecular += "+f.result+";"),m&&y.push(m.code,"reflectedLight.directDiffuse += "+m.result+";"),y.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular;"),g&&(y.push(g.code),v?y.push(v.code,"outgoingLight = mix( outgoingLight, "+g.result+", "+v.result+" );"):y.push("outgoingLight = "+g.result+";")),y.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${o.result} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${o.result}, ${a.result} );\n\t\t\t\t}\n\t\t\t\t`),l&&y.push(l.code,`outgoingLight = spe_blend(outgoingLight, ${l.result}, 1.0, SPE_BLENDING_NORMAL);`),c?y.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${c.result} );`):y.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),y.push("#include <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>","#include <premultiplied_alpha_fragment>","#include <dithering_fragment>"),r=y.join("\n")}return r}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.specular=e.specular.clone(),this.shininess=e.shininess.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.mask&&(this.mask=e.mask.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.normal&&(this.normal=e.normal.clone()),e.light&&(this.light=e.light.clone()),e.shadow&&(this.shadow=e.shadow.clone()),e.ao&&(this.ao=e.ao.clone()),e.emissive&&(this.emissive=e.emissive.clone()),e.ambient&&(this.ambient=e.ambient.clone()),e.environment&&(this.environment=e.environment.clone()),e.environmentAlpha&&(this.environmentAlpha=e.environmentAlpha.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.specular=this.specular.toJSON(e).uuid,t.shininess=this.shininess.toJSON(e).uuid,this.mask&&(t.mask=this.mask.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.normal&&(t.normal=this.normal.toJSON(e).uuid),this.light&&(t.light=this.light.toJSON(e).uuid),this.ao&&(t.ao=this.ao.toJSON(e).uuid),this.ambient&&(t.ambient=this.ambient.toJSON(e).uuid),this.shadow&&(t.shadow=this.shadow.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid),this.environment&&(t.environment=this.environment.toJSON(e).uuid),this.environmentAlpha&&(t.environmentAlpha=this.environmentAlpha.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.specular&&(this.specular=t.getNode(e.specular)),e.shininess&&(this.shininess=t.getNode(e.shininess)),e.mask&&(this.mask=t.getNode(e.mask)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.normal&&(this.normal=t.getNode(e.normal)),e.light&&(this.light=t.getNode(e.light)),e.ao&&(this.ao=t.getNode(e.ao)),e.ambient&&(this.ambient=t.getNode(e.ambient)),e.shadow&&(this.shadow=t.getNode(e.shadow)),e.emissive&&(this.emissive=t.getNode(e.emissive)),e.environment&&(this.environment=t.getNode(e.environment)),e.environmentAlpha&&(this.environmentAlpha=t.getNode(e.environmentAlpha)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}}class Lr extends xr{constructor(e=new Nr,t){super(e,e,t),this.type="ToonNodeMaterial"}}ft.addShortcuts(Lr.prototype,"fragment",["color","afterColor","alpha","shadingAlpha","shadingBlend","specular","shininess","normal","emissive","ambient","light","shadow","ao","environment","environmentAlpha","mask","position"]);class Br extends Lr{constructor(e,t,r){super(t,e),this.userData.type="ToonMaterial",this.userData.category="Toon",this.userData.layers=null!=r?r:this._getLayerStack(null==e?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(void 0!==e.userData.layers&&e.userData.layers instanceof $t){const t=e.userData.layers,r=e.fragment;super.copy(e);const i=r.clone();this.fragment=i,this.vertex=i;const n=t.clone();this.userData.layers=n,n.material=this,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){const i=r.getNode(t.vertex),n=new Br(void 0,i);return n.fromJSON(t,r),n}dispose(){super.dispose()}}class Ir extends gt{constructor(e){super(),this.nodeType="MaxMIPLevel",this.texture=e,this.maxMIPLevel=0}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),t.maxMIPLevel=this.maxMIPLevel),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.texture&&(this.texture=t.getNode(e.texture)),void 0!==e.maxMIPLevel&&(this.maxMIPLevel=e.maxMIPLevel),this}}Object.defineProperties(Ir.prototype,{value:{get:function(){if(0===this.maxMIPLevel){let e=this.texture.value.image;Array.isArray(e)&&(e=e[0]),this.maxMIPLevel=void 0!==e?Math.log(Math.max(e.width,e.height))*Math.LOG2E:0}return this.maxMIPLevel},set:function(){}}});class Pr extends dt{constructor(e=new ut,t){super("f"),this.nodeType="SpecularMIPLevel",this.roughness=e,this.texture=t}setTexture(e){return this.texture=e,this}generate(e,t){var r;if(e.isShader("fragment")){this.maxMIPLevel=null!==(r=this.maxMIPLevel)&&void 0!==r?r:new Ir,this.maxMIPLevel.texture=this.texture;const i=e.include(Pr.Nodes.getSpecularMIPLevel);return e.format(i+"( "+this.roughness.build(e,"f")+", "+this.maxMIPLevel.build(e,"f")+" )",this.type,t)}return console.warn("SpecularMIPLevelNode is not compatible with "+e.shader+" shader."),e.format("0.0",this.type,t)}copy(e){return super.copy(e),this.roughness=e.roughness,e.texture?this.texture?this.texture.copy(e.texture):this.texture=e.texture.clone():this.texture=void 0,e.maxMIPLevel?this.maxMIPLevel?this.maxMIPLevel.copy(e.maxMIPLevel):this.maxMIPLevel=e.maxMIPLevel.clone():this.maxMIPLevel=void 0,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.texture&&(t.texture=this.texture.toJSON(e).uuid),this.roughness&&(t.roughness=this.roughness.toJSON(e).uuid),this.maxMIPLevel&&(t.maxMIPLevel=this.maxMIPLevel.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.texture&&(this.texture=t.getNode(e.texture)),e.maxMIPLevel&&(this.maxMIPLevel=t.getNode(e.maxMIPLevel)),this}}Pr.Nodes={getSpecularMIPLevel:new Ot(["float getSpecularMIPLevel( const in float roughness, const in float maxMIPLevelScalar ) {","\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );","\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );","\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );","}"].join("\n"))};class Rr extends ut{constructor(){super("standard"),this.nodeType="Standard",this.color=new mt(5855577),this.roughness=new gt(.3),this.metalness=new gt(0),this.reflectivity=new gt(.5),this.shadingAlpha=new gt(1),this.shadingBlend=new vt(0)}build(e){var r,i,n,s,o,a,l;let c;e.define("STANDARD");const h=null!==(i=null!==(r=this.clearcoat)&&void 0!==r?r:this.clearcoatRoughness)&&void 0!==i?i:this.clearcoatNormal;if(h&&e.define("CLEARCOAT"),e.requires.lights=!0,e.extensions.derivatives=!0,e.extensions.shaderTextureLOD=!0,e.isShader("vertex")){const r=this.position?this.position.analyzeAndFlow(e,"v3",{cache:"position"}):void 0;e.mergeUniform(t.UniformsUtils.merge([t.UniformsLib.fog,t.UniformsLib.lights])),t.UniformsLib.LTC_1&&(e.uniforms.ltc_1={value:void 0},e.uniforms.ltc_2={value:void 0}),e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include <fog_pars_vertex>","#include <morphtarget_pars_vertex>","#include <skinning_pars_vertex>","#include <shadowmap_pars_vertex>","#include <logdepthbuf_pars_vertex>","#include <clipping_planes_pars_vertex>"].join("\n"));const i=["#include <beginnormal_vertex>","#include <morphnormal_vertex>","#include <skinbase_vertex>","#include <skinnormal_vertex>","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <defaultnormal_vertex>\n\t\t\t\t#endif\n\n\t\t\t\tvec3 displaced_position = position;\n\t\t\t\tvec3 displaced_normal = normal;\n\n\t\t\t\t#if defined( USE_LAYER_DISPLACE )\n\t\t\t\t\tvec3 transformed;\n\t\t\t\t\tvec3 transformedNormal;\n\t\t\t\t#endif\n\t\t\t\t","#ifndef FLAT_SHADED","\tvNormal = normalize( transformedNormal );","#endif","\n\t\t\t\t#if !defined( USE_LAYER_DISPLACE )\n\t\t\t\t\t#include <begin_vertex>\n\t\t\t\t#endif /* !USE_LAYER_DISPLACE */\n\t\t\t\t"];r&&i.push(r.code,r.result?"displaced_position = "+r.result+";":""),i.push("transformed = displaced_position;","transformedNormal = normalMatrix * displaced_normal;","#ifndef FLAT_SHADED"," vNormal = transformedNormal;","#endif"),i.push("#include <morphtarget_vertex>","#include <skinning_vertex>","#include <project_vertex>","#include <fog_vertex>","#include <logdepthbuf_vertex>","#include <clipping_planes_vertex>","\tvViewPosition = - mvPosition.xyz;","#include <worldpos_vertex>","#include <shadowmap_vertex>"),c=i.join("\n")}else{const t=new _t("material.specularRoughness","f"),r=new _t("material.clearcoatRoughness","f"),i={roughness:t,bias:new Pr(t),viewNormal:new _t("normal","v3"),worldNormal:new _t("inverseTransformDirection( geometry.normal, viewMatrix )","v3"),gamma:!0},u={gamma:!0},d={roughness:r,bias:new Pr(r),viewNormal:new _t("clearcoatNormal","v3"),worldNormal:new _t("inverseTransformDirection( geometry.clearcoatNormal, viewMatrix )","v3"),gamma:!0};this.mask&&this.mask.analyze(e),void 0===this.color&&(this.color=new mt(5855577)),this.color.analyze(e,{slot:"color",context:u}),this.roughness.analyze(e),this.metalness.analyze(e),this.shadingAlpha.analyze(e),this.shadingBlend.analyze(e),this.afterColor&&this.afterColor.analyze(e,{slot:"afterColor"}),this.alpha&&this.alpha.analyze(e),this.normal&&this.normal.analyze(e),this.clearcoat&&this.clearcoat.analyze(e),this.clearcoatRoughness&&this.clearcoatRoughness.analyze(e),this.clearcoatNormal&&this.clearcoatNormal.analyze(e),this.reflectivity&&this.reflectivity.analyze(e),this.light&&this.light.analyze(e,{cache:"light"}),this.ao&&this.ao.analyze(e),this.ambient&&this.ambient.analyze(e),this.shadow&&this.shadow.analyze(e),this.emissive&&this.emissive.analyze(e,{slot:"emissive"}),this.environment&&(this.environment.analyze(e,{cache:"radiance",context:i,slot:"radiance"}),e.requires.irradiance&&this.environment.analyze(e,{cache:"irradiance",context:i,slot:"irradiance"})),this.sheen&&this.sheen.analyze(e);const p=this.mask?this.mask.flow(e,"b"):void 0,f=this.color.flow(e,"c",{slot:"color",context:u}),m=this.roughness.flow(e,"f"),g=this.metalness.flow(e,"f"),v=this.shadingAlpha.flow(e,"f"),y=this.shadingBlend.flow(e,"i"),A=this.afterColor?this.afterColor.flow(e,"c",{slot:"afterColor"}):void 0,w=this.alpha?this.alpha.flow(e,"f"):void 0,x=this.normal?this.normal.flow(e,"v3"):void 0,b=this.clearcoat?this.clearcoat.flow(e,"f"):void 0,S=this.clearcoatRoughness?this.clearcoatRoughness.flow(e,"f"):void 0,E=this.clearcoatNormal?this.clearcoatNormal.flow(e,"v3"):void 0,C=this.reflectivity?this.reflectivity.flow(e,"f"):void 0,T=this.light?this.light.flow(e,"v3",{cache:"light"}):void 0,O=this.ao?this.ao.flow(e,"f"):void 0,D=this.ambient?this.ambient.flow(e,"c"):void 0,M=this.shadow?this.shadow.flow(e,"c"):void 0,_=this.emissive?this.emissive.flow(e,"c",{slot:"emissive"}):void 0;let N;this.environment&&(N={radiance:this.environment.flow(e,"c",{cache:"radiance",context:i,slot:"radiance"})},e.requires.irradiance&&(N.irradiance=this.environment.flow(e,"c",{cache:"irradiance",context:i,slot:"irradiance"})));const L=h&&N?null===(n=this.environment)||void 0===n?void 0:n.flow(e,"c",{cache:"clearcoat",context:d,slot:"environment"}):void 0,B=this.sheen?this.sheen.flow(e,"c"):void 0;e.requires.transparent=void 0!==w,e.addParsCode(["varying vec3 vViewPosition;","#ifndef FLAT_SHADED","\tvarying vec3 vNormal;","#endif","#include <dithering_pars_fragment>","#include <fog_pars_fragment>","#include <bsdfs>","#include <lights_pars_begin>","#include <lights_physical_pars_fragment>","#include <shadowmap_pars_fragment>","#include <logdepthbuf_pars_fragment>"].join("\n"));const I=["#include <clipping_planes_fragment>","\t#include <normal_fragment_begin>","\t#include <clearcoat_normal_fragment_begin>","\tPhysicalMaterial material;","\tmaterial.diffuseColor = vec3( 1.0 );"];p&&I.push(p.code,"if ( ! "+p.result+" ) discard;"),I.push(f.code,"\tvec3 diffuseColor = "+f.result+";","\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );","#include <logdepthbuf_fragment>",m.code,"\tfloat roughnessFactor = "+m.result+";",g.code,"\tfloat metalnessFactor = "+g.result+";"),w&&I.push(w.code,"#ifdef ALPHATEST","\tif ( "+w.result+" <= ALPHATEST ) discard;","#endif"),x&&I.push(x.code,"normal = "+x.result+";"),E&&I.push(E.code,"clearcoatNormal = "+E.result+";"),I.push("vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );"),I.push("material.diffuseColor = "+(T?"vec3( 1.0 )":"diffuseColor * ( 1.0 - metalnessFactor )")+";","material.specularRoughness = max( roughnessFactor, 0.0525 );","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularRoughness = clamp( roughnessFactor, 0.04, 1.0 );"),b?I.push(b.code,"material.clearcoat = saturate( "+b.result+" );"):h&&I.push("material.clearcoat = 0.0;"),S?I.push(S.code,"material.clearcoatRoughness = max( "+S.result+", 0.0525 );","material.clearcoatRoughness += geometryRoughness;","material.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );"):h&&I.push("material.clearcoatRoughness = 0.0;"),B&&I.push("material.sheenColor = "+B.result+";"),C?I.push(C.code,"material.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( "+C.result+" ) ), diffuseColor, metalnessFactor );"):I.push("material.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor, metalnessFactor );"),I.push("#include <lights_fragment_begin>"),T&&(I.push(T.code,"reflectedLight.directDiffuse = "+T.result+";"),I.push("diffuseColor *= 1.0 - metalnessFactor;","reflectedLight.directDiffuse *= diffuseColor;","reflectedLight.indirectDiffuse *= diffuseColor;")),O&&I.push(O.code,"reflectedLight.indirectDiffuse *= "+O.result+";","float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );","reflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, "+O.result+", material.specularRoughness );"),D&&I.push(D.code,"reflectedLight.indirectDiffuse += "+D.result+";"),M&&I.push(M.code,"reflectedLight.directDiffuse *= "+M.result+";","reflectedLight.directSpecular *= "+M.result+";"),_&&I.push(_.code,"reflectedLight.directDiffuse += "+_.result+";"),N&&(I.push(null===(s=N.radiance)||void 0===s?void 0:s.code),e.requires.irradiance&&I.push(null===(o=N.irradiance)||void 0===o?void 0:o.code),L&&I.push(L.code,"clearcoatRadiance += "+L.result+";"),I.push("radiance += "+(null===(a=N.radiance)||void 0===a?void 0:a.result)+";"),e.requires.irradiance&&I.push("iblIrradiance += PI * "+(null===(l=N.irradiance)||void 0===l?void 0:l.result)+";")),I.push("#include <lights_fragment_end>"),I.push("vec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular;"),I.push(`\n\t\t\t\tif (outgoingLight != diffuseColor) {\n\t\t\t\t\tfloat lightAccu = clamp( length( reflectedLight.directSpecular + reflectedLight.indirectSpecular ), 0.0, 1.0 );\n\t\t\t\t\taccumAlpha += ( 1.0 - accumAlpha ) * ${v.result} * lightAccu;\n\t\t\t\t\toutgoingLight = spe_blend( diffuseColor, outgoingLight, ${v.result}, ${y.result} );\n\t\t\t\t}\n\t\t\t\t`),A&&I.push(A.code,`outgoingLight = spe_blend(outgoingLight, ${A.result}, 1.0, SPE_BLENDING_NORMAL);`),w?I.push(`gl_FragColor = vec4( outgoingLight, accumAlpha * ${w.result} );`):I.push("gl_FragColor = vec4( outgoingLight, 1.0 );"),I.push("#include <tonemapping_fragment>","#include <encodings_fragment>","#include <fog_fragment>","#include <premultiplied_alpha_fragment>","#include <dithering_fragment>"),c=I.join("\n")}return c}copy(e){return super.copy(e),e.color&&(this.color=e.color.clone()),this.roughness=e.roughness.clone(),this.metalness=e.metalness.clone(),e.position&&(this.position=e.position.clone()),e.afterColor&&(this.afterColor=e.afterColor.clone()),e.mask&&(this.mask=e.mask.clone()),e.alpha&&(this.alpha=e.alpha.clone()),e.normal&&(this.normal=e.normal.clone()),e.clearcoat&&(this.clearcoat=e.clearcoat.clone()),e.clearcoatRoughness&&(this.clearcoatRoughness=e.clearcoatRoughness.clone()),e.clearcoatNormal&&(this.clearcoatNormal=e.clearcoatNormal.clone()),e.reflectivity&&(this.reflectivity=e.reflectivity.clone()),e.light&&(this.light=e.light.clone()),e.shadow&&(this.shadow=e.shadow.clone()),e.ao&&(this.ao=e.ao.clone()),e.emissive&&(this.emissive=e.emissive.clone()),e.ambient&&(this.ambient=e.ambient.clone()),e.environment&&(this.environment=e.environment.clone()),e.sheen&&(this.sheen=e.sheen.clone()),e.shadingAlpha&&(this.shadingAlpha=e.shadingAlpha.clone()),e.shadingBlend&&(this.shadingBlend=e.shadingBlend.clone()),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.position&&(t.position=this.position.toJSON(e).uuid),this.color&&(t.color=this.color.toJSON(e).uuid),t.roughness=this.roughness.toJSON(e).uuid,t.metalness=this.metalness.toJSON(e).uuid,this.mask&&(t.mask=this.mask.toJSON(e).uuid),this.alpha&&(t.alpha=this.alpha.toJSON(e).uuid),this.normal&&(t.normal=this.normal.toJSON(e).uuid),this.clearcoat&&(t.clearcoat=this.clearcoat.toJSON(e).uuid),this.clearcoatRoughness&&(t.clearcoatRoughness=this.clearcoatRoughness.toJSON(e).uuid),this.clearcoatNormal&&(t.clearcoatNormal=this.clearcoatNormal.toJSON(e).uuid),this.reflectivity&&(t.reflectivity=this.reflectivity.toJSON(e).uuid),this.light&&(t.light=this.light.toJSON(e).uuid),this.ao&&(t.ao=this.ao.toJSON(e).uuid),this.ambient&&(t.ambient=this.ambient.toJSON(e).uuid),this.shadow&&(t.shadow=this.shadow.toJSON(e).uuid),this.emissive&&(t.emissive=this.emissive.toJSON(e).uuid),this.environment&&(t.environment=this.environment.toJSON(e).uuid),this.sheen&&(t.sheen=this.sheen.toJSON(e).uuid),this.shadingAlpha&&(t.shadingAlpha=this.shadingAlpha.toJSON(e).uuid),this.shadingBlend&&(t.shadingBlend=this.shadingBlend.toJSON(e).uuid),this.afterColor&&(t.afterColor=this.afterColor.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.position&&(this.position=t.getNode(e.position)),e.color&&(this.color=t.getNode(e.color)),e.roughness&&(this.roughness=t.getNode(e.roughness)),e.metalness&&(this.metalness=t.getNode(e.metalness)),e.mask&&(this.mask=t.getNode(e.mask)),e.alpha&&(this.alpha=t.getNode(e.alpha)),e.normal&&(this.normal=t.getNode(e.normal)),e.clearcoat&&(this.clearcoat=t.getNode(e.clearcoat)),e.clearcoatRoughness&&(this.clearcoatRoughness=t.getNode(e.clearcoatRoughness)),e.clearcoatNormal&&(this.clearcoatNormal=t.getNode(e.clearcoatNormal)),e.reflectivity&&(this.reflectivity=t.getNode(e.reflectivity)),e.light&&(this.light=t.getNode(e.light)),e.ao&&(this.ao=t.getNode(e.ao)),e.ambient&&(this.ambient=t.getNode(e.ambient)),e.shadow&&(this.shadow=t.getNode(e.shadow)),e.emissive&&(this.emissive=t.getNode(e.emissive)),e.environment&&(this.environment=t.getNode(e.environment)),e.sheen&&(this.sheen=t.getNode(e.sheen)),e.shadingAlpha&&(this.shadingAlpha=t.getNode(e.shadingAlpha)),e.shadingBlend&&(this.shadingBlend=t.getNode(e.shadingBlend)),e.afterColor&&(this.afterColor=t.getNode(e.afterColor)),this}}class Fr extends xr{constructor(e=new Rr,t){super(e,e,t),this.type="StandardNodeMaterial"}}ft.addShortcuts(Fr.prototype,"fragment",["color","afterColor","alpha","shadingAlpha","shadingBlend","roughness","metalness","reflectivity","clearcoat","clearcoatRoughness","clearcoatNormal","normal","emissive","fresnel","ambient","light","shadow","ao","environment","mask","position","sheen"]);class Ur extends Fr{constructor(e,t,r){super(t,e),this.userData.type="PhysicalMaterial",this.userData.category="Physical",this.userData.layers=null!=r?r:this._getLayerStack(null==e?void 0:e.map)}get layersList(){return this.userData.layers}set layersList(e){this.userData.layers=e}equals(e){return this.userData.type===e.userData.type&&this.userData.layers.uuid==e.userData.layers.uuid}copy(e){if(void 0!==e.userData.layers&&e.userData.layers instanceof $t){const t=e.userData.layers,r=e.fragment;super.copy(e);const i=r.clone();this.fragment=i,this.vertex=i;const n=t.clone();this.userData.layers=n,n.material=this,i.shadingAlpha.value=r.shadingAlpha.value,i.shadingBlend.value=r.shadingBlend.value}else super.copy(e);return this}static fromJSON(e,t,r){const i=r.getNode(t.vertex),n=new Ur(void 0,i);return n.fromJSON(t,r),n}dispose(){super.dispose()}}const zr={BasicMaterial:Er,PhongMaterial:Or,LambertMaterial:_r,ToonMaterial:Br,PhysicalMaterial:Ur},kr=new Set;var Gr,jr;!function(e){e[e.LINEAR=0]="LINEAR",e[e.EASE=1]="EASE",e[e.EASE_IN=2]="EASE_IN",e[e.EASE_OUT=3]="EASE_OUT",e[e.EASE_IN_OUT=4]="EASE_IN_OUT",e[e.CUBIC=5]="CUBIC",e[e.SPRING=6]="SPRING"}(Gr||(Gr={}));class Vr{constructor(){this.easing=Gr.EASE_IN_OUT,this.duration=1e3,this.delay=0,this.cubicControls=[.5,.05,.1,.3],this.springParameters={mass:1,stiffness:80,damping:10,velocity:0},this.repeat=!1,this.cycle=!1,this.rewind=!1}get sp_mass(){return this.springParameters.mass}set sp_mass(e){this.springParameters.mass=e}get sp_stiffness(){return this.springParameters.stiffness}set sp_stiffness(e){this.springParameters.stiffness=e}get sp_damping(){return this.springParameters.damping}set sp_damping(e){this.springParameters.damping=e}get sp_velocity(){return this.springParameters.velocity}set sp_velocity(e){this.springParameters.velocity=e}copy(e){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters=Object.assign({},e.springParameters),this.repeat=e.repeat,this.cycle=e.cycle,this.rewind=e.rewind,this}clone(){return(new Vr).copy(this)}toJSON(){const e={easing:this.easing,duration:this.duration,delay:this.delay,cubicControls:this.cubicControls,springParameters:Object.assign({},this.springParameters)};return!0===this.repeat&&(e.repeat=!0),!0===this.cycle&&(e.cycle=!0),!0===this.rewind&&(e.rewind=!0),void 0!==this.object&&(e.object=this.object.uuid),void 0!==this.state&&(e.state=this.state.uuid),e}fromJSON(e,t,r){return this.easing=e.easing,this.duration=e.duration,this.delay=e.delay,this.cubicControls=[...e.cubicControls],this.springParameters.mass=e.springParameters.mass,this.springParameters.stiffness=e.springParameters.stiffness,this.springParameters.damping=e.springParameters.damping,this.springParameters.velocity=e.springParameters.velocity,void 0!==e.repeat&&(this.repeat=e.repeat),void 0!==e.cycle&&(this.cycle=e.cycle),void 0!==e.rewind&&(this.rewind=e.rewind),void 0!==e.object&&(this.object=t[e.object]),void 0!==e.state&&(this.state=r[e.state]),this}}!function(e){e[e.MOUSE_DOWN=0]="MOUSE_DOWN",e[e.MOUSE_UP=1]="MOUSE_UP",e[e.MOUSE_HOVER=2]="MOUSE_HOVER",e[e.MOUSE_ENTER=3]="MOUSE_ENTER",e[e.MOUSE_LEAVE=4]="MOUSE_LEAVE",e[e.KEY_DOWN=5]="KEY_DOWN",e[e.KEY_UP=6]="KEY_UP",e[e.START=7]="START",e[e.OPEN_LINK=8]="OPEN_LINK",e[e.LOOK_AT=9]="LOOK_AT",e[e.FOLLOW=10]="FOLLOW"}(jr||(jr={}));class Hr{constructor(e,t){this.targets=[],this.ui={isCollapsed:!1},this._type=e,this.key=t}get type(){return this._type}set type(e){this._type=e,e===jr.LOOK_AT?this.distance=1e3:this.distance=void 0,e!==jr.KEY_DOWN&&e!==jr.KEY_UP&&(this.key=void 0)}newTarget(e){const t=new Vr;if(t.object=e,void 0!==e){const r=e.interaction.states;r.length>0&&(t.state=r[r.length-1])}return this.targets.push(t),kr.add(t),t}addTarget(e,t=0){this.targets.splice(t,0,e),kr.add(e)}removeTarget(e){kr.delete(this.targets[e]),this.targets.splice(e,1)}dispatchReverse(){for(let e=0,t=this.targets.length;e<t;++e){const t=this.targets[e];void 0!==t.state&&void 0!==t.object&&t.object.interaction.reverse(t)}}dispatch(){if(void 0===this.url||this._type!==jr.OPEN_LINK&&this._type!==jr.MOUSE_DOWN&&this._type!==jr.MOUSE_UP&&this._type!==jr.KEY_DOWN&&this._type!==jr.KEY_UP)for(let e=0,t=this.targets.length;e<t;++e){const t=this.targets[e];void 0!==t.state&&void 0!==t.object&&t.object.interaction.play(t)}else["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document?window.location.assign(this.url):window.open(this.url,"_blank")}copy(e){return this._type=e.type,this.key=e.key,this.url=e.url,this.distance=e.distance,this.ui.isCollapsed=e.ui.isCollapsed,this}clone(){return(new Hr).copy(this)}toJSON(){const e={type:this._type,key:this.key,ui:{isCollapsed:this.ui.isCollapsed}};if(void 0!==this.url&&(e.url=this.url),void 0!==this.distance&&(e.distance=this.distance),this.targets.length>0){e.targets=[];for(let t=0,r=this.targets.length;t<r;++t)e.targets.push(this.targets[t].toJSON())}return e}fromJSON(e,t,r){if(this._type=e.type,this.key=e.key,this.targets=[],this.ui={isCollapsed:e.ui.isCollapsed},this.url=e.url,void 0!==e.distance&&(this.distance=e.distance),void 0!==e.targets)for(let i=0,n=e.targets.length;i<n;++i)this.addTarget((new Vr).fromJSON(e.targets[i],t,r),i);return this}}class Jr{constructor(){this.uuid=t.MathUtils.generateUUID(),this.name="",this.position=new t.Vector3,this.rotation=new t.Euler,this.scale=new t.Vector3,this.hiddenMatrix=new t.Matrix4}update(e){this.updateMatrix(e),"geometry"in e&&this.updateGeometry(e),"material"in e&&this.updateMaterial(e),"CombinedCamera"===e.objectType&&this.updateCamera(e)}updateCamera(e){this.camera={zoomPersp:e.perspCamera.zoom,zoomOrtho:e.orthoCamera.zoom}}updateMatrix(e){this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),"hiddenMatrix"in e&&this.hiddenMatrix.copy(e.hiddenMatrix)}updateGeometry(e){if("geometry"in e){const{width:t,height:r,depth:i}=e.geometry.userData.parameters;this.geometry={width:t,height:r,depth:i}}}updateMaterial(e){if("material"in e)if(e.material instanceof Array){this.material=[];for(let t=0,r=e.material.length;t<r;++t){const r=[];let i=e.material[t].layersList.head;for(;i;)r.push(i.clone()),i=i.next;this.material.push({layersList:r})}}else{const t=[];let r=e.material.layersList.head;for(;r;)t.push(r.clone()),r=r.next;this.material={layersList:t}}}execute(e){if(e.position.copy(this.position),e.rotation.copy(this.rotation),e.scale.copy(this.scale),"hiddenMatrix"in e&&e.hiddenMatrix.copy(this.hiddenMatrix),"geometry"in e&&void 0!==this.geometry){const t=e.geometry.userData.parameters,r=this.geometry;r.width===t.width&&r.height===t.height&&r.depth===t.depth||e.updateGeometry({parameters:{width:r.width,height:r.height,depth:r.depth}})}if("material"in e){const t=e.material;if(t instanceof Array){const e=this.material;for(let r=0,i=e.length;r<i;++r){let i=t[r].layersList.head;const n=e[r].layersList;let s=0;for(;i;)i.copy(n[s++]),i=i.next;t[r].dispose()}}else{if(t.userData.isAsset)return;let e=0,r=t.layersList.head;const i=this.material.layersList;for(;r;)r.copyUniforms(i[e++]),r=r.next;t.dispose()}}this.camera&&"CombinedCamera"===e.objectType&&(e.zoom="OrthographicCamera"===e.cameraType?this.camera.zoomOrtho:this.camera.zoomPersp,e.updateProjectionMatrix())}copy(e){if(this.name=e.name,this.position.copy(e.position),this.rotation.copy(e.rotation),this.scale.copy(e.scale),this.hiddenMatrix.copy(e.hiddenMatrix),void 0!==e.geometry&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),void 0!==e.material)if(e.material instanceof Array){this.material=[];for(let t=0,r=e.material.length;t<r;++t)this.material.push({layersList:e.material[t].layersList.map((e=>e.clone()))})}else this.material={layersList:e.material.layersList.map((e=>e.clone()))};return void 0!==e.camera&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho}),this}clone(){return(new Jr).copy(this)}toJSON(e){const t={uuid:this.uuid,name:this.name,position:this.position.toArray(),rotation:this.rotation.toArray(),scale:this.scale.toArray(),hiddenMatrix:this.hiddenMatrix.toArray()};if(void 0!==this.geometry&&(t.geometry={width:this.geometry.width,height:this.geometry.height,depth:this.geometry.depth}),void 0!==this.material)if(this.material instanceof Array){t.material=[];for(let r=0,i=this.material.length;r<i;++r)t.material.push({layersList:this.material[r].layersList.map((t=>t.toJSON(e)))})}else t.material={layersList:this.material.layersList.map((t=>t.toJSON(e)))};return void 0!==this.camera&&(t.camera={zoomPersp:this.camera.zoomPersp,zoomOrtho:this.camera.zoomOrtho}),t}fromJSON(e,t){if(this.uuid=e.uuid,this.name=e.name,this.position.fromArray(e.position),this.rotation.fromArray(e.rotation),this.scale.fromArray(e.scale),this.hiddenMatrix.fromArray(e.hiddenMatrix),void 0!==e.geometry&&(this.geometry={width:e.geometry.width,height:e.geometry.height,depth:e.geometry.depth}),void 0!==e.material)if(e.material instanceof Array){this.material=[];for(let r=0,i=e.material.length;r<i;++r)this.material.push({layersList:e.material[r].layersList.map((e=>ct(e,t)))})}else this.material={layersList:e.material.layersList.map((e=>ct(e,t)))};return void 0!==e.camera&&(this.camera={zoomPersp:e.camera.zoomPersp,zoomOrtho:e.camera.zoomOrtho}),this}}var Qr={update:null,begin:null,loopBegin:null,changeBegin:null,change:null,changeComplete:null,loopComplete:null,complete:null,loop:1,direction:"normal",autoplay:!0,timelineOffset:0,rewind:!0},Yr={duration:1e3,delay:0,endDelay:0,easing:"easeOutElastic(1, .5)",round:0},Wr=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","perspective","matrix","matrix3d"],Xr={CSS:{},springs:{}};function Kr(e,t,r){return Math.min(Math.max(e,t),r)}function qr(e,t){return e.indexOf(t)>-1}function Zr(e,t){return e.apply(null,t)}var $r={arr:function(e){return Array.isArray(e)},obj:function(e){return qr(Object.prototype.toString.call(e),"Object")},pth:function(e){return $r.obj(e)&&e.hasOwnProperty("totalLength")},svg:function(e){return e instanceof SVGElement},inp:function(e){return e instanceof HTMLInputElement},dom:function(e){return!("isNode"in e)&&(e.nodeType||$r.svg(e))},str:function(e){return"string"==typeof e},fnc:function(e){return"function"==typeof e},und:function(e){return void 0===e},hex:function(e){return/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(e)},rgb:function(e){return/^rgb/.test(e)},hsl:function(e){return/^hsl/.test(e)},col:function(e){return $r.hex(e)||$r.rgb(e)||$r.hsl(e)},key:function(e){return!Qr.hasOwnProperty(e)&&!Yr.hasOwnProperty(e)&&"targets"!==e&&"keyframes"!==e}};function ei(e){var t=/\(([^)]+)\)/.exec(e);return t?t[1].split(",").map((function(e){return parseFloat(e)})):[]}function ti(e,t){var r=ei(e),i=Kr($r.und(r[0])?1:r[0],.1,100),n=Kr($r.und(r[1])?100:r[1],.1,100),s=Kr($r.und(r[2])?10:r[2],.1,100),o=Kr($r.und(r[3])?0:r[3],.1,100),a=Math.sqrt(n/i),l=s/(2*Math.sqrt(n*i)),c=l<1?a*Math.sqrt(1-l*l):0,h=l<1?(l*a-o)/c:-o+a;function u(e){var r=t?t*e/1e3:e;return r=l<1?Math.exp(-r*l*a)*(1*Math.cos(c*r)+h*Math.sin(c*r)):(1+h*r)*Math.exp(-r*a),0===e||1===e?e:1-r}return t?u:function(){var t=Xr.springs[e];if(t)return t;for(var r=1/6,i=0,n=0;;)if(1===u(i+=r)){if(++n>=16)break}else n=0;var s=i*r*1e3;return Xr.springs[e]=s,s}}function ri(e){return void 0===e&&(e=10),function(t){return Math.ceil(Kr(t,1e-6,1)*e)*(1/e)}}var ii,ni,si=function(){var e=.1;function t(e,t){return 1-3*t+3*e}function r(e,t){return 3*t-6*e}function i(e){return 3*e}function n(e,n,s){return((t(n,s)*e+r(n,s))*e+i(n))*e}function s(e,n,s){return 3*t(n,s)*e*e+2*r(n,s)*e+i(n)}return function(t,r,i,o){if(0<=t&&t<=1&&0<=i&&i<=1){var a=new Float32Array(11);if(t!==r||i!==o)for(var l=0;l<11;++l)a[l]=n(l*e,t,i);return function(e){return t===r&&i===o||0===e||1===e?e:n(c(e),r,o)}}function c(r){for(var o=0,l=1;10!==l&&a[l]<=r;++l)o+=e;--l;var c=o+(r-a[l])/(a[l+1]-a[l])*e,h=s(c,t,i);return h>=.001?function(e,t,r,i){for(var o=0;o<4;++o){var a=s(t,r,i);if(0===a)return t;t-=(n(t,r,i)-e)/a}return t}(r,c,t,i):0===h?c:function(e,t,r,i,s){var o,a,l=0;do{(o=n(a=t+(r-t)/2,i,s)-e)>0?r=a:t=a}while(Math.abs(o)>1e-7&&++l<10);return a}(r,o,o+e,t,i)}}}(),oi=(ii={linear:function(){return function(e){return e}}},ni={Sine:function(){return function(e){return 1-Math.cos(e*Math.PI/2)}},Circ:function(){return function(e){return 1-Math.sqrt(1-e*e)}},Back:function(){return function(e){return e*e*(3*e-2)}},Bounce:function(){return function(e){for(var t,r=4;e<((t=Math.pow(2,--r))-1)/11;);return 1/Math.pow(4,3-r)-7.5625*Math.pow((3*t-2)/22-e,2)}},Elastic:function(e,t){void 0===e&&(e=1),void 0===t&&(t=.5);var r=Kr(e,1,10),i=Kr(t,.1,2);return function(e){return 0===e||1===e?e:-r*Math.pow(2,10*(e-1))*Math.sin((e-1-i/(2*Math.PI)*Math.asin(1/r))*(2*Math.PI)/i)}}},["Quad","Cubic","Quart","Quint","Expo"].forEach((function(e,t){ni[e]=function(){return function(e){return Math.pow(e,t+2)}}})),Object.keys(ni).forEach((function(e){var t=ni[e];ii["easeIn"+e]=t,ii["easeOut"+e]=function(e,r){return function(i){return 1-t(e,r)(1-i)}},ii["easeInOut"+e]=function(e,r){return function(i){return i<.5?t(e,r)(2*i)/2:1-t(e,r)(-2*i+2)/2}}})),ii);function ai(e,t){if($r.fnc(e))return e;var r=e.split("(")[0],i=oi[r],n=ei(e);switch(r){case"spring":return ti(e,t);case"cubicBezier":return Zr(si,n);case"steps":return Zr(ri,n);default:return Zr(i,n)}}function li(e){try{return document.querySelectorAll(e)}catch(e){return}}function ci(e,t){for(var r=e.length,i=arguments.length>=2?arguments[1]:void 0,n=[],s=0;s<r;s++)if(s in e){var o=e[s];t.call(i,o,s,e)&&n.push(o)}return n}function hi(e){return e.reduce((function(e,t){return e.concat($r.arr(t)?hi(t):t)}),[])}function ui(e){return $r.arr(e)?e:($r.str(e)&&(e=li(e)||e),e instanceof NodeList||e instanceof HTMLCollection?[].slice.call(e):[e])}function di(e,t){return e.some((function(e){return e===t}))}function pi(e){var t={};for(var r in e)t[r]=e[r];return t}function fi(e,t){var r=pi(e);for(var i in e)r[i]=t.hasOwnProperty(i)?t[i]:e[i];return r}function mi(e,t){var r=pi(e);for(var i in t)r[i]=$r.und(e[i])?t[i]:e[i];return r}function gi(e){return $r.rgb(e)?(r=/rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(t=e))?"rgba("+r[1]+",1)":t:$r.hex(e)?function(e){var t=e.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(function(e,t,r,i){return t+t+r+r+i+i})),r=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return"rgba("+parseInt(r[1],16)+","+parseInt(r[2],16)+","+parseInt(r[3],16)+",1)"}(e):$r.hsl(e)?function(e){var t,r,i,n=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(e)||/hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(e),s=parseInt(n[1],10)/360,o=parseInt(n[2],10)/100,a=parseInt(n[3],10)/100,l=n[4]||1;function c(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+(t-e)*(2/3-r)*6:e}if(0==o)t=r=i=a;else{var h=a<.5?a*(1+o):a+o-a*o,u=2*a-h;t=c(u,h,s+1/3),r=c(u,h,s),i=c(u,h,s-1/3)}return"rgba("+255*t+","+255*r+","+255*i+","+l+")"}(e):void 0;var t,r}function vi(e){var t=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(e);if(t)return t[1]}function yi(e,t){return $r.fnc(e)?e(t.target,t.id,t.total):e}function Ai(e,t){return e.getAttribute(t)}function wi(e,t,r){if(di([r,"deg","rad","turn"],vi(t)))return t;var i=Xr.CSS[t+r];if(!$r.und(i))return i;var n=document.createElement(e.tagName),s=e.parentNode&&e.parentNode!==document?e.parentNode:document.body;s.appendChild(n),n.style.position="absolute",n.style.width=100+r;var o=100/n.offsetWidth;s.removeChild(n);var a=o*parseFloat(t);return Xr.CSS[t+r]=a,a}function xi(e,t,r){if(t in e.style){var i=t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),n=e.style[t]||getComputedStyle(e).getPropertyValue(i)||"0";return r?wi(e,n,r):n}}function bi(e,t){return $r.dom(e)&&!$r.inp(e)&&(Ai(e,t)||$r.svg(e)&&e[t])?"attribute":$r.dom(e)&&di(Wr,t)?"transform":$r.dom(e)&&"transform"!==t&&xi(e,t)?"css":null!=e[t]?"object":void 0}function Si(e){if($r.dom(e)){for(var t,r=e.style.transform||"",i=/(\w+)\(([^)]*)\)/g,n=new Map;t=i.exec(r);)n.set(t[1],t[2]);return n}}function Ei(e,t,r,i){var n=qr(t,"scale")?1:0+function(e){return qr(e,"translate")||"perspective"===e?"px":qr(e,"rotate")||qr(e,"skew")?"deg":void 0}(t),s=Si(e).get(t)||n;return r&&(r.transforms.list.set(t,s),r.transforms.last=t),i?wi(e,s,i):s}function Ci(e,t,r,i){switch(bi(e,t)){case"transform":return Ei(e,t,i,r);case"css":return xi(e,t,r);case"attribute":return Ai(e,t);default:return e[t]||0}}function Ti(e,t){var r=/^(\*=|\+=|-=)/.exec(e);if(!r)return e;var i=vi(e)||0,n=parseFloat(t),s=parseFloat(e.replace(r[0],""));switch(r[0][0]){case"+":return n+s+i;case"-":return n-s+i;case"*":return n*s+i}}function Oi(e,t){if($r.col(e))return gi(e);if(/\s/g.test(e))return e;var r=vi(e),i=r?e.substr(0,e.length-r.length):e;return t?i+t:i}function Di(e,t){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function Mi(e){for(var t,r=e.points,i=0,n=0;n<r.numberOfItems;n++){var s=r.getItem(n);n>0&&(i+=Di(t,s)),t=s}return i}function _i(e){if(e.getTotalLength)return e.getTotalLength();switch(e.tagName.toLowerCase()){case"circle":return function(e){return 2*Math.PI*Ai(e,"r")}(e);case"rect":return function(e){return 2*Ai(e,"width")+2*Ai(e,"height")}(e);case"line":return function(e){return Di({x:Ai(e,"x1"),y:Ai(e,"y1")},{x:Ai(e,"x2"),y:Ai(e,"y2")})}(e);case"polyline":return Mi(e);case"polygon":return function(e){var t=e.points;return Mi(e)+Di(t.getItem(t.numberOfItems-1),t.getItem(0))}(e)}}function Ni(e,t){var r=t||{},i=r.el||function(e){for(var t=e.parentNode;$r.svg(t)&&$r.svg(t.parentNode);)t=t.parentNode;return t}(e),n=i.getBoundingClientRect(),s=Ai(i,"viewBox"),o=n.width,a=n.height,l=r.viewBox||(s?s.split(" "):[0,0,o,a]);return{el:i,viewBox:l,x:l[0]/1,y:l[1]/1,w:o/l[2],h:a/l[3]}}function Li(e,t){function r(r){void 0===r&&(r=0);var i=t+r>=1?t+r:0;return e.el.getPointAtLength(i)}var i=Ni(e.el,e.svg),n=r(),s=r(-1),o=r(1);switch(e.property){case"x":return(n.x-i.x)*i.w;case"y":return(n.y-i.y)*i.h;case"angle":return 180*Math.atan2(o.y-s.y,o.x-s.x)/Math.PI}}function Bi(e,t){var r=/[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g,i=Oi($r.pth(e)?e.totalLength:e,t)+"";return{original:i,numbers:i.match(r)?i.match(r).map(Number):[0],strings:$r.str(e)||t?i.split(r):[]}}function Ii(e){return ci(e?hi($r.arr(e)?e.map(ui):ui(e)):[],(function(e,t,r){return r.indexOf(e)===t}))}function Pi(e){var t=Ii(e);return t.map((function(e,r){return{target:e,id:r,total:t.length,transforms:{list:Si(e)}}}))}function Ri(e,t){var r=pi(t);if(/^spring/.test(r.easing)&&(r.duration=ti(r.easing)),$r.arr(e)){var i=e.length;2===i&&!$r.obj(e[0])?e={value:e}:$r.fnc(t.duration)||(r.duration=t.duration/i)}var n=$r.arr(e)?e:[e];return n.map((function(e,r){var i=$r.obj(e)&&!$r.pth(e)?e:{value:e};return $r.und(i.delay)&&(i.delay=r?0:t.delay),$r.und(i.endDelay)&&(i.endDelay=r===n.length-1?t.endDelay:0),i})).map((function(e){return mi(e,r)}))}function Fi(e,t){var r=[],i=t.keyframes;for(var n in i&&(t=mi(function(e){for(var t=ci(hi(e.map((function(e){return Object.keys(e)}))),(function(e){return $r.key(e)})).reduce((function(e,t){return e.indexOf(t)<0&&e.push(t),e}),[]),r={},i=function(i){var n=t[i];r[n]=e.map((function(e){var t={};for(var r in e)$r.key(r)?r==n&&(t.value=e[r]):t[r]=e[r];return t}))},n=0;n<t.length;n++)i(n);return r}(i),t)),t)$r.key(n)&&r.push({name:n,tweens:Ri(t[n],e)});return r}function Ui(e,t){var r;return e.tweens.map((function(i){var n=function(e,t){var r={};for(var i in e){var n=yi(e[i],t);$r.arr(n)&&1===(n=n.map((function(e){return yi(e,t)}))).length&&(n=n[0]),r[i]=n}return r.duration=parseFloat(r.duration),r.delay=parseFloat(r.delay),r}(i,t),s=n.value,o=$r.arr(s)?s[1]:s,a=vi(o),l=Ci(t.target,e.name,a,t),c=r?r.to.original:l,h=$r.arr(s)?s[0]:c,u=vi(h)||vi(l),d=a||u;return $r.und(o)&&(o=c),n.from=Bi(h,d),n.to=Bi(Ti(o,h),d),n.start=r?r.end:0,n.end=n.start+n.delay+n.duration+n.endDelay,n.easing=ai(n.easing,n.duration),n.isPath=$r.pth(s),n.isColor=$r.col(n.from.original),n.isColor&&(n.round=1),r=n,n}))}var zi={css:function(e,t,r){return e.style[t]=r},attribute:function(e,t,r){return e.setAttribute(t,r)},object:function(e,t,r){return e[t]=r},transform:function(e,t,r,i,n){if(i.list.set(t,r),t===i.last||n){var s="";i.list.forEach((function(e,t){s+=t+"("+e+") "})),e.style.transform=s}}};function ki(e,t){Pi(e).forEach((function(e){for(var r in t){var i=yi(t[r],e),n=e.target,s=vi(i),o=Ci(n,r,s,e),a=Ti(Oi(i,s||vi(o)),o),l=bi(n,r);zi[l](n,r,a,e.transforms,!0)}}))}function Gi(e,t){return ci(hi(e.map((function(e){return t.map((function(t){return function(e,t){var r=bi(e.target,t.name);if(r){var i=Ui(t,e),n=i[i.length-1];return{type:r,property:t.name,animatable:e,tweens:i,duration:n.end,delay:i[0].delay,endDelay:n.endDelay}}}(e,t)}))}))),(function(e){return!$r.und(e)}))}function ji(e,t){var r=e.length,i=function(e){return e.timelineOffset?e.timelineOffset:0},n={};return n.duration=r?Math.max.apply(Math,e.map((function(e){return i(e)+e.duration}))):t.duration,n.delay=r?Math.min.apply(Math,e.map((function(e){return i(e)+e.delay}))):t.delay,n.endDelay=r?n.duration-Math.max.apply(Math,e.map((function(e){return i(e)+e.duration-e.endDelay}))):t.endDelay,n}var Vi=0;var Hi,Ji=[],Qi=[],Yi=function(){function e(){Hi=requestAnimationFrame(t)}function t(t){var r=Ji.length;if(r){for(var i=0;i<r;){var n=Ji[i];if(n.paused){var s=Ji.indexOf(n);s>-1&&(Ji.splice(s,1),r=Ji.length)}else n.tick(t);i++}e()}else Hi=cancelAnimationFrame(Hi)}return e}();function Wi(e){void 0===e&&(e={});var t,r=0,i=0,n=0,s=0,o=null;function a(e){var t=window.Promise&&new Promise((function(e){return o=e}));return e.finished=t,t}var l=function(e){var t=fi(Qr,e),r=fi(Yr,e),i=Fi(r,e),n=Pi(e.targets),s=Gi(n,i),o=ji(s,r),a=Vi;return Vi++,mi(t,{id:a,children:[],animatables:n,animations:s,duration:o.duration,delay:o.delay,endDelay:o.endDelay})}(e);a(l);function c(){var e=l.direction;"alternate"!==e&&(l.direction="normal"!==e?"normal":"reverse"),l.reversed=!l.reversed,t.forEach((function(e){return e.reversed=l.reversed}))}function h(e){return l.reversed?l.duration-e:e}function u(){r=0,i=h(l.currentTime)*(1/Wi.speed)}function d(e,t){t&&t.seek(e-t.timelineOffset)}function p(e){var t=0,r=l.animations,i=r.length;for(!0===l.reversePlayback&&!1===l.rewind&&(e=l.duration-e);t<i;){var n=r[t],s=n.animatable,o=n.tweens,a=o.length-1,c=o[a];a&&(c=ci(o,(function(t){return e<t.end}))[0]||c);for(var h=Kr(e-c.start-c.delay,0,c.duration)/c.duration,u=isNaN(h)?1:c.easing(h),d=c.to.strings,p=c.round,f=[],m=c.to.numbers.length,g=void 0,v=0;v<m;v++){var y=void 0;if(!0===l.reversePlayback&&!1===l.rewind)var A=c.to.numbers[v],w=c.from.numbers[v]||0;else w=c.to.numbers[v],A=c.from.numbers[v]||0;y=c.isPath?Li(c.value,u*w):A+u*(w-A),p&&(c.isColor&&v>2||(y=Math.round(y*p)/p)),f.push(y)}var x=d.length;if(x){g=d[0];for(var b=0;b<x;b++){d[b];var S=d[b+1],E=f[b];isNaN(E)||(g+=S?E+S:E+" ")}}else g=f[0];zi[n.type](s.target,n.property,g,s.transforms),n.currentValue=g,t++}}function f(e){l[e]&&!l.passThrough&&l[e](l)}function m(e){var u=l.duration,m=l.delay,g=u-l.endDelay,v=h(e);l.progress=Kr(v/u*100,0,100),l.reversePlayback=v<l.currentTime,t&&function(e){if(l.reversePlayback)for(var r=s;r--;)d(e,t[r]);else for(var i=0;i<s;i++)d(e,t[i])}(v),!l.began&&l.currentTime>0&&(l.began=!0,f("begin")),!l.loopBegan&&l.currentTime>0&&(l.loopBegan=!0,f("loopBegin")),v<=m&&0!==l.currentTime&&p(0),(v>=g&&l.currentTime!==u||!u)&&p(u),v>m&&v<g?(l.changeBegan||(l.changeBegan=!0,l.changeCompleted=!1,f("changeBegin")),f("change"),p(v)):l.changeBegan&&(l.changeCompleted=!0,l.changeBegan=!1,f("changeComplete")),l.currentTime=Kr(v,0,u),l.began&&f("update"),e>=u&&(i=0,l.remaining&&!0!==l.remaining&&l.remaining--,l.remaining?(r=n,f("loopComplete"),l.loopBegan=!1,"alternate"===l.direction&&c()):(l.paused=!0,l.completed||(l.completed=!0,f("loopComplete"),f("complete"),!l.passThrough&&"Promise"in window&&(o(),a(l)))))}return l.reset=function(){var e=l.direction;l.passThrough=!1,l.currentTime=0,l.progress=0,l.paused=!0,l.began=!1,l.loopBegan=!1,l.changeBegan=!1,l.completed=!1,l.changeCompleted=!1,l.reversePlayback=!1,l.reversed="reverse"===e,l.remaining=l.loop,t=l.children;for(var r=s=t.length;r--;)l.children[r].reset();(l.reversed&&!0!==l.loop||"alternate"===e&&1===l.loop)&&l.remaining++,p(l.reversed?l.duration:0)},l.set=function(e,t){return ki(e,t),l},l.tick=function(e){n=e,r||(r=n),m((n+(i-r))*Wi.speed)},l.seek=function(e){m(h(e))},l.pause=function(){l.paused=!0,u()},l.play=function(){l.paused&&(l.completed&&l.reset(),l.paused=!1,Ji.push(l),u(),Hi||Yi())},l.reverse=function(){c(),l.completed=!l.reversed,u()},l.restart=function(){l.reset(),l.play()},l.reset(),l.autoplay&&l.play(),l}function Xi(e,t){for(var r=t.length;r--;)di(e,t[r].animatable.target)&&t.splice(r,1)}"undefined"!=typeof document&&document.addEventListener("visibilitychange",(function(){document.hidden?(Ji.forEach((function(e){return e.pause()})),Qi=Ji.slice(0),Wi.running=Ji=[]):Qi.forEach((function(e){return e.play()}))})),Wi.version="3.2.0",Wi.speed=1,Wi.running=Ji,Wi.remove=function(e){for(var t=Ii(e),r=Ji.length;r--;){var i=Ji[r],n=i.animations,s=i.children;Xi(t,n);for(var o=s.length;o--;){var a=s[o],l=a.animations;Xi(t,l),l.length||a.children.length||s.splice(o,1)}n.length||s.length||i.pause()}},Wi.get=Ci,Wi.set=ki,Wi.convertPx=wi,Wi.path=function(e,t){var r=$r.str(e)?li(e)[0]:e,i=t||100;return function(e){return{property:e,el:r,svg:Ni(r),totalLength:_i(r)*(i/100)}}},Wi.setDashoffset=function(e){var t=_i(e);return e.setAttribute("stroke-dasharray",t),t},Wi.stagger=function(e,t){void 0===t&&(t={});var r=t.direction||"normal",i=t.easing?ai(t.easing):null,n=t.grid,s=t.axis,o=t.from||0,a="first"===o,l="center"===o,c="last"===o,h=$r.arr(e),u=h?parseFloat(e[0]):parseFloat(e),d=h?parseFloat(e[1]):0,p=vi(h?e[1]:e)||0,f=t.start||0+(h?u:0),m=[],g=0;return function(e,t,v){if(a&&(o=0),l&&(o=(v-1)/2),c&&(o=v-1),!m.length){for(var y=0;y<v;y++){if(n){var A=l?(n[0]-1)/2:o%n[0],w=l?(n[1]-1)/2:Math.floor(o/n[0]),x=A-y%n[0],b=w-Math.floor(y/n[0]),S=Math.sqrt(x*x+b*b);"x"===s&&(S=-x),"y"===s&&(S=-b),m.push(S)}else m.push(Math.abs(o-y));g=Math.max.apply(Math,m)}i&&(m=m.map((function(e){return i(e/g)*g}))),"reverse"===r&&(m=m.map((function(e){return s?e<0?-1*e:-e:Math.abs(g-e)})))}return f+(h?(d-u)/g:u)*(Math.round(100*m[t])/100)+p}},Wi.timeline=function(e){void 0===e&&(e={});var t=Wi(e);return t.duration=0,t.add=function(r,i){var n=Ji.indexOf(t),s=t.children;function o(e){e.passThrough=!0}n>-1&&Ji.splice(n,1);for(var a=0;a<s.length;a++)o(s[a]);var l=mi(r,fi(Yr,e));l.targets=l.targets||e.targets;var c=t.duration;l.autoplay=!1,l.direction=t.direction,l.timelineOffset=$r.und(i)?c:Ti(i,c),o(t),l.rewind=t.rewind,t.seek(l.timelineOffset);var h=Wi(l);o(h),s.push(h);var u=ji(s,e);return t.delay=u.delay,t.endDelay=u.endDelay,t.duration=u.duration,t.seek(0),t.reset(),t.autoplay&&t.play(),t},t},Wi.easing=ai,Wi.penner=oi,Wi.random=function(e,t){return Math.floor(Math.random()*(t-e+1))+e};class Ki{constructor(e){this.i=e}updateObject(){void 0!==this.i.selectedState&&this.i.states[this.i.selectedState].updateMatrix(this.i.object)}updateCamera(){void 0!==this.i.selectedState&&"CombinedCamera"===this.i.object.objectType&&(this.i.states[this.i.selectedState].updateMatrix(this.i.object),this.i.states[this.i.selectedState].updateCamera(this.i.object))}updateGeometry(){void 0!==this.i.selectedState&&!1!==Ze(this.i.object)&&(this.i.states[this.i.selectedState].updateMatrix(this.i.object),this.i.states[this.i.selectedState].updateGeometry(this.i.object))}updateSceneGraph(e,r){const i=new t.Matrix4,n=new t.Matrix4;e.updateWorldMatrix(!0,!1),n.copy(e.matrixWorld).invert();for(let e=0,t=this.i.states.length;e<t;++e){const t=this.i.states[e];i.copy(n),null!==this.i.object.parent&&(this.i.object.parent.updateWorldMatrix(!0,!1),i.multiply(this.i.object.parent.matrixWorld)),t.hiddenMatrix.premultiply(i)}}updateMaterialLayer(e){if(void 0===this.i.selectedState||!1===Ze(this.i.object))return;const t=this.i.object.selectedMaterial,r=this.i.states[this.i.selectedState],i=(void 0!==t?r.material[t]:r.material).layersList.find((t=>t.id===e.id));null==i||i.copy(e)}pushMaterialLayer(e){if(0===this.i.states.length||!1===Ze(this.i.object))return;const t=this.i.object;if(t.material instanceof Array){const r=t.selectedMaterial;if(void 0!==r)for(let t=0,i=this.i.states.length;t<i;++t){const i=e.clone();this.i.selectedState!==t&&(i.uniforms[`f${i.id}_alpha`].value=0);this.i.states[t].material[r].layersList.push(i)}}else for(let t=0,r=this.i.states.length;t<r;++t){const r=e.clone();this.i.selectedState!==t&&(r.uniforms[`f${r.id}_alpha`].value=0);this.i.states[t].material.layersList.push(r)}}popMaterialLayer(){if(0===this.i.states.length||!1===Ze(this.i.object))return;const e=this.i.object;if(e.material instanceof Array){const t=e.selectedMaterial;if(void 0!==t)for(let e=0,r=this.i.states.length;e<r;++e){this.i.states[e].material[t].layersList.pop()}}else for(let e=0,t=this.i.states.length;e<t;++e){this.i.states[e].material.layersList.pop()}}removeMaterialLayer(e){if(0===this.i.states.length||!1===Ze(this.i.object))return null;const t=this.i.object,r=[];if(t.material instanceof Array)for(let i=0,n=this.i.states.length;i<n;++i){const n=t.selectedMaterial;if(void 0!==n){const t=this.i.states[i].material[n];r.push({layer:t.layersList[e]}),t.layersList.splice(e,1)}}else for(let t=0,i=this.i.states.length;t<i;++t){const i=this.i.states[t].material;r.push({layer:i.layersList[e]}),i.layersList.splice(e,1)}return{states:r,pos:e}}restoreMaterialLayerRemoved(e){if(0===this.i.states.length||!1===Ze(this.i.object))return;const t=this.i.object;if(t.material instanceof Array)for(let r=0,i=this.i.states.length;r<i;++r){const i=t.selectedMaterial;if(void 0!==i){this.i.states[r].material[i].layersList.splice(e.pos,0,e.states[r].layer)}}else for(let t=0,r=this.i.states.length;t<r;++t){this.i.states[t].material.layersList.splice(e.pos,0,e.states[t].layer)}}changeMaterialLayer(e){if(0===this.i.states.length||!1===Ze(this.i.object))return null;const t=this.i.object,r=[];let i=0;if(t.material instanceof Array){const n=t.selectedMaterial;if(void 0!==n){const t=this.i.states[Number(this.i.selectedState)].material[n].layersList;for(let r=0,n=t.length;r<n;++r)if(t[r].id===e.id){i=r;break}for(let t=0,s=this.i.states.length;t<s;++t){const s=this.i.states[t].material[n].layersList[i],o=e.clone();this.i.selectedState!==t&&(o.uniforms[`f${o.id}_alpha`].value=Number(s.uniforms[`f${s.id}_alpha`].value)),this.i.states[t].material[n].layersList[i]=o,r.push({layer:s})}}}else{const t=this.i.states[Number(this.i.selectedState)].material.layersList;for(let r=0,n=t.length;r<n;++r)if(t[r].id===e.id){i=r;break}for(let t=0,n=this.i.states.length;t<n;++t){const n=this.i.states[t].material.layersList[i],s=e.clone();this.i.selectedState!==t&&(s.uniforms[`f${s.id}_alpha`].value=Number(n.uniforms[`f${n.id}_alpha`].value)),this.i.states[t].material.layersList[i]=s,r.push({layer:n})}}return{states:r,pos:i}}restoreMaterialLayerChanged(e){if(0===this.i.states.length||!1===Ze(this.i.object))return;const t=this.i.object;if(t.material instanceof Array){const r=t.selectedMaterial;if(void 0!==r)for(let t=0,i=this.i.states.length;t<i;++t)this.i.states[t].material[r].layersList[e.pos]=e.states[t].layer}else for(let t=0,r=this.i.states.length;t<r;++t)this.i.states[t].material.layersList[e.pos]=e.states[t].layer}moveMaterialLayer(e,t){if(0===this.i.states.length||!1===Ze(this.i.object))return;const r=this.i.object;if(r.material instanceof Array){const i=r.selectedMaterial;if(void 0!==i)for(let r=0,n=this.i.states.length;r<n;++r){const n=this.i.states[r].material[i].layersList,s=n[e];n[e]=n[t],n[t]=s}}else for(let r=0,i=this.i.states.length;r<i;++r){const i=this.i.states[r].material.layersList,n=i[e];i[e]=i[t],i[t]=n}}restoreMaterialLayerMoved(e,t){this.moveMaterialLayer(e,t)}setMaterialLayers(e){const t=this.i.object,r=[];if(t.material instanceof Array){const i=t.selectedMaterial;if(void 0!==i)for(let t=0,n=this.i.states.length;t<n;++t){const n=this.i.states[t].material[i];r.push({layersList:n.layersList});let s=e.head;for(n.layersList=[];void 0!==s;)n.layersList.push(s.clone()),s=s.next}}else for(let t=0,i=this.i.states.length;t<i;++t){const i=this.i.states[t].material;r.push({layersList:i.layersList});let n=e.head;for(i.layersList=[];void 0!==n;)i.layersList.push(n.clone()),n=n.next}return{states:r}}restoreMaterialLayersSet(e){const t=this.i.object;if(t.material instanceof Array){const r=t.selectedMaterial;if(void 0!==r)for(let t=0,i=this.i.states.length;t<i;++t)this.i.states[t].material[r].layersList=e.states[t].layersList}else for(let t=0,r=this.i.states.length;t<r;++t)this.i.states[t].material.layersList=e.states[t].layersList}}class qi{constructor(){this.encoderPath="",this.encoderConfig={},this.encoderPending=null}setEncoderPath(e){return this.encoderPath=e,this}setEncoderConfig(e){return this.encoderConfig=e,this}_loadLibrary(e,r){const i=new t.FileLoader;return i.setPath(this.encoderPath),i.setResponseType(r),i.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{i.load(e,t,void 0,r)}))}_loadScript(e){return new Promise(((t,r)=>{const i=document.createElement("script");i.onload=t,i.onerror=r,i.src=this.encoderPath+e,document.head.appendChild(i)}))}preload(){return this._initEncoder().then((()=>this))}_initEncoder(){if(this.encoderPending)return this.encoderPending;const e="object"!=typeof WebAssembly||"js"===this.encoderConfig.type,t=[];return e?t.push(this._loadScript("draco_encoder.js")):(t.push(this._loadScript("draco_encoder_wrapper.js")),t.push(this._loadLibrary("draco_encoder.wasm","arraybuffer"))),this.encoderPending=Promise.all(t).then((t=>{e||(this.encoderConfig.wasmBinary=t[1])})),this.encoderPending}async parse(e,t={decodeSpeed:5,encodeSpeed:5,encoderMethod:qi.MESH_EDGEBREAKER_ENCODING,quantization:[16,8,8,8,8],exportUvs:!0,exportNormals:!0,exportColor:!1}){if(!0===e.isBufferGeometry)throw new Error("DRACOExporter: The first parameter of parse() is now an instance of Mesh or Points.");if(await this._initEncoder(),void 0===DracoEncoderModule)throw new Error("THREE.DRACOExporter: required the draco_encoder to work.");const r=e.geometry,i=await DracoEncoderModule(this.encoderConfig),n=new i.Encoder;let s,o;const a={};if(!0!==r.isBufferGeometry)throw new Error("THREE.DRACOExporter.parse(geometry, options): geometry is not a THREE.BufferGeometry instance.");if(!0===e.isMesh){s=new i.MeshBuilder,o=new i.Mesh;const e=r.getAttribute("position");a.POSITION=s.AddFloatAttributeToMesh(o,i.POSITION,e.count,e.itemSize,e.array);const n=r.getIndex();if(null!==n)s.AddFacesToMesh(o,n.count/3,n.array);else{const t=new(e.count>65535?Uint32Array:Uint16Array)(e.count);for(let e=0;e<t.length;e++)t[e]=e;s.AddFacesToMesh(o,e.count,t)}if(!0===t.exportNormals){const e=r.getAttribute("normal");void 0!==e&&(a.NORMAL=s.AddFloatAttributeToMesh(o,i.NORMAL,e.count,e.itemSize,e.array))}if(!0===t.exportUvs){const e=r.getAttribute("uv");void 0!==e&&(a.TEXCOORD_0=s.AddFloatAttributeToMesh(o,i.TEX_COORD,e.count,e.itemSize,e.array))}if(!0===t.exportColor){const e=r.getAttribute("color");void 0!==e&&(a.COLOR_0=s.AddFloatAttributeToMesh(o,i.COLOR,e.count,e.itemSize,e.array))}}else{if(!0!==e.isPoints)throw new Error("DRACOExporter: Unsupported object type: "+e.type);{s=new i.PointCloudBuilder,o=new i.PointCloud;const e=r.getAttribute("position");if(s.AddFloatAttribute(o,i.POSITION,e.count,e.itemSize,e.array),!0===t.exportColor){const e=r.getAttribute("color");void 0!==e&&s.AddFloatAttribute(o,i.COLOR,e.count,e.itemSize,e.array)}}}const l=new i.DracoInt8Array,c=void 0!==t.encodeSpeed?t.encodeSpeed:5,h=void 0!==t.decodeSpeed?t.decodeSpeed:5;if(n.SetSpeedOptions(c,h),void 0!==t.encoderMethod&&n.SetEncodingMethod(t.encoderMethod),void 0!==t.quantization)for(let e=0;e<5;e++)void 0!==t.quantization[e]&&n.SetAttributeQuantization(e,t.quantization[e]);let u;if(u=!0===e.isMesh?n.EncodeMeshToDracoBuffer(o,l):n.EncodePointCloudToDracoBuffer(o,!0,l),i.destroy(o),0===u)throw new Error("THREE.DRACOExporter: Draco encoding failed.");const d=new Int8Array(new ArrayBuffer(u));for(let e=0;e<u;e++)d[e]=l.GetValue(e);return i.destroy(l),i.destroy(n),i.destroy(s),{buffer:d,attributeIDs:a}}}qi.MESH_EDGEBREAKER_ENCODING=1,qi.MESH_SEQUENTIAL_ENCODING=0,qi.POINT_CLOUD=0,qi.TRIANGULAR_MESH=1,qi.INVALID=-1,qi.POSITION=0,qi.NORMAL=1,qi.COLOR=2,qi.TEX_COORD=3,qi.GENERIC=4;class Zi{constructor(){this.dracoExporter=null,this.pluginCallbacks=[],this.register((function(e){return new On(e)})),this.register((function(e){return new Dn(e)})),this.register((function(e){return new Mn(e)}))}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}setDRACOExporter(e){return this.dracoExporter=e,this}parse(e,t,r){const i=new Tn,n=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)n.push(this.pluginCallbacks[e](i));r&&r.draco&&(i.dracoExporter=this.dracoExporter),i.setPlugins(n),i.write(e,t,r)}}const $i=0,en=1,tn=2,rn=3,nn=4,sn=5121,on=5123,an=5126,ln=5125,cn=34962,hn=34963,un=9728,dn=9729,pn=9984,fn=9985,mn=9986,gn=9987,vn=33071,yn=33648,An=10497,wn={};wn[t.NearestFilter]=un,wn[t.NearestMipmapNearestFilter]=pn,wn[t.NearestMipmapLinearFilter]=mn,wn[t.LinearFilter]=dn,wn[t.LinearMipmapNearestFilter]=fn,wn[t.LinearMipmapLinearFilter]=gn,wn[t.ClampToEdgeWrapping]=vn,wn[t.RepeatWrapping]=An,wn[t.MirroredRepeatWrapping]=yn;const xn={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"};function bn(e,t){return e.length===t.length&&e.every((function(e,r){return e===t[r]}))}function Sn(e){return 4*Math.ceil(e/4)}function En(e,t=0){const r=Sn(e.byteLength);if(r!==e.byteLength){const i=new Uint8Array(r);if(i.set(new Uint8Array(e)),0!==t)for(let n=e.byteLength;n<r;n++)i[n]=t;return i.buffer}return e}let Cn=null;class Tn{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}async write(e,t,r){this.options=Object.assign({},{binary:!1,draco:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},r),this.options.animations.length>0&&(this.options.trs=!0),await this.processInput(e);const i=this;Promise.all(this.pending).then((function(){const e=i.buffers,r=i.json,n=i.options,s=i.extensionsUsed,o=new Blob(e,{type:"application/octet-stream"}),a=Object.keys(s);if(a.length>0&&(r.extensionsUsed=a),r.buffers&&r.buffers.length>0&&(r.buffers[0].byteLength=o.size),!0===n.binary){const e=new window.FileReader;e.readAsArrayBuffer(o),e.onloadend=function(){const i=En(e.result),n=new DataView(new ArrayBuffer(8));n.setUint32(0,i.byteLength,!0),n.setUint32(4,5130562,!0);const s=En(function(e){if(void 0!==window.TextEncoder)return(new TextEncoder).encode(e).buffer;const t=new Uint8Array(new ArrayBuffer(e.length));for(let r=0,i=e.length;r<i;r++){const i=e.charCodeAt(r);t[r]=i>255?32:i}return t.buffer}(JSON.stringify(r)),32),o=new DataView(new ArrayBuffer(8));o.setUint32(0,s.byteLength,!0),o.setUint32(4,1313821514,!0);const a=new ArrayBuffer(12),l=new DataView(a);l.setUint32(0,1179937895,!0),l.setUint32(4,2,!0);const c=12+o.byteLength+s.byteLength+n.byteLength+i.byteLength;l.setUint32(8,c,!0);const h=new Blob([a,o,s,n,i],{type:"application/octet-stream"}),u=new window.FileReader;u.readAsArrayBuffer(h),u.onloadend=function(){t(u.result)}}}else if(r.buffers&&r.buffers.length>0){const e=new window.FileReader;e.readAsDataURL(o),e.onloadend=function(){const i=e.result;r.buffers[0].uri=i,t(r)}}else t(r)}))}serializeUserData(e,t){if(0===Object.keys(e.userData).length)return;const r=this.options,i=this.extensionsUsed;try{const n=JSON.parse(JSON.stringify(e.userData));if(r.includeCustomExtensions&&n.gltfExtensions){void 0===t.extensions&&(t.extensions={});for(const e in n.gltfExtensions)t.extensions[e]=n.gltfExtensions[e],i[e]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(t){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+t.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const r=new t.Vector3;for(let t=0,i=e.count;t<i;t++)if(Math.abs(r.fromBufferAttribute(e,t).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const r=this.cache;if(r.attributesNormalized.has(e))return r.attributesNormalized.get(e);const i=e.clone(),n=new t.Vector3;for(let e=0,t=i.count;e<t;e++)n.fromBufferAttribute(i,e),0===n.x&&0===n.y&&0===n.z?n.setX(1):n.normalize(),i.setXYZ(e,n.x,n.y,n.z);return r.attributesNormalized.set(e,i),i}applyTextureTransform(e,t){let r=!1;const i={};0===t.offset.x&&0===t.offset.y||(i.offset=t.offset.toArray(),r=!0),0!==t.rotation&&(i.rotation=t.rotation,r=!0),1===t.repeat.x&&1===t.repeat.y||(i.scale=t.repeat.toArray(),r=!0),r&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){const t=this.json,r=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),r.push(e),0}processBufferView(e,t,r,i,n){const s=this.json;let o;s.bufferViews||(s.bufferViews=[]),o=t===sn?1:t===on?2:4;const a=Sn(i*e.itemSize*o),l=new DataView(new ArrayBuffer(a));let c=0;for(let n=r;n<r+i;n++)for(let r=0;r<e.itemSize;r++){let i;e.itemSize>4?i=e.array[n*e.itemSize+r]:0===r?i=e.getX(n):1===r?i=e.getY(n):2===r?i=e.getZ(n):3===r&&(i=e.getW(n)),t===an?l.setFloat32(c,i,!0):t===ln?l.setUint32(c,i,!0):t===on?l.setUint16(c,i,!0):t===sn&&l.setUint8(c,i),c+=o}const h={buffer:this.processBuffer(l.buffer),byteOffset:this.byteOffset,byteLength:a};void 0!==n&&(h.target=n),n===cn&&(h.byteStride=e.itemSize*o),this.byteOffset+=a,s.bufferViews.push(h);return{id:s.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,r=t.json;return r.bufferViews||(r.bufferViews=[]),new Promise((function(i){const n=new window.FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){const e=En(n.result),s={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,i(r.bufferViews.push(s)-1)}}))}processAccessor(e,t,r,i){const n=this.options,s=this.json;let o;if(e.array.constructor===Float32Array)o=an;else if(e.array.constructor===Uint32Array)o=ln;else if(e.array.constructor===Uint16Array)o=on;else{if(e.array.constructor!==Uint8Array)throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");o=sn}if(void 0===r&&(r=0),void 0===i&&(i=e.count),n.truncateDrawRange&&void 0!==t&&null===t.index){const n=r+i,s=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;r=Math.max(r,t.drawRange.start),(i=Math.min(n,s)-r)<0&&(i=0)}if(0===i)return null;const a=function(e,t,r){const i={min:new Array(e.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(e.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let n=t;n<t+r;n++)for(let t=0;t<e.itemSize;t++){let r;e.itemSize>4?r=e.array[n*e.itemSize+t]:0===t?r=e.getX(n):1===t?r=e.getY(n):2===t?r=e.getZ(n):3===t&&(r=e.getW(n)),i.min[t]=Math.min(i.min[t],r),i.max[t]=Math.max(i.max[t],r)}return i}(e,r,i),l={componentType:o,count:i,max:a.max,min:a.min,type:{1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"}[e.itemSize]};if(!this.options.draco){let n;void 0!==t&&(n=e===t.index?hn:cn);const s=this.processBufferView(e,o,r,i,n);l.bufferView=s.id,l.byteOffset=s.byteOffset}return!0===e.normalized&&(l.normalized=!0),s.accessors||(s.accessors=[]),s.accessors.push(l)-1}processImage(e,r,i){const n=this,s=n.cache,o=n.json,a=n.options,l=n.pending;s.images.has(e)||s.images.set(e,{});const c=s.images.get(e),h=r===t.RGBAFormat?"image/png":"image/jpeg",u=h+":flipY/"+i.toString();if(void 0!==c[u])return c[u];o.images||(o.images=[]);const d={mimeType:h};if(a.embedImages){const s=Cn=Cn||document.createElement("canvas");s.width=Math.min(e.width,a.maxTextureSize),s.height=Math.min(e.height,a.maxTextureSize);const o=s.getContext("2d");if(!0===i&&(o.translate(0,s.height),o.scale(1,-1)),"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement||"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)o.drawImage(e,0,0,s.width,s.height);else{r!==t.RGBAFormat&&r!==t.RGBFormat&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const i=new Uint8ClampedArray(e.height*e.width*4);if(r===t.RGBAFormat)for(let t=0;t<i.length;t+=4)i[t+0]=e.data[t+0],i[t+1]=e.data[t+1],i[t+2]=e.data[t+2],i[t+3]=e.data[t+3];else for(let t=0,r=0;t<i.length;t+=4,r+=3)i[t+0]=e.data[r+0],i[t+1]=e.data[r+1],i[t+2]=e.data[r+2],i[t+3]=255;o.putImageData(new ImageData(i,e.width,e.height),0,0)}!0===a.binary?l.push(new Promise((function(e){s.toBlob((function(t){n.processBufferViewImage(t).then((function(t){d.bufferView=t,e()}))}),h)}))):d.uri=s.toDataURL(h)}else d.uri=e.src;const p=o.images.push(d)-1;return c[u]=p,p}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const r={magFilter:wn[e.magFilter],minFilter:wn[e.minFilter],wrapS:wn[e.wrapS],wrapT:wn[e.wrapT]};return t.samplers.push(r)-1}processTexture(e){const t=this.cache,r=this.json;if(t.textures.has(e))return t.textures.get(e);r.textures||(r.textures=[]);const i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(i.name=e.name),this._invokeAll((function(t){t.writeTexture&&t.writeTexture(e,i)}));const n=r.textures.push(i)-1;return t.textures.set(e,n),n}processMaterial(e){const r=this.cache,i=this.json;if(r.materials.has(e))return r.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;i.materials||(i.materials=[]);const n={pbrMetallicRoughness:{}};!0!==e.isMeshStandardMaterial&&!0!==e.isMeshBasicMaterial&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const s=e.color.toArray().concat([e.opacity]);if(bn(s,[1,1,1,1])||(n.pbrMetallicRoughness.baseColorFactor=s),e.isMeshStandardMaterial?(n.pbrMetallicRoughness.metallicFactor=e.metalness,n.pbrMetallicRoughness.roughnessFactor=e.roughness):(n.pbrMetallicRoughness.metallicFactor=.5,n.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap)if(e.metalnessMap===e.roughnessMap){const t={index:this.processTexture(e.metalnessMap)};this.applyTextureTransform(t,e.metalnessMap),n.pbrMetallicRoughness.metallicRoughnessTexture=t}else console.warn("THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.");if(e.map){const t={index:this.processTexture(e.map)};this.applyTextureTransform(t,e.map),n.pbrMetallicRoughness.baseColorTexture=t}if(e.emissive){const t=e.emissive.clone().multiplyScalar(e.emissiveIntensity),r=Math.max(t.r,t.g,t.b);if(r>1&&(t.multiplyScalar(1/r),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),r>0&&(n.emissiveFactor=t.toArray()),e.emissiveMap){const t={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(t,e.emissiveMap),n.emissiveTexture=t}}if(e.normalMap){const t={index:this.processTexture(e.normalMap)};e.normalScale&&-1!==e.normalScale.x&&(e.normalScale.x!==e.normalScale.y&&console.warn("THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X."),t.scale=e.normalScale.x),this.applyTextureTransform(t,e.normalMap),n.normalTexture=t}if(e.aoMap){const t={index:this.processTexture(e.aoMap),texCoord:1};1!==e.aoMapIntensity&&(t.strength=e.aoMapIntensity),this.applyTextureTransform(t,e.aoMap),n.occlusionTexture=t}e.transparent?n.alphaMode="BLEND":e.alphaTest>0&&(n.alphaMode="MASK",n.alphaCutoff=e.alphaTest),e.side===t.DoubleSide&&(n.doubleSided=!0),""!==e.name&&(n.name=e.name),this.serializeUserData(e,n),this._invokeAll((function(t){t.writeMaterial&&t.writeMaterial(e,n)}));const o=i.materials.push(n)-1;return r.materials.set(e,o),o}async processMesh(e){const r=this.cache,i=this.json,n=[e.geometry.uuid];if(Array.isArray(e.material))for(let t=0,r=e.material.length;t<r;t++)n.push(e.material[t].uuid);else n.push(e.material.uuid);const s=n.join(":");if(r.meshes.has(s))return r.meshes.get(s);const o=e.geometry;let a;if(a=e.isLineSegments?en:e.isLineLoop?tn:e.isLine?rn:e.isPoints?$i:e.material.wireframe?en:nn,!0!==o.isBufferGeometry)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");const l={},c={},h=[],u=[],d={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},p=o.getAttribute("normal");void 0===p||this.isNormalizedNormalAttribute(p)||(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(p)));let f=null;for(let e in o.attributes){if("morph"===e.substr(0,5))continue;const i=o.attributes[e];e=d[e]||e.toUpperCase();if(/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(e)||(e="_"+e),r.attributes.has(this.getUID(i))){c[e]=r.attributes.get(this.getUID(i));continue}f=null;const n=i.array;"JOINTS_0"!==e||n instanceof Uint16Array||n instanceof Uint8Array||(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),f=new t.BufferAttribute(new Uint16Array(n),i.itemSize,i.normalized));const s=this.processAccessor(f||i,o);null!==s&&(c[e]=s,r.attributes.set(this.getUID(i),s))}if(void 0!==p&&o.setAttribute("normal",p),0===Object.keys(c).length)return null;if(void 0!==e.morphTargetInfluences&&e.morphTargetInfluences.length>0){const t=[],i=[],n={};if(void 0!==e.morphTargetDictionary)for(const t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let s=0;s<e.morphTargetInfluences.length;++s){const a={};let l=!1;for(const e in o.morphAttributes){if("position"!==e&&"normal"!==e){l||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),l=!0);continue}const t=o.morphAttributes[e][s],i=e.toUpperCase(),n=o.attributes[e];if(r.attributes.has(this.getUID(t))){a[i]=r.attributes.get(this.getUID(t));continue}const c=t.clone();if(!o.morphTargetsRelative)for(let e=0,r=t.count;e<r;e++)c.setXYZ(e,t.getX(e)-n.getX(e),t.getY(e)-n.getY(e),t.getZ(e)-n.getZ(e));a[i]=this.processAccessor(c,o),r.attributes.set(this.getUID(n),a[i])}u.push(a),t.push(e.morphTargetInfluences[s]),void 0!==e.morphTargetDictionary&&i.push(n[s])}l.weights=t,i.length>0&&(l.extras={},l.extras.targetNames=i)}const m=Array.isArray(e.material);if(m&&0===o.groups.length)return null;const g=m?e.material:[e.material],v=m?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,t=v.length;e<t;e++){const t={mode:a,attributes:c};if(this.serializeUserData(o,t),u.length>0&&(t.targets=u),null!==o.index){let i=this.getUID(o.index);void 0===v[e].start&&void 0===v[e].count||(i+=":"+v[e].start+":"+v[e].count),r.attributes.has(i)?t.indices=r.attributes.get(i):(t.indices=this.processAccessor(o.index,o,v[e].start,v[e].count),r.attributes.set(i,t.indices)),null===t.indices&&delete t.indices}const i=this.processMaterial(g[v[e].materialIndex]);null!==i&&(t.material=i),h.push(t)}if(l.primitives=h,this.options.draco){const t=await this.dracoExporter.parse(e);this.processBuffer(t.buffer);const r={buffer:0,byteOffset:this.byteOffset,byteLength:t.buffer.length};this.byteOffset+=r.byteLength,i.bufferViews||(i.bufferViews=[]),i.bufferViews.push(r),h.forEach((e=>{e.extensions||(e.extensions={}),e.extensions.KHR_draco_mesh_compression={bufferView:i.bufferViews.length-1,attributes:t.attributeIDs}})),i.extensionsRequired||(i.extensionsRequired=[]),i.extensionsRequired.includes("KHR_draco_mesh_compression")||i.extensionsRequired.push("KHR_draco_mesh_compression"),this.extensionsUsed.KHR_draco_mesh_compression=!0}i.meshes||(i.meshes=[]),this._invokeAll((function(t){t.writeMesh&&t.writeMesh(e,l)}));const y=i.meshes.push(l)-1;return r.meshes.set(s,y),y}processCamera(e){const r=this.json;r.cameras||(r.cameras=[]);const i=e.isOrthographicCamera,n={type:i?"orthographic":"perspective"};return i?n.orthographic={xmag:2*e.right,ymag:2*e.top,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:n.perspective={aspectRatio:e.aspect,yfov:t.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},""!==e.name&&(n.name=e.type),r.cameras.push(n)-1}processAnimation(e,r){const i=this.json,n=this.nodeMap;i.animations||(i.animations=[]);const s=(e=Zi.Utils.mergeMorphTargetTracks(e.clone(),r)).tracks,o=[],a=[];for(let e=0;e<s.length;++e){const i=s[e],l=t.PropertyBinding.parseTrackName(i.name);let c=t.PropertyBinding.findNode(r,l.nodeName);const h=xn[l.propertyName];if("bones"===l.objectName&&(c=!0===c.isSkinnedMesh?c.skeleton.getBoneByName(l.objectIndex):void 0),!c||!h)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',i.name),null;const u=1;let d,p=i.values.length/i.times.length;h===xn.morphTargetInfluences&&(p/=c.morphTargetInfluences.length),!0===i.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline?(d="CUBICSPLINE",p/=3):d=i.getInterpolation()===t.InterpolateDiscrete?"STEP":"LINEAR",a.push({input:this.processAccessor(new t.BufferAttribute(i.times,u)),output:this.processAccessor(new t.BufferAttribute(i.values,p)),interpolation:d}),o.push({sampler:a.length-1,target:{node:n.get(c),path:h}})}return i.animations.push({name:e.name||"clip_"+i.animations.length,samplers:a,channels:o}),i.animations.length-1}processSkin(e){const r=this.json,i=this.nodeMap,n=r.nodes[i.get(e)],s=e.skeleton;if(void 0===s)return null;const o=e.skeleton.bones[0];if(void 0===o)return null;const a=[],l=new Float32Array(16*s.bones.length),c=new t.Matrix4;for(let t=0;t<s.bones.length;++t)a.push(i.get(s.bones[t])),c.copy(s.boneInverses[t]),c.multiply(e.bindMatrix).toArray(l,16*t);void 0===r.skins&&(r.skins=[]),r.skins.push({inverseBindMatrices:this.processAccessor(new t.BufferAttribute(l,16)),joints:a,skeleton:i.get(o)});return n.skin=r.skins.length-1}async processNode(e){const t=this.json,r=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const n={};if(r.trs){const t=e.quaternion.toArray(),r=e.position.toArray(),i=e.scale.toArray();bn(t,[0,0,0,1])||(n.rotation=t),bn(r,[0,0,0])||(n.translation=r),bn(i,[1,1,1])||(n.scale=i)}else e.matrixAutoUpdate&&e.updateMatrix(),!1===bn(e.matrix.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])&&(n.matrix=e.matrix.elements);if(""!==e.name&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){const t=await this.processMesh(e);null!==t&&(n.mesh=t)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const t=[];for(let i=0,n=e.children.length;i<n;i++){const n=e.children[i];if(n.visible||!1===r.onlyVisible){const e=await this.processNode(n);null!==e&&t.push(e)}}t.length>0&&(n.children=t)}this._invokeAll((function(t){t.writeNode&&t.writeNode(e,n)}));const s=t.nodes.push(n)-1;return i.set(e,s),s}async processScene(e){const t=this.json,r=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};""!==e.name&&(i.name=e.name),t.scenes.push(i);const n=[];for(let t=0,i=e.children.length;t<i;t++){const i=e.children[t];if(i.visible||!1===r.onlyVisible){const e=await this.processNode(i);null!==e&&n.push(e)}}n.length>0&&(i.nodes=n),this.serializeUserData(e,i)}async processObjects(e){const r=new t.Scene;r.name="AuxScene";for(let t=0;t<e.length;t++)r.children.push(e[t]);await this.processScene(r)}async processInput(e){const r=this.options;e=e instanceof Array?e:[e],this._invokeAll((function(t){t.beforeParse&&t.beforeParse(e)}));const i=[];for(let r=0;r<e.length;r++)e[r]instanceof t.Scene?await this.processScene(e[r]):i.push(e[r]);i.length>0&&await this.processObjects(i);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let t=0;t<r.animations.length;++t)this.processAnimation(r.animations[t],e[0]);this._invokeAll((function(t){t.afterParse&&t.afterParse(e)}))}_invokeAll(e){for(let t=0,r=this.plugins.length;t<r;t++)e(this.plugins[t])}}class On{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight)return void console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);const r=this.writer,i=r.json,n=r.extensionsUsed,s={};e.name&&(s.name=e.name),s.color=e.color.toArray(),s.intensity=e.intensity,e.isDirectionalLight?s.type="directional":e.isPointLight?(s.type="point",e.distance>0&&(s.range=e.distance)):e.isSpotLight&&(s.type="spot",e.distance>0&&(s.range=e.distance),s.spot={},s.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,s.spot.outerConeAngle=e.angle),void 0!==e.decay&&2!==e.decay&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),!e.target||e.target.parent===e&&0===e.target.position.x&&0===e.target.position.y&&-1===e.target.position.z||console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},n[this.name]=!0);const o=i.extensions[this.name].lights;o.push(s),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}}class Dn{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const r=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},r[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class Mn{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;const r=this.writer,i=r.extensionsUsed,n={};t.pbrMetallicRoughness.baseColorFactor&&(n.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);const s=[1,1,1];if(e.specular.toArray(s,0),n.specularFactor=s,n.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(n.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){const t={index:r.processTexture(e.specularMap)};r.applyTextureTransform(t,e.specularMap),n.specularGlossinessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}Zi.Utils={insertKeyframe:function(e,t){const r=.001,i=e.getValueSize(),n=new e.TimeBufferType(e.times.length+1),s=new e.ValueBufferType(e.values.length+i),o=e.createInterpolant(new e.ValueBufferType(i));let a;if(0===e.times.length){n[0]=t;for(let e=0;e<i;e++)s[e]=0;a=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<r)return 0;n[0]=t,n.set(e.times,1),s.set(o.evaluate(t),0),s.set(e.values,i),a=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<r)return e.times.length-1;n[n.length-1]=t,n.set(e.times,0),s.set(e.values,0),s.set(o.evaluate(t),e.values.length),a=n.length-1}else for(let l=0;l<e.times.length;l++){if(Math.abs(e.times[l]-t)<r)return l;if(e.times[l]<t&&e.times[l+1]>t){n.set(e.times.slice(0,l+1),0),n[l+1]=t,n.set(e.times.slice(l+1),l+2),s.set(e.values.slice(0,(l+1)*i),0),s.set(o.evaluate(t),(l+1)*i),s.set(e.values.slice((l+1)*i),(l+2)*i),a=l+1;break}}return e.times=n,e.values=s,a},mergeMorphTargetTracks:function(e,r){const i=[],n={},s=e.tracks;for(let e=0;e<s.length;++e){let o=s[e];const a=t.PropertyBinding.parseTrackName(o.name),l=t.PropertyBinding.findNode(r,a.nodeName);if("morphTargetInfluences"!==a.propertyName||void 0===a.propertyIndex){i.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(t.InterpolateLinear)}const c=l.morphTargetInfluences.length,h=l.morphTargetDictionary[a.propertyIndex];if(void 0===h)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let u;if(void 0===n[l.uuid]){u=o.clone();const e=new u.ValueBufferType(c*u.times.length);for(let t=0;t<u.times.length;t++)e[t*c+h]=u.values[t];u.name=(a.nodeName||"")+".morphTargetInfluences",u.values=e,n[l.uuid]=u,i.push(u);continue}const d=o.createInterpolant(new o.ValueBufferType(1));u=n[l.uuid];for(let e=0;e<u.times.length;e++)u.values[e*c+h]=d.evaluate(u.times[e]);for(let e=0;e<o.times.length;e++){const t=this.insertKeyframe(u,o.times[e]);u.values[t*c+h]=o.values[e]}}return e.tracks=i,e}};const _n=!1;function Nn(e,t,r){return void 0===e[t.uuid]&&(e[t.uuid]=t.toJSON(r)),t.uuid}const Ln=new Zi,Bn=new qi;function In(e){const t=[];for(const r in e){const i=e[r];delete i.metadata,t.push(i)}return t}Bn.setEncoderPath("/_libraries/"),Ln.setDRACOExporter(Bn);class Pn{constructor(e){this.object=e,this.uuid=t.MathUtils.generateUUID(),this.states=[],this.events=[],this._interpolateMaterialBetweenValues=(e,t,r,i=t.getNames())=>{var n,s,o,a,l;for(let e=0,l=i.length;e<l;++e){const l=i[e],c=`f${t.id}_${l}`,h=`f${r.id}_${l}`,u=t.uniforms[c],d=r.uniforms[h];void 0!==u.value&&("mode"!==l&&"boolean"!=typeof u.value?"number"!=typeof u.value?"isVector2"in u.value?!1===u.value.equals(d.value)&&(null===(s=this._animation)||void 0===s||s.add({targets:u,x:d.value.x,y:d.value.y},0)):"isVector3"in u.value?!1===u.value.equals(d.value)&&(null===(o=this._animation)||void 0===o||o.add({targets:u,x:d.value.x,y:d.value.y,z:d.value.z},0)):"isColor"in u.value&&!1===u.value.equals(d.value)&&(null===(a=this._animation)||void 0===a||a.add({targets:u.value,r:d.value.r,g:d.value.g,b:d.value.b},0)):u.value!==d.value&&(null===(n=this._animation)||void 0===n||n.add({targets:u,value:Number(d.value)},0)):u.value!==d.value&&(u.value=d.value))}if(t.backLayer){const e=`f${t.backLayer.id}_alpha`,r=t.backLayer.uniforms[e];null===(l=this._animation)||void 0===l||l.add({targets:r,value:0},0)}},this._interpolateMaterialBetweenLayers=(e,t,r)=>{var i,n,s;const o=e.layersList;if(void 0===t.backLayer){const i=r.getValues();i.alpha=0,t.backLayer=o.addLayerBeforeAt(i,t),t.backLayer.isBack=!0,e.dispose()}const a=`f${t.id}_alpha`,l=`f${null===(i=t.backLayer)||void 0===i?void 0:i.id}_alpha`,c=t.uniforms[a],h=null===(n=t.backLayer)||void 0===n?void 0:n.uniforms[l];null===(s=this._animation)||void 0===s||s.add({targets:c,value:0},0).add({targets:h,value:r.uniforms[`f${r.id}_alpha`].value},0)},this._interpolateMaterialTexture=(e,t,r)=>{var i;const n=`f${t.id}_texture`,s=t.uniforms[n].value,o=r.uniforms[`f${r.id}_texture`].value,a=t.uniforms[`f${t.id}_crop`],l=r.uniforms[`f${r.id}_crop`];a&&l&&a.value!==l.value&&(a.value=Number(l.value)),s.wrapS===o.wrapS&&s.wrapT===o.wrapT||(s.wrapS=o.wrapS,s.wrapT=o.wrapT,s.needsUpdate=!0);const c=s.matrix,h=o.matrix;if(!1===c.equals(h)){const e={repeatX:s.repeat.x,repeatY:s.repeat.y,offsetX:s.offset.x,offsetY:s.offset.y};null===(i=this._animation)||void 0===i||i.add({targets:e,repeatX:o.repeat.x,repeatY:o.repeat.y,offsetX:o.offset.x,offsetY:o.offset.y,update:()=>{s.repeat.set(e.repeatX,e.repeatY),s.offset.set(e.offsetX,e.offsetY),s.updateMatrix(),s.needsUpdate=!0}},0)}const u=["alpha","mode"];"displace_map"===t.type&&u.push("intensity"),this._interpolateMaterialBetweenValues(e,t,r,u)},this._interpolateMaterialGradient=(e,t,r)=>{var i;const n=t.uniforms[`f${t.id}_num`],s=r.uniforms[`f${r.id}_num`],o=`f${t.id}_steps`,a=`f${r.id}_steps`,l=t.uniforms[o],c=r.uniforms[a],h=`f${t.id}_colors`,u=`f${r.id}_colors`,d=t.uniforms[h],p=r.uniforms[u];if(n.value<=s.value){const e=d.value[n.value-1];for(let t=Number(n.value);t<s.value;++t)l.value[t]=1,d.value[t].copy(e);n.value!==s.value&&(n.value=Number(s.value));for(let e=0;e<s.value;++e){const t=d.value[e],r=p.value[e];if(l.value[e]!==c.value[e]||!t.equals(r)){const n={value:l.value[e]};null===(i=this._animation)||void 0===i||i.add({targets:[n,t],value:c.value[e],x:r.x,y:r.y,z:r.z,w:r.w,update:()=>{l.value[e]=n.value}},0)}}}else{const e=[];for(let t=0;t<s.value;++t){const r=d.value[t],i=p.value[t];if(l.value[t]!==c.value[t]||!r.equals(i)){const n={value:l.value[t]};e.push(new Promise((e=>{var s;null===(s=this._animation)||void 0===s||s.add({targets:[n,r],value:c.value[t],x:i.x,y:i.y,z:i.z,w:i.w,update:()=>{l.value[t]=n.value},complete:()=>{e(t)}},0)})))}}const t=p.value[s.value-1];for(let r=Number(s.value);r<n.value;++r){const i=d.value[r];l.value[r]===c.value[r]&&i.equals(t)||e.push(new Promise((e=>{var n;const s={value:l.value[r]};null===(n=this._animation)||void 0===n||n.add({targets:[s,i],value:1,x:t.x,y:t.y,z:t.z,w:t.w,update:()=>{l.value[r]=s.value},complete:()=>{e(r)}},0)})))}Promise.all(e).then((()=>{n.value=Number(s.value)}),(()=>{}))}this._interpolateMaterialBetweenValues(e,t,r,["alpha","mode","gl_type","smooth","offset","morph","angle"])},this.statesManager=new Ki(this)}computeCache(){return this.cache={mouseDown:this.events.find((e=>e.type===jr.MOUSE_DOWN)),mouseUp:this.events.find((e=>e.type===jr.MOUSE_UP)),mouseHover:this.events.find((e=>e.type===jr.MOUSE_HOVER)),start:this.events.find((e=>e.type===jr.START)),lookAt:this.events.find((e=>e.type===jr.LOOK_AT)),follow:this.events.find((e=>e.type===jr.FOLLOW)),keyDown:this.events.filter((e=>e.type===jr.KEY_DOWN)),keyUp:this.events.filter((e=>e.type===jr.KEY_UP))},this.cache}newState(e){const t=new Jr;return t.name=e,t.update(this.object),this.selectedState=this.states.length,this.states.push(t),t}addState(e,t){this.states.splice(t,0,e)}removeState(e){this.selectedState===e&&(this.selectedState=void 0),this.states.splice(e,1)}selectState(e){void 0!==e&&this.states[e].execute(this.object),this.selectedState=e}hasEventType(e,t){return e===jr.KEY_DOWN||e===jr.KEY_UP?void 0!==t&&this.events.some((r=>r.type===e&&r.key===t)):this.events.some((t=>t.type===e))}newEvent(){const e=[jr.MOUSE_DOWN,jr.MOUSE_UP,jr.MOUSE_HOVER,jr.KEY_DOWN].find((e=>!1===this.hasEventType(e))),t=new Hr(e);return this.events.push(t),t}addEvent(e,t){this.events.splice(t,0,e);const r=this.events[t].targets;for(let e=0,t=r.length;e<t;++e)void 0!==r[e].object&&kr.add(r[e])}removeEvent(e){const t=this.events[e].targets;for(let e=0,r=t.length;e<r;++e)void 0!==t[e].object&&kr.delete(t[e]);this.events.splice(e,1)}copy(e){this.selectedState=e.selectedState;for(let t=0,r=e.states.length;t<r;++t)this.addState(e.states[t].clone(),t);for(let t=0,r=e.events.length;t<r;++t){this.addEvent(e.events[t].clone(),t);const r=e.events[t].targets;for(let i=0,n=r.length;i<n;++i){const n=r[i].clone();r[i].object===e.object?(n.object=this.object,n.state=this.states[e.states.indexOf(r[i].state)]):(n.object=r[i].object,n.state=r[i].state),this.events[t].addTarget(n,i)}}return this}clone(e){return new Pn(e).copy(this)}toJSON(e){void 0===e&&(e={nodes:{},geometries:{},materials:{},textures:{},images:{},interactionStates:{}});const t={uuid:this.uuid};if(void 0!==this.selectedState&&(t.selectedState=this.selectedState),this.states.length>0){t.states=[];for(let r=0,i=this.states.length;r<i;++r)t.states.push(Nn(e.interactionStates,this.states[r],e))}if(this.events.length>0){t.events=[];for(let e=0,r=this.events.length;e<r;++e)t.events.push(this.events[e].toJSON())}return t}fromJSON(e,t,r){if(this.uuid=e.uuid,this.selectedState=e.selectedState,this.states=[],this.events=[],void 0!==e.states)for(let t=0,i=e.states.length;t<i;++t)this.states.push(r[e.states[t]]);if(void 0!==e.events)for(let i=0,n=e.events.length;i<n;++i)this.events.push((new Hr).fromJSON(e.events[i],t,r));return this}start(){void 0!==this._animation&&(this._animation.pause(),this._animation=void 0,this._removeBackLayer()),this.states.length>1?(this.states[0].execute(this.object),this._currentState=this.states[0],this._prevState=void 0):void 0!==this._state0?this._state0.execute(this.object):this.events.some((e=>e.type===jr.LOOK_AT||e.type===jr.FOLLOW))&&(this._state0=new Jr,this._state0.update(this.object))}end(){var e;void 0!==this._animation&&(this._animation.pause(),this._animation=void 0,this._removeBackLayer()),this.states.length>1?this.states[null!==(e=this.selectedState)&&void 0!==e?e:0].execute(this.object):void 0!==this._state0&&(this._state0.execute(this.object),this._state0=void 0),this._currentState=void 0,this._prevState=void 0}lookAt(e){var t;this.object.lookAt(e),null===(t=this._animation)||void 0===t||t.finished.then((()=>{this.lookAt(e)}))}follow(e){this.object.position.copy(e),null!==this.object.parent&&this.object.position.applyMatrix4((new t.Matrix4).copy(this.object.parent.matrixWorld).invert()),this.object.position.applyMatrix4((new t.Matrix4).copy(this.object.hiddenMatrix).invert())}play(e){this.object.visible&&void 0!==e.state&&this.animate(e.state,e)}reverse(e){this.object.visible&&void 0!==this._prevState&&this.animate(this._prevState,e)}_removeBackLayer(){if("material"in this.object){const e=this.object.material;if(e instanceof Array)for(let t=0,r=e.length;t<r;++t){const r=e[t].layersList;let i=r.head;for(;i;)if(i.backLayer){delete i.backLayer;const e=i.next;r.removeLayer(i.id),i=e}else i.isBack?(i.isBack=!1,i=i.next):i=i.next}else{const t=e.layersList;let r=t.head;for(;r;)for(;r;)if(r.backLayer){delete r.backLayer;const e=r.next;t.removeLayer(r.id),r=e}else r.isBack?(r.isBack=!1,r=r.next):r=r.next}}}getTimingFunction(e,t,r){switch(e){case Gr.LINEAR:return"cubicBezier( 0, 0, 1, 1 )";case Gr.EASE:return"cubicBezier( .25, .1, .25, 1 )";case Gr.EASE_IN:return"cubicBezier( .42, 0, 1, 1 )";case Gr.EASE_OUT:return"cubicBezier( 0, 0, .58, 1 )";case Gr.EASE_IN_OUT:return"cubicBezier( .42, 0, .58, 1 )";case Gr.CUBIC:return`cubicBezier( ${t[0]}, ${t[1]}, ${t[2]}, ${t[3]} )`;case Gr.SPRING:return`spring( ${r.mass}, ${r.stiffness}, ${r.damping}, ${r.velocity} )`}}animate(e,t){var r,i,n,s,o,a;if(this._currentState===e){if(null===(r=this._animation)||void 0===r?void 0:r.reversed){const e=null!==(n=null===(i=this._animation)||void 0===i?void 0:i.currentTime)&&void 0!==n?n:0;null===(s=this._animation)||void 0===s||s.reset(),null===(o=this._animation)||void 0===o||o.seek(e),null===(a=this._animation)||void 0===a||a.play()}}else this._prevState=this._currentState,this._currentState=e,void 0!==this._animation&&this._animation.pause(),this._removeBackLayer(),!0===t.cycle&&!0===t.repeat?this._animation=Wi.timeline({duration:t.duration,delay:t.delay/2,endDelay:t.delay/2,direction:"alternate",loop:!0,rewind:t.rewind,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters)}):!0===t.cycle&&!1===t.repeat?this._animation=Wi.timeline({duration:t.duration,delay:t.delay,endDelay:t.delay/2,direction:"alternate",rewind:t.rewind,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters)}):!1===t.cycle&&!0===t.repeat?this._animation=Wi.timeline({duration:t.duration,delay:t.delay,direction:"normal",loop:!0,easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters)}):this._animation=Wi.timeline({duration:t.duration,delay:t.delay,direction:"normal",easing:this.getTimingFunction(t.easing,t.cubicControls,t.springParameters)}),this._animation.finished.then((()=>{this._removeBackLayer(),this._animation=void 0})),this.animateMatrix(e),this.animateGeometry(e),this.animateMaterial(e),this.animateCamera(e)}animateMatrix(e){var r,i,n,s;if(!1===this.object.position.equals(e.position)){const t=this.object.position.clone(),i={t:0};null===(r=this._animation)||void 0===r||r.add({targets:i,t:1,update:()=>{this.object.position.lerpVectors(t,e.position,i.t)}},0)}if(!1===this.object.scale.equals(e.scale)){const t=this.object.scale.clone(),r={t:0};null===(i=this._animation)||void 0===i||i.add({targets:r,t:1,update:()=>{this.object.scale.lerpVectors(t,e.scale,r.t)}},0)}if(!1===this.object.rotation.equals(e.rotation)){const r=this.object.quaternion.clone(),i={t:0},s={x:this.object.rotation.x-e.rotation.x,y:this.object.rotation.y-e.rotation.y,z:this.object.rotation.z-e.rotation.z},o=e.rotation.clone(),a=.01*t.MathUtils.DEG2RAD,l=359.99*t.MathUtils.DEG2RAD;s.x===2*Math.PI?0===o.x?o.x=a:o.x===2*Math.PI&&(o.x=l):s.x===2*-Math.PI&&(0===o.x?o.x=-a:o.x===2*Math.PI&&(o.x=-l)),s.y===2*Math.PI?0===o.y?o.y=a:o.y===2*Math.PI&&(o.y=l):s.y===2*-Math.PI&&(0===o.y?o.y=-a:o.y===2*Math.PI&&(o.y=-l)),s.z===2*Math.PI?0===o.z?o.z=a:o.z===2*Math.PI&&(o.z=l):s.z===2*-Math.PI&&(0===o.z?o.z=-a:o.z===2*Math.PI&&(o.z=-l));const c=(new t.Quaternion).setFromEuler(o);null===(n=this._animation)||void 0===n||n.add({targets:i,t:1,update:()=>{!function(e,t,r,i){if(0===i)return r.copy(e);if(1===i)return r.copy(t);const n=e.w*t.w+e.x*t.x+e.y*t.y+e.z*t.z;if(n>=1)return r.copy(e);const s=1-n*n;if(s<=Number.EPSILON){const n=1-i;return r.w=n*e.w+i*t.w,r.x=n*e.x+i*t.x,r.y=n*e.y+i*t.y,r.z=n*e.z+i*t.z,r.normalize(),r}const o=Math.sqrt(s),a=Math.atan2(o,n),l=Math.sin((1-i)*a)/o,c=Math.sin(i*a)/o;r.w=e.w*l+t.w*c,r.x=e.x*l+t.x*c,r.y=e.y*l+t.y*c,r.z=e.z*l+t.z*c}(r,c,this.object.quaternion,i.t)}},0)}const o=new t.Vector3,a=new t.Quaternion,l=new t.Vector3;if(e.hiddenMatrix.decompose(o,a,l),"hiddenMatrix"in this.object){const r=new t.Vector3,i=new t.Quaternion,n=new t.Vector3;if(this.object.hiddenMatrix.decompose(r,i,n),!1===this.object.hiddenMatrix.equals(e.hiddenMatrix)){const e=new t.Vector3,c=new t.Quaternion,h=new t.Vector3,u={t:0},d=this.object.hiddenMatrix;null===(s=this._animation)||void 0===s||s.add({targets:u,t:1,update:()=>{c.slerpQuaternions(i,a,u.t),e.lerpVectors(r,o,u.t),h.lerpVectors(n,l,u.t),d.compose(e,c,h)}},0)}}}animateGeometry(e){var t;if("geometry"in this.object&&void 0!==e.geometry){const r=this.object.geometry.userData.parameters,i=e.geometry;if(i.width!==r.width||i.height!==r.height||i.depth!==r.depth){const e=this.object;null===(t=this._animation)||void 0===t||t.add({targets:r,width:i.width,height:i.height,depth:i.depth,update:()=>{e.updateGeometry({parameters:{width:r.width,height:r.height,depth:r.depth}})}},0)}}}animateMaterial(e){if("material"in this.object)if(this.object.material instanceof Array)for(let t=0,r=this.object.material.length;t<r;++t)this._interpolateMaterial(this.object.material[t],e.material[t]);else{if(this.object.material.userData.isAsset)return;this._interpolateMaterial(this.object.material,e.material)}}_interpolateMaterial(e,t){let r=e.layersList.head,i=0;for(;r;){if(!0===r.isBack){r=r.next;continue}const n=t.layersList[i++];if(ht(r)){const t=r.uniforms[`f${r.id}_texture`].value,i=n.uniforms[`f${n.id}_texture`].value;t.image===i.image?this._interpolateMaterialTexture(e,r,n):this._interpolateMaterialBetweenLayers(e,r,n)}else"gradient"===r.type?r.uniforms[`f${r.id}_gl_type`].value===n.uniforms[`f${n.id}_gl_type`].value?this._interpolateMaterialGradient(e,r,n):this._interpolateMaterialBetweenLayers(e,r,n):this._interpolateMaterialBetweenValues(e,r,n);r=r.next}}animateCamera(e){var t;if("CombinedCamera"===this.object.objectType&&void 0!==e.camera){const r=this.object,i="OrthographicCamera"===r.cameraType?e.camera.zoomOrtho:e.camera.zoomPersp;r.zoom!==i&&(null===(t=this._animation)||void 0===t||t.add({targets:r,zoom:i,update:()=>{r.updateProjectionMatrix()}},0))}}}const Rn=e=>class extends e{hasEntityChild(){return this.children.some((e=>qe(e)))}attach(e,r){this.updateWorldMatrix(!0,!1);const i=(new t.Matrix4).copy(this.matrixWorld).invert();return null!==e.parent&&(e.parent.updateWorldMatrix(!0,!1),i.multiply(e.parent.matrixWorld)),qe(e)?e.hiddenMatrix.premultiply(i):e.applyMatrix4(i),e.updateWorldMatrix(!1,!1),this.add(e),void 0!==r&&(this.children.pop(),this.children.splice(r,0,e)),this}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.matrix.copy(e.matrix),this.matrixWorld.copy(e.matrixWorld),this.matrixAutoUpdate=e.matrixAutoUpdate,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.userData=JSON.parse(JSON.stringify(e.userData)),!0===t)for(let t=0;t<e.children.length;t++){const r=e.children[t];this.add(r.clone())}return this}toJSON(e){const r=void 0===e,i={object:{uuid:"",objectType:""}};void 0===e&&(e={geometries:{},materials:{},textures:{},images:{},interactionStates:{},nodes:{}},i.metadata={version:1.5,type:"Object",generator:"Object3D.toJSON"});const n={uuid:this.uuid,objectType:this.type};if(""!==this.name&&(n.name=this.name),n.matrix=this.matrix.toArray(),!0===this.castShadow&&(n.castShadow=!0),!0===this.receiveShadow&&(n.receiveShadow=!0),!1===this.visible&&(n.visible=!1),!1===this.frustumCulled&&(n.frustumCulled=!1),0!==this.renderOrder&&(n.renderOrder=this.renderOrder),n.layers=this.layers.mask,"{}"!==JSON.stringify(this.userData)&&(n.userData=this.userData),this.children.length>0){n.children=[];for(const r of this.children)(qe(r)||r instanceof t.Light)&&n.children.push(r.toJSON(e).object)}if(r){const t=In(e.geometries),r=In(e.materials),n=In(e.textures),s=In(e.images),o=In(e.interactionStates),a=function(e){const t=[];for(const r in e)t.push(e[r]);return t}(e.nodes);t.length>0&&(i.geometries=t),r.length>0&&(i.materials=r),n.length>0&&(i.textures=n),s.length>0&&(i.images=s),o.length>0&&(i.interactionStates=o),a.length>0&&(i.nodes=a)}return i.object=n,i}fromJSON(e){return this.uuid=e.uuid,void 0!==e.name&&(this.name=e.name),void 0!==e.matrix?(this.matrix.fromArray(e.matrix),void 0!==e.matrixAutoUpdate&&(this.matrixAutoUpdate=e.matrixAutoUpdate),this.matrixAutoUpdate&&this.matrix.decompose(this.position,this.quaternion,this.scale)):(void 0!==e.position&&this.position.fromArray(e.position),void 0!==e.rotation&&this.rotation.fromArray(e.rotation),void 0!==e.quaternion&&this.quaternion.fromArray(e.quaternion),void 0!==e.scale&&this.scale.fromArray(e.scale)),this.castShadow=void 0!==e.castShadow,this.receiveShadow=void 0!==e.receiveShadow,void 0!==e.visible&&(this.visible=e.visible),void 0!==e.frustumCulled&&(this.frustumCulled=e.frustumCulled),void 0!==e.renderOrder&&(this.renderOrder=e.renderOrder),void 0!==e.layers&&(this.layers.mask=e.layers),void 0!==e.userData&&(this.userData=e.userData),this}},Fn=e=>"isEntity"in e,Un=e=>"isAbstractMesh"in e,zn=e=>"objectHelper"in e,kn=e=>class extends(Rn(e)){constructor(){super(...arguments),this.objectType="",this.isEntity=!0,this.raycastLock=!1,this.scaleLock=!1,this.hiddenMatrix=new t.Matrix4,this.interaction=new Pn(this),this.forceComputeSize=!1}set visibility(e){this.visible=e;for(const t of this.children)Fn(t)&&t.traverseEntity((t=>{zn(t)&&t.visible&&(t.objectHelper.visible=e)}))}get visibility(){return this.visible}get interactionCache(){return void 0===this.interaction.cache&&this.interaction.computeCache(),this.interaction.cache}traverseEntity(e){e(this);for(const t of this.children)Fn(t)&&t.traverseEntity(e)}computeSingleBoundingBox(){this.singleBoundingBox||(this.singleBoundingBox=new st),this.singleBoundingBox.setFromObjectSize(this,!1),this.singleBoundingBox.computeVertices(),this.singleBoundingBox.computeEdges(),this.singleBoundingBox.computeFaces()}computeComplexBoundingBox(e){this.complexBoundingBox||(this.complexBoundingBox=new st),this.complexBoundingBox.setFromObjectSize(this,e),this.complexBoundingBox.computeVertices(),this.complexBoundingBox.computeEdges(),this.complexBoundingBox.computeFaces()}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),this.matrixWorldNeedsUpdate=!1,e=!0);for(const t of this.children)t.updateMatrixWorld(e)}updateWorldMatrix(e,t){const r=this.parent;if(e&&null!==r&&r.updateWorldMatrix(!0,!1),this.matrixAutoUpdate&&this.updateMatrix(),null===this.parent?this.matrixWorld.multiplyMatrices(this.hiddenMatrix,this.matrix):(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.hiddenMatrix),this.matrixWorld.multiplyMatrices(this.matrixWorld,this.matrix)),t)for(const e of this.children)e.updateWorldMatrix(!1,!0)}shallowClone(e){return(new this.constructor).shallowCopy(this,e)}shallowCopy(e,t=!0){if(super.copy(e,!1),this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),void 0!==e.interaction&&this.interaction.copy(e.interaction),!0===t)for(const t of e.children)Fn(t)&&this.add(t.shallowClone());return this}clone(e){return(new this.constructor).copy(this,e)}copy(e,t=!0){if(super.copy(e,!1),this.raycastLock=e.raycastLock,this.scaleLock=e.scaleLock,this.hiddenMatrix.copy(e.hiddenMatrix),void 0!==e.interaction&&this.interaction.copy(e.interaction),!0===t)for(const t of e.children)Fn(t)&&this.add(t.clone());return this}keepChildrenMatrixWorld(){const e=new t.Matrix4,r=this.matrixWorld.clone();this.updateWorldMatrix(!1,!1),e.copy(this.matrixWorld).invert(),e.multiply(r);for(const t of this.children)Fn(t)&&t.hiddenMatrix.premultiply(e)}toJSON(e){const t=super.toJSON(e),r=t.object;return!0===this.raycastLock&&(r.raycastLock=!0),!0===this.scaleLock&&(r.scaleLock=!0),r.hiddenMatrix=this.hiddenMatrix.toArray(),void 0!==this.interaction&&(r.interaction=this.interaction.toJSON(e)),t}fromJSON(e){return super.fromJSON(e),void 0!==e.raycastLock&&(this.raycastLock=e.raycastLock),void 0!==e.scaleLock&&(this.scaleLock=e.scaleLock),this.hiddenMatrix.fromArray(e.hiddenMatrix),this}fromObject3D(e){const r=e.children;return e.children=[],Object.assign(e,{raycastLock:!1,scaleLock:!1,hiddenMatrix:new t.Matrix4}),this.copy(e),e.children=r,this}};class Gn extends t.Object3D{constructor(e,r={}){super(),this.object=e,e.computeComplexBoundingBox(!0);const i=e.complexBoundingBox.getSize(new t.Vector3),n=.1;this.parameters={type:void 0!==r.type?r.type:"radial",hideBase:void 0!==r.hideBase&&r.hideBase,count:void 0!==r.count?r.count:3,ra_radius:void 0!==r.ra_radius?r.ra_radius:2*Math.max(i.x,i.y),ra_startAngle:void 0!==r.ra_startAngle?r.ra_startAngle:0,ra_endAngle:void 0!==r.ra_endAngle?r.ra_endAngle:360,ra_align:void 0!==r.ra_align&&r.ra_align,ra_axis:void 0!==r.ra_axis?r.ra_axis:"y",ra_scale:void 0!==r.ra_scale?r.ra_scale.clone():new t.Vector3,ra_rotation:void 0!==r.ra_rotation?r.ra_rotation.clone():new t.Euler,ra_position:void 0!==r.ra_position?r.ra_position.clone():new t.Vector3,li_scale:void 0!==r.li_scale?r.li_scale.clone():new t.Vector3,li_rotation:void 0!==r.li_rotation?r.li_rotation.clone():new t.Euler,li_position:void 0!==r.li_position?r.li_position.clone():new t.Vector3(i.x+i.x*n,0,0).round(),gr_count:void 0!==r.gr_count?r.gr_count.clone():new t.Vector3(2,2,2),gr_size:void 0!==r.gr_size?r.gr_size.clone():new t.Vector3(i.x+i.x*n,i.y+i.y*n,i.z+i.z*n).round(),gr_fromCenter:void 0===r.gr_fromCenter||r.gr_fromCenter},this.update(),this.setHideBase(this.parameters.hideBase)}refreshMaterial(){if("material"in this.object)for(const e of this.children)e.material=this.object.material}setHideBase(e){if("material"in this.object){if(Array.isArray(this.object.material)){if(this.children.length>0){for(const e of this.object.material)e.visible=!0;if(e){const e=this.object.material.map((e=>e.clone()));for(const t of this.children)t.material=e}else for(const e of this.children)e.material=this.object.material}for(const t of this.object.material)t.visible=!e}else{if(this.children.length>0)if(this.object.material.visible=!0,e){const e=this.object.material.clone();for(const t of this.children)t.material=e}else for(const e of this.children)e.material=this.object.material;this.object.material.visible=!e}this.parameters.hideBase=e}}update(){switch(this._updateCount(),this.parameters.type){case"radial":this._updateRadial(this.parameters);break;case"linear":this._updateLinear(this.parameters);break;case"grid":this._updateGrid(this.parameters)}}_updateCount(){const e="grid"===this.parameters.type?this.parameters.gr_count.x*this.parameters.gr_count.y*this.parameters.gr_count.z:this.parameters.count;if(this.children.length!==e)if(this.children.length<e)for(let t=0,r=e-this.children.length;t<r;++t){const e=this.object.shallowClone(!1);e.visible=!0,this.add(e),this.parameters.hideBase&&this.setHideBase(!0)}else for(let t=0,r=this.children.length-e;t<r;++t)this.remove(this.children[0])}_updateRadial(e){const r=e.ra_startAngle*t.MathUtils.DEG2RAD,i=r-e.ra_endAngle*t.MathUtils.DEG2RAD,n=new t.Euler(e.ra_rotation.x*t.MathUtils.DEG2RAD,e.ra_rotation.y*t.MathUtils.DEG2RAD,e.ra_rotation.z*t.MathUtils.DEG2RAD);let s;switch(e.ra_axis){case"x":s=new t.Vector3(1,0,0);break;case"y":s=new t.Vector3(0,1,0);break;case"z":s=new t.Vector3(0,0,1)}for(const[t,o]of this.children.entries()){o.hiddenMatrix.identity(),o.scale.x=e.ra_scale.x+1,o.scale.y=e.ra_scale.y+1,o.scale.z=e.ra_scale.z+1,o.position.setScalar(0);const a=i/e.count*t-r;switch(e.ra_axis){case"x":o.rotation.set(0,a,0);break;case"y":o.rotation.set(0,0,a);break;case"z":o.rotation.set(a,0,0)}o.translateOnAxis(s,e.ra_radius),o.position.add(e.ra_position),!0===e.ra_align?(o.rotation.x+=n.x,o.rotation.y+=n.y,o.rotation.z+=n.z):o.rotation.copy(n)}}_updateLinear(e){if("linear"!==e.type)throw new Error;const r=new t.Euler(e.li_rotation.x*t.MathUtils.DEG2RAD,e.li_rotation.y*t.MathUtils.DEG2RAD,e.li_rotation.z*t.MathUtils.DEG2RAD);for(const[t,i]of this.children.entries())i.hiddenMatrix.identity(),i.scale.x=e.li_scale.x*t+1,i.scale.y=e.li_scale.y*t+1,i.scale.z=e.li_scale.z*t+1,i.rotation.x=r.x*t,i.rotation.y=r.y*t,i.rotation.z=r.z*t,i.position.x=e.li_position.x*t,i.position.y=e.li_position.y*t,i.position.z=e.li_position.z*t}_updateGrid(e){let r=0;if(!0===e.gr_fromCenter){const i={x:e.gr_count.x%2==0?2:1,y:e.gr_count.y%2==0?2:1,z:e.gr_count.z%2==0?2:1},n=new t.Vector3(e.gr_size.x*(e.gr_count.x-i.x)*.5,e.gr_size.y*(e.gr_count.y-i.y)*.5,e.gr_size.z*(e.gr_count.z-i.z)*.5);for(let t=0;t<e.gr_count.x;t++)for(let i=0;i<e.gr_count.y;i++)for(let s=0;s<e.gr_count.z;s++){const o=this.children[r++];o.hiddenMatrix.identity(),o.scale.setScalar(1),o.rotation.set(0,0,0),o.position.x=e.gr_size.x*t-n.x,o.position.y=e.gr_size.y*i-n.y,o.position.z=e.gr_size.z*s-n.z}}else for(let t=0;t<e.gr_count.x;t++)for(let i=0;i<e.gr_count.y;i++)for(let n=0;n<e.gr_count.z;n++){const s=this.children[r++];s.hiddenMatrix.identity(),s.scale.setScalar(1),s.rotation.set(0,0,0),s.position.x=e.gr_size.x*t,s.position.y=-e.gr_size.y*i,s.position.z=-e.gr_size.z*n}}toJSON(){return{type:"Cloner",parameters:{type:this.parameters.type,hideBase:this.parameters.hideBase,count:this.parameters.count,ra_radius:this.parameters.ra_radius,ra_startAngle:this.parameters.ra_startAngle,ra_endAngle:this.parameters.ra_endAngle,ra_align:this.parameters.ra_align,ra_axis:this.parameters.ra_axis,ra_scale:this.parameters.ra_scale.toArray(),ra_rotation:this.parameters.ra_rotation.toArray(),ra_position:this.parameters.ra_position.toArray(),li_scale:this.parameters.li_scale.toArray(),li_rotation:this.parameters.li_rotation.toArray(),li_position:this.parameters.li_position.toArray(),gr_count:this.parameters.gr_count.toArray(),gr_size:this.parameters.gr_size.toArray(),gr_fromCenter:this.parameters.gr_fromCenter}}}fromJSON(e){const t=e.parameters;return this.parameters.type=t.type,this.parameters.hideBase=t.hideBase,this.parameters.count=t.count,this.parameters.ra_radius=t.ra_radius,this.parameters.ra_startAngle=t.ra_startAngle,this.parameters.ra_endAngle=t.ra_endAngle,this.parameters.ra_align=t.ra_align,this.parameters.ra_axis=t.ra_axis,this.parameters.ra_scale.fromArray(t.ra_scale),this.parameters.ra_rotation.fromArray(t.ra_rotation),this.parameters.ra_position.fromArray(t.ra_position),this.parameters.li_scale.fromArray(t.li_scale),this.parameters.li_rotation.fromArray(t.li_rotation),this.parameters.li_position.fromArray(t.li_position),this.parameters.gr_count.fromArray(t.gr_count),this.parameters.gr_size.fromArray(t.gr_size),this.parameters.gr_fromCenter=t.gr_fromCenter,this.update(),this.setHideBase(this.parameters.hideBase),this}}class jn extends(kn(t.Mesh)){constructor(e,t){super(e,t),this.isAbstractMesh=!0,Array.isArray(t)&&(this.selectedMaterial=0)}get cloner(){return this._cloner}set cloner(e){this._cloner&&this.remove(this._cloner),e&&this.add(e),this._cloner=e}getSelectedMaterial(e){return Array.isArray(this.material)?(void 0===this.selectedMaterial&&(this.selectedMaterial=null!=e?e:0),this.material[null!=e?e:this.selectedMaterial]):this.material}setSelectedMaterial(e,t){Array.isArray(this.material)?(void 0===this.selectedMaterial&&(this.selectedMaterial=null!=t?t:0),t=null!=t?t:this.selectedMaterial,this.material[t].dispose(),this.material[t]=e):(this.material.dispose(),this.material=e)}updateGeometry(e){const t=this.geometry,r=Xe[t.userData.type],i="NonParametric"===this.objectType?Object.assign({},t.userData,{geometry:t}):t.userData,n=r.build(r.normalizeInputs(e,i)),s=t.uuid;this.geometry.dispose(),this.geometry=n,this.geometry.uuid=s,this.geometry.computeBoundingSphere()}resizeGeometry(e,t,r){((e,{width:t,height:r,depth:i})=>{t=Math.abs(t),r=Math.abs(r),i=Math.abs(i);const n=e.userData.parameters;let s,o,a;0===t?(t=n.width,s=1):s=t/n.width,0===r?(r=n.height,o=1):o=r/n.height,0===i?(i=n.depth,a=1):a=i/n.depth,e.scale(s,o,a),n.width=t,n.height=r,n.depth=i})(this.geometry,{width:e,height:t,depth:r})}shallowClone(e){return new this.constructor(this.geometry,this.material).shallowCopy(this,e)}clone(e){const t="NonParametric"===this.objectType?Object.assign({},this.geometry.userData,{geometry:this.geometry.clone()}):this.geometry.userData,r=Ke(t),i=Array.isArray(this.material)?this.material.map((e=>e.clone())):this.material.clone();return new this.constructor(r,i).copy(this,e)}copy(e,t=!0){return super.copy(e,t),e.cloner&&(this.cloner=new Gn(e,e.cloner.parameters),this.add(this.cloner)),this}toJSON(e){const t=super.toJSON(e),r=t.object;if(void 0!==this.cloner&&(r.cloner=this.cloner.toJSON()),r.geometry=function(e,t,r){if(void 0===e[t.uuid])if("SubdivGeometry"===t.userData.type&&_n&&0===(t=Be.create({geometry:t.clone()})).userData.parameters.subdivisions&&(delete t.attributes.color,delete t.attributes.faceMap),"NonParametricGeometry"===t.userData.type||"SubdivGeometry"===t.userData.type){const r=t.originalGeometry;if(void 0!==r){const e=t.userData;(t=r).userData=e}e[t.uuid]=t.toJSON()}else{let r=t.userData;if("VectorGeometry"===r.type){const e=t.userData.shape;r=Object.assign({},r,{shape:e.toJSON()})}e[t.uuid]={uuid:t.uuid,userData:r}}return t.uuid}(e.geometries,this.geometry,this.material),Array.isArray(this.material)){const t=[];for(let r=0,i=this.material.length;r<i;r++)t.push(Nn(e.materials,this.material[r],e));r.material=t}else r.material=Nn(e.materials,this.material,e);return t}fromJSON(e){return super.fromJSON(e),void 0!==e.selectedMaterial&&(this.selectedMaterial=e.selectedMaterial),void 0!==e.cloner&&(this.cloner=new Gn(this).fromJSON(e.cloner)),this}}const Vn=e=>{var r;return(r=class extends e{constructor(){super(...arguments),this.isObjectHelper=!0}}).geometryHelper=new t.BoxBufferGeometry(30,30,30),r},Hn=new t.Ray,Jn=new t.Sphere,Qn=new t.Matrix4,Yn=(e,r,i,n)=>{const s=r,o=e.matrixWorld;if(null===s.boundingSphere&&s.computeBoundingSphere(),Jn.copy(s.boundingSphere),Jn.applyMatrix4(o),!1===i.ray.intersectsSphere(Jn))return;if(Qn.copy(o).invert(),Hn.copy(i.ray).applyMatrix4(Qn),null!==s.boundingBox&&!1===Hn.intersectsBox(s.boundingBox))return;let a,l,c,h;const u=s.index,d=s.attributes.position,p=s.drawRange;let f,m;for(f=Math.max(0,p.start),m=Math.min(u.count,p.start+p.count);f<m;f+=3)if(l=u.getX(f),c=u.getX(f+1),h=u.getX(f+2),a=g(e,i,Hn,d,l,c,h),a)return a.faceIndex=Math.floor(f/3),void n.push(a);function g(e,r,i,n,s,o,a){const l=new t.Vector3,c=new t.Vector3,h=new t.Vector3,u=new t.Vector3,d=new t.Vector3;l.fromBufferAttribute(n,s),c.fromBufferAttribute(n,o),h.fromBufferAttribute(n,a);if(null===i.intersectTriangle(l,c,h,!1,u))return null;d.copy(u),d.applyMatrix4(e.matrixWorld);const p=r.ray.origin.distanceTo(d);return p<r.near||p>r.far?null:{faceIndex:1,distance:p,point:d.clone(),object:e}}};class Wn extends(Vn(t.CameraHelper)){constructor(e){super(e),this.object=e;const r=new t.SphereGeometry(15,4,2),i=new t.MeshBasicMaterial({wireframe:!0,fog:!1,toneMapped:!1}),n=new t.Mesh(r,i);this.add(n),this.object=e,this.name=`CombinedCameraHelper: ${e.uuid}`}raycast(e,t){Yn(this.object,Wn.geometryHelper,e,t)}}class Xn extends(Vn(t.DirectionalLightHelper)){constructor(e,t=15,r=10066329){super(e,t,r),this.object=e,this.name=`DirectionalLightHelper: ${e.uuid}`}raycast(e,t){Yn(this.object,Xn.geometryHelper,e,t)}}class Kn extends(Vn(t.AxesHelper)){constructor(e,t=15){super(t),this.object=e,this.object.updateMatrixWorld(),this.name=`EmptyObjectHelper: ${e.uuid}`,this.matrix=e.matrixWorld,this.matrixAutoUpdate=!1}raycast(e,t){Yn(this.object,Kn.geometryHelper,e,t)}update(){}}class qn extends(Vn(t.PointLightHelper)){constructor(e,t=15,r=6710886){super(e,t,r),this.object=e,this.name=`PointLightHelper: ${e.uuid}`}raycast(e,t){Yn(this.object,qn.geometryHelper,e,t)}}class Zn extends(Vn(t.SpotLightHelper)){constructor(e,t=6710886){super(e,t),this.object=e,this.name=`SpotLightHelper: ${e.uuid}`}raycast(e,t){Yn(this.object,Zn.geometryHelper,e,t)}update(){if(void 0!==this.object){const e=Zn._vector,t=this.object.distance?this.object.distance:1e3,r=t*Math.tan(this.object.angle);this.cone.scale.set(r,r,t),e.setFromMatrixPosition(this.object.target.matrixWorld),this.cone.lookAt(e);const i=void 0!==this.color?this.color:this.light.color;if(this.cone.material instanceof Array)for(let e=0,t=this.cone.material.length;e<t;e++)this.cone.material[e].color.set(i);else this.cone.material.color.set(i)}}}Zn._vector=new t.Vector3;new t.Sphere,new t.Matrix4,new t.Ray,new t.Vector3;const $n=new t.Vector3(0,0,1),es=new t.Vector3,ts=new t.Vector3,rs=new t.Matrix3;class is extends jn{constructor(e=ce.create({}),r=new Er({side:t.DoubleSide})){var i;super(e,r),this.recursiveSelection=!1,this.objectType="VectorObject",this.eventDispatcher=new t.EventDispatcher,this._onShapeUpdate=()=>{if(this.geometry instanceof se){if(this.geometry.updateFromShape()){const e=this.geometry.drawCount,t=this.geometry.userData;this.updateGeometry(Object.assign(this.geometry.userData,{parameters:Object.assign(t.parameters,{surfaceMaxCount:e+1e3})}))}}else this.updateGeometry({});this.computeSingleBoundingBox(),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox()},this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!0,this.shape=e.userData.shape,null===(i=this.shape.eventDispatcher)||void 0===i||i.addEventListener("update",this._onShapeUpdate)}toJSON(e){const t=super.toJSON(e);return t.object.objectType="VectorObject",t}setHelperVisibility(){}updateGeometry(e){if(super.updateGeometry(e),"userData"in this.geometry){const e=this.geometry.userData.parameters;this.eventDispatcher.dispatchEvent({type:"geometryUpdate",parameters:e})}}setShape(e){var t,r;this.shape&&(null===(t=this.shape.eventDispatcher)||void 0===t||t.removeEventListener("update",this._onShapeUpdate)),this.shape=e,null===(r=this.shape.eventDispatcher)||void 0===r||r.addEventListener("update",this._onShapeUpdate)}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),rs.getNormalMatrix(this.matrixWorld),es.copy($n).applyMatrix3(rs).normalize(),ts.setFromMatrixPosition(this.matrixWorld),this.shape.plane.setFromNormalAndCoplanarPoint(es,ts)}clone(e){const t=this.shape.clone(),r=this.material.clone(),i=this.geometry.userData,n=ce.create(Object.assign({},i,{shape:t})),s=new is(n,r).copy(this,e);return s.shape=t,t.update(),s}raycast(e,t){jn.prototype.raycast.call(this,e,t)}}new t.TextureLoader,new t.Vector2,new t.Vector2,new t.Vector2,new t.LineBasicMaterial({linewidth:1,depthTest:!0,depthWrite:!1,side:t.FrontSide,transparent:!1,vertexColors:!0}),new t.MeshBasicMaterial({opacity:.2,transparent:!0,vertexColors:!0,side:t.DoubleSide}),new t.PointsMaterial({size:3,color:new t.Color("hsl(0, 0%, 70%)"),sizeAttenuation:!1});const ns=(e,t)=>class extends e{constructor(){super(...arguments),this.objectHelper=new t(this),this.enableHelper=!1}set visibility(e){this.visible=e,this.setHelperVisibility(e),this.setHelperChildrenVisibility(e)}get visibility(){return this.visible}get geometryHelper(){return t.geometryHelper}setHelperVisibility(e){this.objectHelper.visible=e}setHelperChildrenVisibility(e){for(const t of this.children)Fn(t)&&t.traverseEntity((t=>{zn(t)&&t.visible&&(t.objectHelper.visible=e)}))}raycast(e,t){this.objectHelper.raycast(e,t)}copy(e,t=!0){return super.copy(e,t),void 0!==e.enableHelper&&(this.enableHelper=e.enableHelper),void 0!==e.objectHelper&&(this.objectHelper.visible=e.objectHelper.visible),this}toJSON(e){const t=super.toJSON(e);return t.object.enableHelper=this.enableHelper,t}fromJSON(e){return super.fromJSON(e),void 0!==e.enableHelper&&(this.enableHelper=!0),this}};class ss extends(ns(kn(t.Camera),Wn)){constructor(e=100,r=100,i=45,n=50,s=5e4){super(),this.objectType="CombinedCamera",this.width=window.innerWidth,this.height=window.innerHeight,this.orthoCamera=new t.OrthographicCamera(-.5*e,.5*e,.5*r,-.5*r,n,s),this.perspCamera=new t.PerspectiveCamera(i,e/r,n,s),this._cameraType="OrthographicCamera",this.left=this.orthoCamera.left,this.right=this.orthoCamera.right,this.top=this.orthoCamera.top,this.bottom=this.orthoCamera.bottom,this.far=this.orthoCamera.far,this.view=this.orthoCamera.view,this.aspect=this.perspCamera.aspect,this.fov=this.perspCamera.fov,this.focus=this.perspCamera.focus,this.filmGauge=this.perspCamera.filmGauge,this.filmOffset=this.perspCamera.filmOffset,this.targetOffset=1e3,this.toOrthographic(!0)}setDefault(){this.name="Default Camera",this.isEntity=!1,this.enableHelper=!1,this.objectHelper.visible=!1}get isPerspectiveCamera(){return"PerspectiveCamera"===this.cameraType}get isOrthographicCamera(){return!this.isPerspectiveCamera}get cameraType(){return this._cameraType}set cameraType(e){"PerspectiveCamera"===e?this.toPerspective():"OrthographicCamera"===e&&this.toOrthographic()}get near(){return"PerspectiveCamera"===this._cameraType?this.perspCamera.near:this.orthoCamera.near}set near(e){"PerspectiveCamera"===this._cameraType?this.perspCamera.near=e:this.orthoCamera.near=e}get zoom(){return"PerspectiveCamera"===this._cameraType?this.perspCamera.zoom:this.orthoCamera.zoom}set zoom(e){e>=0&&("PerspectiveCamera"===this._cameraType?this.perspCamera.zoom=e:this.orthoCamera.zoom=e)}getTarget(e){const r=this.getWorldDirection(new t.Vector3).multiplyScalar(this.targetOffset);return e.copy(this.position).add(r),e}getViewFrontToObject(e){const r=e.getWorldPosition(new t.Vector3),i=e.getWorldDirection(new t.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().add(i),target:r}}getViewToObject(e){const r=e.getWorldPosition(new t.Vector3),i=this.getWorldDirection(new t.Vector3).multiplyScalar(this.targetOffset);return{position:r.clone().sub(i),target:r}}setViewplaneSize(e,t){this.left=.5*-e,this.right=.5*e,this.top=.5*t,this.bottom=.5*-t,this.aspect=e/t,this.updateProjectionMatrix()}toOrthographic(e){this.orthoCamera.left=this.left,this.orthoCamera.right=this.right,this.orthoCamera.top=this.top,this.orthoCamera.bottom=this.bottom,this.orthoCamera.view=this.view,this.orthoCamera.far=this.far,this.orthoCamera.updateProjectionMatrix(),this.projectionMatrix=this.orthoCamera.projectionMatrix,this.projectionMatrixInverse=this.orthoCamera.projectionMatrixInverse,this._cameraType="OrthographicCamera",!0!==this.enableHelper&&!0!==e||this.objectHelper.update()}toPerspective(e){this.perspCamera.aspect=this.aspect,this.perspCamera.fov=this.fov,this.perspCamera.view=this.view,this.perspCamera.far=this.far,this.perspCamera.updateProjectionMatrix(),this.projectionMatrix=this.perspCamera.projectionMatrix,this.projectionMatrixInverse=this.perspCamera.projectionMatrixInverse,this._cameraType="PerspectiveCamera",!0!==this.enableHelper&&!0!==e||this.objectHelper.update()}setFocalLength(e){this.perspCamera.setFocalLength(e),this.toPerspective()}getFocalLength(){return this.perspCamera.getFocalLength()}getEffectiveFOV(){return this.perspCamera.getEffectiveFOV()}getFilmWidth(){return this.perspCamera.getFilmWidth()}getFilmHeight(){return this.perspCamera.getFilmHeight()}setViewOffset(e,t,r,i,n,s){"PerspectiveCamera"===this._cameraType?this.perspCamera.setViewOffset(e,t,r,i,n,s):this.orthoCamera.setViewOffset(e,t,r,i,n,s)}clearViewOffset(){"PerspectiveCamera"===this._cameraType?(this.perspCamera.clearViewOffset(),this.toPerspective()):(this.orthoCamera.clearViewOffset(),this.toOrthographic())}updateProjectionMatrix(e){"PerspectiveCamera"===this._cameraType?this.toPerspective(e):"OrthographicCamera"===this._cameraType&&this.toOrthographic(e)}updateMatrixWorld(e){super.updateMatrixWorld(e),this.matrixWorldInverse.copy(this.matrixWorld).invert()}updateWorldMatrix(e,t){super.updateWorldMatrix(e,t),this.matrixWorldInverse.copy(this.matrixWorld).invert()}raycast(e,t){this.enableHelper&&this.objectHelper.visible&&this.objectHelper.raycast(e,t)}copy(e,t){return super.copy(e,t),this.orthoCamera.copy(e.orthoCamera),this.perspCamera.copy(e.perspCamera),this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.far=e.far,this.view=null===e.view?null:Object.assign({},e.view),this._cameraType=e._cameraType,this.aspect=e.aspect,this.fov=e.fov,this.focus=e.focus,this.filmGauge=e.filmGauge,this.filmOffset=e.filmOffset,this.targetOffset=e.targetOffset,this.updateProjectionMatrix(),this}fromCameraRender(e){const t={near:this.orthoCamera.near,far:this.orthoCamera.far},r={near:this.perspCamera.near,far:this.perspCamera.far};return this.copy(e),this.name="",this.isEntity=!0,this.enableHelper=!0,this.objectHelper.visible=!0,this.orthoCamera.near=t.near,this.orthoCamera.far=t.far,this.perspCamera.near=r.near,this.perspCamera.far=r.far,this.updateProjectionMatrix(),this}toJSON(e){const t=super.toJSON(e),r=t.object;return r.objectType="CombinedCamera",r.cameraType=this.cameraType,r.targetOffset=this.targetOffset,r.left=this.left,r.right=this.right,r.top=this.top,r.bottom=this.bottom,null!==this.view&&(r.view=Object.assign({},this.view)),r.zoomOrtho=this.orthoCamera.zoom,r.nearOrtho=this.orthoCamera.near,r.far=this.far,r.aspect=this.aspect,r.fov=this.fov,r.focus=this.focus,r.filmGauge=this.filmGauge,r.filmOffset=this.filmOffset,r.zoomPersp=this.perspCamera.zoom,r.nearPersp=this.perspCamera.near,t}fromJSON(e){return super.fromJSON(e),this.cameraType=e.cameraType,void 0!==e.targetOffset&&(this.targetOffset=e.targetOffset),void 0!==e.left&&(this.left=e.left),void 0!==e.right&&(this.right=e.right),void 0!==e.top&&(this.top=e.top),void 0!==e.bottom&&(this.bottom=e.bottom),void 0!==e.view&&(this.view=Object.assign({},e.view)),void 0!==e.zoomOrtho&&(this.orthoCamera.zoom=e.zoomOrtho),void 0!==e.nearOrtho&&(this.orthoCamera.near=e.nearOrtho),void 0!==e.far&&(this.far=e.far),void 0!==e.aspect&&(this.aspect=e.aspect),void 0!==e.fov&&(this.fov=e.fov),void 0!==e.focus&&(this.focus=e.focus),void 0!==e.filmGauge&&(this.filmGauge=e.filmGauge),void 0!==e.filmOffset&&(this.filmOffset=e.filmOffset),void 0!==e.zoomPersp&&(this.perspCamera.zoom=e.zoomPersp),void 0!==e.nearPersp&&(this.perspCamera.near=e.nearPersp),this.updateProjectionMatrix(),this}}class os extends(ns(kn(t.Group),Kn)){constructor(){super(...arguments),this.objectType="EmptyObject"}toJSON(e){const t=super.toJSON(e);return t.object.objectType="EmptyObject",t}}class as extends(ns(kn(t.DirectionalLight),Xn)){constructor(...e){super(...e),this.objectType="LightDirectional",this._gizmos={},this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;const r=this.shadow.camera;r.top=1250,r.bottom=-1250,r.right=1250,r.left=-1250,r.near=1,r.far=2500;const i=new t.CameraHelper(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}get gizmos(){return this._gizmos}showGizmos(){for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.CameraHelper&&(r.visible=!0)}}hideGizmos(){for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.CameraHelper&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.CameraHelper&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),!0===this.enableHelper&&!0===this.objectHelper.visible&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e),r=t.object;return r.objectType="LightDirectional",r.color=this.color.getHex(),r.intensity=this.intensity,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var t;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.shadow.normalBias=null!==(t=e.shadow.normalBias)&&void 0!==t?t:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);const r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.left=i.left,r.right=i.right,r.top=i.top,r.bottom=i.bottom,void 0!==i.view&&(r.view=Object.assign({},i.view)),this}}class ls extends(ns(kn(t.PointLight),qn)){constructor(...e){super(...e),this.objectType="LightPoint",this._gizmos={},this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;const r=this.shadow.camera;r.fov=90,r.aspect=1,r.near=100,r.far=2500;const i=new t.Vector3(-r.far+this.position.x,-r.far+this.position.y,-r.far+this.position.z),n=new t.Vector3(r.far+this.position.x,r.far+this.position.y,r.far+this.position.z),s=new t.Box3(i,n),o=new t.Box3Helper(s,new t.Color(16755200));o.visible=!1,this._gizmos.shadowmap=o,this.update()}get gizmos(){return this._gizmos}showGizmos(){for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.Box3Helper&&(r.visible=!0)}}hideGizmos(){for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.Box3Helper&&(r.visible=!1)}}update(){if(this.shadow&&(this.shadow.camera.updateProjectionMatrix(),this._gizmos))for(const e in this._gizmos){const r=this._gizmos[e];if(r instanceof t.Box3Helper){const e=this.shadow.camera,i=new t.Vector3(-e.far+this.position.x,-e.far+this.position.y,-e.far+this.position.z),n=new t.Vector3(e.far+this.position.x,e.far+this.position.y,e.far+this.position.z);r.box.set(i,n),r.updateMatrixWorld(!0)}}}updateMatrixWorld(e){super.updateMatrixWorld(e),!0===this.enableHelper&&!0===this.objectHelper.visible&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e),r=t.object;return r.objectType="LightPoint",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.decay=this.decay,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var t;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.decay=e.decay,this.shadow.normalBias=null!==(t=e.shadow.normalBias)&&void 0!==t?t:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);const r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,void 0!==i.view&&(r.view=Object.assign({},i.view)),this}}const cs=new t.Vector3,hs=new t.Vector3,us=new t.Quaternion;class ds extends(ns(kn(t.SpotLight),Zn)){constructor(...e){super(...e),this.objectType="LightSpot",this._gizmos={},this.shadow.mapSize.width=1024,this.shadow.mapSize.height=1024;const r=this.shadow.camera;r.fov=2*t.MathUtils.RAD2DEG*this.angle,r.aspect=1,r.near=100,r.far=2500;const i=new t.CameraHelper(this.shadow.camera);i.visible=!1,this._gizmos.shadowmap=i,this.update()}get gizmos(){return this._gizmos}showGizmos(){for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.CameraHelper&&(r.visible=!0)}}hideGizmos(){for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.CameraHelper&&(r.visible=!1)}}update(){this.shadow.camera.updateProjectionMatrix();for(const e in this._gizmos){const r=this._gizmos[e];r instanceof t.CameraHelper&&r.update()}}updateMatrixWorld(e){super.updateMatrixWorld(e),hs.setFromMatrixPosition(this.matrixWorld),us.setFromRotationMatrix(this.matrixWorld),cs.copy(this.up).applyQuaternion(us).negate().multiplyScalar(this.distance),this.target.position.copy(hs).add(cs),this.target.updateMatrixWorld(),!0===this.enableHelper&&!0===this.objectHelper.visible&&this.objectHelper.update()}copy(e,t=!0){return super.copy(e,t),this.color.copy(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.penumbra=e.penumbra,this.decay=e.decay,this.target=e.target.clone(),this.shadow=e.shadow.clone(),this}toJSON(e){const t=super.toJSON(e),r=t.object;return r.objectType="LightSpot",r.color=this.color.getHex(),r.intensity=this.intensity,r.distance=this.distance,r.angle=this.angle,r.decay=this.decay,r.penumbra=this.penumbra,r.shadow=this.shadow.toJSON(),t}fromJSON(e){var t;super.fromJSON(e),this.color.set(e.color),this.intensity=e.intensity,this.distance=e.distance,this.angle=e.angle,this.decay=e.decay,this.penumbra=e.penumbra,this.shadow.normalBias=null!==(t=e.shadow.normalBias)&&void 0!==t?t:0,this.shadow.radius=e.shadow.radius,this.shadow.mapSize.fromArray(e.shadow.mapSize);const r=this.shadow.camera,i=e.shadow.camera;return r.near=i.near,r.far=i.far,r.zoom=i.zoom,r.fov=i.fov,r.focus=i.focus,r.aspect=i.aspect,r.filmGauge=i.filmGauge,r.filmOffset=i.filmOffset,void 0!==i.view&&(r.view=Object.assign({},i.view)),this}}const ps=e=>"VIDEO"===e.tagName;class fs{static resize(e,t,r){const i=e/t;let n;if(!r.image)return;const s=r.image;n=ps(s)?s.videoWidth/s.videoHeight:s.width/s.height,i>n&&("WEBCAM"==r.imageType?r.repeat.set(-1,1*n/i):r.repeat.set(1,1*n/i)),i<n&&("WEBCAM"==r.imageType?r.repeat.set(1*i/n*-1,1):r.repeat.set(1*i/n,1)),i==n&&("WEBCAM"==r.imageType?r.repeat.set(-1,1):r.repeat.set(1,1))}static resizeTextureLayer(e,t,r){const i=e/t,n=void 0!==r.image?r.image.width/r.image.height:1;let s;s=i>n?{x:1,y:n/i}:i<n?{x:i/n,y:1}:{x:1,y:1},r.repeat.set(s.x,s.y),r.updateMatrix()}static resizeTextureLayers(e,t,r){const i=r.userData.layers,n=i.getLayers();for(let r=0;r<n.length;r++){const s=n[r];ht(s)&&(fs.resizeTextureLayer(e,t,s.uniforms[`f${s.id}_texture`].value),i.updateLayerUniform())}}static resizeComplex(e,t,r,i){const n=e/t;let s;const o=r.image;s=ps(o)?o.videoWidth/o.videoHeight:o.width/o.height,i.geometry.type.includes("Shape")?(n>s&&("WEBCAM"==r.imageType?r.repeat.set(1/e*-1,1/t*s/n):r.repeat.set(1/e,1/t*s/n)),n<s&&("WEBCAM"==r.imageType?r.repeat.set(1/e*n/s*-1,1/t):r.repeat.set(1/e*n/s,1/t)),n==s&&("WEBCAM"==r.imageType?r.repeat.set(1/e*-1,1/t):r.repeat.set(1/e,1/t))):(n>s&&("WEBCAM"==r.imageType?r.repeat.set(-1,1*s/n):r.repeat.set(1,1*s/n)),n<s&&("WEBCAM"==r.imageType?r.repeat.set(1*n/s*-1,1):r.repeat.set(1*n/s,1)),n==s&&("WEBCAM"==r.imageType?r.repeat.set(-1,1):r.repeat.set(1,1)))}}class ms extends jn{constructor(e,t=new Er){super(e,t),this.objectType="Mesh2D",this.castShadow=!0,this.receiveShadow=!0}updateGeometry(e){super.updateGeometry(e),this.material.userData.layers&&fs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}resizeGeometry(e,t){super.resizeGeometry(e,t,0),this.material.userData.layers&&fs.resizeTextureLayers(this.geometry.userData.parameters.width,this.geometry.userData.parameters.height,this.material)}toJSON(e){const t=super.toJSON(e);return t.object.objectType="Mesh2D",t}static fromTexture(e){let r,i;if(e instanceof t.VideoTexture){const t=e.image;r=.5*t.videoWidth,i=.5*t.videoHeight}else{const t=e.image;r=.5*t.width,i=.5*t.height}const n=Ue.create({parameters:{width:r,height:i}}),s=new Er;return s.layersList.changeLayer(0,{type:ot.TEXTURE,texture:e}),s.layersList.moveLayer(0,1),s.dispose(),new ms(n,s)}}class gs extends jn{constructor(e,t=new Or){super(e,t),this.objectType="Mesh3D",this.castShadow=!0,this.receiveShadow=!0}toJSON(e){const t=super.toJSON(e);return t.object.objectType="Mesh3D",t}}class vs extends gs{constructor(e,t=new Or){super(e,t),this.objectType="NonParametric"}toJSON(e){const t=super.toJSON(e);return t.object.objectType="NonParametric",t}}class ys{constructor(e,i,n){this.isEnable=!1,this._enableEvent={},this._map={},this._prevAncestors=[],this._raycaster=new r,this._intersection=new t.Vector3,this._plane=new t.Plane,this._normal=new t.Vector3,this._position=new t.Vector3,this._onMouseDown=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseDownEvent()},this._onMouseUp=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._handleMouseUpEvent()},this._onMouseMove=e=>{this._raycaster.setFromCamera(this._getPointer(e.clientX,e.clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent()},this._onTouchStart=e=>{1===e.touches.length&&(e.preventDefault(),this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseDownEvent(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())},this._onTouchEnd=()=>{this._handleMouseUpEvent(),this._handleMouseHoverEvent(!0)},this._onTouchMove=e=>{1===e.touches.length&&(e.preventDefault(),e.stopPropagation(),this._raycaster.setFromCamera(this._getPointer(e.touches[0].clientX,e.touches[0].clientY),this._camera),this._camera.getWorldDirection(this._normal),this._normal.negate(),this._handleMouseHoverEvent(),this._handleLookAtEvent(),this._handleFollowEvent())},this._onKeyDown=e=>{this._handleKeyDownEvent(e.key)},this._onKeyUp=e=>{this._handleKeyUpEvent(e.key)},this._domElement=e,this._scene=i,this._camera=n}activate(){this.isEnable=!0,this._scene.traverseEntity((e=>{if(void 0!==e.interaction){e.interaction.start();for(const t of e.interaction.events){const r=t.type;this._enableEvent[r]=!0,r!==jr.KEY_DOWN&&r!==jr.KEY_UP&&r!==jr.START&&r!==jr.LOOK_AT&&r!==jr.FOLLOW||(void 0===this._map[r]&&(this._map[r]=[]),this._map[r].push(e))}}})),void 0!==this._enableEvent[jr.START]&&this._handleStartEvent(),void 0!==this._enableEvent[jr.MOUSE_DOWN]&&(this._domElement.addEventListener("pointerdown",this._onMouseDown,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1)),void 0!==this._enableEvent[jr.MOUSE_UP]&&(this._domElement.addEventListener("pointerup",this._onMouseUp,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1)),void 0===this._enableEvent[jr.MOUSE_HOVER]&&void 0===this._enableEvent[jr.LOOK_AT]&&void 0===this._enableEvent[jr.FOLLOW]||(this._domElement.addEventListener("pointermove",this._onMouseMove,!1),this._domElement.addEventListener("touchstart",this._onTouchStart,!1),this._domElement.addEventListener("touchend",this._onTouchEnd,!1),this._domElement.addEventListener("touchmove",this._onTouchMove,!1)),void 0!==this._enableEvent[jr.KEY_DOWN]&&document.addEventListener("keydown",this._onKeyDown,!1),void 0!==this._enableEvent[jr.KEY_UP]&&document.addEventListener("keyup",this._onKeyUp,!1)}deactivate(){this._scene.traverseEntity((e=>{void 0!==e.interaction&&e.interaction.end(),e.interaction.cache=void 0})),this._domElement.removeEventListener("pointerdown",this._onMouseDown),this._domElement.removeEventListener("pointerup",this._onMouseUp),this._domElement.removeEventListener("pointermove",this._onMouseMove),this._domElement.removeEventListener("touchstart",this._onTouchStart),this._domElement.removeEventListener("touchend",this._onTouchEnd),this._domElement.removeEventListener("touchmove",this._onTouchMove),document.removeEventListener("keydown",this._onKeyDown),document.removeEventListener("keyup",this._onKeyUp),this._enableEvent={},this._map={},this.isEnable=!1}reset(){this._scene.traverseEntity((e=>{e.interaction.start()})),this._handleStartEvent()}_getPointer(e,t){const r=this._domElement.getBoundingClientRect();return{x:(e-r.left)/r.width*2-1,y:-(t-r.top)/r.height*2+1}}_handleStartEvent(){var e;null===(e=this._map[jr.START])||void 0===e||e.forEach((e=>{var t;null===(t=e.interactionCache.start)||void 0===t||t.dispatch()}))}_handleMouseDownEvent(){var e;const t=this._raycastMesh(this._raycaster);for(let r=0,i=t.length;r<i;++r){const i=t[r].object;if(null===(e=i.interactionCache.mouseDown)||void 0===e||e.dispatch(),i.traverseAncestors((e=>{var t;e instanceof os&&(null===(t=e.interactionCache.mouseDown)||void 0===t||t.dispatch())})),!i.interactionCache.follow)break}}_handleMouseUpEvent(){var e;const t=this._raycastMesh(this._raycaster);for(let r=0,i=t.length;r<i;++r){const i=t[r].object;if(null===(e=i.interactionCache.mouseUp)||void 0===e||e.dispatch(),i.traverseAncestors((e=>{var t;e instanceof os&&(null===(t=e.interactionCache.mouseUp)||void 0===t||t.dispatch())})),!i.interactionCache.follow)break}}_handleMouseHoverEvent(e=!1){var t,r;if(void 0!==this._enableEvent[jr.MOUSE_HOVER]){let i;if(!e){const e=this._raycastMesh(this._raycaster).find((e=>!e.object.interactionCache.follow));i=e?e.object:void 0}if(this._prevObject!==i){void 0!==this._prevObject&&(null===(t=this._prevObject.interactionCache.mouseHover)||void 0===t||t.dispatchReverse()),void 0!==i&&(null===(r=i.interactionCache.mouseHover)||void 0===r||r.dispatch());const e=[];null==i||i.traverseAncestors((t=>{t instanceof os&&t.interactionCache.mouseHover&&e.push(t)})),this._prevAncestors.filter((t=>{var r;return!e.includes(t)&&(null===(r=t.interactionCache.mouseHover)||void 0===r||r.dispatchReverse(),!0)}));const n=e.filter((e=>{var t;return!this._prevAncestors.includes(e)&&(null===(t=e.interactionCache.mouseHover)||void 0===t||t.dispatch(),!0)})),s=this._prevAncestors.filter((t=>e.includes(t)));this._prevAncestors=[...s,...n]}this._prevObject=i}}_handleLookAtEvent(){var e;null===(e=this._map[jr.LOOK_AT])||void 0===e||e.forEach((e=>{var t;const r=null===(t=e.interactionCache.lookAt)||void 0===t?void 0:t.distance;void 0!==r&&(this._plane.set(this._normal,-r),this._raycaster.ray.intersectPlane(this._plane,this._intersection),e.interaction.lookAt(this._intersection))}))}_handleFollowEvent(){var e;null===(e=this._map[jr.FOLLOW])||void 0===e||e.forEach((e=>{this._plane.setFromNormalAndCoplanarPoint(this._normal,e.getWorldPosition(this._position)),this._raycaster.ray.intersectPlane(this._plane,this._intersection),e.interaction.follow(this._intersection)}))}_handleKeyDownEvent(e){var t;null===(t=this._map[jr.KEY_DOWN])||void 0===t||t.forEach((t=>{var r;const i=null===(r=t.interactionCache.keyDown)||void 0===r?void 0:r.find((t=>t.key===e));null==i||i.dispatch()}))}_handleKeyUpEvent(e){var t;null===(t=this._map[jr.KEY_UP])||void 0===t||t.forEach((t=>{var r;const i=null===(r=t.interactionCache.keyUp)||void 0===r?void 0:r.find((t=>t.key===e));null==i||i.dispatch()}))}_raycastMesh(e){const t=[],r=i=>{for(const n of i.children)Fn(n)&&!n.raycastLock&&n.visible&&(Un(n)&&e.intersectObject(n,!1,t),r(n))};return r(this._scene),t}}
/**
* postprocessing v6.22.3 build Sat Jul 31 2021
* https://github.com/vanruesc/postprocessing
* Copyright 2021 Raoul van Rüschen
* @license Zlib
*/var As=0,ws=1,xs="varying vec2 vUv;void main(){vUv=position.xy*0.5+0.5;gl_Position=vec4(position.xy,1.0,1.0);}",bs=class extends t.ShaderMaterial{constructor(e=!1,r=!1){super({type:"BokehMaterial",defines:{PASS:e?"2":"1"},uniforms:{kernel64:new t.Uniform(null),kernel16:new t.Uniform(null),inputBuffer:new t.Uniform(null),cocBuffer:new t.Uniform(null),texelSize:new t.Uniform(new t.Vector2),scale:new t.Uniform(1)},fragmentShader:"#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\nuniform lowp sampler2D cocBuffer;uniform vec2 texelSize;uniform float scale;\n#if PASS == 1\nuniform vec4 kernel64[32];\n#else\nuniform vec4 kernel16[8];\n#endif\nvarying vec2 vUv;void main(){\n#ifdef FOREGROUND\nvec2 CoCNearFar=texture2D(cocBuffer,vUv).rg;float CoC=CoCNearFar.r*scale;\n#else\nfloat CoC=texture2D(cocBuffer,vUv).g*scale;\n#endif\nif(CoC==0.0){gl_FragColor=texture2D(inputBuffer,vUv);}else{\n#ifdef FOREGROUND\nvec2 step=texelSize*max(CoC,CoCNearFar.g*scale);\n#else\nvec2 step=texelSize*CoC;\n#endif\n#if PASS == 1\nvec4 acc=vec4(0.0);for(int i=0;i<32;++i){vec4 kernel=kernel64[i];vec2 uv=step*kernel.xy+vUv;acc+=texture2D(inputBuffer,uv);uv=step*kernel.zw+vUv;acc+=texture2D(inputBuffer,uv);}gl_FragColor=acc/64.0;\n#else\nvec4 maxValue=texture2D(inputBuffer,vUv);for(int i=0;i<8;++i){vec4 kernel=kernel16[i];vec2 uv=step*kernel.xy+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);uv=step*kernel.zw+vUv;maxValue=max(texture2D(inputBuffer,uv),maxValue);}gl_FragColor=maxValue;\n#endif\n}}",vertexShader:xs,blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,r&&(this.defines.FOREGROUND="1"),this.generateKernel()}generateKernel(){const e=new Float32Array(128),r=new Float32Array(32);let i=0,n=0;for(let t=0;t<80;++t){const s=2.39996323*t,o=Math.sqrt(t)/Math.sqrt(80),a=o*Math.cos(s),l=o*Math.sin(s);t%5==0?(r[n++]=a,r[n++]=l):(e[i++]=a,e[i++]=l)}const s=[],o=[];for(let r=0;r<128;)s.push(new t.Vector4(e[r++],e[r++],e[r++],e[r++]));for(let e=0;e<32;)o.push(new t.Vector4(r[e++],r[e++],r[e++],r[e++]));this.uniforms.kernel64.value=s,this.uniforms.kernel16.value=o}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t)}},Ss=class extends t.ShaderMaterial{constructor(e){super({type:"CircleOfConfusionMaterial",defines:{DEPTH_PACKING:"0"},uniforms:{depthBuffer:new t.Uniform(null),focusDistance:new t.Uniform(0),focalLength:new t.Uniform(0),cameraNear:new t.Uniform(.3),cameraFar:new t.Uniform(1e3)},fragmentShader:"#include <common>\n#include <packing>\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer;\n#else\nuniform mediump sampler2D depthBuffer;\n#endif\nuniform float focusDistance;uniform float focalLength;uniform float cameraNear;uniform float cameraFar;varying vec2 vUv;float readDepth(const in vec2 uv){\n#if DEPTH_PACKING == 3201\nreturn unpackRGBAToDepth(texture2D(depthBuffer,uv));\n#else\nreturn texture2D(depthBuffer,uv).r;\n#endif\n}void main(){float depth=readDepth(vUv);\n#ifdef PERSPECTIVE_CAMERA\nfloat viewZ=perspectiveDepthToViewZ(depth,cameraNear,cameraFar);float linearDepth=viewZToOrthographicDepth(viewZ,cameraNear,cameraFar);\n#else\nfloat linearDepth=depth;\n#endif\nfloat signedDistance=linearDepth-focusDistance;float magnitude=smoothstep(0.0,focalLength,abs(signedDistance));gl_FragColor.rg=vec2(step(signedDistance,0.0)*magnitude,step(0.0,signedDistance)*magnitude);}",vertexShader:xs,blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.adoptCameraSettings(e)}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}adoptCameraSettings(e=null){null!==e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof t.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}},Es=class extends t.ShaderMaterial{constructor(e=new t.Vector2){super({type:"ConvolutionMaterial",uniforms:{inputBuffer:new t.Uniform(null),texelSize:new t.Uniform(new t.Vector2),halfTexelSize:new t.Uniform(new t.Vector2),kernel:new t.Uniform(0),scale:new t.Uniform(1)},fragmentShader:"#include <common>\n#include <dithering_pars_fragment>\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\nvarying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec4 sum=texture2D(inputBuffer,vUv0);sum+=texture2D(inputBuffer,vUv1);sum+=texture2D(inputBuffer,vUv2);sum+=texture2D(inputBuffer,vUv3);gl_FragColor=sum*0.25;\n#include <dithering_fragment>\n}",vertexShader:"uniform vec2 texelSize;uniform vec2 halfTexelSize;uniform float kernel;uniform float scale;varying vec2 vUv0;varying vec2 vUv1;varying vec2 vUv2;varying vec2 vUv3;void main(){vec2 uv=position.xy*0.5+0.5;vec2 dUv=(texelSize*vec2(kernel)+halfTexelSize)*scale;vUv0=vec2(uv.x-dUv.x,uv.y+dUv.y);vUv1=vec2(uv.x+dUv.x,uv.y+dUv.y);vUv2=vec2(uv.x+dUv.x,uv.y-dUv.y);vUv3=vec2(uv.x-dUv.x,uv.y-dUv.y);gl_Position=vec4(position.xy,1.0,1.0);}",blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.setTexelSize(e.x,e.y),this.kernelSize=Ts.LARGE}getKernel(){return Cs[this.kernelSize]}setTexelSize(e,t){this.uniforms.texelSize.value.set(e,t),this.uniforms.halfTexelSize.value.set(e,t).multiplyScalar(.5)}},Cs=[new Float32Array([0,0]),new Float32Array([0,1,1]),new Float32Array([0,1,1,2]),new Float32Array([0,1,2,2,3]),new Float32Array([0,1,2,3,4,4,5]),new Float32Array([0,1,2,3,4,5,7,8,9,10])],Ts={VERY_SMALL:0,SMALL:1,MEDIUM:2,LARGE:3,VERY_LARGE:4,HUGE:5},Os=class extends t.ShaderMaterial{constructor(){super({type:"CopyMaterial",uniforms:{inputBuffer:new t.Uniform(null),opacity:new t.Uniform(1)},fragmentShader:"#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\nuniform float opacity;varying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);gl_FragColor=opacity*texel;\n#include <encodings_fragment>\n}",vertexShader:xs,blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1}},Ds=class extends t.ShaderMaterial{constructor(e=new t.Vector2,r=Ms.COLOR){super({type:"EdgeDetectionMaterial",defines:{LOCAL_CONTRAST_ADAPTATION_FACTOR:"2.0",EDGE_THRESHOLD:"0.1",DEPTH_THRESHOLD:"0.01",PREDICATION_MODE:"0",PREDICATION_THRESHOLD:"0.01",PREDICATION_SCALE:"2.0",PREDICATION_STRENGTH:"1.0",DEPTH_PACKING:"0"},uniforms:{inputBuffer:new t.Uniform(null),depthBuffer:new t.Uniform(null),predicationBuffer:new t.Uniform(null),texelSize:new t.Uniform(e)},fragmentShader:"varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;\n#if EDGE_DETECTION_MODE != 0\nvarying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;\n#endif\n#if EDGE_DETECTION_MODE == 1\n#include <common>\n#endif\n#if EDGE_DETECTION_MODE == 0 || PREDICATION_MODE == 1\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer;\n#else\nuniform mediump sampler2D depthBuffer;\n#endif\nfloat readDepth(const in vec2 uv){\n#if DEPTH_PACKING == 3201\nreturn unpackRGBAToDepth(texture2D(depthBuffer,uv));\n#else\nreturn texture2D(depthBuffer,uv).r;\n#endif\n}vec3 gatherNeighbors(){float p=readDepth(vUv);float pLeft=readDepth(vUv0);float pTop=readDepth(vUv1);return vec3(p,pLeft,pTop);}\n#elif PREDICATION_MODE == 2\nuniform sampler2D predicationBuffer;vec3 gatherNeighbors(){float p=texture2D(predicationBuffer,vUv).r;float pLeft=texture2D(predicationBuffer,vUv0).r;float pTop=texture2D(predicationBuffer,vUv1).r;return vec3(p,pLeft,pTop);}\n#endif\n#if PREDICATION_MODE != 0\nvec2 calculatePredicatedThreshold(){vec3 neighbours=gatherNeighbors();vec2 delta=abs(neighbours.xx-neighbours.yz);vec2 edges=step(PREDICATION_THRESHOLD,delta);return PREDICATION_SCALE*EDGE_THRESHOLD*(1.0-PREDICATION_STRENGTH*edges);}\n#endif\n#if EDGE_DETECTION_MODE != 0\nuniform sampler2D inputBuffer;\n#endif\nvoid main(){\n#if EDGE_DETECTION_MODE == 0\nconst vec2 threshold=vec2(DEPTH_THRESHOLD);\n#elif PREDICATION_MODE != 0\nvec2 threshold=calculatePredicatedThreshold();\n#else\nconst vec2 threshold=vec2(EDGE_THRESHOLD);\n#endif\n#if EDGE_DETECTION_MODE == 0\nvec3 neighbors=gatherNeighbors();vec2 delta=abs(neighbors.xx-vec2(neighbors.y,neighbors.z));vec2 edges=step(threshold,delta);if(dot(edges,vec2(1.0))==0.0){discard;}gl_FragColor=vec4(edges,0.0,1.0);\n#elif EDGE_DETECTION_MODE == 1\nfloat l=linearToRelativeLuminance(texture2D(inputBuffer,vUv).rgb);float lLeft=linearToRelativeLuminance(texture2D(inputBuffer,vUv0).rgb);float lTop=linearToRelativeLuminance(texture2D(inputBuffer,vUv1).rgb);vec4 delta;delta.xy=abs(l-vec2(lLeft,lTop));vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}float lRight=linearToRelativeLuminance(texture2D(inputBuffer,vUv2).rgb);float lBottom=linearToRelativeLuminance(texture2D(inputBuffer,vUv3).rgb);delta.zw=abs(l-vec2(lRight,lBottom));vec2 maxDelta=max(delta.xy,delta.zw);float lLeftLeft=linearToRelativeLuminance(texture2D(inputBuffer,vUv4).rgb);float lTopTop=linearToRelativeLuminance(texture2D(inputBuffer,vUv5).rgb);delta.zw=abs(vec2(lLeft,lTop)-vec2(lLeftLeft,lTopTop));maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges.xy*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);\n#elif EDGE_DETECTION_MODE == 2\nvec4 delta;vec3 c=texture2D(inputBuffer,vUv).rgb;vec3 cLeft=texture2D(inputBuffer,vUv0).rgb;vec3 t=abs(c-cLeft);delta.x=max(max(t.r,t.g),t.b);vec3 cTop=texture2D(inputBuffer,vUv1).rgb;t=abs(c-cTop);delta.y=max(max(t.r,t.g),t.b);vec2 edges=step(threshold,delta.xy);if(dot(edges,vec2(1.0))==0.0){discard;}vec3 cRight=texture2D(inputBuffer,vUv2).rgb;t=abs(c-cRight);delta.z=max(max(t.r,t.g),t.b);vec3 cBottom=texture2D(inputBuffer,vUv3).rgb;t=abs(c-cBottom);delta.w=max(max(t.r,t.g),t.b);vec2 maxDelta=max(delta.xy,delta.zw);vec3 cLeftLeft=texture2D(inputBuffer,vUv4).rgb;t=abs(c-cLeftLeft);delta.z=max(max(t.r,t.g),t.b);vec3 cTopTop=texture2D(inputBuffer,vUv5).rgb;t=abs(c-cTopTop);delta.w=max(max(t.r,t.g),t.b);maxDelta=max(maxDelta.xy,delta.zw);float finalDelta=max(maxDelta.x,maxDelta.y);edges*=step(finalDelta,LOCAL_CONTRAST_ADAPTATION_FACTOR*delta.xy);gl_FragColor=vec4(edges,0.0,1.0);\n#endif\n}",vertexShader:"uniform vec2 texelSize;varying vec2 vUv;varying vec2 vUv0;varying vec2 vUv1;\n#if EDGE_DETECTION_MODE != 0\nvarying vec2 vUv2;varying vec2 vUv3;varying vec2 vUv4;varying vec2 vUv5;\n#endif\nvoid main(){vUv=position.xy*0.5+0.5;vUv0=vUv+texelSize*vec2(-1.0,0.0);vUv1=vUv+texelSize*vec2(0.0,-1.0);\n#if EDGE_DETECTION_MODE != 0\nvUv2=vUv+texelSize*vec2(1.0,0.0);vUv3=vUv+texelSize*vec2(0.0,1.0);vUv4=vUv+texelSize*vec2(-2.0,0.0);vUv5=vUv+texelSize*vec2(0.0,-2.0);\n#endif\ngl_Position=vec4(position.xy,1.0,1.0);}",blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.setEdgeDetectionMode(r)}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setEdgeDetectionMode(e){this.defines.EDGE_DETECTION_MODE=e.toFixed(0),this.needsUpdate=!0}setLocalContrastAdaptationFactor(e){this.defines.LOCAL_CONTRAST_ADAPTATION_FACTOR=e.toFixed("6"),this.needsUpdate=!0}setEdgeDetectionThreshold(e){this.defines.EDGE_THRESHOLD=e.toFixed("6"),this.defines.DEPTH_THRESHOLD=(.1*e).toFixed("6"),this.needsUpdate=!0}setPredicationMode(e){this.defines.PREDICATION_MODE=e.toFixed(0),this.needsUpdate=!0}setPredicationBuffer(e){this.uniforms.predicationBuffer.value=e}setPredicationThreshold(e){this.defines.PREDICATION_THRESHOLD=e.toFixed("6"),this.needsUpdate=!0}setPredicationScale(e){this.defines.PREDICATION_SCALE=e.toFixed("6"),this.needsUpdate=!0}setPredicationStrength(e){this.defines.PREDICATION_STRENGTH=e.toFixed("6"),this.needsUpdate=!0}},Ms={DEPTH:0,LUMA:1,COLOR:2},_s=1,Ns=class extends t.ShaderMaterial{constructor(e=null,r=null,i=null,n,s=!1){super({type:"EffectMaterial",defines:{DEPTH_PACKING:"0",ENCODE_OUTPUT:"1"},uniforms:{inputBuffer:new t.Uniform(null),depthBuffer:new t.Uniform(null),resolution:new t.Uniform(new t.Vector2),texelSize:new t.Uniform(new t.Vector2),cameraNear:new t.Uniform(.3),cameraFar:new t.Uniform(1e3),aspect:new t.Uniform(1),time:new t.Uniform(0)},blending:t.NoBlending,depthWrite:!1,depthTest:!1,dithering:s}),this.toneMapped=!1,null!==e&&this.setShaderParts(e),null!==r&&this.setDefines(r),null!==i&&this.setUniforms(i),this.adoptCameraSettings(n)}get depthPacking(){return Number(this.defines.DEPTH_PACKING)}set depthPacking(e){this.defines.DEPTH_PACKING=e.toFixed(0),this.needsUpdate=!0}setShaderParts(e){return this.fragmentShader="#include <common>\n#include <packing>\n#include <dithering_pars_fragment>\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\n#ifdef GL_FRAGMENT_PRECISION_HIGH\nuniform highp sampler2D depthBuffer;\n#else\nuniform mediump sampler2D depthBuffer;\n#endif\nuniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;float readDepth(const in vec2 uv){\n#if DEPTH_PACKING == 3201\nreturn unpackRGBAToDepth(texture2D(depthBuffer,uv));\n#else\nreturn texture2D(depthBuffer,uv).r;\n#endif\n}float getViewZ(const in float depth){\n#ifdef PERSPECTIVE_CAMERA\nreturn perspectiveDepthToViewZ(depth,cameraNear,cameraFar);\n#else\nreturn orthographicDepthToViewZ(depth,cameraNear,cameraFar);\n#endif\n}FRAGMENT_HEADvoid main(){FRAGMENT_MAIN_UVvec4 color0=texture2D(inputBuffer,UV);vec4 color1=vec4(0.0);FRAGMENT_MAIN_IMAGEgl_FragColor=color0;\n#ifdef ENCODE_OUTPUT\n#include <encodings_fragment>\n#endif\n#include <dithering_fragment>\n}".replace(Ls.FRAGMENT_HEAD,e.get(Ls.FRAGMENT_HEAD)).replace(Ls.FRAGMENT_MAIN_UV,e.get(Ls.FRAGMENT_MAIN_UV)).replace(Ls.FRAGMENT_MAIN_IMAGE,e.get(Ls.FRAGMENT_MAIN_IMAGE)),this.vertexShader="uniform vec2 resolution;uniform vec2 texelSize;uniform float cameraNear;uniform float cameraFar;uniform float aspect;uniform float time;varying vec2 vUv;VERTEX_HEADvoid main(){vUv=position.xy*0.5+0.5;VERTEX_MAIN_SUPPORTgl_Position=vec4(position.xy,1.0,1.0);}".replace(Ls.VERTEX_HEAD,e.get(Ls.VERTEX_HEAD)).replace(Ls.VERTEX_MAIN_SUPPORT,e.get(Ls.VERTEX_MAIN_SUPPORT)),this.needsUpdate=!0,this}setDefines(e){for(const t of e.entries())this.defines[t[0]]=t[1];return this.needsUpdate=!0,this}setUniforms(e){for(const t of e.entries())this.uniforms[t[0]]=t[1];return this}adoptCameraSettings(e=null){null!==e&&(this.uniforms.cameraNear.value=e.near,this.uniforms.cameraFar.value=e.far,e instanceof t.PerspectiveCamera?this.defines.PERSPECTIVE_CAMERA="1":delete this.defines.PERSPECTIVE_CAMERA,this.needsUpdate=!0)}setSize(e,t){const r=Math.max(e,1),i=Math.max(t,1);this.uniforms.resolution.value.set(r,i),this.uniforms.texelSize.value.set(1/r,1/i),this.uniforms.aspect.value=r/i}},Ls={FRAGMENT_HEAD:"FRAGMENT_HEAD",FRAGMENT_MAIN_UV:"FRAGMENT_MAIN_UV",FRAGMENT_MAIN_IMAGE:"FRAGMENT_MAIN_IMAGE",VERTEX_HEAD:"VERTEX_HEAD",VERTEX_MAIN_SUPPORT:"VERTEX_MAIN_SUPPORT"},Bs=class extends t.ShaderMaterial{constructor(e=!1,r=null){const i=null!==r;super({type:"LuminanceMaterial",uniforms:{inputBuffer:new t.Uniform(null),threshold:new t.Uniform(0),smoothing:new t.Uniform(1),range:new t.Uniform(i?r:new t.Vector2)},fragmentShader:"#include <common>\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\n#ifdef RANGE\nuniform vec2 range;\n#elif defined(THRESHOLD)\nuniform float threshold;uniform float smoothing;\n#endif\nvarying vec2 vUv;void main(){vec4 texel=texture2D(inputBuffer,vUv);float l=linearToRelativeLuminance(texel.rgb);\n#ifdef RANGE\nfloat low=step(range.x,l);float high=step(l,range.y);l*=low*high;\n#elif defined(THRESHOLD)\nl=smoothstep(threshold,threshold+smoothing,l);\n#endif\n#ifdef COLOR\ngl_FragColor=vec4(texel.rgb*l,l);\n#else\ngl_FragColor=vec4(l);\n#endif\n}",vertexShader:xs,blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.colorOutput=e,this.useThreshold=!0,this.useRange=i}get threshold(){return this.uniforms.threshold.value}set threshold(e){this.uniforms.threshold.value=e}get smoothing(){return this.uniforms.smoothing.value}set smoothing(e){this.uniforms.smoothing.value=e}get useThreshold(){return void 0!==this.defines.THRESHOLD}set useThreshold(e){e?this.defines.THRESHOLD="1":delete this.defines.THRESHOLD,this.needsUpdate=!0}get colorOutput(){return void 0!==this.defines.COLOR}set colorOutput(e){e?this.defines.COLOR="1":delete this.defines.COLOR,this.needsUpdate=!0}setColorOutputEnabled(e){this.colorOutput=e}get useRange(){return void 0!==this.defines.RANGE}set useRange(e){e?this.defines.RANGE="1":delete this.defines.RANGE,this.needsUpdate=!0}get luminanceRange(){return this.useRange}set luminanceRange(e){this.useRange=e}setLuminanceRangeEnabled(e){this.useRange=e}},Is=class extends t.ShaderMaterial{constructor(e=null){super({type:"MaskMaterial",uniforms:{maskTexture:new t.Uniform(e),inputBuffer:new t.Uniform(null),strength:new t.Uniform(1)},fragmentShader:"#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\n#ifdef MASK_PRECISION_HIGH\nuniform mediump sampler2D maskTexture;\n#else\nuniform lowp sampler2D maskTexture;\n#endif\n#if MASK_FUNCTION != 0\nuniform float strength;\n#endif\nvarying vec2 vUv;void main(){\n#if COLOR_CHANNEL == 0\nfloat mask=texture2D(maskTexture,vUv).r;\n#elif COLOR_CHANNEL == 1\nfloat mask=texture2D(maskTexture,vUv).g;\n#elif COLOR_CHANNEL == 2\nfloat mask=texture2D(maskTexture,vUv).b;\n#else\nfloat mask=texture2D(maskTexture,vUv).a;\n#endif\n#if MASK_FUNCTION == 0\n#ifdef INVERTED\nmask=step(mask,0.0);\n#else\nmask=1.0-step(mask,0.0);\n#endif\n#else\nmask=clamp(mask*strength,0.0,1.0);\n#ifdef INVERTED\nmask=1.0-mask;\n#endif\n#endif\n#if MASK_FUNCTION == 2\ngl_FragColor=vec4(mask*texture2D(inputBuffer,vUv).rgb,mask);\n#else\ngl_FragColor=mask*texture2D(inputBuffer,vUv);\n#endif\n}",vertexShader:xs,blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1,this.colorChannel=As,this.maskFunction=Ps.DISCARD}set maskTexture(e){this.uniforms.maskTexture.value=e,delete this.defines.MASK_PRECISION_HIGH,e.type!==t.UnsignedByteType&&(this.defines.MASK_PRECISION_HIGH="1"),this.needsUpdate=!0}set colorChannel(e){this.defines.COLOR_CHANNEL=e.toFixed(0),this.needsUpdate=!0}set maskFunction(e){this.defines.MASK_FUNCTION=e.toFixed(0),this.needsUpdate=!0}get inverted(){return void 0!==this.defines.INVERTED}set inverted(e){this.inverted&&!e?delete this.defines.INVERTED:e&&(this.defines.INVERTED="1"),this.needsUpdate=!0}get strength(){return this.uniforms.strength.value}set strength(e){this.uniforms.strength.value=e}},Ps={DISCARD:0,MULTIPLY:1,MULTIPLY_RGB_SET_ALPHA:2},Rs=class extends t.ShaderMaterial{constructor(e=new t.Vector2,r=new t.Vector2){super({type:"SMAAWeightsMaterial",defines:{MAX_SEARCH_STEPS_INT:"16",MAX_SEARCH_STEPS_FLOAT:"16.0",MAX_SEARCH_STEPS_DIAG_INT:"8",MAX_SEARCH_STEPS_DIAG_FLOAT:"8.0",CORNER_ROUNDING:"25",CORNER_ROUNDING_NORM:"0.25",AREATEX_MAX_DISTANCE:"16.0",AREATEX_MAX_DISTANCE_DIAG:"20.0",AREATEX_PIXEL_SIZE:"(1.0 / vec2(160.0, 560.0))",AREATEX_SUBTEX_SIZE:"(1.0 / 7.0)",SEARCHTEX_SIZE:"vec2(66.0, 33.0)",SEARCHTEX_PACKED_SIZE:"vec2(64.0, 16.0)"},uniforms:{inputBuffer:new t.Uniform(null),areaTexture:new t.Uniform(null),searchTexture:new t.Uniform(null),texelSize:new t.Uniform(e),resolution:new t.Uniform(r)},fragmentShader:"#define sampleLevelZeroOffset(t, coord, offset) texture2D(t, coord + offset * texelSize)\n#if __VERSION__ < 300\n#define round(v) floor(v + 0.5)\n#endif\n#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D inputBuffer;\n#else\nuniform lowp sampler2D inputBuffer;\n#endif\nuniform lowp sampler2D areaTexture;uniform lowp sampler2D searchTexture;uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}vec2 decodeDiagBilinearAccess(in vec2 e){e.r=e.r*abs(5.0*e.r-5.0*0.75);return round(e);}vec4 decodeDiagBilinearAccess(in vec4 e){e.rb=e.rb*abs(5.0*e.rb-5.0*0.75);return round(e);}vec2 searchDiag1(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 searchDiag2(const in vec2 texCoord,const in vec2 dir,out vec2 e){vec4 coord=vec4(texCoord,-1.0,1.0);coord.x+=0.25*texelSize.x;vec3 t=vec3(texelSize,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(coord.z<float(MAX_SEARCH_STEPS_DIAG_INT-1)&&coord.w>0.9)){break;}coord.xyz=t*vec3(dir,1.0)+coord.xyz;e=texture2D(inputBuffer,coord.xy).rg;e=decodeDiagBilinearAccess(e);coord.w=dot(e,vec2(0.5));}return coord.zw;}vec2 areaDiag(const in vec2 dist,const in vec2 e,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE_DIAG,AREATEX_MAX_DISTANCE_DIAG)*e+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.x+=0.5;texCoord.y+=AREATEX_SUBTEX_SIZE*offset;return texture2D(areaTexture,texCoord).rg;}vec2 calculateDiagWeights(const in vec2 texCoord,const in vec2 e,const in vec4 subsampleIndices){vec2 weights=vec2(0.0);vec4 d;vec2 end;if(e.r>0.0){d.xz=searchDiag1(texCoord,vec2(-1.0,1.0),end);d.x+=float(end.y>0.9);}else{d.xz=vec2(0.0);}d.yw=searchDiag1(texCoord,vec2(1.0,-1.0),end);if(d.x+d.y>2.0){vec4 coords=vec4(-d.x+0.25,d.x,d.y,-d.y-0.25)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.xy=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).rg;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).rg;c.yxwz=decodeDiagBilinearAccess(c.xyzw);vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.z);}d.xz=searchDiag2(texCoord,vec2(-1.0,-1.0),end);if(sampleLevelZeroOffset(inputBuffer,texCoord,vec2(1,0)).r>0.0){d.yw=searchDiag2(texCoord,vec2(1.0),end);d.y+=float(end.y>0.9);}else{d.yw=vec2(0.0);}if(d.x+d.y>2.0){vec4 coords=vec4(-d.x,-d.x,d.y,d.y)*texelSize.xyxy+texCoord.xyxy;vec4 c;c.x=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(-1,0)).g;c.y=sampleLevelZeroOffset(inputBuffer,coords.xy,vec2(0,-1)).r;c.zw=sampleLevelZeroOffset(inputBuffer,coords.zw,vec2(1,0)).gr;vec2 cc=vec2(2.0)*c.xz+c.yw;movec(bvec2(step(0.9,d.zw)),cc,vec2(0.0));weights+=areaDiag(d.xy,cc,subsampleIndices.w).gr;}return weights;}float searchLength(const in vec2 e,const in float offset){vec2 scale=SEARCHTEX_SIZE*vec2(0.5,-1.0);vec2 bias=SEARCHTEX_SIZE*vec2(offset,1.0);scale+=vec2(-1.0,1.0);bias+=vec2(0.5,-0.5);scale*=1.0/SEARCHTEX_PACKED_SIZE;bias*=1.0/SEARCHTEX_PACKED_SIZE;return texture2D(searchTexture,scale*e+bias).r;}float searchXLeft(in vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x>end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(-2.0,0.0)*texelSize+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.0)+3.25;return texelSize.x*offset+texCoord.x;}float searchXRight(vec2 texCoord,const in float end){vec2 e=vec2(0.0,1.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.x<end&&e.g>0.8281&&e.r==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(2.0,0.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e,0.5)+3.25;return-texelSize.x*offset+texCoord.x;}float searchYUp(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;++i){if(!(texCoord.y>end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=-vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.0)+3.25;return texelSize.y*offset+texCoord.y;}float searchYDown(vec2 texCoord,const in float end){vec2 e=vec2(1.0,0.0);for(int i=0;i<MAX_SEARCH_STEPS_INT;i++){if(!(texCoord.y<end&&e.r>0.8281&&e.g==0.0)){break;}e=texture2D(inputBuffer,texCoord).rg;texCoord=vec2(0.0,2.0)*texelSize.xy+texCoord;}float offset=-(255.0/127.0)*searchLength(e.gr,0.5)+3.25;return-texelSize.y*offset+texCoord.y;}vec2 area(const in vec2 dist,const in float e1,const in float e2,const in float offset){vec2 texCoord=vec2(AREATEX_MAX_DISTANCE)*round(4.0*vec2(e1,e2))+dist;texCoord=AREATEX_PIXEL_SIZE*texCoord+0.5*AREATEX_PIXEL_SIZE;texCoord.y=AREATEX_SUBTEX_SIZE*offset+texCoord.y;return texture2D(areaTexture,texCoord).rg;}void detectHorizontalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){\n#if !defined(DISABLE_CORNER_DETECTION)\nvec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,1)).r;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).r;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(0,-2)).r;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,-2)).r;weights*=clamp(factor,0.0,1.0);\n#endif\n}void detectVerticalCornerPattern(inout vec2 weights,const in vec4 texCoord,const in vec2 d){\n#if !defined(DISABLE_CORNER_DETECTION)\nvec2 leftRight=step(d.xy,d.yx);vec2 rounding=(1.0-CORNER_ROUNDING_NORM)*leftRight;rounding/=leftRight.x+leftRight.y;vec2 factor=vec2(1.0);factor.x-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(1,0)).g;factor.x-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(1,1)).g;factor.y-=rounding.x*sampleLevelZeroOffset(inputBuffer,texCoord.xy,vec2(-2,0)).g;factor.y-=rounding.y*sampleLevelZeroOffset(inputBuffer,texCoord.zw,vec2(-2,1)).g;weights*=clamp(factor,0.0,1.0);\n#endif\n}void main(){vec4 weights=vec4(0.0);vec4 subsampleIndices=vec4(0.0);vec2 e=texture2D(inputBuffer,vUv).rg;if(e.g>0.0){\n#if !defined(DISABLE_DIAG_DETECTION)\nweights.rg=calculateDiagWeights(vUv,e,subsampleIndices);if(weights.r==-weights.g){\n#endif\nvec2 d;vec3 coords;coords.x=searchXLeft(vOffset[0].xy,vOffset[2].x);coords.y=vOffset[1].y;d.x=coords.x;float e1=texture2D(inputBuffer,coords.xy).r;coords.z=searchXRight(vOffset[0].zw,vOffset[2].y);d.y=coords.z;d=round(resolution.xx*d+-vPixCoord.xx);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.zy,vec2(1,0)).r;weights.rg=area(sqrtD,e1,e2,subsampleIndices.y);coords.y=vUv.y;detectHorizontalCornerPattern(weights.rg,coords.xyzy,d);\n#if !defined(DISABLE_DIAG_DETECTION)\n}else{e.r=0.0;}\n#endif\n}if(e.r>0.0){vec2 d;vec3 coords;coords.y=searchYUp(vOffset[1].xy,vOffset[2].z);coords.x=vOffset[0].x;d.x=coords.y;float e1=texture2D(inputBuffer,coords.xy).g;coords.z=searchYDown(vOffset[1].zw,vOffset[2].w);d.y=coords.z;d=round(resolution.yy*d-vPixCoord.yy);vec2 sqrtD=sqrt(abs(d));float e2=sampleLevelZeroOffset(inputBuffer,coords.xz,vec2(0,1)).g;weights.ba=area(sqrtD,e1,e2,subsampleIndices.x);coords.x=vUv.x;detectVerticalCornerPattern(weights.ba,coords.xyxz,d);}gl_FragColor=weights;}",vertexShader:"uniform vec2 texelSize;uniform vec2 resolution;varying vec2 vUv;varying vec4 vOffset[3];varying vec2 vPixCoord;void main(){vUv=position.xy*0.5+0.5;vPixCoord=vUv*resolution;vOffset[0]=vUv.xyxy+texelSize.xyxy*vec4(-0.25,-0.125,1.25,-0.125);vOffset[1]=vUv.xyxy+texelSize.xyxy*vec4(-0.125,-0.25,-0.125,1.25);vOffset[2]=vec4(vOffset[0].xz,vOffset[1].yw)+vec4(-2.0,2.0,-2.0,2.0)*texelSize.xxyy*MAX_SEARCH_STEPS_FLOAT;gl_Position=vec4(position.xy,1.0,1.0);}",blending:t.NoBlending,depthWrite:!1,depthTest:!1}),this.toneMapped=!1}setOrthogonalSearchSteps(e){const t=Math.min(Math.max(e,0),112);this.defines.MAX_SEARCH_STEPS_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setDiagonalSearchSteps(e){const t=Math.min(Math.max(e,0),20);this.defines.MAX_SEARCH_STEPS_DIAG_INT=t.toFixed("0"),this.defines.MAX_SEARCH_STEPS_DIAG_FLOAT=t.toFixed("1"),this.needsUpdate=!0}setCornerRounding(e){const t=Math.min(Math.max(e,0),100);this.defines.CORNER_ROUNDING=t.toFixed("4"),this.defines.CORNER_ROUNDING_NORM=(t/100).toFixed("4"),this.needsUpdate=!0}get diagonalDetection(){return void 0===this.defines.DISABLE_DIAG_DETECTION}set diagonalDetection(e){e?delete this.defines.DISABLE_DIAG_DETECTION:this.defines.DISABLE_DIAG_DETECTION="1",this.needsUpdate=!0}get cornerRounding(){return void 0===this.defines.DISABLE_CORNER_DETECTION}set cornerRounding(e){e?delete this.defines.DISABLE_CORNER_DETECTION:this.defines.DISABLE_CORNER_DETECTION="1",this.needsUpdate=!0}},Fs=new t.Camera,Us=null;var zs=class{constructor(e="Pass",r=new t.Scene,i=Fs){this.name=e,this.scene=r,this.camera=i,this.screen=null,this.rtt=!0,this.needsSwap=!0,this.needsDepthTexture=!1,this.enabled=!0}get renderToScreen(){return!this.rtt}set renderToScreen(e){if(this.rtt===e){const t=this.getFullscreenMaterial();null!==t&&(t.needsUpdate=!0),this.rtt=!e}}getFullscreenMaterial(){return null!==this.screen?this.screen.material:null}setFullscreenMaterial(e){let r=this.screen;null!==r?r.material=e:(r=new t.Mesh(function(){if(null===Us){const e=new Float32Array([-1,-1,0,3,-1,0,-1,3,0]),r=new Float32Array([0,0,2,0,0,2]);void 0!==(Us=new t.BufferGeometry).setAttribute?(Us.setAttribute("position",new t.BufferAttribute(e,3)),Us.setAttribute("uv",new t.BufferAttribute(r,2))):(Us.addAttribute("position",new t.BufferAttribute(e,3)),Us.addAttribute("uv",new t.BufferAttribute(r,2)))}return Us}(),e),r.frustumCulled=!1,null===this.scene&&(this.scene=new t.Scene),this.scene.add(r),this.screen=r)}getDepthTexture(){return null}setDepthTexture(e,t=0){}render(e,t,r,i,n){throw new Error("Render method not implemented!")}setSize(e,t){}initialize(e,t,r){}dispose(){const e=this.getFullscreenMaterial();null!==e&&e.dispose();for(const e of Object.keys(this)){const r=this[e];if(null!==r&&"function"==typeof r.dispose){if(r instanceof t.Scene)continue;this[e].dispose()}}}},ks=-1,Gs=class{constructor(e,r=-1,i=-1,n=1){this.resizable=e,this.base=new t.Vector2(1,1),this.target=new t.Vector2(r,i),this.s=n}get scale(){return this.s}set scale(e){this.s=e,this.target.x=ks,this.target.y=ks,this.resizable.setSize(this.base.x,this.base.y)}get width(){const e=this.base,t=this.target;let r;return r=t.x!==ks?t.x:t.y!==ks?Math.round(t.y*(e.x/e.y)):Math.round(e.x*this.s),r}set width(e){this.target.x=e,this.resizable.setSize(this.base.x,this.base.y)}get height(){const e=this.base,t=this.target;let r;return r=t.y!==ks?t.y:t.x!==ks?Math.round(t.x/(e.x/e.y)):Math.round(e.y*this.s),r}set height(e){this.target.y=e,this.resizable.setSize(this.base.x,this.base.y)}static get AUTO_SIZE(){return ks}},js=class extends zs{constructor({resolutionScale:e=.5,width:r=Gs.AUTO_SIZE,height:i=Gs.AUTO_SIZE,kernelSize:n=Ts.LARGE}={}){super("BlurPass"),this.renderTargetA=new t.WebGLRenderTarget(1,1,{minFilter:t.LinearFilter,magFilter:t.LinearFilter,stencilBuffer:!1,depthBuffer:!1}),this.renderTargetA.texture.name="Blur.Target.A",this.renderTargetB=this.renderTargetA.clone(),this.renderTargetB.texture.name="Blur.Target.B",this.resolution=new Gs(this,r,i,e),this.convolutionMaterial=new Es,this.ditheredConvolutionMaterial=new Es,this.ditheredConvolutionMaterial.dithering=!0,this.dithering=!1,this.kernelSize=n}get width(){return this.resolution.width}set width(e){this.resolution.width=e}get height(){return this.resolution.height}set height(e){this.resolution.height=e}get scale(){return this.convolutionMaterial.uniforms.scale.value}set scale(e){this.convolutionMaterial.uniforms.scale.value=e,this.ditheredConvolutionMaterial.uniforms.scale.value=e}get kernelSize(){return this.convolutionMaterial.kernelSize}set kernelSize(e){this.convolutionMaterial.kernelSize=e,this.ditheredConvolutionMaterial.kernelSize=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}render(e,t,r,i,n){const s=this.scene,o=this.camera,a=this.renderTargetA,l=this.renderTargetB;let c=this.convolutionMaterial,h=c.uniforms;const u=c.getKernel();let d,p,f,m=t;for(this.setFullscreenMaterial(c),p=0,f=u.length-1;p<f;++p)d=0==(1&p)?a:l,h.kernel.value=u[p],h.inputBuffer.value=m.texture,e.setRenderTarget(d),e.render(s,o),m=d;this.dithering&&(c=this.ditheredConvolutionMaterial,h=c.uniforms,this.setFullscreenMaterial(c)),h.kernel.value=u[p],h.inputBuffer.value=m.texture,e.setRenderTarget(this.renderToScreen?null:r),e.render(s,o)}setSize(e,t){const r=this.resolution;r.base.set(e,t);const i=r.width,n=r.height;this.renderTargetA.setSize(i,n),this.renderTargetB.setSize(i,n),this.convolutionMaterial.setTexelSize(1/i,1/n),this.ditheredConvolutionMaterial.setTexelSize(1/i,1/n)}initialize(e,r,i){if(r||i!==t.UnsignedByteType||(this.renderTargetA.texture.format=t.RGBFormat,this.renderTargetB.texture.format=t.RGBFormat),void 0!==i&&(this.renderTargetA.texture.type=i,this.renderTargetB.texture.type=i,i!==t.UnsignedByteType)){const e=this.convolutionMaterial,t=this.ditheredConvolutionMaterial;e.defines.FRAMEBUFFER_PRECISION_HIGH="1",t.defines.FRAMEBUFFER_PRECISION_HIGH="1"}}static get AUTO_SIZE(){return Gs.AUTO_SIZE}},Vs=class extends zs{constructor(){super("ClearMaskPass",null,null),this.needsSwap=!1}render(e,t,r,i,n){const s=e.state.buffers.stencil;s.setLocked(!1),s.setTest(!1)}},Hs=new t.Color,Js=class extends zs{constructor(e=!0,t=!0,r=!1){super("ClearPass",null,null),this.needsSwap=!1,this.color=e,this.depth=t,this.stencil=r,this.overrideClearColor=null,this.overrideClearAlpha=-1}render(e,t,r,i,n){const s=this.overrideClearColor,o=this.overrideClearAlpha,a=e.getClearAlpha(),l=null!==s,c=o>=0;l?(Hs.copy(e.getClearColor(Hs)),e.setClearColor(s,c?o:a)):c&&e.setClearAlpha(o),e.setRenderTarget(this.renderToScreen?null:t),e.clear(this.color,this.depth,this.stencil),l?e.setClearColor(Hs,a):c&&e.setClearAlpha(a)}},Qs=!1,Ys=class{constructor(e=null){this.originalMaterials=new Map,this.material=null,this.materials=null,this.materialsBackSide=null,this.materialsDoubleSide=null,this.materialsFlatShaded=null,this.materialsFlatShadedBackSide=null,this.materialsFlatShadedDoubleSide=null,this.setMaterial(e),this.meshCount=0,this.replaceMaterial=e=>{if(e.isMesh){let r;if(e.material.flatShading)switch(e.material.side){case t.DoubleSide:r=this.materialsFlatShadedDoubleSide;break;case t.BackSide:r=this.materialsFlatShadedBackSide;break;default:r=this.materialsFlatShaded}else switch(e.material.side){case t.DoubleSide:r=this.materialsDoubleSide;break;case t.BackSide:r=this.materialsBackSide;break;default:r=this.materials}this.originalMaterials.set(e,e.material),e.isSkinnedMesh?e.material=r[2]:e.isInstancedMesh?e.material=r[1]:e.material=r[0],++this.meshCount}}}setMaterial(e){if(this.disposeMaterials(),this.material=e,null!==e){const r=this.materials=[e.clone(),e.clone(),e.clone()];for(const i of r)i.uniforms=Object.assign({},e.uniforms),i.side=t.FrontSide;r[2].skinning=!0,this.materialsBackSide=r.map((r=>{const i=r.clone();return i.uniforms=Object.assign({},e.uniforms),i.side=t.BackSide,i})),this.materialsDoubleSide=r.map((r=>{const i=r.clone();return i.uniforms=Object.assign({},e.uniforms),i.side=t.DoubleSide,i})),this.materialsFlatShaded=r.map((t=>{const r=t.clone();return r.uniforms=Object.assign({},e.uniforms),r.flatShading=!0,r})),this.materialsFlatShadedBackSide=r.map((r=>{const i=r.clone();return i.uniforms=Object.assign({},e.uniforms),i.flatShading=!0,i.side=t.BackSide,i})),this.materialsFlatShadedDoubleSide=r.map((r=>{const i=r.clone();return i.uniforms=Object.assign({},e.uniforms),i.flatShading=!0,i.side=t.DoubleSide,i}))}}render(e,t,r){const i=e.shadowMap.enabled;if(e.shadowMap.enabled=!1,Qs){const i=this.originalMaterials;this.meshCount=0,t.traverse(this.replaceMaterial),e.render(t,r);for(const e of i)e[0].material=e[1];this.meshCount!==i.size&&i.clear()}else{const i=t.overrideMaterial;t.overrideMaterial=this.material,e.render(t,r),t.overrideMaterial=i}e.shadowMap.enabled=i}disposeMaterials(){if(null!==this.material){const e=this.materials.concat(this.materialsBackSide).concat(this.materialsDoubleSide).concat(this.materialsFlatShaded).concat(this.materialsFlatShadedBackSide).concat(this.materialsFlatShadedDoubleSide);for(const t of e)t.dispose()}}dispose(){this.originalMaterials.clear(),this.disposeMaterials()}static get workaroundEnabled(){return Qs}static set workaroundEnabled(e){Qs=e}},Ws=class extends zs{constructor(e,t,r=null){super("RenderPass",e,t),this.needsSwap=!1,this.clearPass=new Js,this.overrideMaterialManager=null===r?null:new Ys(r)}get renderToScreen(){return super.renderToScreen}set renderToScreen(e){super.renderToScreen=e,this.clearPass.renderToScreen=e}get overrideMaterial(){const e=this.overrideMaterialManager;return null!==e?e.material:null}set overrideMaterial(e){const t=this.overrideMaterialManager;null!==e?null!==t?t.setMaterial(e):this.overrideMaterialManager=new Ys(e):null!==t&&(t.dispose(),this.overrideMaterialManager=null)}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}getClearPass(){return this.clearPass}render(e,t,r,i,n){const s=this.scene,o=this.camera,a=s.background,l=this.renderToScreen?null:t;this.clear&&(null!==this.clearPass.overrideClearColor&&(s.background=null),this.clearPass.render(e,t)),e.setRenderTarget(l),null!==this.overrideMaterialManager?this.overrideMaterialManager.render(e,s,o):e.render(s,o),s.background!==a&&(s.background=a)}},Xs=class extends zs{constructor(e,r,{resolutionScale:i=1,width:n=Gs.AUTO_SIZE,height:s=Gs.AUTO_SIZE,renderTarget:o}={}){super("DepthPass"),this.needsSwap=!1,this.renderPass=new Ws(e,r,new t.MeshDepthMaterial({depthPacking:t.RGBADepthPacking}));const a=this.renderPass.getClearPass();a.overrideClearColor=new t.Color(16777215),a.overrideClearAlpha=1,this.renderTarget=o,void 0===this.renderTarget&&(this.renderTarget=new t.WebGLRenderTarget(1,1,{minFilter:t.NearestFilter,magFilter:t.NearestFilter,stencilBuffer:!1}),this.renderTarget.texture.name="DepthPass.Target"),this.resolution=new Gs(this,n,s,i)}get texture(){return this.renderTarget.texture}getResolutionScale(){return this.resolutionScale}setResolutionScale(e){this.resolutionScale=e,this.setSize(this.resolution.base.x,this.resolution.base.y)}render(e,t,r,i,n){const s=this.renderToScreen?null:this.renderTarget;this.renderPass.render(e,s)}setSize(e,t){const r=this.resolution;r.base.set(e,t),this.renderTarget.setSize(r.width,r.height)}},Ks=0,qs=13,Zs=14,$s=16,eo=new Map([[Ks,null],[1,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x+y,1.0)*opacity+x*(1.0-opacity);}"],[2,"vec3 blend(const in vec3 x,const in vec3 y,const in float opacity){return y*opacity+x*(1.0-opacity);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){float a=min(y.a,opacity);return vec4(blend(x.rgb,y.rgb,a),max(x.a,a));}"],[3,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y)*0.5*opacity+x*(1.0-opacity);}"],[4,"float blend(const in float x,const in float y){return(y==0.0)? y : max(1.0-(1.0-x)/y,0.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}"],[5,"float blend(const in float x,const in float y){return(y==1.0)? y : min(x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}"],[6,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return min(x,y)*opacity+x*(1.0-opacity);}"],[7,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return abs(x-y)*opacity+x*(1.0-opacity);}"],[8,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(x+y-2.0*x*y)*opacity+x*(1.0-opacity);}"],[9,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x,y)*opacity+x*(1.0-opacity);}"],[10,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return x*y*opacity+x*(1.0-opacity);}"],[11,"float blend(const in float x,const in float y){return(y>0.0)? min(x/y,1.0): 1.0;}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}"],[12,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-abs(1.0-x-y))*opacity+x*(1.0-opacity);}"],[qs,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return y*opacity+x*(1.0-opacity);}"],[Zs,"float blend(const in float x,const in float y){return(x<0.5)?(2.0*x*y):(1.0-2.0*(1.0-x)*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}"],[15,"float blend(const in float x,const in float y){return(y==1.0)? y : min(x*x/(1.0-y),1.0);}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}"],[$s,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return(1.0-(1.0-x)*(1.0-y))*opacity+x*(1.0-opacity);}"],[17,"float blend(const in float x,const in float y){return(y<0.5)?(2.0*x*y+x*x*(1.0-2.0*y)):(sqrt(x)*(2.0*y-1.0)+2.0*x*(1.0-y));}vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){vec4 z=vec4(blend(x.r,y.r),blend(x.g,y.g),blend(x.b,y.b),blend(x.a,y.a));return z*opacity+x*(1.0-opacity);}"],[18,"vec4 blend(const in vec4 x,const in vec4 y,const in float opacity){return max(x+y-1.0,0.0)*opacity+x*(1.0-opacity);}"]]),to=class extends t.EventDispatcher{constructor(e,r=1){super(),this.blendFunction=e,this.opacity=new t.Uniform(r)}getBlendFunction(){return this.blendFunction}setBlendFunction(e){this.blendFunction=e,this.dispatchEvent({type:"change"})}getShaderCode(){return eo.get(this.blendFunction)}},ro=class extends t.EventDispatcher{constructor(e,t,{attributes:r=io.NONE,blendFunction:i=$s,defines:n=new Map,uniforms:s=new Map,extensions:o=null,vertexShader:a=null}={}){super(),this.name=e,this.attributes=r,this.fragmentShader=t,this.vertexShader=a,this.defines=n,this.uniforms=s,this.extensions=o,this.blendMode=new to(i),this.blendMode.addEventListener("change",(e=>this.setChanged()))}setChanged(){this.dispatchEvent({type:"change"})}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e,this.setChanged()}getFragmentShader(){return this.fragmentShader}setFragmentShader(e){this.fragmentShader=e,this.setChanged()}getVertexShader(){return this.vertexShader}setVertexShader(e){this.vertexShader=e,this.setChanged()}setDepthTexture(e,t=0){}update(e,t,r){}setSize(e,t){}initialize(e,t,r){}dispose(){for(const e of Object.keys(this)){const r=this[e];if(null!==r&&"function"==typeof r.dispose){if(r instanceof t.Scene)continue;this[e].dispose()}}}},io={NONE:0,DEPTH:1,CONVOLUTION:2};function no(e,t){const r=[];let i;for(;null!==(i=e.exec(t));)r.push(i[1]);return r}function so(e,t,r){let i,n;for(const s of t){i="$1"+e+s.charAt(0).toUpperCase()+s.slice(1),n=new RegExp("([^\\.])(\\b"+s+"\\b)","g");for(const e of r.entries())null!==e[1]&&r.set(e[0],e[1].replace(n,i))}}function oo(e,t,r,i,n,s,o){const a=/(?:\w+\s+(\w+)\([\w\s,]*\)\s*{[^}]+})/g,l=/(?:varying\s+\w+\s+(\w*))/g,c=t.blendMode,h=new Map([["fragment",t.getFragmentShader()],["vertex",t.getVertexShader()]]),u=void 0!==h.get("fragment")&&/mainImage/.test(h.get("fragment")),d=void 0!==h.get("fragment")&&/mainUv/.test(h.get("fragment"));let p=[],f=[],m=!1,g=!1;if(void 0===h.get("fragment"))console.error("Missing fragment shader",t);else if(d&&0!=(o&io.CONVOLUTION))console.error("Effects that transform UV coordinates are incompatible with convolution effects",t);else if(u||d){if(d&&(r.set(Ls.FRAGMENT_MAIN_UV,r.get(Ls.FRAGMENT_MAIN_UV)+"\t"+e+"MainUv(UV);\n"),m=!0),null!==h.get("vertex")&&/mainSupport/.test(h.get("vertex"))){let t="\t"+e+"MainSupport(";/mainSupport *\([\w\s]*?uv\s*?\)/.test(h.get("vertex"))&&(t+="vUv"),t+=");\n",r.set(Ls.VERTEX_MAIN_SUPPORT,r.get(Ls.VERTEX_MAIN_SUPPORT)+t),p=p.concat(no(l,h.get("vertex"))),f=f.concat(p).concat(no(a,h.get("vertex")))}if(f=f.concat(no(a,h.get("fragment"))).concat(Array.from(t.defines.keys()).map((e=>e.replace(/\([\w\s,]*\)/g,"")))).concat(Array.from(t.uniforms.keys())),t.uniforms.forEach(((t,r)=>s.set(e+r.charAt(0).toUpperCase()+r.slice(1),t))),t.defines.forEach(((t,r)=>n.set(e+r.charAt(0).toUpperCase()+r.slice(1),t))),so(e,f,n),so(e,f,h),i.set(c.blendFunction,c),u){const t=/MainImage *\([\w\s,]*?depth[\w\s,]*?\)/;let i=e+"MainImage(color0, UV, ";0!=(o&io.DEPTH)&&t.test(h.get("fragment"))&&(i+="depth, ",g=!0),i+="color1);\n\t";const n=e+"BlendOpacity";s.set(n,c.opacity),i+="color0 = blend"+c.getBlendFunction()+"(color0, color1, "+n+");\n\n\t",r.set(Ls.FRAGMENT_MAIN_IMAGE,r.get(Ls.FRAGMENT_MAIN_IMAGE)+i),r.set(Ls.FRAGMENT_HEAD,r.get(Ls.FRAGMENT_HEAD)+"uniform float "+n+";\n\n")}r.set(Ls.FRAGMENT_HEAD,r.get(Ls.FRAGMENT_HEAD)+h.get("fragment")+"\n"),null!==h.get("vertex")&&r.set(Ls.VERTEX_HEAD,r.get(Ls.VERTEX_HEAD)+h.get("vertex")+"\n")}else console.error("The fragment shader contains neither a mainImage nor a mainUv function",t);return{varyings:p,transformedUv:m,readDepth:g}}var ao,lo,co,ho,uo=class extends zs{constructor(e,...t){super("EffectPass"),this.setFullscreenMaterial(new Ns(null,null,null,e)),this.effects=t.sort(((e,t)=>t.attributes-e.attributes)),this.skipRendering=!1,this.uniforms=0,this.varyings=0,this.minTime=1,this.maxTime=Number.POSITIVE_INFINITY}get encodeOutput(){return void 0!==this.getFullscreenMaterial().defines.ENCODE_OUTPUT}set encodeOutput(e){if(this.encodeOutput!==e){const t=this.getFullscreenMaterial();t.needsUpdate=!0,e?t.defines.ENCODE_OUTPUT="1":delete t.defines.ENCODE_OUTPUT}}get dithering(){return this.getFullscreenMaterial().dithering}set dithering(e){const t=this.getFullscreenMaterial();t.dithering!==e&&(t.dithering=e,t.needsUpdate=!0)}verifyResources(e){const t=e.capabilities;let r=Math.min(t.maxFragmentUniforms,t.maxVertexUniforms);this.uniforms>r&&console.warn("The current rendering context doesn't support more than "+r+" uniforms, but "+this.uniforms+" were defined"),r=t.maxVaryings,this.varyings>r&&console.warn("The current rendering context doesn't support more than "+r+" varyings, but "+this.varyings+" were defined")}updateMaterial(){const e=/\bblend\b/g,t=new Map([[Ls.FRAGMENT_HEAD,""],[Ls.FRAGMENT_MAIN_UV,""],[Ls.FRAGMENT_MAIN_IMAGE,""],[Ls.VERTEX_HEAD,""],[Ls.VERTEX_MAIN_SUPPORT,""]]),r=new Map,i=new Map,n=new Map,s=new Set;let o,a=0,l=0,c=0,h=!1,u=!1;for(const e of this.effects)if(e.blendMode.getBlendFunction()===Ks)c|=e.getAttributes()&io.DEPTH;else if(0!=(c&io.CONVOLUTION)&&0!=(e.getAttributes()&io.CONVOLUTION))console.error("Convolution effects cannot be merged",e);else if(c|=e.getAttributes(),o=oo("e"+a++,e,t,r,i,n,c),l+=o.varyings.length,h=h||o.transformedUv,u=u||o.readDepth,null!==e.extensions)for(const t of e.extensions)s.add(t);for(const i of r.values())t.set(Ls.FRAGMENT_HEAD,t.get(Ls.FRAGMENT_HEAD)+i.getShaderCode().replace(e,"blend"+i.getBlendFunction())+"\n");0!=(c&io.DEPTH)?(u&&t.set(Ls.FRAGMENT_MAIN_IMAGE,"float depth = readDepth(UV);\n\n\t"+t.get(Ls.FRAGMENT_MAIN_IMAGE)),this.needsDepthTexture=null===this.getDepthTexture()):this.needsDepthTexture=!1,h?(t.set(Ls.FRAGMENT_MAIN_UV,"vec2 transformedUv = vUv;\n"+t.get(Ls.FRAGMENT_MAIN_UV)),i.set("UV","transformedUv")):i.set("UV","vUv"),t.forEach(((e,t,r)=>r.set(t,e.trim().replace(/^#/,"\n#")))),this.uniforms=n.size,this.varyings=l,this.skipRendering=0===a,this.needsSwap=!this.skipRendering;const d=this.getFullscreenMaterial();if(d.setShaderParts(t).setDefines(i).setUniforms(n),d.extensions={},s.size>0)for(const e of s)d.extensions[e]=!0;this.needsUpdate=!1}recompile(e){this.updateMaterial(),void 0!==e&&this.verifyResources(e)}getDepthTexture(){return this.getFullscreenMaterial().uniforms.depthBuffer.value}setDepthTexture(e,r=t.BasicDepthPacking){const i=this.getFullscreenMaterial();i.uniforms.depthBuffer.value=e,i.depthPacking=r,i.needsUpdate=!0;for(const t of this.effects)t.setDepthTexture(e,r)}render(e,t,r,i,n){const s=this.getFullscreenMaterial(),o=s.uniforms.time.value+i;this.needsUpdate&&this.recompile(e);for(const r of this.effects)r.update(e,t,i);this.skipRendering&&!this.renderToScreen||(s.uniforms.inputBuffer.value=t.texture,s.uniforms.time.value=o<=this.maxTime?o:this.minTime,e.setRenderTarget(this.renderToScreen?null:r),e.render(this.scene,this.camera))}setSize(e,t){this.getFullscreenMaterial().setSize(e,t);for(const r of this.effects)r.setSize(e,t)}initialize(e,r,i){for(const t of this.effects)t.initialize(e,r,i),t.addEventListener("change",(e=>this.handleEvent(e)));if(this.updateMaterial(),this.verifyResources(e),void 0!==i&&i!==t.UnsignedByteType){this.getFullscreenMaterial().defines.FRAMEBUFFER_PRECISION_HIGH="1"}}dispose(){super.dispose();for(const e of this.effects)e.dispose()}handleEvent(e){switch(e.type){case"change":this.needsUpdate=!0}}},po=class extends zs{constructor({width:e=Gs.AUTO_SIZE,height:r=Gs.AUTO_SIZE,renderTarget:i,luminanceRange:n,colorOutput:s}={}){super("LuminancePass"),this.setFullscreenMaterial(new Bs(s,n)),this.needsSwap=!1,this.renderTarget=i,void 0===this.renderTarget&&(this.renderTarget=new t.WebGLRenderTarget(1,1,{minFilter:t.LinearFilter,magFilter:t.LinearFilter,format:s?t.RGBAFormat:t.LuminanceFormat,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="LuminancePass.Target",this.renderTarget.texture.generateMipmaps=!1),this.resolution=new Gs(this,e,r)}get texture(){return this.renderTarget.texture}render(e,t,r,i,n){this.getFullscreenMaterial().uniforms.inputBuffer.value=t.texture,e.setRenderTarget(this.renderToScreen?null:this.renderTarget),e.render(this.scene,this.camera)}setSize(e,t){const r=this.resolution;r.base.set(e,t),this.renderTarget.setSize(r.width,r.height)}initialize(e,r,i){if(void 0!==i&&i!==t.UnsignedByteType){this.getFullscreenMaterial().defines.FRAMEBUFFER_PRECISION_HIGH="1"}}},fo=class extends zs{constructor(e,t){super("MaskPass",e,t),this.needsSwap=!1,this.clearPass=new Js(!1,!1,!0),this.inverse=!1}get clear(){return this.clearPass.enabled}set clear(e){this.clearPass.enabled=e}render(e,t,r,i,n){const s=e.getContext(),o=e.state.buffers,a=this.scene,l=this.camera,c=this.clearPass,h=this.inverse?0:1,u=1-h;o.color.setMask(!1),o.depth.setMask(!1),o.color.setLocked(!0),o.depth.setLocked(!0),o.stencil.setTest(!0),o.stencil.setOp(s.REPLACE,s.REPLACE,s.REPLACE),o.stencil.setFunc(s.ALWAYS,h,4294967295),o.stencil.setClear(u),o.stencil.setLocked(!0),this.clear&&(this.renderToScreen?c.render(e,null):(c.render(e,t),c.render(e,r))),this.renderToScreen?(e.setRenderTarget(null),e.render(a,l)):(e.setRenderTarget(t),e.render(a,l),e.setRenderTarget(r),e.render(a,l)),o.color.setLocked(!1),o.depth.setLocked(!1),o.stencil.setLocked(!1),o.stencil.setFunc(s.EQUAL,1,4294967295),o.stencil.setOp(s.KEEP,s.KEEP,s.KEEP),o.stencil.setLocked(!0)}},mo=class extends zs{constructor(e,t="inputBuffer"){super("ShaderPass"),this.setFullscreenMaterial(e),this.uniform=null,this.setInput(t)}setInput(e){const t=this.getFullscreenMaterial();if(this.uniform=null,null!==t){const r=t.uniforms;void 0!==r&&void 0!==r[e]&&(this.uniform=r[e])}}render(e,t,r,i,n){null!==this.uniform&&null!==t&&(this.uniform.value=t.texture),e.setRenderTarget(this.renderToScreen?null:r),e.render(this.scene,this.camera)}initialize(e,r,i){if(void 0!==i&&i!==t.UnsignedByteType){this.getFullscreenMaterial().defines.FRAMEBUFFER_PRECISION_HIGH="1"}}},go=class extends ro{constructor({blendFunction:e=$s,luminanceThreshold:r=.9,luminanceSmoothing:i=.025,resolutionScale:n=.5,intensity:s=1,width:o=Gs.AUTO_SIZE,height:a=Gs.AUTO_SIZE,kernelSize:l=Ts.LARGE}={}){super("BloomEffect","#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D map;\n#else\nuniform lowp sampler2D map;\n#endif\nuniform float intensity;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){outputColor=clamp(texture2D(map,uv)*intensity,0.0,1.0);}",{blendFunction:e,uniforms:new Map([["map",new t.Uniform(null)],["intensity",new t.Uniform(s)]])}),this.renderTarget=new t.WebGLRenderTarget(1,1,{minFilter:t.LinearFilter,magFilter:t.LinearFilter,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="Bloom.Target",this.renderTarget.texture.generateMipmaps=!1,this.uniforms.get("map").value=this.renderTarget.texture,this.blurPass=new js({resolutionScale:n,width:o,height:a,kernelSize:l}),this.blurPass.resolution.resizable=this,this.luminancePass=new po({renderTarget:this.renderTarget,colorOutput:!0}),this.luminancePass.resolution=this.resolution,this.luminanceMaterial.threshold=r,this.luminanceMaterial.smoothing=i}get texture(){return this.renderTarget.texture}get luminanceMaterial(){return this.luminancePass.getFullscreenMaterial()}get resolution(){return this.blurPass.resolution}get width(){return this.resolution.width}set width(e){this.resolution.width=e}get height(){return this.resolution.height}set height(e){this.resolution.height=e}get dithering(){return this.blurPass.dithering}set dithering(e){this.blurPass.dithering=e}get kernelSize(){return this.blurPass.kernelSize}set kernelSize(e){this.blurPass.kernelSize=e}get distinction(){return console.warn(this.name,"The distinction field has been removed, use luminanceMaterial.threshold and luminanceMaterial.smoothing instead."),1}set distinction(e){console.warn(this.name,"The distinction field has been removed, use luminanceMaterial.threshold and luminanceMaterial.smoothing instead.")}get intensity(){return this.uniforms.get("intensity").value}set intensity(e){this.uniforms.get("intensity").value=e}getResolutionScale(){return this.resolution.scale}setResolutionScale(e){this.resolution.scale=e}update(e,t,r){const i=this.renderTarget;this.luminancePass.enabled?(this.luminancePass.render(e,t,i),this.blurPass.render(e,i,i)):this.blurPass.render(e,t,i)}setSize(e,t){this.blurPass.setSize(e,t),this.renderTarget.setSize(this.resolution.width,this.resolution.height)}initialize(e,r,i){this.blurPass.initialize(e,r,i),r||i!==t.UnsignedByteType||(this.renderTarget.texture.format=t.RGBFormat),void 0!==i&&(this.renderTarget.texture.type=i)}},vo=class extends ro{constructor({blendFunction:e=qs,brightness:r=0,contrast:i=0}={}){super("BrightnessContrastEffect","uniform float brightness;uniform float contrast;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=inputColor.rgb+vec3(brightness-0.5);if(contrast>0.0){color/=vec3(1.0-contrast);}else{color*=vec3(1.0+contrast);}outputColor=vec4(min(color+vec3(0.5),1.0),inputColor.a);}",{blendFunction:e,uniforms:new Map([["brightness",new t.Uniform(r)],["contrast",new t.Uniform(i)]])})}},yo=class extends ro{constructor(e=qs){super("ColorAverageEffect","void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){float sum=inputColor.r+inputColor.g+inputColor.b;outputColor=vec4(vec3(sum/3.0),inputColor.a);}",{blendFunction:e})}},Ao=class extends ro{constructor({blendFunction:e=qs,offset:r=new t.Vector2(.001,5e-4)}={}){super("ChromaticAberrationEffect","varying vec2 vUvR;varying vec2 vUvB;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 color=inputColor;\n#ifdef ALPHA\nvec2 ra=texture2D(inputBuffer,vUvR).ra;vec2 ba=texture2D(inputBuffer,vUvB).ba;color.r=ra.x;color.b=ba.x;color.a=max(max(ra.y,ba.y),inputColor.a);\n#else\ncolor.r=texture2D(inputBuffer,vUvR).r;color.b=texture2D(inputBuffer,vUvB).b;\n#endif\noutputColor=color;}",{vertexShader:"uniform vec2 offset;varying vec2 vUvR;varying vec2 vUvB;void mainSupport(const in vec2 uv){vUvR=uv+offset;vUvB=uv-offset;}",blendFunction:e,attributes:io.CONVOLUTION,uniforms:new Map([["offset",new t.Uniform(r)]])})}get offset(){return this.uniforms.get("offset").value}set offset(e){this.uniforms.get("offset").value=e}initialize(e,t,r){t?this.defines.set("ALPHA","1"):this.defines.delete("ALPHA")}},wo=class extends ro{constructor(e,{blendFunction:r=qs,focusDistance:i=0,focalLength:n=.1,bokehScale:s=1,width:o=Gs.AUTO_SIZE,height:a=Gs.AUTO_SIZE}={}){super("DepthOfFieldEffect","#ifdef FRAMEBUFFER_PRECISION_HIGH\nuniform mediump sampler2D nearColorBuffer;uniform mediump sampler2D farColorBuffer;\n#else\nuniform lowp sampler2D nearColorBuffer;uniform lowp sampler2D farColorBuffer;\n#endif\nuniform lowp sampler2D nearCoCBuffer;uniform float scale;void mainImage(const in vec4 inputColor,const in vec2 uv,const in float depth,out vec4 outputColor){vec4 colorNear=texture2D(nearColorBuffer,uv);vec4 colorFar=texture2D(farColorBuffer,uv);float CoCNear=texture2D(nearCoCBuffer,uv).r;CoCNear=min(CoCNear*scale,1.0);vec4 result=inputColor*(1.0-colorFar.a)+colorFar;result=mix(result,colorNear,CoCNear);outputColor=result;}",{blendFunction:r,attributes:io.DEPTH,uniforms:new Map([["nearColorBuffer",new t.Uniform(null)],["farColorBuffer",new t.Uniform(null)],["nearCoCBuffer",new t.Uniform(null)],["scale",new t.Uniform(1)]])}),this.camera=e,this.renderTarget=new t.WebGLRenderTarget(1,1,{minFilter:t.LinearFilter,magFilter:t.LinearFilter,stencilBuffer:!1,depthBuffer:!1}),this.renderTarget.texture.name="DoF.Intermediate",this.renderTarget.texture.generateMipmaps=!1,this.renderTargetMasked=this.renderTarget.clone(),this.renderTargetMasked.texture.name="DoF.Masked.Far",this.renderTargetNear=this.renderTarget.clone(),this.renderTargetNear.texture.name="DoF.Bokeh.Near",this.uniforms.get("nearColorBuffer").value=this.renderTargetNear.texture,this.renderTargetFar=this.renderTarget.clone(),this.renderTargetFar.texture.name="DoF.Bokeh.Far",this.uniforms.get("farColorBuffer").value=this.renderTargetFar.texture,this.renderTargetCoC=this.renderTarget.clone(),this.renderTargetCoC.texture.format=t.RGBFormat,this.renderTargetCoC.texture.name="DoF.CoC",this.renderTargetCoCBlurred=this.renderTargetCoC.clone(),this.renderTargetCoCBlurred.texture.name="DoF.CoC.Blurred",this.uniforms.get("nearCoCBuffer").value=this.renderTargetCoCBlurred.texture,this.cocPass=new mo(new Ss(e));const l=this.circleOfConfusionMaterial;l.uniforms.focusDistance.value=i,l.uniforms.focalLength.value=n,this.blurPass=new js({width:o,height:a,kernelSize:Ts.MEDIUM}),this.blurPass.resolution.resizable=this,this.maskPass=new mo(new Is(this.renderTargetCoC.texture));const c=this.maskPass.getFullscreenMaterial();c.maskFunction=Ps.MULTIPLY,c.colorChannel=ws,this.bokehNearBasePass=new mo(new bs(!1,!0)),this.bokehNearFillPass=new mo(new bs(!0,!0)),this.bokehFarBasePass=new mo(new bs(!1,!1)),this.bokehFarFillPass=new mo(new bs(!0,!1)),this.bokehScale=s,this.target=null}get circleOfConfusionMaterial(){return this.cocPass.getFullscreenMaterial()}get resolution(){return this.blurPass.resolution}get bokehScale(){return this.uniforms.get("scale").value}set bokehScale(e){[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].map((e=>e.getFullscreenMaterial().uniforms.scale)).forEach((t=>{t.value=e})),this.maskPass.getFullscreenMaterial().uniforms.strength.value=e,this.uniforms.get("scale").value=e}calculateFocusDistance(e){const t=this.camera,r=t.far-t.near,i=t.position.distanceTo(e);return Math.min(Math.max(i/r,0),1)}setDepthTexture(e,r=t.BasicDepthPacking){const i=this.circleOfConfusionMaterial;i.uniforms.depthBuffer.value=e,i.depthPacking=r}update(e,t,r){const i=this.renderTarget,n=this.renderTargetCoC,s=this.renderTargetCoCBlurred,o=this.renderTargetMasked,a=this.bokehFarBasePass,l=this.bokehFarFillPass,c=a.getFullscreenMaterial().uniforms,h=l.getFullscreenMaterial().uniforms,u=this.bokehNearBasePass,d=this.bokehNearFillPass,p=u.getFullscreenMaterial().uniforms,f=d.getFullscreenMaterial().uniforms;if(null!==this.target){const e=this.calculateFocusDistance(this.target);this.circleOfConfusionMaterial.uniforms.focusDistance.value=e}this.cocPass.render(e,null,n),this.blurPass.render(e,n,s),this.maskPass.render(e,t,o),c.cocBuffer.value=h.cocBuffer.value=n.texture,a.render(e,o,i),l.render(e,i,this.renderTargetFar),p.cocBuffer.value=f.cocBuffer.value=s.texture,u.render(e,t,i),d.render(e,i,this.renderTargetNear)}setSize(e,t){const r=this.resolution;let i=[this.cocPass,this.blurPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass];i.push(this.renderTargetCoC,this.renderTargetMasked),i.forEach((r=>r.setSize(e,t)));const n=r.width,s=r.height;i=[this.renderTarget,this.renderTargetNear,this.renderTargetFar,this.renderTargetCoCBlurred],i.forEach((e=>e.setSize(n,s)));[this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach((e=>e.getFullscreenMaterial().setTexelSize(1/n,1/s)))}initialize(e,r,i){[this.cocPass,this.maskPass,this.bokehNearBasePass,this.bokehNearFillPass,this.bokehFarBasePass,this.bokehFarFillPass].forEach((t=>t.initialize(e,r,i))),this.blurPass.initialize(e,r,t.UnsignedByteType),r||i!==t.UnsignedByteType||(this.renderTargetNear.texture.type=t.RGBFormat),void 0!==i&&(this.renderTarget.texture.type=i,this.renderTargetNear.texture.type=i,this.renderTargetFar.texture.type=i,this.renderTargetMasked.texture.type=i)}},xo=(new t.Vector3,new t.Matrix4,class extends ro{constructor({blendFunction:e=qs,hue:r=0,saturation:i=0}={}){super("HueSaturationEffect","uniform vec3 hue;uniform float saturation;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 color=vec3(dot(inputColor.rgb,hue.xyz),dot(inputColor.rgb,hue.zxy),dot(inputColor.rgb,hue.yzx));float average=(color.r+color.g+color.b)/3.0;vec3 diff=average-color;if(saturation>0.0){color+=diff*(1.0-1.0/(1.001-saturation));}else{color+=diff*-saturation;}outputColor=vec4(min(color,1.0),inputColor.a);}",{blendFunction:e,uniforms:new Map([["hue",new t.Uniform(new t.Vector3)],["saturation",new t.Uniform(i)]])}),this.setHue(r)}setHue(e){const t=Math.sin(e),r=Math.cos(e);this.uniforms.get("hue").value.set(2*r,-Math.sqrt(3)*t-r,Math.sqrt(3)*t-r).addScalar(1).divideScalar(3)}}),bo=(new t.Color,class extends ro{constructor({blendFunction:e=$s,premultiply:t=!1}={}){super("NoiseEffect","void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec3 noise=vec3(rand(uv*time));\n#ifdef PREMULTIPLY\noutputColor=vec4(min(inputColor.rgb*noise,vec3(1.0)),inputColor.a);\n#else\noutputColor=vec4(noise,inputColor.a);\n#endif\n}",{blendFunction:e}),this.premultiply=t}get premultiply(){return this.defines.has("PREMULTIPLY")}set premultiply(e){this.premultiply!==e&&(e?this.defines.set("PREMULTIPLY","1"):this.defines.delete("PREMULTIPLY"),this.setChanged())}}),So=class extends ro{constructor(e=30){super("PixelationEffect","uniform bool active;uniform vec2 d;void mainUv(inout vec2 uv){if(active){uv=vec2(d.x*(floor(uv.x/d.x)+0.5),d.y*(floor(uv.y/d.y)+0.5));}}",{uniforms:new Map([["active",new t.Uniform(!1)],["d",new t.Uniform(new t.Vector2)]])}),this.resolution=new t.Vector2,this.granularity=e}getGranularity(){return this.granularity}setGranularity(e){(e=Math.floor(e))%2>0&&(e+=1);const t=this.uniforms;t.get("active").value=e>0,t.get("d").value.set(e,e).divide(this.resolution),this.granularity=e}setSize(e,t){this.resolution.set(e,t),this.setGranularity(this.granularity)}},Eo=(new t.Vector3,new t.Vector3,"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAAQCAYAAACm53kpAAAAeElEQVRYR+2XSwqAMAxEJ168ePEqwRSKhIIiuHjJqiU0gWE+1CQdApcVAMUAuARaMGCX1MIL/Ow13++9lW2s3mW9MWvsnWc/2fvGygwPAN4E8QzAA4CXAB6AHjG4JTHYI1ey3pcx6FHnEfhLDOIBKAmUBK6/ANUDTlROXAHd9EC1AAAAAElFTkSuQmCC"),Co="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAAIwCAYAAAABNmBHAAAgAElEQVR4Xuy9CbhlV1ktOvbpq09DkiIkUBI6kxASIH0DlAQiIK1wRfSJTx+i4JX7vKIigs8HXpXvqVcvrcC9agQ7IDTSSWgqCQQliDRBJKkkhDSkqVPNqVOnP+8b//rH3P+eZ+199tlznVTlvVrft7+1T7OaueZY42/m37QALKNk2wHg1pITlB17mC+Pp11W3X/LHyT32vhg48/5SOv+PnwpsHA70JoGlueB1iKApeqzvOzn44GatTB76Xzhd7suBR7+WWADgDEAwwCG/L54b/poDLrHuvvm70Z2Avhsc+PVcxscBU8F8C8ADg5+ipIjD/PlGwfgju8B924E5seARUfLsiNmqQW0IjL8+7L2NYD/7COBzfcCm+aB8SVgdAkYIRCXKyDax4EdAanL5PuNPllNvXDlAHwFgP8AcC2AhRIoDXbsYb48dl5WkVFTE3LGDcC9m4CZCWBuFFgeAZaGAYJQQCRqDHT+McJrVb8zwATUXH02MHYfMHEIGFsAxgjApQqACYQORjtd/B7Axt/z79sC0+cMPgjjlwPwVwHcA+DfAHzTxcVgWBroqMN8+cYBeM71wH0TwKExYHYUWCIAHYRLTlkCYgcIBcAgU/n3qy8GRu4HRgnAOWBkERhddPAJhGJDBxkvw7cqimr+zFM/ZLnZF64cgL8BYD+AW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fLOB7MhrfnJoPwPER59Px+o3e76mL5Kwp2G57xPl0kxc3er+nLvyKtLmhfUC78RHn081ONnq/pzcAR5xPR9mRRu/31IVgvgUccT4dNaobvd/TGYAjzqejumqj93s6A3DE+XRUg2VSCjdaGr3fUw+I+VPwiPPpqJjO8J1Nw43e7ymHwHoAKMFd7QErAeEE5NNJMb3R+z3lsGcNzgfgiPPpomJ6o/d76oGwPgCOKJ8uKqY3er+nKwBHmE+noqRG7/fUA199U/AI8+kEwEbv93QHoEhZTnA+nYqSGr3fBoAtaiqBUImdm5hPJwA2er+nKwBHnE+X1gUzSbnR+z11wPj/AeCpPDD3t7rvAAAAAElFTkSuQmCC",To=class extends ro{constructor(e,r,i=Oo.HIGH,n=Ms.COLOR){super("SMAAEffect","uniform sampler2D weightMap;varying vec2 vOffset0;varying vec2 vOffset1;void movec(const in bvec2 c,inout vec2 variable,const in vec2 value){if(c.x){variable.x=value.x;}if(c.y){variable.y=value.y;}}void movec(const in bvec4 c,inout vec4 variable,const in vec4 value){movec(c.xy,variable.xy,value.xy);movec(c.zw,variable.zw,value.zw);}void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){vec4 a;a.x=texture2D(weightMap,vOffset0).a;a.y=texture2D(weightMap,vOffset1).g;a.wz=texture2D(weightMap,uv).rb;vec4 color=inputColor;if(dot(a,vec4(1.0))>=1e-5){bool h=max(a.x,a.z)>max(a.y,a.w);vec4 blendingOffset=vec4(0.0,a.y,0.0,a.w);vec2 blendingWeight=a.yw;movec(bvec4(h),blendingOffset,vec4(a.x,0.0,a.z,0.0));movec(bvec2(h),blendingWeight,a.xz);blendingWeight/=dot(blendingWeight,vec2(1.0));vec4 blendingCoord=blendingOffset*vec4(texelSize,-texelSize)+uv.xyxy;color=blendingWeight.x*texture2D(inputBuffer,blendingCoord.xy);color+=blendingWeight.y*texture2D(inputBuffer,blendingCoord.zw);}outputColor=color;}",{vertexShader:"varying vec2 vOffset0;varying vec2 vOffset1;void mainSupport(const in vec2 uv){vOffset0=uv+texelSize*vec2(1.0,0.0);vOffset1=uv+texelSize*vec2(0.0,1.0);}",blendFunction:qs,attributes:io.CONVOLUTION|io.DEPTH,uniforms:new Map([["weightMap",new t.Uniform(null)]])}),this.renderTargetEdges=new t.WebGLRenderTarget(1,1,{minFilter:t.LinearFilter,stencilBuffer:!1,depthBuffer:!1,format:t.RGBFormat}),this.renderTargetEdges.texture.name="SMAA.Edges",this.renderTargetWeights=this.renderTargetEdges.clone(),this.renderTargetWeights.texture.name="SMAA.Weights",this.renderTargetWeights.texture.format=t.RGBAFormat,this.uniforms.get("weightMap").value=this.renderTargetWeights.texture,this.clearPass=new Js(!0,!1,!1),this.clearPass.overrideClearColor=new t.Color(0),this.clearPass.overrideClearAlpha=1,this.edgeDetectionPass=new mo(new Ds(new t.Vector2,n)),this.weightsPass=new mo(new Rs);const s=new t.Texture(e);s.name="SMAA.Search",s.magFilter=t.NearestFilter,s.minFilter=t.NearestFilter,s.format=t.RGBAFormat,s.generateMipmaps=!1,s.needsUpdate=!0,s.flipY=!0;const o=new t.Texture(r);o.name="SMAA.Area",o.magFilter=t.LinearFilter,o.minFilter=t.LinearFilter,o.format=t.RGBAFormat,o.generateMipmaps=!1,o.needsUpdate=!0,o.flipY=!1;const a=this.weightsPass.getFullscreenMaterial();a.uniforms.searchTexture.value=s,a.uniforms.areaTexture.value=o,this.applyPreset(i)}get edgeDetectionMaterial(){return this.edgeDetectionPass.getFullscreenMaterial()}get colorEdgesMaterial(){return this.edgeDetectionMaterial}get weightsMaterial(){return this.weightsPass.getFullscreenMaterial()}setEdgeDetectionThreshold(e){this.edgeDetectionPass.getFullscreenMaterial().setEdgeDetectionThreshold(e)}setOrthogonalSearchSteps(e){this.weightsPass.getFullscreenMaterial().setOrthogonalSearchSteps(e)}applyPreset(e){const t=this.edgeDetectionMaterial,r=this.weightsMaterial;switch(e){case Oo.LOW:t.setEdgeDetectionThreshold(.15),r.setOrthogonalSearchSteps(4),r.diagonalDetection=!1,r.cornerRounding=!1;break;case Oo.MEDIUM:t.setEdgeDetectionThreshold(.1),r.setOrthogonalSearchSteps(8),r.diagonalDetection=!1,r.cornerRounding=!1;break;case Oo.HIGH:t.setEdgeDetectionThreshold(.1),r.setOrthogonalSearchSteps(16),r.setDiagonalSearchSteps(8),r.setCornerRounding(25),r.diagonalDetection=!0,r.cornerRounding=!0;break;case Oo.ULTRA:t.setEdgeDetectionThreshold(.05),r.setOrthogonalSearchSteps(32),r.setDiagonalSearchSteps(16),r.setCornerRounding(25),r.diagonalDetection=!0,r.cornerRounding=!0}}setDepthTexture(e,r=t.BasicDepthPacking){const i=this.edgeDetectionMaterial;i.uniforms.depthBuffer.value=e,i.depthPacking=r}update(e,t,r){this.clearPass.render(e,this.renderTargetEdges),this.edgeDetectionPass.render(e,t,this.renderTargetEdges),this.weightsPass.render(e,this.renderTargetEdges,this.renderTargetWeights)}setSize(e,t){const r=this.edgeDetectionPass.getFullscreenMaterial(),i=this.weightsPass.getFullscreenMaterial();this.renderTargetEdges.setSize(e,t),this.renderTargetWeights.setSize(e,t),i.uniforms.resolution.value.set(e,t),i.uniforms.texelSize.value.set(1/e,1/t),r.uniforms.texelSize.value.copy(i.uniforms.texelSize.value)}dispose(){const e=this.weightsPass.getFullscreenMaterial().uniforms;e.searchTexture.value.dispose(),e.areaTexture.value.dispose(),super.dispose()}static get searchImageDataURL(){return Eo}static get areaImageDataURL(){return Co}},Oo={LOW:0,MEDIUM:1,HIGH:2,ULTRA:3},Do=class extends ro{constructor(e={}){const r=Object.assign({blendFunction:qs,eskil:!1,offset:.5,darkness:.5},e);super("VignetteEffect","uniform float offset;uniform float darkness;void mainImage(const in vec4 inputColor,const in vec2 uv,out vec4 outputColor){const vec2 center=vec2(0.5);vec3 color=inputColor.rgb;\n#ifdef ESKIL\nvec2 coord=(uv-center)*vec2(offset);color=mix(color,vec3(1.0-darkness),dot(coord,coord));\n#else\nfloat d=distance(uv,center);color*=smoothstep(0.8,offset*0.799,d*(darkness+offset));\n#endif\noutputColor=vec4(color,inputColor.a);}",{blendFunction:r.blendFunction,uniforms:new Map([["offset",new t.Uniform(r.offset)],["darkness",new t.Uniform(r.darkness)]])}),this.eskil=r.eskil}get eskil(){return this.defines.has("ESKIL")}set eskil(e){this.eskil!==e&&(e?this.defines.set("ESKIL","1"):this.defines.delete("ESKIL"),this.setChanged())}},Mo=class extends t.Loader{load(e=(()=>{}),r=null){4===arguments.length?(e=arguments[1],r=arguments[3]):3!==arguments.length&&"function"==typeof arguments[0]||(e=arguments[1],r=null);const i=this.manager,n=new t.LoadingManager;return new Promise(((t,s)=>{const o=new Image,a=new Image;n.onError=e=>{i.itemError(e),null!==r?(r(`Failed to load ${e}`),t()):s(`Failed to load ${e}`)},n.onLoad=()=>{const r=[o,a];e(r),t(r)},o.addEventListener("error",(e=>{n.itemError("smaa-search")})),a.addEventListener("error",(e=>{n.itemError("smaa-area")})),o.addEventListener("load",(()=>{i.itemEnd("smaa-search"),n.itemEnd("smaa-search")})),a.addEventListener("load",(()=>{i.itemEnd("smaa-area"),n.itemEnd("smaa-area")})),i.itemStart("smaa-search"),i.itemStart("smaa-area"),n.itemStart("smaa-search"),n.itemStart("smaa-area"),o.src=Eo,a.src=Co}))}};class _o{constructor(e,t){this.enabled=!1,this.effect=new e(t),Object.defineProperty(this,"opacity",{enumerable:!0,set(e){this.effect.blendMode.opacity.value=e},get(){return this.effect.blendMode.opacity.value}}),Object.defineProperty(this,"blendFunction",{enumerable:!0,set(e){this.effect.blendMode.setBlendFunction(Number(e))},get(){return this.effect.blendMode.blendFunction}}),this.blendFunction=qs}toJSON(){const e=Object.assign({},this),t=Object.getPrototypeOf(this),r=Object.getOwnPropertyNames(t);for(const i of r){const r=Object.getOwnPropertyDescriptor(t,i);r&&"function"==typeof r.get&&(e[i]=this[i])}return["constructor","effect","subscriptions"].forEach((t=>delete e[t])),e}}class No extends _o{constructor(){super(go),this.blendFunction=$s}set intensity(e){this.effect.intensity=e}get intensity(){return this.effect.intensity}set luminanceThreshold(e){this.effect.luminanceMaterial.threshold=e}get luminanceThreshold(){return this.effect.luminanceMaterial.threshold}set luminanceSmoothing(e){this.effect.luminanceMaterial.smoothing=e}get luminanceSmoothing(){return this.effect.luminanceMaterial.smoothing}set blurScale(e){this.effect.blurPass.scale=e}get blurScale(){return this.effect.blurPass.scale}set kernelSize(e){this.effect.blurPass.kernelSize=e}get kernelSize(){return this.effect.blurPass.kernelSize}}class Lo extends _o{constructor(){super(vo)}set contrast(e){this.effect.uniforms.get("contrast").value=e}get contrast(){return this.effect.uniforms.get("contrast").value}set brightness(e){this.effect.uniforms.get("brightness").value=e}get brightness(){return this.effect.uniforms.get("brightness").value}}class Bo extends _o{constructor(){super(Ao),this.effect.offset=new t.Vector2(.01,.01)}set offset(e){this.effect.offset.set(e[0]/1e3,e[1]/1e3)}get offset(){return[1e3*this.effect.offset.x,1e3*this.effect.offset.y]}}class Io extends _o{constructor(){super(yo)}}class Po extends _o{constructor(){super(xo),this._hue=0}set hue(e){this._hue=e,this.effect.setHue(e)}get hue(){return this._hue}set saturation(e){this.effect.uniforms.get("saturation").value=e}get saturation(){return this.effect.uniforms.get("saturation").value}}class Ro extends _o{constructor(){super(bo),this.blendFunction=Zs}}class Fo extends _o{constructor(){super(Do)}get eskil(){return this.effect.eskil}set eskil(e){this.effect.eskil=e}get darkness(){return this.effect.uniforms.get("darkness").value}set darkness(e){this.effect.uniforms.get("darkness").value=e}get offset(){return this.effect.uniforms.get("offset").value}set offset(e){this.effect.uniforms.get("offset").value=e}}class Uo extends _o{constructor(e){super(wo,e)}set focalLength(e){this.effect.circleOfConfusionMaterial.uniforms.focalLength.value=e}get focalLength(){return this.effect.circleOfConfusionMaterial.uniforms.focalLength.value}set focusDistance(e){this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value=e}get focusDistance(){return this.effect.circleOfConfusionMaterial.uniforms.focusDistance.value}get bokehScale(){return this.effect.bokehScale}set bokehScale(e){this.effect.bokehScale=e}}class zo extends _o{constructor(){super(So)}get granularity(){return this.effect.getGranularity()}set granularity(e){this.effect.setGranularity(e)}}function ko(e,t){return t&&t.enabled&&e.push(t.effect),e}class Go{constructor(){this.effects=new Map,this.loadingManager=new t.LoadingManager,this.smaaImageLoader=new Mo(this.loadingManager),this.renderPass=new Ws,this.depthPass=new Xs,this.clock=new t.Clock,this.enabled=!1,this.debug=!1,this.effects.set("bloom",new No),this.effects.set("chromaticAberration",new Bo),this.effects.set("vignette",new Fo),this.effects.set("noise",new Ro),this.effects.set("colorAverage",new Io),this.effects.set("hueSaturation",new Po),this.effects.set("brightnessContrast",new Lo),this.effects.set("depthOfField",new Uo),this.effects.set("pixelation",new zo)}reinit(){if(this.effectComposer=new class{constructor(e=null,{depthBuffer:t=!0,stencilBuffer:r=!1,alpha:i=!1,multisampling:n=0,frameBufferType:s}={}){this.renderer=e,this.inputBuffer=null,this.outputBuffer=null,null!==this.renderer&&(this.renderer.autoClear=!1,this.inputBuffer=this.createBuffer(t,r,s,n),this.outputBuffer=this.inputBuffer.clone()),this.copyPass=new mo(new Os),this.alpha=i,this.depthTexture=null,this.passes=[],this.autoRenderToScreen=!0}get multisampling(){return this.inputBuffer instanceof t.WebGLMultisampleRenderTarget?this.inputBuffer.samples:0}set multisampling(e){const t=this.inputBuffer,r=this.multisampling;r>0&&e>0?(this.inputBuffer.samples=e,this.outputBuffer.samples=e):r!==e&&(this.inputBuffer.dispose(),this.outputBuffer.dispose(),this.inputBuffer=this.createBuffer(t.depthBuffer,t.stencilBuffer,t.texture.type,e),this.inputBuffer.depthTexture=this.depthTexture,this.outputBuffer=this.inputBuffer.clone())}getRenderer(){return this.renderer}replaceRenderer(e,r=!0){const i=this.renderer;if(null!==i&&i!==e){const n=i.getSize(new t.Vector2),s=e.getSize(new t.Vector2),o=i.domElement.parentNode;this.renderer=e,this.renderer.autoClear=!1,n.equals(s)||this.setSize(),r&&null!==o&&(o.removeChild(i.domElement),o.appendChild(e.domElement))}return i}createDepthTexture(){const e=this.depthTexture=new t.DepthTexture;return this.inputBuffer.depthTexture=e,this.inputBuffer.dispose(),this.inputBuffer.stencilBuffer?(e.format=t.DepthStencilFormat,e.type=t.UnsignedInt248Type):e.type=t.UnsignedIntType,e}deleteDepthTexture(){if(null!==this.depthTexture){this.depthTexture.dispose(),this.depthTexture=null,this.inputBuffer.depthTexture=null,this.inputBuffer.dispose();for(const e of this.passes)e.setDepthTexture(null)}}createBuffer(e,r,i,n){const s=this.renderer,o=s.getContext(),a=s.getDrawingBufferSize(new t.Vector2),l={format:this.alpha||o.getContextAttributes().alpha||i!==t.UnsignedByteType?t.RGBAFormat:t.RGBFormat,minFilter:t.LinearFilter,magFilter:t.LinearFilter,stencilBuffer:r,depthBuffer:e,type:i},c=n>0?new t.WebGLMultisampleRenderTarget(a.width,a.height,l):new t.WebGLRenderTarget(a.width,a.height,l);return n>0&&(c.samples=n),c.texture.name="EffectComposer.Buffer",c.texture.generateMipmaps=!1,c}addPass(e,r){const i=this.passes,n=this.renderer,s=n.getDrawingBufferSize(new t.Vector2),o=n.getContext().getContextAttributes().alpha,a=this.inputBuffer.texture.type;if(e.setSize(s.width,s.height),e.initialize(n,o,a),this.autoRenderToScreen&&(i.length>0&&(i[i.length-1].renderToScreen=!1),e.renderToScreen&&(this.autoRenderToScreen=!1)),void 0!==r?i.splice(r,0,e):i.push(e),this.autoRenderToScreen&&(i[i.length-1].renderToScreen=!0),e.needsDepthTexture||null!==this.depthTexture)if(null===this.depthTexture){const t=this.createDepthTexture();for(e of i)e.setDepthTexture(t)}else e.setDepthTexture(this.depthTexture)}removePass(e){const t=this.passes,r=t.indexOf(e);if(-1!==r&&t.splice(r,1).length>0){if(null!==this.depthTexture){const r=(e,t)=>e||t.needsDepthTexture;t.reduce(r,!1)||(e.getDepthTexture()===this.depthTexture&&e.setDepthTexture(null),this.deleteDepthTexture())}this.autoRenderToScreen&&r===t.length&&(e.renderToScreen=!1,t.length>0&&(t[t.length-1].renderToScreen=!0))}}removeAllPasses(){const e=this.passes;this.deleteDepthTexture(),e.length>0&&(this.autoRenderToScreen&&(e[e.length-1].renderToScreen=!1),this.passes=[])}render(e){const t=this.renderer,r=this.copyPass;let i,n,s,o=this.inputBuffer,a=this.outputBuffer,l=!1;for(const c of this.passes)c.enabled&&(c.render(t,o,a,e,l),c.needsSwap&&(l&&(r.renderToScreen=c.renderToScreen,i=t.getContext(),n=t.state.buffers.stencil,n.setFunc(i.NOTEQUAL,1,4294967295),r.render(t,o,a,e,l),n.setFunc(i.EQUAL,1,4294967295)),s=o,o=a,a=s),c instanceof fo?l=!0:c instanceof Vs&&(l=!1))}setSize(e,r,i){const n=this.renderer;if(void 0===e||void 0===r){const i=n.getSize(new t.Vector2);e=i.width,r=i.height}else n.setSize(e,r,i);const s=n.getDrawingBufferSize(new t.Vector2);this.inputBuffer.setSize(s.width,s.height),this.outputBuffer.setSize(s.width,s.height);for(const e of this.passes)e.setSize(s.width,s.height)}reset(){this.dispose(),this.autoRenderToScreen=!0}dispose(){for(const e of this.passes)e.dispose();this.passes=[],null!==this.inputBuffer&&this.inputBuffer.dispose(),null!==this.outputBuffer&&this.outputBuffer.dispose(),this.deleteDepthTexture(),this.copyPass.dispose()}}(this.renderer),this.renderPass=new Ws(this.scene,this.camera),this.enabled){const e=new To(this.search,this.area,Oo.ULTRA,Ms.COLOR);e.edgeDetectionMaterial.setPredicationMode(_s),e.edgeDetectionMaterial.setEdgeDetectionThreshold(.05),e.edgeDetectionMaterial.setPredicationThreshold(.002),e.edgeDetectionMaterial.setPredicationScale(1),this.depthPass=new Xs(this.scene,this.camera),this.effectComposer.addPass(this.renderPass),this.effectComposer.addPass(this.depthPass),this.effectComposer.addPass(new uo(this.camera,e));const t=[this.effects.get("chromaticAberration"),this.effects.get("bloom"),this.effects.get("colorAverage"),this.effects.get("hueSaturation"),this.effects.get("brightnessContrast"),this.effects.get("vignette"),this.effects.get("noise")].reduce(ko,[]),r=[this.effects.get("pixelation")].reduce(ko,[]);r.length>0&&this.effectComposer.addPass(new uo(this.camera,...r)),this.effectComposer.addPass(new uo(this.camera,...t))}else this.effectComposer.addPass(this.renderPass)}init({renderer:e,camera:t,scene:r}){return this.renderer=e,this.scene=r,this.camera=t,this.smaaImageLoader.load((([e,t])=>{this.search=e,this.area=t,this.reinit()}))}setInternalSize(e,t){const{renderer:r,effectComposer:i}=this;if(!r)return;e=Math.round(e),t=Math.round(t);const n=r.getPixelRatio(),{width:s,height:o}=i.inputBuffer;if(s/n!==e||o/n!==t){i.inputBuffer.setSize(e*n,t*n),i.outputBuffer.setSize(e*n,t*n);for(const r of i.passes)r.setSize(e*n,t*n)}}fromJSON(e){e&&(Object.keys(e).forEach((t=>{const r=e[t],i=this.effects.get(t);Object.keys(r).forEach((e=>{i[e]=r[e]}))})),this.enabled=e.enabled)}toJSON(){const e={};return this.effects.forEach(((t,r)=>{e[r]=t.toJSON()}),e),Object.assign({enabled:this.enabled},e)}render(){var e;null===(e=this.effectComposer)||void 0===e||e.render(this.clock.getDelta())}}class jo extends(Rn(t.Scene)){constructor(){super(),this.objectType="Scene",this.alpha=1,this.backupFog=new t.Fog(16777215,.1,2e3),this.fogUseBGColor=!1,this.directionalLightState=!0,this.ambientLightState=!0,this.wireframeState=!1,this._color=new t.Color(1644825),this.canvas={mode:1,preset:"fullscreen",size:{width:512,height:512},editorSize:{width:1,height:1},color:[0,0,0,.5]},this.name="Untitled"}get color(){return this._color}set color(e){!0===this.fogUseBGColor&&this.backupFog.color.copy(e),this._color.copy(e)}get enableFog(){return null!==this.fog}set enableFog(e){this.fog=!0===e?this.backupFog:null}init(e,r){this.camera=new ss(e,r),this.camera.setDefault(),this.camera.orthoCamera.near=-5e4,this.camera.perspCamera.near=50,this.camera.orthoCamera.far=1e5,this.camera.perspCamera.far=1e5,this.camera.updateProjectionMatrix(),this.camera.position.set(0,0,this.camera.targetOffset),this.camera.lookAt(new t.Vector3(0,0,-1)),this.add(this.camera),this.canvas.size.width=e,this.canvas.size.height=r,this.ambientLight=new t.HemisphereLight(13882323,8553090,.75),this.ambientLight.name="Default Ambient Light",this.add(this.ambientLight),this.directionalLight=new t.DirectionalLight(16777215,.75),this.directionalLight.name="Default Directional Light",this.directionalLight.position.set(85e4,13e5,1e6),this.activeCamera=this.camera,this.activeCamera.add(this.directionalLight),this.postprocessing=new Go}initFromObjectLoader(e){return this.traverse((t=>{t.uuid===e.ambientLight?this.ambientLight=t:t.uuid===e.directionalLight?this.directionalLight=t:(t.uuid===e.activeCamera&&(this.activeCamera=t),t.uuid===e.camera&&(this.camera=t,this.camera.setDefault()))})),this}addDefaultChild(){const e=new Er,t=e.userData.layers,r=t.head.id;t.getLayer(r).uniforms[`f${r}_color`].value.setRGB(1,1,1);const i=new ms(Ue.create({parameters:{width:320,height:320}}),e);return i.position.z=-1,this.add(i),i}raycast(e){const t=[],r=i=>{for(const n of i.children)Fn(n)&&!n.raycastLock&&n.visible&&((Ze(n)||$e(n)&&n.enableHelper)&&e.intersectObject(n,!1,t),r(n))};return r(this),t}traverseEntity(e){for(const t of this.children)Fn(t)&&this.camera!==t&&t.traverseEntity(e)}toJSON(e){var r,i,n,s,o;const a=super.toJSON(e),l=a.object;return l.objectType="Scene",l.activeCamera=null===(r=this.activeCamera)||void 0===r?void 0:r.uuid,l.camera=null===(i=this.camera)||void 0===i?void 0:i.uuid,l.directionalLight=null===(n=this.directionalLight)||void 0===n?void 0:n.uuid,l.ambientLight=null===(s=this.ambientLight)||void 0===s?void 0:s.uuid,l.color=this.color.toArray(),l.alpha=this.alpha,this.background instanceof t.Texture?l.background=this.background.toJSON(e):this.background instanceof t.Color&&(l.background=this.background.toArray()),null!==this.environment&&(l.environment=this.environment.toJSON(e)),!0===this.enableFog&&(l.enableFog=!0,!0===this.fogUseBGColor&&(l.fogUseBGColor=!0),null!==this.fog&&(l.fog=this.fog.toJSON())),!0===this.directionalLightState&&(l.directionalLightState=!0),!0===this.ambientLightState&&(l.ambientLightState=!0),!0===this.wireframeState&&(l.wireframeState=!0),l.canvas={mode:this.canvas.mode,preset:this.canvas.preset,editorSize:{width:window.innerWidth,height:window.innerHeight},color:this.canvas.color},1!==this.canvas.mode&&(l.canvas.size={width:this.canvas.size.width,height:this.canvas.size.height}),l.postprocessing=null===(o=this.postprocessing)||void 0===o?void 0:o.toJSON(),a}fromJSON(e){var r,i,n,s,o;super.fromJSON(e),this.postprocessing=new Go,this.color.fromArray(e.color),this.alpha=e.alpha,void 0!==e.background&&Array.isArray(e.background)&&(this.background=(new t.Color).fromArray(e.background)),void 0!==e.fog&&("FogExp2"===e.fog.type?this.backupFog=new t.FogExp2(e.fog.color,e.fog.density):this.backupFog=new t.Fog(e.fog.color,e.fog.near,e.fog.far)),this.fogUseBGColor=null!==(r=e.fogUseBGColor)&&void 0!==r&&r,this.enableFog=null!==(i=e.enableFog)&&void 0!==i&&i,this.directionalLightState=null!==(n=e.directionalLightState)&&void 0!==n&&n,this.ambientLightState=null!==(s=e.ambientLightState)&&void 0!==s&&s,this.wireframeState=null!==(o=e.wireframeState)&&void 0!==o&&o;const a=e.canvas;return this.canvas.mode=a.mode,a.size&&(this.canvas.size={width:a.size.width,height:a.size.height}),this.canvas.editorSize=a.editorSize?{width:a.editorSize.width,height:a.editorSize.height}:{width:window.innerWidth,height:window.innerHeight},a.color&&(this.canvas.color=[...a.color]),this.postprocessing.fromJSON(e.postprocessing),this}dispose(){this.traverseEntity((e=>{"geometry"in e&&e.geometry.dispose(),"material"in e&&(e.material instanceof Array?e.material.forEach((e=>e.dispose())):e.material.dispose())}))}}!function(e){e[e.STANDARD=1]="STANDARD",e[e.UPPERCASE=2]="UPPERCASE",e[e.LOWERCASE=3]="LOWERCASE"}(ao||(ao={})),function(e){e[e.TOP=1]="TOP",e[e.MIDDLE=2]="MIDDLE",e[e.BOTTOM=3]="BOTTOM"}(lo||(lo={})),function(e){e[e.LEFT=1]="LEFT",e[e.RIGHT=2]="RIGHT",e[e.CENTER=3]="CENTER",e[e.JUSTIFY=4]="JUSTIFY"}(co||(co={})),function(e){e[e.TO_RIGHT=1]="TO_RIGHT",e[e.TO_LEFT=-1]="TO_LEFT"}(ho||(ho={}));const Vo=new t.Vector2;class Ho{constructor(e,r,i){this.message=[],this.endLine=!0,this.yLinePos=e,this.lineHeight=r,this.maxCharSize=i,this.nextChar3DPos=new t.Vector2(0,this.yLinePos+this.maxCharSize*this.lineHeight),this.align=co.LEFT}addChar3D(e,t,r=this.message.length){this.message.splice(r,0,e),e.fontSize>this.maxCharSize?(this.maxCharSize=e.fontSize,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight,this.fullUpdate(t)):(e.updatePosition(this.nextChar3DPos,t),this.nextChar3DPos.x+=e.charSize)}deleteChar3D(e=this.message.length-1){const t=this.message[e];return t?(this.message.splice(e,1),this.nextChar3DPos.x-=t.charSize,t):void 0}isEndLine(e){this.endLine=e}fullUpdate(e,t=0){this.nextChar3DPos.x=0;for(let r=t,i=this.message.length;r<i;r+=1)this.message[r].updatePosition(this.nextChar3DPos,e),this.nextChar3DPos.x+=this.message[r].charSize}checkOverFlow(e){let t,r=this.message.length-1;if(r<=0)return!1;for(;r>=0;){if(" "!==this.message[r].char){t=this.message[r];break}r-=1}return!!(r>=0&&t&&t.localPosition.x+t.charSize>e)}containSpaceOverFlow(e=this.message.length-1){for(let t=e;t>=0;t-=1)if(" "===this.message[t].char)return!0;return!1}containSpace(e=this.message.length-1){if(this.endLine)return!0;for(let t=e;t>=0;t-=1)if(" "===this.message[t].char)return!0;return!1}popWord(e=this.message.length-1){let t,r=[],i=!0;for(t=e;t>=0;t-=1){if(" "===this.message[t].char){i=!1,0===r.length&&(t-=1,r.splice(0,0,this.message[t]));break}r.splice(0,0,this.message[t])}return i?r=[]:this.message.splice(t+1,r.length),r}getWord(e=0,t=1){const r=[];let i=e;for(i=e;;i+=t){if(!this.message[i]||" "===this.message[i].char){0===r.length&&this.message[i]&&(r.push(this.message[i]),this.message.splice(i,1));break}t>0?(r.push(this.message[i]),this.message.splice(i,1),i-=t):(r.splice(0,0,this.message[i]),this.message.splice(i,1))}return r}getWordAtIndex(e){const t=[];for(let r=e;r<this.message.length&&" "!==this.message[r].char;r++)t.push(this.message[r]);for(let r=e-1;r>=0&&" "!==this.message[r].char;r--)t.splice(0,0,this.message[r]);return t}wordSize(e=0,t=-1){let r=0,i=e;for(;i>=0&&i<this.message.length;){if(" "===this.message[i].char){0===r&&(r=this.message[i].charSize);break}r+=this.message[i].charSize,i+=t}return(i<0||i>=this.message.length)&&!this.endLine?this.message[e]?this.message[e].charSize:999999999:0===r?999999999:r}spaceLeft(e){return e-this.nextChar3DPos.x}popChar(e=this.message.length-1){return this.nextChar3DPos.x-=this.message[e].charSize,this.message.splice(e,1)}isEmpty(){return!this.message.length}updateNextCharPosY(){this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}updateYLinePos(e){this.yLinePos=e,this.updateNextCharPosY()}updatelineHeight(e){this.lineHeight=e,this.updateNextCharPosY()}updateFontSize(e,t=0,r=this.message.length-1){for(let i=t;i<=r;i+=1)this.message[i].updateFontSize(e);this.maxCharSize=e,this.nextChar3DPos.y=this.yLinePos+this.maxCharSize*this.lineHeight}countSpaces(){let e=0;for(let t=0;t<this.message.length;t++)" "===this.message[t].char&&(e+=1);return e}alignText(e,t,r,i,n){switch(r){case co.LEFT:this.leftAlign(e,n);break;case co.CENTER:this.centerAlign(this.spaceLeft(t),e,n);break;case co.RIGHT:this.rightAlign(this.spaceLeft(t),e,n);break;case co.JUSTIFY:this.justifyAlign(this.spaceLeft(t),e,n)}}offsetCharacters(e,t,r){Vo.set(t,r);const i=this.message.length;for(let t=0;t<i;t++)this.message[t].updatePosition(this.message[t].localPosition.add(Vo),e)}leftAlign(e,t){this.align=co.LEFT,this.offsetCharacters(e,0,t)}centerAlign(e,t,r){this.align=co.CENTER,this.offsetCharacters(t,e/2,r)}rightAlign(e,t,r){this.align=co.RIGHT,this.offsetCharacters(t,e,r)}justifyAlign(e,t,r){if(this.align=co.JUSTIFY,this.endLine)return void this.offsetCharacters(t,0,r);const i=this.countSpaces();if(0===i)return void this.offsetCharacters(t,0,r);const n=e/i;let s=0;for(let e=0;e<this.message.length;e++)" "===this.message[e].char&&(s+=n),Vo.set(s,r),this.message[e].updatePosition(this.message[e].localPosition.add(Vo),t)}clone(){const e=new Ho(this.yLinePos,this.lineHeight,this.maxCharSize);e.nextChar3DPos=this.nextChar3DPos.clone(),e.align=this.align,e.endLine=this.endLine;for(let t=0;t<this.message.length;t++)e.message.push(this.message[t].clone());return e}}class Jo extends t.Mesh{constructor({char:e,originalChar:r,fontFamily:i,letterSpacing:n,fontSize:s,LOD:o=16},a=new t.MeshBasicMaterial({color:0,opacity:1,visible:!0,transparent:!0,side:t.DoubleSide})){const l=Jo.loadChar(e,i,o);super(l.geometry,a),this.char=e,this.originalChar=null!=r?r:e,this.fontFamily=i,this.letterSpacing=n,this.fontSize=s,this.LOD=o,this.resolution=l.resolution,this.glyphsHa=l.glyphsHa,this.localPosition=new t.Vector2,this.charSize=0,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}static get FONTS_PATH(){return Jo._fontPath}static set FONTS_PATH(e){Jo._fontPath=e}updatePosition(e,r){this.localPosition.copy(e);const i=new t.Vector3(this.localPosition.x,-this.localPosition.y,0);this.position.copy(i).add(r)}updateFontSize(e){const t=e/this.resolution;this.fontSize=e,this.scale.set(this.fontSize,this.fontSize,1),this.charSize=this.glyphsHa*t*this.letterSpacing}updateFontFamily(e){if(this.fontFamily===e)return;this.fontFamily=e;const t=Jo.loadChar(this.char,e,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateChar(e){if(this.char===e)return;this.char=e;const t=Jo.loadChar(e,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}updateLetterSpacing(e){this.letterSpacing!==e&&(this.letterSpacing=e,this.updateFontSize(this.fontSize))}updateLOD(e){if(this.LOD===e)return;this.LOD=e;const t=Jo.loadChar(this.char,this.fontFamily,this.LOD);this.geometry=t.geometry,this.resolution=t.resolution,this.glyphsHa=t.glyphsHa,this.geometry.userData={type:"CharacterGeometry",parameters:{char:this.char,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,lod:this.LOD,resolution:this.resolution,charSize:this.charSize,localPosition:this.localPosition}},this.updateFontSize(this.fontSize)}clone(){const e={char:this.char,originalChar:this.originalChar,fontFamily:this.fontFamily,letterSpacing:this.letterSpacing,fontSize:this.fontSize,LOD:this.LOD};return new Jo(e).copy(this)}static loadFont(e){return new Promise((function(r,i){if(Jo.fontCache[e])r(Jo.fontCache[e]);else{(new t.FontLoader).load(Jo.FONTS_PATH+e+".json",(t=>{Jo.fontCache[e]=t,r(t)}),void 0,i)}}))}static loadChar(e,r,i){if(Jo.charCache[e]){if(Jo.charCache[e][i]&&Jo.charCache[e][i].fontFamily===r)return Jo.charCache[e][i]}else Jo.charCache[e]={};const n=Jo.fontCache[r],s=n.generateShapes(e,1);return Jo.charCache[e][i]={geometry:new t.ShapeBufferGeometry(s,i),fontFamily:r,resolution:n.data.resolution,glyphsHa:n.data.glyphs[e].ha},Jo.charCache[e][i]}}Jo.charCache={},Jo.fontCache={},Jo._fontPath="/_assets/_fonts/";class Qo extends jn{constructor(e,r=new Er({transparent:!0,opacity:1,visible:!1,side:t.DoubleSide})){super(e,r),this.objectType="TextFrame",this.material.visible=!1,this._geometryUserData=e.userData,this.userData.textFrame={hexColor:6974058,opacity:1,visible:!0,fontSize:16,lineHeight:1.5,letterSpacing:1,fontFamily:"roboto_regular",textTransform:ao.STANDARD,horizontalAlignment:1,verticalAlignment:lo.TOP,LOD:16,maxLineSize:this._geometryUserData.parameters.width,textOrigin:new t.Vector3(-.5*this._geometryUserData.parameters.width,.5*this._geometryUserData.parameters.height,0),textLines:[]},this.createTextLine()}raycast(e,t){const r=[];if(super.raycast(e,r),r.length>0)return void t.push(r[0]);const i=[];for(let r=0,n=this.children.length;r<n;++r)if(this.children[r]instanceof Jo&&(e.intersectObject(this.children[r],!1,i),i.length>0))return i[0].object=this,void t.push(i[0])}updateGeometry(e){var t,r;const i=this.userData,n=this.geometry.userData,s=n.parameters.width,o=null===(t=e.parameters)||void 0===t?void 0:t.width,a=null===(r=e.parameters)||void 0===r?void 0:r.height,l=n.parameters.height,c=i.textFrame;super.updateGeometry(e),c.maxLineSize=n.parameters.width,c.textOrigin.set(-.5*n.parameters.width,.5*n.parameters.height,0),void 0!==a&&l!==a?(this.checkOverFlow(),this.checkCapacity()):void 0!==o&&(s<o?this.checkCapacity():s>o&&this.checkOverFlow())}checkOverFlow(e=0){const t=this.userData,r=t.textFrame.textOrigin,i=t.textFrame.textLines;for(let n=e;n<i.length;n++){i[n].updateYLinePos(this.getNewLinePosition(n)),i[n].fullUpdate(r);const e=[];for(;i[n].checkOverFlow(t.textFrame.maxLineSize);)i[n].containSpaceOverFlow()?e.splice(0,0,i[n].getWord(i[n].message.length-1,ho.TO_LEFT)):e.splice(0,0,i[n].popChar());if(e.length>0){void 0===i[n+1]&&(i[n].isEndLine(!1),this.createTextLine());let t=0;for(let s=0;s<e.length;s+=1)for(let o=0;o<e[s].length;o+=1)i[n+1].addChar3D(e[s][o],r,t),t+=1;i[n+1].fullUpdate(r)}i[n].fullUpdate(r)}this.textFullUpdate(e)}checkCapacity(e=0){const t=this.userData,r=t.textFrame.textOrigin,i=t.textFrame.maxLineSize,n=t.textFrame.textLines;for(let t=e;t<n.length;t+=1)if(n[t].updateYLinePos(this.getNewLinePosition(t)),n[t].fullUpdate(r),n[t-1])for(;!n[t-1].endLine;){let e;const s=n[t-1].spaceLeft(i);if(!(n[t].wordSize(0,ho.TO_RIGHT)<=s)){n[t].isEmpty()?(n[t].endLine&&n[t-1].isEndLine(!0),n.splice(t,1),t-=1):(n[t].updateYLinePos(this.getNewLinePosition(t)),n[t].fullUpdate(r));break}e=n[t].containSpace()?n[t].getWord(0,ho.TO_RIGHT):n[t].popChar(0);for(let i=0;i<e.length;i+=1)e[i]&&n[t-1].addChar3D(e[i],r)}this.textFullUpdate(e)}createTextLine(e=this.userData.textFrame.textLines.length){const t=this.userData.textFrame;t.textLines.splice(e,0,new Ho(this.getNewLinePosition(e),t.lineHeight,t.fontSize))}textFullUpdate(e=0){const t=this.userData.textFrame,r=t.textLines,i=this.getVerticalAlignmentOffSet();for(let n=e;n<r.length;n++)r[n].updateYLinePos(this.getNewLinePosition(n)),r[n].fullUpdate(t.textOrigin),r[n].alignText(t.textOrigin,t.maxLineSize,t.horizontalAlignment,t.verticalAlignment,i)}getVerticalAlignmentOffSet(){switch(this.userData.textFrame.verticalAlignment){case lo.TOP:return 0;case lo.MIDDLE:return this.getRemainingVerticalSpace()/2;case lo.BOTTOM:return this.getRemainingVerticalSpace();default:return 0}}getRemainingVerticalSpace(){const e=this.userData.textFrame.textLines;return this.geometry.userData.parameters.height-this.getNewLinePosition(e.length)}getNewLinePosition(e){const t=this.userData.textFrame.textLines;let r=0;for(let i=0;i<e;i+=1)r+=t[i].maxCharSize*t[i].lineHeight;return r}updateColor(e){const t=this.userData;t.textFrame.hexColor=e;const r=t.textFrame.textLines;for(let t=0;t<r.length;t++){const i=r[t].message;for(let t=0;t<i.length;t++){i[t].material.color.setHex(e)}}}updateOpacity(e){const t=this.userData;t.textFrame.opacity=e;const r=t.textFrame.textLines;for(let t=0;t<r.length;t++){const i=r[t].message;for(let t=0;t<i.length;t++){i[t].material.opacity=e}}}updateVisible(e){const t=this.userData;t.textFrame.visible=e;const r=t.textFrame.textLines;for(let t=0;t<r.length;t++){const i=r[t].message;for(let t=0;t<i.length;t++){i[t].material.visible=e}}}updateFontFamily(e){return er(this,void 0,void 0,(function*(){yield Jo.loadFont(e);const t=this.userData.textFrame,r=t.textLines;t.fontFamily=e;for(let t=0;t<r.length;t++){const i=r[t].message;for(let t=0;t<i.length;t++)i[t].updateFontFamily(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}))}updateFontSize(e){const t=this.userData.textFrame,r=t.textLines,i=t.fontSize;t.fontSize=e;for(let t=0;t<r.length;t++)r[t].updateFontSize(e);this.textFullUpdate(),e>i?this.checkOverFlow():e<i&&this.checkCapacity()}updateTextTransform(e){return er(this,void 0,void 0,(function*(){const t=this.userData.textFrame;yield Jo.loadFont(t.fontFamily);const r=t.textLines;switch(t.textTransform=e,e){case ao.UPPERCASE:for(let e=0;e<r.length;e++){const t=r[e].message;for(let i=0;i<t.length;i++)r[e].message[i].updateChar(t[i].char.toUpperCase())}break;case ao.LOWERCASE:for(let e=0;e<r.length;e++){const t=r[e].message;for(let i=0;i<t.length;i++)r[e].message[i].updateChar(t[i].char.toLowerCase())}break;default:for(let e=0;e<r.length;e++){const t=r[e].message;for(let i=0;i<t.length;i++)r[e].message[i].updateChar(t[i].originalChar)}}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}))}updateLetterSpacing(e){const t=this.userData,r=t.textFrame.textLines;t.textFrame.letterSpacing=e;for(let t=0;t<r.length;t++){const i=r[t].message;for(let t=0;t<i.length;t++)i[t].updateLetterSpacing(e)}this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLOD(e){const t=this.userData;t.textFrame.LOD=e;const r=t.textFrame.textLines;for(let e=0;e<r.length;e++);this.textFullUpdate(),this.checkOverFlow(),this.checkCapacity()}updateLineHeight(e){const t=this.userData,r=t.textFrame.textLines;t.textFrame.lineHeight=e;for(let t=0;t<r.length;t++)r[t].updatelineHeight(e);this.textFullUpdate()}updateVerticalAlignment(e){this.userData.textFrame.verticalAlignment=e,this.textFullUpdate()}updateHorizontalAlignment(e){this.userData.textFrame.horizontalAlignment=e,this.textFullUpdate()}copy(e,r){super.copy(e,r);const i=this.userData,n=e.userData,s=this.geometry.userData;i.textFrame.textOrigin=new t.Vector3(-.5*s.parameters.width,.5*s.parameters.height,0);const o=n.textFrame.textLines;i.textFrame.textLines=[];for(let e=0;e<o.length;e++){const t=o[e].clone(),r=t.message;i.textFrame.textLines.push(t);for(let e=0;e<r.length;e++)this.add(r[e])}return this.textFullUpdate(),this.updateColor(n.textFrame.hexColor),this}toJSON(e){const t=super.toJSON(e),r=t.object;r.objectType="TextFrame";const i=this.userData.textFrame.textLines.map((e=>{const t=e.message.map((e=>({char:e.char,originalChar:e.originalChar,fontFamily:e.fontFamily,letterSpacing:e.letterSpacing,fontSize:e.fontSize,LOD:e.LOD})));return{align:e.align,endLine:e.endLine,lineHeight:e.lineHeight,maxCharSize:e.maxCharSize,yLinePos:e.yLinePos,message:t}}));return r.userData.textFrame.textLinesData=i,t}fromJSONasync(e){const r=Object.create(null,{fromJSON:{get:()=>super.fromJSON}});return er(this,void 0,void 0,(function*(){if(r.fromJSON.call(this,e),void 0!==e.userData){const r=e.userData.textFrame;yield Jo.loadFont(r.fontFamily),r.textOrigin=new t.Vector3(r.textOrigin.x,r.textOrigin.y,r.textOrigin.z);const i=new t.MeshBasicMaterial({color:r.hexColor,opacity:r.opacity,visible:r.visible,transparent:!0,side:t.DoubleSide});r.textLinesData&&(r.textLines=r.textLinesData.map(((e,t)=>{const n=new Ho(Number(e.yLinePos),Number(e.lineHeight),Number(e.maxCharSize)),s=e.message.map(((e,s)=>{if(void 0===e.char){const i=r.textLines[t].message[s];if("geometries"in i){const t=i.geometries[0].userData.parameters;Object.assign(e,{LOD:t.lod,char:t.char,fontFamily:t.fontFamily,fontSize:t.fontSize,letterSpacing:t.letterSpacing,originalChar:t.char})}}const o={char:e.char,fontFamily:e.fontFamily,letterSpacing:Number(e.letterSpacing),fontSize:Number(e.fontSize),LOD:e.LOD},a=new Jo(o,i.clone());return n.addChar3D(a,r.textOrigin),this.add(a),a}));return n.message=s,n})),this.userData.textFrame=r),this.textFullUpdate()}return this}))}}Qo.VERTICAL_ALIGN=lo,Qo.HORIZONTAL_ALIGN=co,Qo.TEXT_TRANSFORM=ao,Qo.TRAVEL_DIRECTION=ho;var Yo="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Wo(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets option of @rollup/plugin-commonjs appropriately for this require call to behave properly.')}
/*!
pica
https://github.com/nodeca/pica
*/var Xo;!function(e){var t={exports:{}};e(t,t.exports)}((function(e,t){e.exports=function(){function e(t,r,i){function n(o,a){if(!r[o]){if(!t[o]){if(!a&&Wo)return Wo(o);if(s)return s(o,!0);var l=new Error("Cannot find module '"+o+"'");throw l.code="MODULE_NOT_FOUND",l}var c=r[o]={exports:{}};t[o][0].call(c.exports,(function(e){return n(t[o][1][e]||e)}),c,c.exports,e,t,r,i)}return r[o].exports}for(var s=Wo,o=0;o<i.length;o++)n(i[o]);return n}return e}()({1:[function(e,t,r){var i=e("inherits"),n=e("multimath"),s=e("./mm_unsharp_mask"),o=e("./mm_resize");function a(e){var t=e||[],r={js:t.indexOf("js")>=0,wasm:t.indexOf("wasm")>=0};n.call(this,r),this.features={js:r.js,wasm:r.wasm&&this.has_wasm()},this.use(s),this.use(o)}i(a,n),a.prototype.resizeAndUnsharp=function(e,t){var r=this.resize(e,t);return e.unsharpAmount&&this.unsharp_mask(r,e.toWidth,e.toHeight,e.unsharpAmount,e.unsharpRadius,e.unsharpThreshold),r},t.exports=a},{"./mm_resize":4,"./mm_unsharp_mask":9,inherits:19,multimath:20}],2:[function(e,t,r){function i(e){return e<0?0:e>255?255:e}function n(e,t,r,n,s,o){var a,l,c,h,u,d,p,f,m,g,v,y=0,A=0;for(m=0;m<n;m++){for(u=0,g=0;g<s;g++){for(d=o[u++],p=o[u++],f=y+4*d|0,a=l=c=h=0;p>0;p--)h=h+(v=o[u++])*e[f+3]|0,c=c+v*e[f+2]|0,l=l+v*e[f+1]|0,a=a+v*e[f]|0,f=f+4|0;t[A+3]=i(h+8192>>14),t[A+2]=i(c+8192>>14),t[A+1]=i(l+8192>>14),t[A]=i(a+8192>>14),A=A+4*n|0}A=4*(m+1)|0,y=(m+1)*r*4|0}}function s(e,t,r,n,s,o){var a,l,c,h,u,d,p,f,m,g,v,y=0,A=0;for(m=0;m<n;m++){for(u=0,g=0;g<s;g++){for(d=o[u++],p=o[u++],f=y+4*d|0,a=l=c=h=0;p>0;p--)h=h+(v=o[u++])*e[f+3]|0,c=c+v*e[f+2]|0,l=l+v*e[f+1]|0,a=a+v*e[f]|0,f=f+4|0;t[A+3]=i(h+8192>>14),t[A+2]=i(c+8192>>14),t[A+1]=i(l+8192>>14),t[A]=i(a+8192>>14),A=A+4*n|0}A=4*(m+1)|0,y=(m+1)*r*4|0}}t.exports={convolveHorizontally:n,convolveVertically:s}},{}],3:[function(e,t,r){t.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAEXA2AAAGAGf39/f39/AGAHf39/f39/fwACDwEDZW52Bm1lbW9yeQIAAAMEAwABAgYGAX8AQQALB1cFEV9fd2FzbV9jYWxsX2N0b3JzAAAIY29udm9sdmUAAQpjb252b2x2ZUhWAAIMX19kc29faGFuZGxlAwAYX193YXNtX2FwcGx5X2RhdGFfcmVsb2NzAAAK7AMDAwABC8YDAQ9/AkAgA0UNACAERQ0AA0AgDCENQQAhE0EAIQcDQCAHQQJqIQYCfyAHQQF0IAVqIgcuAQIiFEUEQEGAwAAhCEGAwAAhCUGAwAAhCkGAwAAhCyAGDAELIBIgBy4BAGohCEEAIQsgFCEHQQAhDiAGIQlBACEPQQAhEANAIAUgCUEBdGouAQAiESAAIAhBAnRqKAIAIgpBGHZsIBBqIRAgCkH/AXEgEWwgC2ohCyAKQRB2Qf8BcSARbCAPaiEPIApBCHZB/wFxIBFsIA5qIQ4gCEEBaiEIIAlBAWohCSAHQQFrIgcNAAsgC0GAQGshCCAOQYBAayEJIA9BgEBrIQogEEGAQGshCyAGIBRqCyEHIAEgDUECdGogCUEOdSIGQf8BIAZB/wFIGyIGQQAgBkEAShtBCHRBgP4DcSAKQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EQdEGAgPwHcSALQQ51IgZB/wEgBkH/AUgbIgZBACAGQQBKG0EYdHJyIAhBDnUiBkH/ASAGQf8BSBsiBkEAIAZBAEobcjYCACADIA1qIQ0gE0EBaiITIARHDQALIAxBAWoiDCACbCESIAMgDEcNAAsLCx4AQQAgAiADIAQgBSAAEAEgAkEAIAQgBSAGIAEQAQs="},{}],4:[function(e,t,r){t.exports={name:"resize",fn:e("./resize"),wasm_fn:e("./resize_wasm"),wasm_src:e("./convolve_wasm_base64")}},{"./convolve_wasm_base64":3,"./resize":5,"./resize_wasm":8}],5:[function(e,t,r){var i=e("./resize_filter_gen"),n=e("./convolve").convolveHorizontally,s=e("./convolve").convolveVertically;function o(e,t,r){for(var i=3,n=t*r*4|0;i<n;)e[i]=255,i=i+4|0}t.exports=function(e){var t=e.src,r=e.width,a=e.height,l=e.toWidth,c=e.toHeight,h=e.scaleX||e.toWidth/e.width,u=e.scaleY||e.toHeight/e.height,d=e.offsetX||0,p=e.offsetY||0,f=e.dest||new Uint8Array(l*c*4),m=void 0===e.quality?3:e.quality,g=e.alpha||!1,v=i(m,r,l,h,d),y=i(m,a,c,u,p),A=new Uint8Array(l*a*4);return n(t,A,r,a,l,v),s(A,f,a,l,c,y),g||o(f,l,c),f}},{"./convolve":2,"./resize_filter_gen":6}],6:[function(e,t,r){var i=e("./resize_filter_info"),n=14;function s(e){return Math.round(e*((1<<n)-1))}t.exports=function(e,t,r,n,o){var a,l,c,h,u,d,p,f,m,g,v,y,A,w,x,b,S,E=i[e].filter,C=1/n,T=Math.min(1,n),O=i[e].win/T,D=Math.floor(2*(O+1)),M=new Int16Array((D+2)*r),_=0,N=!M.subarray||!M.set;for(a=0;a<r;a++){for(l=(a+.5)*C+o,c=Math.max(0,Math.floor(l-O)),u=(h=Math.min(t-1,Math.ceil(l+O)))-c+1,d=new Float32Array(u),p=new Int16Array(u),f=0,m=c,g=0;m<=h;m++,g++)f+=v=E((m+.5-l)*T),d[g]=v;for(y=0,g=0;g<d.length;g++)y+=A=d[g]/f,p[g]=s(A);for(p[r>>1]+=s(1-y),w=0;w<p.length&&0===p[w];)w++;if(w<p.length){for(x=p.length-1;x>0&&0===p[x];)x--;if(b=c+w,S=x-w+1,M[_++]=b,M[_++]=S,N)for(g=w;g<=x;g++)M[_++]=p[g];else M.set(p.subarray(w,x+1),_),_+=S}else M[_++]=0,M[_++]=0}return M}},{"./resize_filter_info":7}],7:[function(e,t,r){t.exports=[{win:.5,filter:function(e){return e>=-.5&&e<.5?1:0}},{win:1,filter:function(e){if(e<=-1||e>=1)return 0;if(e>-1.1920929e-7&&e<1.1920929e-7)return 1;var t=e*Math.PI;return Math.sin(t)/t*(.54+.46*Math.cos(t/1))}},{win:2,filter:function(e){if(e<=-2||e>=2)return 0;if(e>-1.1920929e-7&&e<1.1920929e-7)return 1;var t=e*Math.PI;return Math.sin(t)/t*Math.sin(t/2)/(t/2)}},{win:3,filter:function(e){if(e<=-3||e>=3)return 0;if(e>-1.1920929e-7&&e<1.1920929e-7)return 1;var t=e*Math.PI;return Math.sin(t)/t*Math.sin(t/3)/(t/3)}}]},{}],8:[function(e,t,r){var i=e("./resize_filter_gen");function n(e,t,r){for(var i=3,n=t*r*4|0;i<n;)e[i]=255,i=i+4|0}function s(e){return new Uint8Array(e.buffer,0,e.byteLength)}var o=!0;try{o=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0]}catch(e){}function a(e,t,r){if(o)t.set(s(e),r);else for(var i=r,n=0;n<e.length;n++){var a=e[n];t[i++]=255&a,t[i++]=a>>8&255}}t.exports=function(e){var t=e.src,r=e.width,s=e.height,o=e.toWidth,l=e.toHeight,c=e.scaleX||e.toWidth/e.width,h=e.scaleY||e.toHeight/e.height,u=e.offsetX||0,d=e.offsetY||0,p=e.dest||new Uint8Array(o*l*4),f=void 0===e.quality?3:e.quality,m=e.alpha||!1,g=i(f,r,o,c,u),v=i(f,s,l,h,d),y=0,A=this.__align(y+Math.max(t.byteLength,p.byteLength)),w=this.__align(A+s*o*4),x=this.__align(w+g.byteLength),b=x+v.byteLength,S=this.__instance("resize",b),E=new Uint8Array(this.__memory.buffer),C=new Uint32Array(this.__memory.buffer),T=new Uint32Array(t.buffer);return C.set(T),a(g,E,w),a(v,E,x),(S.exports.convolveHV||S.exports._convolveHV)(w,x,A,r,s,o,l),new Uint32Array(p.buffer).set(new Uint32Array(this.__memory.buffer,0,l*o)),m||n(p,o,l),p}},{"./resize_filter_gen":6}],9:[function(e,t,r){t.exports={name:"unsharp_mask",fn:e("./unsharp_mask"),wasm_fn:e("./unsharp_mask_wasm"),wasm_src:e("./unsharp_mask_wasm_base64")}},{"./unsharp_mask":10,"./unsharp_mask_wasm":11,"./unsharp_mask_wasm_base64":12}],10:[function(e,t,r){var i=e("glur/mono16");function n(e,t,r){for(var i,n,s,o,a=t*r,l=new Uint16Array(a),c=0;c<a;c++)i=e[4*c],n=e[4*c+1],s=e[4*c+2],o=i>=n&&i>=s?i:n>=s&&n>=i?n:s,l[c]=o<<8;return l}t.exports=function(e,t,r,s,o,a){var l,c,h,u,d;if(!(0===s||o<.5)){o>2&&(o=2);var p=n(e,t,r),f=new Uint16Array(p);i(f,t,r,o);for(var m=s/100*4096+.5|0,g=a<<8,v=t*r,y=0;y<v;y++)u=(l=p[y])-f[y],Math.abs(u)>=g&&(h=((c=(c=(c=l+(m*u+2048>>12))>65280?65280:c)<0?0:c)<<12)/(l=0!==l?l:1)|0,e[d=4*y]=e[d]*h+2048>>12,e[d+1]=e[d+1]*h+2048>>12,e[d+2]=e[d+2]*h+2048>>12)}}},{"glur/mono16":18}],11:[function(e,t,r){t.exports=function(e,t,r,i,n,s){if(!(0===i||n<.5)){n>2&&(n=2);var o=t*r,a=4*o,l=2*o,c=2*o,h=4*Math.max(t,r),u=32,d=0,p=a,f=p+l,m=f+c,g=m+c,v=g+h,y=this.__instance("unsharp_mask",a+l+2*c+h+u,{exp:Math.exp}),A=new Uint32Array(e.buffer);new Uint32Array(this.__memory.buffer).set(A);var w=y.exports.hsv_v16||y.exports._hsv_v16;w(d,p,t,r),(w=y.exports.blurMono16||y.exports._blurMono16)(p,f,m,g,v,t,r,n),(w=y.exports.unsharp||y.exports._unsharp)(d,d,p,f,t,r,i,s),A.set(new Uint32Array(this.__memory.buffer,0,o))}}},{}],12:[function(e,t,r){t.exports="AGFzbQEAAAAADAZkeWxpbmsAAAAAAAE0B2AAAGAEf39/fwBgBn9/f39/fwBgCH9/f39/f39/AGAIf39/f39/f30AYAJ9fwBgAXwBfAIZAgNlbnYDZXhwAAYDZW52Bm1lbW9yeQIAAAMHBgAFAgQBAwYGAX8AQQALB4oBCBFfX3dhc21fY2FsbF9jdG9ycwABFl9fYnVpbGRfZ2F1c3NpYW5fY29lZnMAAg5fX2dhdXNzMTZfbGluZQADCmJsdXJNb25vMTYABAdoc3ZfdjE2AAUHdW5zaGFycAAGDF9fZHNvX2hhbmRsZQMAGF9fd2FzbV9hcHBseV9kYXRhX3JlbG9jcwABCsUMBgMAAQvWAQEHfCABRNuGukOCGvs/IAC7oyICRAAAAAAAAADAohAAIgW2jDgCFCABIAKaEAAiAyADoCIGtjgCECABRAAAAAAAAPA/IAOhIgQgBKIgAyACIAKgokQAAAAAAADwP6AgBaGjIgS2OAIAIAEgBSAEmqIiB7Y4AgwgASADIAJEAAAAAAAA8D+gIASioiIItjgCCCABIAMgAkQAAAAAAADwv6AgBKKiIgK2OAIEIAEgByAIoCAFRAAAAAAAAPA/IAahoC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AogCUQAAAAAAADwP6AgC6KiIg+2OAIIIAQgCiAJRAAAAAAAAPC/oCALoqIiCbY4AgQgBCAOIA+gIAxEAAAAAAAA8D8gDaGgIgqjtjgCHCAEIAsgCaAgCqO2OAIYIAYEQANAIAAgBSAIbEEBdGogAiAIQQF0aiADIAQgBSAGEAMgCEEBaiIIIAZHDQALCyAFRQ0AQQAhCANAIAIgBiAIbEEBdGogASAIQQF0aiADIAQgBiAFEAMgCEEBaiIIIAVHDQALCwtxAQN/IAIgA2wiBQRAA0AgASAAKAIAIgRBEHZB/wFxIgIgAiAEQQh2Qf8BcSIDIAMgBEH/AXEiBEkbIAIgA0sbIgYgBiAEIAIgBEsbIAMgBEsbQQh0OwEAIAFBAmohASAAQQRqIQAgBUEBayIFDQALCwuZAgIDfwF8IAQgBWwhBAJ/IAazQwAAgEWUQwAAyEKVu0QAAAAAAADgP6AiC5lEAAAAAAAA4EFjBEAgC6oMAQtBgICAgHgLIQUgBARAIAdBCHQhCUEAIQYDQCAJIAIgBkEBdCIHai8BACIBIAMgB2ovAQBrIgcgB0EfdSIIaiAIc00EQCAAIAZBAnQiCGoiCiAFIAdsQYAQakEMdSABaiIHQYD+AyAHQYD+A0gbIgdBACAHQQBKG0EMdCABQQEgARtuIgEgCi0AAGxBgBBqQQx2OgAAIAAgCEEBcmoiByABIActAABsQYAQakEMdjoAACAAIAhBAnJqIgcgASAHLQAAbEGAEGpBDHY6AAALIAZBAWoiBiAERw0ACwsL"},{}],13:[function(e,t,r){var i=100;function n(e,t){this.create=e,this.available=[],this.acquired={},this.lastId=1,this.timeoutId=0,this.idle=t||2e3}n.prototype.acquire=function(){var e,t=this;return 0!==this.available.length?e=this.available.pop():((e=this.create()).id=this.lastId++,e.release=function(){return t.release(e)}),this.acquired[e.id]=e,e},n.prototype.release=function(e){var t=this;delete this.acquired[e.id],e.lastUsed=Date.now(),this.available.push(e),0===this.timeoutId&&(this.timeoutId=setTimeout((function(){return t.gc()}),i))},n.prototype.gc=function(){var e=this,t=Date.now();this.available=this.available.filter((function(r){return!(t-r.lastUsed>e.idle&&(r.destroy(),1))})),0!==this.available.length?this.timeoutId=setTimeout((function(){return e.gc()}),i):this.timeoutId=0},t.exports=n},{}],14:[function(e,t,r){var i=2;t.exports=function(e,t,r,n,s,o){var a=r/e,l=n/t,c=(2*o+i+1)/s;if(c>.5)return[[r,n]];var h=Math.ceil(Math.log(Math.min(a,l))/Math.log(c));if(h<=1)return[[r,n]];for(var u=[],d=0;d<h;d++){var p=Math.round(Math.pow(Math.pow(e,h-d-1)*Math.pow(r,d+1),1/h)),f=Math.round(Math.pow(Math.pow(t,h-d-1)*Math.pow(n,d+1),1/h));u.push([p,f])}return u}},{}],15:[function(e,t,r){var i=1e-5;function n(e){var t=Math.round(e);return Math.abs(e-t)<i?t:Math.floor(e)}function s(e){var t=Math.round(e);return Math.abs(e-t)<i?t:Math.ceil(e)}t.exports=function(e){var t,r,i,o,a,l,c=e.toWidth/e.width,h=e.toHeight/e.height,u=n(e.srcTileSize*c)-2*e.destTileBorder,d=n(e.srcTileSize*h)-2*e.destTileBorder;if(u<1||d<1)throw new Error("Internal error in pica: target tile width/height is too small.");var p,f=[];for(o=0;o<e.toHeight;o+=d)for(i=0;i<e.toWidth;i+=u)(t=i-e.destTileBorder)<0&&(t=0),t+(a=i+u+e.destTileBorder-t)>=e.toWidth&&(a=e.toWidth-t),(r=o-e.destTileBorder)<0&&(r=0),r+(l=o+d+e.destTileBorder-r)>=e.toHeight&&(l=e.toHeight-r),p={toX:t,toY:r,toWidth:a,toHeight:l,toInnerX:i,toInnerY:o,toInnerWidth:u,toInnerHeight:d,offsetX:t/c-n(t/c),offsetY:r/h-n(r/h),scaleX:c,scaleY:h,x:n(t/c),y:n(r/h),width:s(a/c),height:s(l/h)},f.push(p);return f}},{}],16:[function(e,t,r){function i(e){return Object.prototype.toString.call(e)}t.exports.isCanvas=function(e){var t=i(e);return"[object HTMLCanvasElement]"===t||"[object OffscreenCanvas]"===t||"[object Canvas]"===t},t.exports.isImage=function(e){return"[object HTMLImageElement]"===i(e)},t.exports.isImageBitmap=function(e){return"[object ImageBitmap]"===i(e)},t.exports.limiter=function(e){var t=0,r=[];function i(){t<e&&r.length&&(t++,r.shift()())}return function(e){return new Promise((function(n,s){r.push((function(){e().then((function(e){n(e),t--,i()}),(function(e){s(e),t--,i()}))})),i()}))}},t.exports.cib_quality_name=function(e){switch(e){case 0:return"pixelated";case 1:return"low";case 2:return"medium"}return"high"},t.exports.cib_support=function(e){return Promise.resolve().then((function(){if("undefined"==typeof createImageBitmap)return!1;var t=e(100,100);return createImageBitmap(t,0,0,100,100,{resizeWidth:10,resizeHeight:10,resizeQuality:"high"}).then((function(e){var r=10===e.width;return e.close(),t=null,r}))})).catch((function(){return!1}))},t.exports.worker_offscreen_canvas_support=function(){return new Promise((function(e,t){if("undefined"!=typeof OffscreenCanvas){var r=btoa("(".concat(n.toString(),")(self);")),i=new Worker("data:text/javascript;base64,".concat(r));i.onmessage=function(t){return e(t.data)},i.onerror=t}else e(!1);function n(e){"undefined"!=typeof createImageBitmap?Promise.resolve().then((function(){var e=new OffscreenCanvas(10,10);return e.getContext("2d").rect(0,0,1,1),createImageBitmap(e,0,0,1,1)})).then((function(){return e.postMessage(!0)}),(function(){return e.postMessage(!1)})):e.postMessage(!1)}})).then((function(e){return e}),(function(){return!1}))},t.exports.can_use_canvas=function(e){var t=!1;try{var r=e(2,1).getContext("2d"),i=r.createImageData(2,1);i.data[0]=12,i.data[1]=23,i.data[2]=34,i.data[3]=255,i.data[4]=45,i.data[5]=56,i.data[6]=67,i.data[7]=255,r.putImageData(i,0,0),i=null,12===(i=r.getImageData(0,0,2,1)).data[0]&&23===i.data[1]&&34===i.data[2]&&255===i.data[3]&&45===i.data[4]&&56===i.data[5]&&67===i.data[6]&&255===i.data[7]&&(t=!0)}catch(e){}return t},t.exports.cib_can_use_region=function(){return new Promise((function(e){if("undefined"!=typeof createImageBitmap){var t=new Image;t.src="data:image/jpeg;base64,/9j/4QBiRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAYAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAAAAABIAAAAAQAAAEgAAAAB/9sAQwAEAwMEAwMEBAMEBQQEBQYKBwYGBgYNCQoICg8NEBAPDQ8OERMYFBESFxIODxUcFRcZGRsbGxAUHR8dGh8YGhsa/9sAQwEEBQUGBQYMBwcMGhEPERoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoaGhoa/8IAEQgAAQACAwERAAIRAQMRAf/EABQAAQAAAAAAAAAAAAAAAAAAAAf/xAAUAQEAAAAAAAAAAAAAAAAAAAAA/9oADAMBAAIQAxAAAAF/P//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAQUCf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Bf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Bf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEABj8Cf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8hf//aAAwDAQACAAMAAAAQH//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQMBAT8Qf//EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQIBAT8Qf//EABQQAQAAAAAAAAAAAAAAAAAAAAD/2gAIAQEAAT8Qf//Z",t.onload=function(){createImageBitmap(t,0,0,t.width,t.height).then((function(r){r.width===t.width&&r.height===t.height?e(!0):e(!1)}),(function(){return e(!1)}))},t.onerror=function(){return e(!1)}}else e(!1)}))}},{}],17:[function(e,t,r){t.exports=function(){var t,r=e("./mathlib");onmessage=function(e){var i=e.data.opts,n=!1;if(!i.src&&i.srcBitmap){var s=new OffscreenCanvas(i.width,i.height),o=s.getContext("2d",{alpha:Boolean(i.alpha)});o.drawImage(i.srcBitmap,0,0),i.src=o.getImageData(0,0,i.width,i.height).data,s.width=s.height=0,s=null,i.srcBitmap.close(),i.srcBitmap=null,n=!0}t||(t=new r(e.data.features));var a=t.resizeAndUnsharp(i);if(n){var l=new ImageData(new Uint8ClampedArray(a),i.toWidth,i.toHeight),c=new OffscreenCanvas(i.toWidth,i.toHeight);c.getContext("2d",{alpha:Boolean(i.alpha)}).putImageData(l,0,0),createImageBitmap(c).then((function(e){postMessage({bitmap:e},[e])}))}else postMessage({data:a},[a.buffer])}}},{"./mathlib":1}],18:[function(e,t,r){var i,n,s,o,a,l;function c(e){e<.5&&(e=.5);var t=Math.exp(.527076)/e,r=Math.exp(-t),c=Math.exp(-2*t),h=(1-r)*(1-r)/(1+2*t*r-c);return i=h,n=h*(t-1)*r,s=h*(t+1)*r,o=-h*c,a=2*r,l=-c,new Float32Array([i,n,s,o,a,l,(i+n)/(1-a-l),(s+o)/(1-a-l)])}function h(e,t,r,i,n,s){var o,a,l,c,h,u,d,p,f,m,g,v,y,A;for(f=0;f<s;f++){for(d=f,p=0,c=h=(o=e[u=f*n])*i[6],g=i[0],v=i[1],y=i[4],A=i[5],m=0;m<n;m++)l=(a=e[u])*g+o*v+c*y+h*A,h=c,c=l,o=a,r[p]=c,p++,u++;for(p--,d+=s*(n-1),c=h=(o=e[--u])*i[7],a=o,g=i[2],v=i[3],m=n-1;m>=0;m--)l=a*g+o*v+c*y+h*A,h=c,c=l,o=a,a=e[u],t[d]=r[p]+c,u--,p--,d-=s}}function u(e,t,r,i){if(i){var n=new Uint16Array(e.length),s=new Float32Array(Math.max(t,r)),o=c(i);h(e,n,s,o,t,r),h(n,e,s,o,r,t)}}t.exports=u},{}],19:[function(e,t,r){"function"==typeof Object.create?t.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},{}],20:[function(e,t,r){var i=e("object-assign"),n=e("./lib/base64decode"),s=e("./lib/wa_detect"),o={js:!0,wasm:!0};function a(e){if(!(this instanceof a))return new a(e);var t=i({},o,e||{});if(this.options=t,this.__cache={},this.__init_promise=null,this.__modules=t.modules||{},this.__memory=null,this.__wasm={},this.__isLE=1===new Uint32Array(new Uint8Array([1,0,0,0]).buffer)[0],!this.options.js&&!this.options.wasm)throw new Error('mathlib: at least "js" or "wasm" should be enabled')}a.prototype.has_wasm=s,a.prototype.use=function(e){return this.__modules[e.name]=e,this.options.wasm&&this.has_wasm()&&e.wasm_fn?this[e.name]=e.wasm_fn:this[e.name]=e.fn,this},a.prototype.init=function(){if(this.__init_promise)return this.__init_promise;if(!this.options.js&&this.options.wasm&&!this.has_wasm())return Promise.reject(new Error('mathlib: only "wasm" was enabled, but it\'s not supported'));var e=this;return this.__init_promise=Promise.all(Object.keys(e.__modules).map((function(t){var r=e.__modules[t];return e.options.wasm&&e.has_wasm()&&r.wasm_fn?e.__wasm[t]?null:WebAssembly.compile(e.__base64decode(r.wasm_src)).then((function(r){e.__wasm[t]=r})):null}))).then((function(){return e})),this.__init_promise},a.prototype.__base64decode=n,a.prototype.__reallocate=function(e){if(!this.__memory)return this.__memory=new WebAssembly.Memory({initial:Math.ceil(e/65536)}),this.__memory;var t=this.__memory.buffer.byteLength;return t<e&&this.__memory.grow(Math.ceil((e-t)/65536)),this.__memory},a.prototype.__instance=function(e,t,r){if(t&&this.__reallocate(t),!this.__wasm[e]){var n=this.__modules[e];this.__wasm[e]=new WebAssembly.Module(this.__base64decode(n.wasm_src))}if(!this.__cache[e]){var s={memoryBase:0,memory:this.__memory,tableBase:0,table:new WebAssembly.Table({initial:0,element:"anyfunc"})};this.__cache[e]=new WebAssembly.Instance(this.__wasm[e],{env:i(s,r||{})})}return this.__cache[e]},a.prototype.__align=function(e,t){var r=e%(t=t||8);return e+(r?t-r:0)},t.exports=a},{"./lib/base64decode":21,"./lib/wa_detect":22,"object-assign":23}],21:[function(e,t,r){var i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";t.exports=function(e){for(var t=e.replace(/[\r\n=]/g,""),r=t.length,n=new Uint8Array(3*r>>2),s=0,o=0,a=0;a<r;a++)a%4==0&&a&&(n[o++]=s>>16&255,n[o++]=s>>8&255,n[o++]=255&s),s=s<<6|i.indexOf(t.charAt(a));var l=r%4*6;return 0===l?(n[o++]=s>>16&255,n[o++]=s>>8&255,n[o++]=255&s):18===l?(n[o++]=s>>10&255,n[o++]=s>>2&255):12===l&&(n[o++]=s>>4&255),n}},{}],22:[function(e,t,r){var i;t.exports=function(){if(void 0!==i)return i;if(i=!1,"undefined"==typeof WebAssembly)return i;try{var e=new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,127,1,127,3,2,1,0,5,3,1,0,1,7,8,1,4,116,101,115,116,0,0,10,16,1,14,0,32,0,65,1,54,2,0,32,0,40,2,0,11]),t=new WebAssembly.Module(e);return 0!==new WebAssembly.Instance(t,{}).exports.test(4)&&(i=!0),i}catch(e){}return i}},{}],23:[function(e,t,r){var i=Object.getOwnPropertySymbols,n=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable;function o(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}function a(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach((function(e){i[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},i)).join("")}catch(e){return!1}}t.exports=a()?Object.assign:function(e,t){for(var r,a,l=o(e),c=1;c<arguments.length;c++){for(var h in r=Object(arguments[c]))n.call(r,h)&&(l[h]=r[h]);if(i){a=i(r);for(var u=0;u<a.length;u++)s.call(r,a[u])&&(l[a[u]]=r[a[u]])}}return l}},{}],24:[function(e,t,r){var i=arguments[3],n=arguments[4],s=arguments[5],o=JSON.stringify;t.exports=function(e,t){for(var r,a=Object.keys(s),l=0,c=a.length;l<c;l++){var h=a[l],u=s[h].exports;if(u===e||u&&u.default===e){r=h;break}}if(!r){r=Math.floor(Math.pow(16,8)*Math.random()).toString(16);var d={};for(l=0,c=a.length;l<c;l++)d[h=a[l]]=h;n[r]=["function(require,module,exports){"+e+"(self); }",d]}var p=Math.floor(Math.pow(16,8)*Math.random()).toString(16),f={};f[r]=r,n[p]=["function(require,module,exports){var f = require("+o(r)+");(f.default ? f.default : f)(self);}",f];var m={};function g(e){for(var t in m[e]=!0,n[e][1]){var r=n[e][1][t];m[r]||g(r)}}g(p);var v="("+i+")({"+Object.keys(m).map((function(e){return o(e)+":["+n[e][0]+","+o(n[e][1])+"]"})).join(",")+"},{},["+o(p)+"])",y=window.URL||window.webkitURL||window.mozURL||window.msURL,A=new Blob([v],{type:"text/javascript"});if(t&&t.bare)return A;var w=y.createObjectURL(A),x=new Worker(w);return x.objectURL=w,x}},{}],"/index.js":[function(e,t,r){function i(e,t){return l(e)||a(e,t)||s(e,t)||n()}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function s(e,t){if(e){if("string"==typeof e)return o(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,i=new Array(t);r<t;r++)i[r]=e[r];return i}function a(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var i,n,s=[],o=!0,a=!1;try{for(r=r.call(e);!(o=(i=r.next()).done)&&(s.push(i.value),!t||s.length!==t);o=!0);}catch(e){a=!0,n=e}finally{try{o||null==r.return||r.return()}finally{if(a)throw n}}return s}}function l(e){if(Array.isArray(e))return e}var c=e("object-assign"),h=e("webworkify"),u=e("./lib/mathlib"),d=e("./lib/pool"),p=e("./lib/utils"),f=e("./lib/worker"),m=e("./lib/stepper"),g=e("./lib/tiler"),v={},y=!1;try{"undefined"!=typeof navigator&&navigator.userAgent&&(y=navigator.userAgent.indexOf("Safari")>=0)}catch(e){}var A=1;"undefined"!=typeof navigator&&(A=Math.min(navigator.hardwareConcurrency||1,4));var w={tile:1024,concurrency:A,features:["js","wasm","ww"],idle:2e3,createCanvas:function(e,t){var r=document.createElement("canvas");return r.width=e,r.height=t,r}},x={quality:3,alpha:!1,unsharpAmount:0,unsharpRadius:0,unsharpThreshold:0},b=!1,S=!1,E=!1,C=!1,T=!1;function O(){return{value:h(f),destroy:function(){if(this.value.terminate(),"undefined"!=typeof window){var e=window.URL||window.webkitURL||window.mozURL||window.msURL;e&&e.revokeObjectURL&&this.value.objectURL&&e.revokeObjectURL(this.value.objectURL)}}}}function D(e){if(!(this instanceof D))return new D(e);this.options=c({},w,e||{});var t="lk_".concat(this.options.concurrency);this.__limit=v[t]||p.limiter(this.options.concurrency),v[t]||(v[t]=this.__limit),this.features={js:!1,wasm:!1,cib:!1,ww:!1},this.__workersPool=null,this.__requested_features=[],this.__mathlib=null}D.prototype.init=function(){var t=this;if(this.__initPromise)return this.__initPromise;if("undefined"!=typeof ImageData&&"undefined"!=typeof Uint8ClampedArray)try{new ImageData(new Uint8ClampedArray(400),10,10),b=!0}catch(e){}"undefined"!=typeof ImageBitmap&&(ImageBitmap.prototype&&ImageBitmap.prototype.close?S=!0:this.debug("ImageBitmap does not support .close(), disabled"));var r=this.options.features.slice();if(r.indexOf("all")>=0&&(r=["cib","wasm","js","ww"]),this.__requested_features=r,this.__mathlib=new u(r),r.indexOf("ww")>=0&&"undefined"!=typeof window&&"Worker"in window)try{e("webworkify")((function(){})).terminate(),this.features.ww=!0;var i="wp_".concat(JSON.stringify(this.options));v[i]?this.__workersPool=v[i]:(this.__workersPool=new d(O,this.options.idle),v[i]=this.__workersPool)}catch(e){}var n,s,o=this.__mathlib.init().then((function(e){c(t.features,e.features)}));n=S?p.cib_support(this.options.createCanvas).then((function(e){t.features.cib&&r.indexOf("cib")<0?t.debug("createImageBitmap() resize supported, but disabled by config"):r.indexOf("cib")>=0&&(t.features.cib=e)})):Promise.resolve(!1),E=p.can_use_canvas(this.options.createCanvas),s=(s=S&&b&&-1!==r.indexOf("ww")?p.worker_offscreen_canvas_support():Promise.resolve(!1)).then((function(e){C=e}));var a=p.cib_can_use_region().then((function(e){T=e}));return this.__initPromise=Promise.all([o,n,s,a]).then((function(){return t})),this.__initPromise},D.prototype.__invokeResize=function(e,t){var r=this;return t.__mathCache=t.__mathCache||{},Promise.resolve().then((function(){return r.features.ww?new Promise((function(i,n){var s=r.__workersPool.acquire();t.cancelToken&&t.cancelToken.catch((function(e){return n(e)})),s.value.onmessage=function(e){s.release(),e.data.err?n(e.data.err):i(e.data)};var o=[];e.src&&o.push(e.src.buffer),e.srcBitmap&&o.push(e.srcBitmap),s.value.postMessage({opts:e,features:r.__requested_features,preload:{wasm_nodule:r.__mathlib.__}},o)})):{data:r.__mathlib.resizeAndUnsharp(e,t.__mathCache)}}))},D.prototype.__extractTileData=function(e,t,r,i,n){if(this.features.ww&&C&&(p.isCanvas(t)||T))return this.debug("Create tile for OffscreenCanvas"),createImageBitmap(i.srcImageBitmap||t,e.x,e.y,e.width,e.height).then((function(e){return n.srcBitmap=e,n}));if(p.isCanvas(t))return i.srcCtx||(i.srcCtx=t.getContext("2d",{alpha:Boolean(r.alpha)})),this.debug("Get tile pixel data"),n.src=i.srcCtx.getImageData(e.x,e.y,e.width,e.height).data,n;this.debug("Draw tile imageBitmap/image to temporary canvas");var s=this.options.createCanvas(e.width,e.height),o=s.getContext("2d",{alpha:Boolean(r.alpha)});return o.globalCompositeOperation="copy",o.drawImage(i.srcImageBitmap||t,e.x,e.y,e.width,e.height,0,0,e.width,e.height),this.debug("Get tile pixel data"),n.src=o.getImageData(0,0,e.width,e.height).data,s.width=s.height=0,n},D.prototype.__landTileData=function(e,t,r){var i;if(this.debug("Convert raw rgba tile result to ImageData"),t.bitmap)return r.toCtx.drawImage(t.bitmap,e.toX,e.toY),null;if(b)i=new ImageData(new Uint8ClampedArray(t.data),e.toWidth,e.toHeight);else if((i=r.toCtx.createImageData(e.toWidth,e.toHeight)).data.set)i.data.set(t.data);else for(var n=i.data.length-1;n>=0;n--)i.data[n]=t.data[n];return this.debug("Draw tile"),y?r.toCtx.putImageData(i,e.toX,e.toY,e.toInnerX-e.toX,e.toInnerY-e.toY,e.toInnerWidth+1e-5,e.toInnerHeight+1e-5):r.toCtx.putImageData(i,e.toX,e.toY,e.toInnerX-e.toX,e.toInnerY-e.toY,e.toInnerWidth,e.toInnerHeight),null},D.prototype.__tileAndResize=function(e,t,r){var i=this,n={srcCtx:null,srcImageBitmap:null,isImageBitmapReused:!1,toCtx:null},s=function(t){return i.__limit((function(){if(r.canceled)return r.cancelToken;var s={width:t.width,height:t.height,toWidth:t.toWidth,toHeight:t.toHeight,scaleX:t.scaleX,scaleY:t.scaleY,offsetX:t.offsetX,offsetY:t.offsetY,quality:r.quality,alpha:r.alpha,unsharpAmount:r.unsharpAmount,unsharpRadius:r.unsharpRadius,unsharpThreshold:r.unsharpThreshold};return i.debug("Invoke resize math"),Promise.resolve(s).then((function(s){return i.__extractTileData(t,e,r,n,s)})).then((function(e){return i.debug("Invoke resize math"),i.__invokeResize(e,r)})).then((function(e){return r.canceled?r.cancelToken:(n.srcImageData=null,i.__landTileData(t,e,n))}))}))};return Promise.resolve().then((function(){if(n.toCtx=t.getContext("2d",{alpha:Boolean(r.alpha)}),p.isCanvas(e))return null;if(p.isImageBitmap(e))return n.srcImageBitmap=e,n.isImageBitmapReused=!0,null;if(p.isImage(e))return S?(i.debug("Decode image via createImageBitmap"),createImageBitmap(e).then((function(e){n.srcImageBitmap=e})).catch((function(e){return null}))):null;throw new Error('Pica: ".from" should be Image, Canvas or ImageBitmap')})).then((function(){if(r.canceled)return r.cancelToken;i.debug("Calculate tiles");var e=g({width:r.width,height:r.height,srcTileSize:i.options.tile,toWidth:r.toWidth,toHeight:r.toHeight,destTileBorder:r.__destTileBorder}).map((function(e){return s(e)}));function o(e){e.srcImageBitmap&&(e.isImageBitmapReused||e.srcImageBitmap.close(),e.srcImageBitmap=null)}return i.debug("Process tiles"),Promise.all(e).then((function(){return i.debug("Finished!"),o(n),t}),(function(e){throw o(n),e}))}))},D.prototype.__processStages=function(e,t,r,n){var s=this;if(n.canceled)return n.cancelToken;var o,a=i(e.shift(),2),l=a[0],h=a[1],u=0===e.length;return n=c({},n,{toWidth:l,toHeight:h,quality:u?n.quality:Math.min(1,n.quality)}),u||(o=this.options.createCanvas(l,h)),this.__tileAndResize(t,u?r:o,n).then((function(){return u?r:(n.width=l,n.height=h,s.__processStages(e,o,r,n))})).then((function(e){return o&&(o.width=o.height=0),e}))},D.prototype.__resizeViaCreateImageBitmap=function(e,t,r){var i=this,n=t.getContext("2d",{alpha:Boolean(r.alpha)});return this.debug("Resize via createImageBitmap()"),createImageBitmap(e,{resizeWidth:r.toWidth,resizeHeight:r.toHeight,resizeQuality:p.cib_quality_name(r.quality)}).then((function(e){if(r.canceled)return r.cancelToken;if(!r.unsharpAmount)return n.drawImage(e,0,0),e.close(),n=null,i.debug("Finished!"),t;i.debug("Unsharp result");var s=i.options.createCanvas(r.toWidth,r.toHeight),o=s.getContext("2d",{alpha:Boolean(r.alpha)});o.drawImage(e,0,0),e.close();var a=o.getImageData(0,0,r.toWidth,r.toHeight);return i.__mathlib.unsharp_mask(a.data,r.toWidth,r.toHeight,r.unsharpAmount,r.unsharpRadius,r.unsharpThreshold),n.putImageData(a,0,0),s.width=s.height=0,a=o=s=n=null,i.debug("Finished!"),t}))},D.prototype.resize=function(e,t,r){var i=this;this.debug("Start resize...");var n=c({},x);if(isNaN(r)?r&&(n=c(n,r)):n=c(n,{quality:r}),n.toWidth=t.width,n.toHeight=t.height,n.width=e.naturalWidth||e.width,n.height=e.naturalHeight||e.height,0===t.width||0===t.height)return Promise.reject(new Error("Invalid output size: ".concat(t.width,"x").concat(t.height)));n.unsharpRadius>2&&(n.unsharpRadius=2),n.canceled=!1,n.cancelToken&&(n.cancelToken=n.cancelToken.then((function(e){throw n.canceled=!0,e}),(function(e){throw n.canceled=!0,e})));var s=3;return n.__destTileBorder=Math.ceil(Math.max(s,2.5*n.unsharpRadius|0)),this.init().then((function(){if(n.canceled)return n.cancelToken;if(i.features.cib)return i.__resizeViaCreateImageBitmap(e,t,n);if(!E){var r=new Error("Pica: cannot use getImageData on canvas, make sure fingerprinting protection isn't enabled");throw r.code="ERR_GET_IMAGE_DATA",r}var s=m(n.width,n.height,n.toWidth,n.toHeight,i.options.tile,n.__destTileBorder);return i.__processStages(s,e,t,n)}))},D.prototype.resizeBuffer=function(e){var t=this,r=c({},x,e);return this.init().then((function(){return t.__mathlib.resizeAndUnsharp(r)}))},D.prototype.toBlob=function(e,t,r){return t=t||"image/png",new Promise((function(i){if(e.toBlob)e.toBlob((function(e){return i(e)}),t,r);else if(e.convertToBlob)i(e.convertToBlob({type:t,quality:r}));else{for(var n=atob(e.toDataURL(t,r).split(",")[1]),s=n.length,o=new Uint8Array(s),a=0;a<s;a++)o[a]=n.charCodeAt(a);i(new Blob([o],{type:t}))}}))},D.prototype.debug=function(){},t.exports=D},{"./lib/mathlib":1,"./lib/pool":13,"./lib/stepper":14,"./lib/tiler":15,"./lib/utils":16,"./lib/worker":17,"object-assign":23,webworkify:24}]},{},[])("/index.js")}));!function(e){e[e.TEXT=0]="TEXT",e[e.ARRAY_BUFFER=1]="ARRAY_BUFFER",e[e.BINARY_STRING=2]="BINARY_STRING"}(Xo||(Xo={}));const Ko=e=>class{constructor(r=t.DefaultLoadingManager){this.manager=r,this.loader=new e(r)}};function qo(e){!function(e){var t;if(void 0!==e)for(const r of e)if(void 0!==(null===(t=r.userData)||void 0===t?void 0:t.type)){const e=r.userData.parameters;"extrudeDepth"in e||Object.assign(e,{extrudeDepth:0}),"extrudeBevelSize"in e||Object.assign(e,{extrudeBevelSize:0}),"extrudeBevelSegments"in e||Object.assign(e,{extrudeBevelSegments:1})}}(e.geometries),function(e){if(void 0!==e)for(const r of e)if(void 0!==r.quaternion){const e=(new t.Quaternion).fromArray(r.quaternion);Object.assign(r,{rotation:(new t.Euler).setFromQuaternion(e).toArray()})}}(e.interactionStates),Zo(e.object),function(e){if(void 0!==e)for(const t of e){let e=t.userData.layers.head;for(;e;){for(const t in e.uniforms){const r=`f${e.id}_tex`,i=`f${e.id}_texture`;t===r&&(e.uniforms[i]=e.uniforms[r],delete e.uniforms[r])}e=e.next}}}(e.materials)}function Zo(e){var r,i,n,s;if(void 0===(null===(r=e.userData)||void 0===r?void 0:r.type))if("OrthographicCamera"===e.type||"PerspectiveCamera"===e.type){const r=e;Object.assign(e,{objectType:"CombinedCamera",cameraType:r.type,isDefaultCamera:!0,hiddenMatrix:(new t.Matrix4).toArray(),name:"Default Camera",far:1e5,zoomOrtho:r.zoom,zoomPersp:1,nearOrtho:-5e4,nearPersp:50}),delete e.type,void 0!==r.typeCamera&&(Object.assign(e,{cameraType:r.typeCamera}),delete e.typeCamera)}else"Scene"===e.type?(Object.assign(e,{objectType:e.type}),delete e.type):"HemisphereLight"===e.type?Object.assign(e,{isDefaultAmbientLight:!0}):"DirectionalLight"===e.type&&Object.assign(e,{isDefaultDirectionalLight:!0});if(void 0!==e.userData){const r=e.userData;void 0!==r.type&&(Object.assign(e,{objectType:r.type}),delete r.type),void 0!==r.interaction&&(Object.assign(e,{interaction:r.interaction}),delete r.interaction),!0===r.isDefaultAmbientLight?(Object.assign(e,{isDefaultAmbientLight:!0}),delete r.isDefaultAmbientLight):!0===r.isDefaultDirectionalLight?(Object.assign(e,{isDefaultDirectionalLight:!0}),delete r.isDefaultDirectionalLight):!0===r.isDefaultCamera&&(Object.assign(e,{isDefaultCamera:!0}),delete r.isDefaultCamera),Object.assign(e,{raycastLock:r.lock,scaleLock:r.scaleLock,hiddenMatrix:null!==(n=null===(i=r.hiddenMatrix)||void 0===i?void 0:i.elements)&&void 0!==n?n:(new t.Matrix4).toArray()}),delete r.lock,delete r.scaleLock,delete r.hiddenMatrix,delete r.isEntity}if(void 0!==(null===(s=e.interaction)||void 0===s?void 0:s.events))for(const t of e.interaction.events)if(void 0!==t.targets)for(const e of t.targets)void 0!==e.springControls&&(Object.assign(e,{springParameters:{mass:e.springControls[0],stiffness:e.springControls[1],damping:e.springControls[2],velocity:e.springControls[3]}}),delete e.springControls);if(void 0!==e.children)for(const t of e.children)Zo(t)}function $o(e){ea(e.object,e.object)}function ea(e,t){var r;if("HemisphereLight"===e.type||!0===e.isDefaultAmbientLight?t.ambientLight=e.uuid:!0===(null===(r=e.userData)||void 0===r?void 0:r.isDefaultDirectionalLight)||!0===e.isDefaultDirectionalLight?t.directionalLight=e.uuid:!0===e.isDefaultCamera&&(t.camera=e.uuid,t.activeCamera=e.uuid,Object.assign(e,{name:"Default Camera"})),void 0!==e.children)for(const r of e.children)ea(r,t)}function ta(e){!function(e){var r,i,n,s,o,a,l;if("Scene"===e.objectType){const c=e.userData,h=null!==(r=c.rgb)&&void 0!==r?r:{r:25,g:25,b:25},u=null!==(i=c.fogColor)&&void 0!==i?i:{r:25,g:25,b:25};Object.assign(e,{color:[h.r/255,h.g/255,h.b/255],alpha:c.alpha,enableFog:c.fogEnable,fogUseBGColor:c.fogUseBGColor,fog:{color:(new t.Color).setRGB(u.r/255,u.g/255,u.b/255).getHex(),near:c.fogNear,far:c.fogFar},directionalLightState:c.directionalLightState,ambientLightState:c.ambientLightState,shadowsState:c.shadowsState,wireframeState:c.wireframeState,canvas:{mode:null!==(n=c.canvasMode)&&void 0!==n?n:1,size:{width:null!==(o=null===(s=c.canvasCustomSize)||void 0===s?void 0:s.width)&&void 0!==o?o:512,height:null!==(l=null===(a=c.canvasCustomSize)||void 0===a?void 0:a.height)&&void 0!==l?l:512}}}),delete c.rgb,delete c.alpha,delete c.fogEnable,delete c.fogUseBGColor,delete c.fogColor,delete c.fogNear,delete c.fogFar,delete c.directionalLightState,delete c.ambientLightState,delete c.shadowsState,delete c.wireframeState,delete c.canvasMode,delete c.canvasFullScreen,delete c.canvasCustomSize}}(e.object)}function ra(e,r){const i=(new t.Color).set(e);return{uuid:t.MathUtils.generateUUID(),type:"c",r:i.r,g:i.g,b:i.b,value:e,alpha:null==r?void 0:r.uuid,nodeType:"Color"}}function ia(e){return{uuid:t.MathUtils.generateUUID(),type:"f",value:e,nodeType:"Float"}}function na(e){return{uuid:t.MathUtils.generateUUID(),type:"i",value:e,nodeType:"Int"}}function sa(e){const{x:r,y:i}=e;return{uuid:t.MathUtils.generateUUID(),type:"v2",x:r,y:i,nodeType:"Vector2"}}function oa(e){const{x:r,y:i,z:n}=e;return{uuid:t.MathUtils.generateUUID(),type:"v3",x:r,y:i,z:n,nodeType:"Vector3"}}function aa(e,r){const i={uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"Blend",a:null==e?void 0:e.uuid,b:r.uuid};return"mode"in r&&(i.mode=r.mode),i}function la(e,t){const r=e.uniforms,i=e.id,n=na(r[`f${i}_mode`].value),s=ia(r[`f${i}_alpha`].value),o=ra(r[`f${i}_color`].value,s);return[o,s,n].forEach((e=>t[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${i}_color`]:o.uuid,[`f${i}_alpha`]:s.uuid,[`f${i}_mode`]:n.uuid}}),o}function ca(e,r){const i=e.uniforms,n=e.id,s=na(i[`f${n}_mode`].value),o=ia(i[`f${n}_alpha`].value),a=na(i[`f${n}_gl_type`].value),l=na(i[`f${n}_num`].value),c=(h=i[`f${n}_smooth`].value,{uuid:t.MathUtils.generateUUID(),type:"b",value:h,nodeType:"Bool"});var h;const u=function(e,r){return{uuid:t.MathUtils.generateUUID(),type:"v4[]",size:e,value:r,nodeType:"Vector4Array"}}(10,i[`f${n}_colors`].value),d=function(e,r){return{uuid:t.MathUtils.generateUUID(),type:"f[]",size:e,value:r,nodeType:"FloatArray"}}(10,i[`f${n}_steps`].value),p=sa(i[`f${n}_offset`].value),f=sa(i[`f${n}_morph`].value),m=ia(i[`f${n}_angle`].value);return[a,l,c,u,d,p,f,m,o,s].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_gl_type`]:a.uuid,[`f${n}_num`]:l.uuid,[`f${n}_smooth`]:c.uuid,[`f${n}_colors`]:u.uuid,[`f${n}_steps`]:d.uuid,[`f${n}_offset`]:p.uuid,[`f${n}_morph`]:f.uuid,[`f${n}_angle`]:m.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"Gradient",gl_type:a.uuid,num:l.uuid,smooth:c.uuid,colors:u.uuid,steps:d.uuid,offset:p.uuid,morph:f.uuid,angle:m.uuid,alpha:o.uuid,mode:s.uuid}}function ha(e,r){const i=e.uniforms,n=e.id,s=t.MathUtils.generateUUID(),o=na(i[`f${n}_mode`].value),a=ia(i[`f${n}_alpha`].value),l=ia(i[`f${n}_crop`].value),c=(h=0,{uuid:t.MathUtils.generateUUID(),type:"v2",index:h,nodeType:"UV"});var h;const u=(d=i[`f${n}_texture`].value,p=c,{uuid:t.MathUtils.generateUUID(),type:"v4",value:d,uv:p.uuid,project:!1,nodeType:"Texture"});var d,p;const f=function(e){return{uuid:t.MathUtils.generateUUID(),type:"m3",elements:e.elements,nodeType:"Matrix3"}}(i[`f${n}_mat`].value);return[u,c,f,l,a,o].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_texture`]:u.uuid,[`f${n}_mat`]:f.uuid,[`f${n}_crop`]:l.uuid,[`f${n}_alpha`]:a.uuid,[`f${n}_mode`]:o.uuid}}),{uuid:s,type:"v3",nodeType:"CustomTexture",texture:u.uuid,crop:l.uuid,alpha:a.uuid,mode:o.uuid}}function ua(e,r,i){const n=r.uniforms,s=r.id,o=ia(n[`f${s}_alpha`].value),a=na(n[`f${s}_mode`].value);return[o,a].forEach((e=>i[e.uuid]=e)),Object.assign(r,{uniforms:{[`f${s}_alpha`]:o.uuid,[`f${s}_mode`]:a.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"basic",nodeType:"Basic",shadingAlpha:o.uuid,shadingBlend:a.uuid}}const da=new t.Matrix4,pa=["RectangleGeometry","TriangleGeometry","PolygonGeometry","StarGeometry"];function fa(e){const r={};!function(e,t){if(void 0!==e)for(const r of e){const{beforeLayers:e,lightingLayer:i,afterLayers:n}=ga(r.userData.layers);if(!i){console.error("Material upgrade: could not find a ligthing layer");continue}const s=va(r,i,t);if(t[s.uuid]=s,e.length>0){let r=ya(e[0],t);t[r.uuid]=r;for(let i=1,n=e.length;i<n;++i){const n=ya(e[i],t),s=aa(r,n);t[s.uuid]=s,t[n.uuid]=n,r=s}s.color=r.uuid}if(n.length>0){let e;for(const r of n){const i=ya(r,t),n=aa(e,i);t[n.uuid]=n,t[i.uuid]=i,e=n}s.afterColor=null==e?void 0:e.uuid}Object.assign(r,{type:"ShaderMaterial",wireframeLinecap:"",wireframeLinejoin:"",vertex:null==s?void 0:s.uuid,fragment:null==s?void 0:s.uuid}),delete r.color,delete r.emissive,delete r.specular,delete r.shininess,delete r.roughness,delete r.metalness}}(e.materials,r),function(e,t){if(void 0!==e)for(const r of e)if(r.material)if(Array.isArray(r.material))for(const e of r.material)for(const r of e.layersList)ya(r,t);else for(const e of r.material.layersList)ya(e,t)}(e.interactionStates,r),function(e,r){var i;if(void 0!==e)for(const n of e)if(n.userData&&pa.includes(null===(i=n.userData)||void 0===i?void 0:i.type)){const e=n.userData.parameters,i=e.extrudeBevelSize;if(i>0){e.width+=2*i,e.height+=2*i,e.extrudeDepth+=2*i;const s=ma(r,n.uuid);if(void 0!==s){const e=new t.Object3D;da.fromArray(s.matrix),e.applyMatrix4(da),e.position.z-=i,e.updateMatrix(),s.matrix=e.matrix.toArray()}}}}(e.geometries,e.object),r!=={}&&(e.nodes=function(e){const t=[];for(const r in e)t.push(e[r]);return t}(r))}function ma(e,t){const r=e.geometry;if(r&&r===t)return e;const i=e.children;if(i)for(let e=0,r=i.length;e<r;e++){const r=ma(i[e],t);if(void 0!==r)return r}}function ga(e){const t=[],r=[];let i,n=e.head;for(;n;){if("light"===n.type){i=n,n=n.next;break}t.push(n),n=n.next}for(;n;)r.unshift(n),n=n.next;return{beforeLayers:t,lightingLayer:i,afterLayers:r}}function va(e,r,i){let n,s;switch(e.userData.type){case"BasicMaterial":n=ua(0,r,i),s="BasicNodeMaterial";break;case"PhongMaterial":n=function(e,r,i){var n,s;const o=r.uniforms,a=r.id,l=ra(null!==(n=e.specular)&&void 0!==n?n:69905),c=ia(null!==(s=e.shininess)&&void 0!==s?s:30),h=ia(o[`f${a}_alpha`].value),u=na(o[`f${a}_mode`].value);return[l,c,h,u].forEach((e=>i[e.uuid]=e)),Object.assign(r,{uniforms:{[`f${a}_alpha`]:h.uuid,[`f${a}_mode`]:u.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"phong",nodeType:"Phong",specular:l.uuid,shininess:c.uuid,shadingAlpha:h.uuid,shadingBlend:u.uuid}}(e,r,i),s="PhongNodeMaterial";break;case"LambertMaterial":n=function(e,r,i){var n,s;const o=r.uniforms,a=r.id,l=ra(null!==(n=e.emissive)&&void 0!==n?n:0),c=ia(null!==(s=e.emissiveIntensity)&&void 0!==s?s:1),h=ia(o[`f${a}_alpha`].value),u=na(o[`f${a}_mode`].value);return[c,l,h,u].forEach((e=>i[e.uuid]=e)),Object.assign(r,{uniforms:{[`f${a}_alpha`]:h.uuid,[`f${a}_mode`]:u.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"lambert",nodeType:"Lambert",emissiveIntensity:c.uuid,emissive:l.uuid,shadingAlpha:h.uuid,shadingBlend:u.uuid}}(e,r,i),s="LambertNodeMaterial";break;case"ToonMaterial":n=function(e,r,i){var n,s;const o=r.uniforms,a=r.id,l=ra(null!==(n=e.specular)&&void 0!==n?n:69905),c=ia(null!==(s=e.shininess)&&void 0!==s?s:30),h=ia(o[`f${a}_alpha`].value),u=na(o[`f${a}_mode`].value);return[l,c,h,u].forEach((e=>i[e.uuid]=e)),Object.assign(r,{uniforms:{[`f${a}_alpha`]:h.uuid,[`f${a}_mode`]:u.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"toon",nodeType:"Toon",specular:l.uuid,shininess:c.uuid,shadingAlpha:h.uuid,shadingBlend:u.uuid}}(e,r,i),s="ToonNodeMaterial";break;case"PhysicalMaterial":n=function(e,r,i){var n,s,o;const a=r.uniforms,l=r.id,c=ia(null!==(n=e.roughness)&&void 0!==n?n:.3),h=ia(null!==(s=e.metalness)&&void 0!==s?s:0),u=ia(null!==(o=e.reflectivity)&&void 0!==o?o:.5),d=ia(a[`f${l}_alpha`].value),p=na(a[`f${l}_mode`].value);return[c,h,u,d,p].forEach((e=>i[e.uuid]=e)),Object.assign(r,{uniforms:{[`f${l}_alpha`]:d.uuid,[`f${l}_mode`]:p.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"standard",nodeType:"Standard",roughness:c.uuid,metalness:h.uuid,reflectivity:u.uuid,shadingAlpha:d.uuid,shadingBlend:p.uuid}}(e,r,i),s="StandardNodeMaterial";break;default:console.warn(`Material upgrade: could not find a properly material node to ${e.userData.type}`),n=ua(0,r,i),s="BasicNodeMaterial"}return Object.assign(e.userData,{nodeType:s}),n}function ya(e,r){switch(e.type){case"light":return function(e,r){const i=e.uniforms,n=e.id,s=ia(i[`f${n}_alpha`].value),o=na(i[`f${n}_mode`].value);return[s,o].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_alpha`]:s.uuid,[`f${n}_mode`]:o.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"CustomTexture",alpha:s.uuid,mode:o.uuid}}(e,r);case"color":return la(e,r);case"depth":return function(e,r){const i=e.uniforms,n=e.id,s=na(i[`f${n}_mode`].value),o=ia(i[`f${n}_alpha`].value),a=ia(i[`f${n}_near`].value),l=ia(i[`f${n}_far`].value),c=ia(i[`f${n}_isVector`].value),h=oa(i[`f${n}_origin`].value),u=ra(i[`f${n}_colorA`].value),d=ra(i[`f${n}_colorB`].value);return[a,l,c,h,u,d,o,s].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_near`]:a.uuid,[`f${n}_far`]:l.uuid,[`f${n}_isVector`]:c.uuid,[`f${n}_origin`]:h.uuid,[`f${n}_colorA`]:u.uuid,[`f${n}_colorB`]:d.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"Depth",near:a.uuid,far:l.uuid,isVector:c.uuid,origin:h.uuid,colorA:u.uuid,colorB:d.uuid,alpha:o.uuid,mode:s.uuid}}(e,r);case"fresnel":return function(e,r){const i=e.uniforms,n=e.id,s=na(i[`f${n}_mode`].value),o=ia(i[`f${n}_alpha`].value),a=ra(i[`f${n}_color`].value),l=ia(i[`f${n}_bias`].value),c=ia(i[`f${n}_scale`].value),h=ia(i[`f${n}_intensity`].value),u=ia(i[`f${n}_factor`].value);return[a,l,c,h,u,o,s].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_color`]:a.uuid,[`f${n}_bias`]:l.uuid,[`f${n}_scale`]:c.uuid,[`f${n}_intensity`]:h.uuid,[`f${n}_factor`]:u.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"Fresnel",color:a.uuid,bias:l.uuid,scale:c.uuid,intensity:h.uuid,factor:u.uuid,alpha:o.uuid,mode:s.uuid}}(e,r);case"gradient":return ca(e,r);case"noise":return function(e,r){const i=e.uniforms,n=e.id,s=na(i[`f${n}_mode`].value),o=ia(i[`f${n}_alpha`].value),a=ia(i[`f${n}_scale`].value),l=ia(i[`f${n}_move`].value),c=sa(i[`f${n}_fA`].value),h=sa(i[`f${n}_fB`].value),u=sa(i[`f${n}_distortion`].value),d=ra(i[`f${n}_colorA`].value),p=ra(i[`f${n}_colorB`].value),f=ra(i[`f${n}_colorC`].value),m=ra(i[`f${n}_colorD`].value),g=na(i[`f${n}_intA`].value),v=na(i[`f${n}_intB`].value),y=na(i[`f${n}_intC`].value),A=na(i[`f${n}_intD`].value);return[a,l,c,h,u,d,p,f,m,g,v,y,A,o,s].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_scale`]:a.uuid,[`f${n}_move`]:l.uuid,[`f${n}_fA`]:c.uuid,[`f${n}_fB`]:h.uuid,[`f${n}_distortion`]:u.uuid,[`f${n}_colorA`]:d.uuid,[`f${n}_colorB`]:p.uuid,[`f${n}_colorC`]:f.uuid,[`f${n}_colorD`]:m.uuid,[`f${n}_intA`]:g.uuid,[`f${n}_intB`]:v.uuid,[`f${n}_intC`]:y.uuid,[`f${n}_intD`]:A.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"Noise",scale:a.uuid,move:l.uuid,fA:c.uuid,fB:h.uuid,distortion:u.uuid,colorA:d.uuid,colorB:p.uuid,colorC:f.uuid,colorD:m.uuid,intA:g.uuid,intB:v.uuid,intC:y.uuid,intD:A.uuid,alpha:o.uuid,mode:s.uuid}}(e,r);case"normal":return function(e,r){const i=e.uniforms,n=e.id,s=na(i[`f${n}_mode`].value),o=ia(i[`f${n}_alpha`].value),a=oa(i[`f${n}_cnormal`].value);return[a,o,s].forEach((e=>r[e.uuid]=e)),Object.assign(e,{uniforms:{[`f${n}_cnormal`]:a.uuid,[`f${n}_alpha`]:o.uuid,[`f${n}_mode`]:s.uuid}}),{uuid:t.MathUtils.generateUUID(),type:"v3",nodeType:"CustomNormal",cnormal:a.uuid,alpha:o.uuid,mode:s.uuid}}(e,r);case"texture":return ha(e,r);default:return console.warn(`Material upgrade: could not find a properly "layer" node to ${e.type}`),la(e,r)}}function Aa(e){const t=e.metadata;return console.info(`File format version ${null==t?void 0:t.version}`),void 0===(null==t?void 0:t.version)?(console.warn("Unknow file version"),!1):((t.version<=1.1||4.5===t.version)&&(qo(e),t.version=1.2,console.warn("File upgraded from v1.1 or inferior to v1.2")),1.2===t.version&&($o(e),t.version=1.3,console.warn("File upgraded from v1.2 to v1.3")),1.3===t.version&&(ta(e),t.version=1.4,console.warn("File upgraded from v1.3 to v1.4")),1.4===t.version&&(fa(e),t.version=1.5,console.warn("File upgraded from v1.4 to v1.5")),!0)}class wa extends jn{constructor(e=We.create({}),t=new Or){super(e,t),this.objectType="SubdivObject",this.resized=!1,this.addToCheckpoints=!1,this.castShadow=!0,this.receiveShadow=!0,this.forceComputeSize=!1,this.subdivPointer=We.activeSubdivPtr}toJSON(e){const t=super.toJSON(e);return t.object.objectType="SubdivObject",t}updateGeometry(e){const t=this.geometry,r=Xe[t.userData.type],i="SubdivObject"===this.objectType?Object.assign({},t.userData,{geometry:t,subdivPointer:this.subdivPointer,smoothShading:this.smoothShading}):t.userData,n=r.build(r.normalizeInputs(e,i));this.geometry.dispose(),this.geometry=n}clone(e){var t,r;const i=this.material.clone(),n=We.clone(Object.assign({},this.geometry.userData.parameters),this.subdivPointer,this.smoothShading),s=null!==(t=this.geometry.originalGeometry)&&void 0!==t?t:this.geometry;return(null!==(r=n.originalGeometry)&&void 0!==r?r:n).boundingSphere=s.boundingSphere.clone(),this.subdivPointer=We.activeSubdivPtr,new wa(n,i).copy(this,e)}}var xa;!function(e){e.EQUAL="==",e.NOT_EQUAL="!=",e.GREATER=">",e.GREATER_EQUAL=">=",e.LESS="<",e.LESS_EQUAL="<=",e.AND="&&",e.OR="||"}(xa||(xa={}));class ba extends dt{constructor(e=new ut,t=new ut,r=ba.GREATER,i=new ut,n=new ut){super(),this.nodeType="Cond",this.a=e,this.b=t,this.op=r,this.ifNode=i,this.elseNode=n}getType(e){if(this.ifNode){const t=this.ifNode.getType(e),r=this.elseNode.getType(e);return e.getTypeLength(r)>e.getTypeLength(t)?r:t}return"b"}getCondType(e){return e.getTypeLength(this.b.getType(e))>e.getTypeLength(this.a.getType(e))?this.b.getType(e):this.a.getType(e)}generate(e,t){const r=this.getType(e),i=this.getCondType(e),n=this.a.build(e,i),s=this.b.build(e,i);let o;if(this.type=r,this.ifNode){const t=this.ifNode.build(e,r),i=this.elseNode.build(e,r);o="( "+[n,this.op,s,"?",t,":",i].join(" ")+" )"}else o="( "+n+" "+this.op+" "+s+" )";return e.format(o,this.getType(e),t)}copy(e){return super.copy(e),this.a.copy(e.a),this.b.copy(e.b),this.op=e.op,this.ifNode.copy(e.ifNode),this.elseNode.copy(e.elseNode),this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.a=this.a.toJSON(e).uuid,t.b=this.b.toJSON(e).uuid,t.op=this.op,this.ifNode&&(t.ifNode=this.ifNode.toJSON(e).uuid),this.elseNode&&(t.elseNode=this.elseNode.toJSON(e).uuid)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.a&&(this.a=t.getNode(e.a)),e.b&&(this.b=t.getNode(e.b)),e.op&&(this.op=e.op),e.ifNode&&(this.ifNode=t.getNode(e.ifNode)),e.elseNode&&(this.elseNode=t.getNode(e.elseNode)),this}}ba.EQUAL=xa.EQUAL,ba.NOT_EQUAL=xa.NOT_EQUAL,ba.GREATER=xa.GREATER,ba.GREATER_EQUAL=xa.GREATER_EQUAL,ba.LESS=xa.LESS,ba.LESS_EQUAL=xa.LESS_EQUAL,ba.AND=xa.AND,ba.OR=xa.OR;const Sa={Int:vt,Float:gt,Bool:yt,Vector2:At,Vector3:wt,Vector4:rr,Matrix3:Rt,Matrix4:class extends pt{constructor(e){super("m4"),this.nodeType="Matrix4",this.value=null!=e?e:new t.Matrix4}generateReadonly(e,t,r,i,n,s){return e.format("mat4("+this.value.elements.join(", ")+")",i,t)}copy(e){return super.copy(e),this.elements=e.elements,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),t.elements=this.value.elements.concat()),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.elements&&(this.elements=e.elements),this}get elements(){return this.value.elements}set elements(e){this.value.fromArray(e)}},FloatArray:bt,Vector4Array:xt,Normal:hr,Position:ur,Reflect:dr,UV:Et,Attribute:class extends dt{constructor(e="",t){super(t),this.nodeType="Attribute",this.name=e}getAttributeType(e){return"number"==typeof this.type?e.getConstructorFromLength(this.type):this.type}getType(e){const t=this.getAttributeType(e);return e.getTypeByFormat(t)}generate(e,t,r,i,n){i=this.getAttributeType(e);const s=e.getAttribute(this.name,i),o=e.isShader("vertex")?this.name:s.varying.name;return e.format(o,this.getType(e),t)}toJSON(e){const t=super.toJSON(e);return t.nodeType=this.nodeType,t.name=this.name,t}fromJSON(e,t){return super.fromJSON(e,t),e.scope&&(this.scope=e.scope),e.name&&(this.name=e.name),this}},Const:Mt,Struct:sr,Varying:class extends ut{constructor(e="",t=0){super(e),this.nodeType="Varying",this.value=t}getType(e){return e.getTypeByFormat(this.type)}generate(e,t,r,i,n){const s=e.getVar(this.uuid,this.type);return this.value&&e.isShader("vertex")&&e.addNodeCode(s.name+" = "+this.value.build(e,this.getType(e))+";"),e.format(s.name,this.getType(e),t)}copy(e){return super.copy(e),this.value=e.value,this}toJSON(e){let t=this.getJSONNode(e);return t||(t=this.createJSONNode(e),this.value&&(t.value=this.value)),t.nodeType=this.nodeType,t}fromJSON(e,t){return super.fromJSON(e,t),e.value&&(this.value=e.value),this}},SpecularMIPLevel:Pr,MaxMIPLevel:Ir,ColorSpace:Nt,Noise:Wt,TextureCubeUV:cr,TextureCube:pr,Operator:Xt,Math:lr,Cond:ba,Fresnel:kt,Rainbow:jt,Depth:qt,Blend:Kt,Raw:wr,CubeTexture:fr,Texture:Pt,CustomTexture:zt,VertexDisplacement:Yt,CustomNormal:Vt,Gradient:Ht,Matcap:Zt,Expression:_t,Color:mt,Phong:Cr,Basic:br,Lambert:Dr,Standard:Rr,Toon:Nr};class Ea{constructor(){this._nodes={},this._dataNodes={},this._textures={},this.uuid=t.MathUtils.generateUUID()}init(e,t){this._dataNodes=e,this._textures=t}clear(){this._nodes={},this._dataNodes={},this._textures={}}getNode(e){let t=this._nodes[e];return t||(t=this.createNode(e)),t}getNodeData(e){return this._dataNodes[e]}getTexture(e){const t=this._textures[e];if(!t)throw new Error("This texture does not exist in the library "+e);return t}createNode(e){const t=this._dataNodes[e];if(!t)throw new Error("Failed to create Node from uuid: "+e+", its data does not seem to exist");const r=Sa[t.nodeType];if(!r)throw new Error("Failed to create Node from uuid: "+e+" and nodeType: "+t.nodeType+", constructor for this not is not registered");const i=(new r).fromJSON(t,this);return this._nodes[e]=i,i}}class Ca{constructor(){this._buffers=[]}parse(e){var r;const i=new t.BufferGeometry;if(this._vertexData=e.vertexData,this._loadBuffers(this._vertexData.buffers),i.uuid=e.uuid,this._vertexData.accessors)for(let e=0,t=this._vertexData.accessors.length;e<t;++e){const t=this._vertexData.accessors[e].attributeName;"indices"===t?i.setIndex(this._loadAccessor(e)):i.setAttribute(t,this._loadAccessor(e))}if(null===(r=e.data)||void 0===r?void 0:r.groups)for(const t of e.data.groups)i.addGroup(t.start,t.count,t.materialIndex);return i}_loadAccessor(e){const r=this._vertexData.accessors[e],i=this._loadBufferView(r.bufferView),n=Oa[r.type],s=new(0,Ta[r.componentType])(i.buffer);return new t.BufferAttribute(s,n)}_loadBufferView(e){const t=this._vertexData.bufferViews[e],r=this._buffers[t.buffer],i=t.byteLength||0,n=t.byteOffset||0;return r.slice(n,n+i)}_loadBuffers(e){for(const t of e){if(!t.uri)continue;const e=t.uri.slice(t.uri.indexOf("base64")+7),r=atob(e),i=new Uint8Array(r.length);for(let e=0;e<r.length;e++)i[e]=r.charCodeAt(e);this._buffers.push(i)}}}const Ta={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Oa={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};class Da extends t.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new Ba(e)})),this.register((function(e){return new Ua(e)})),this.register((function(e){return new za(e)})),this.register((function(e){return new Ia(e)})),this.register((function(e){return new Pa(e)})),this.register((function(e){return new Ra(e)})),this.register((function(e){return new Fa(e)})),this.register((function(e){return new Na(e)})),this.register((function(e){return new ka(e)}))}load(e,r,i,n){const s=this;let o;o=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:t.LoaderUtils.extractUrlBase(e),this.manager.itemStart(e);const a=function(t){n?n(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},l=new t.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,(function(t){try{s.parse(t,o,(function(t){r(t),s.manager.itemEnd(e)}),a)}catch(e){a(e)}}),i,a)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,r,i,n){let s;const o={},a={};if("string"==typeof e)s=e;else{if(t.LoaderUtils.decodeText(new Uint8Array(e,0,4))===Ga){try{o[_a.KHR_BINARY_GLTF]=new Ha(e)}catch(e){return void(n&&n(e))}s=o[_a.KHR_BINARY_GLTF].content}else s=t.LoaderUtils.decodeText(new Uint8Array(e))}const l=JSON.parse(s);if(void 0===l.asset||l.asset.version[0]<2)return void(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new bl(l,{path:r||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](c);a[t.name]=t,o[t.name]=!0}if(l.extensionsUsed)for(let e=0;e<l.extensionsUsed.length;++e){const t=l.extensionsUsed[e],r=l.extensionsRequired||[];switch(t){case _a.KHR_MATERIALS_UNLIT:o[t]=new La;break;case _a.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:o[t]=new Wa;break;case _a.KHR_DRACO_MESH_COMPRESSION:o[t]=new Ja(l,this.dracoLoader);break;case _a.KHR_TEXTURE_TRANSFORM:o[t]=new Qa;break;case _a.KHR_MESH_QUANTIZATION:o[t]=new Xa;break;default:r.indexOf(t)>=0&&void 0===a[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}c.setExtensions(o),c.setPlugins(a),c.parse(i,n)}}function Ma(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const _a={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class Na{constructor(e){this.parser=e,this.name=_a.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,i=t.length;r<i;r++){const i=t[r];i.extensions&&i.extensions[this.name]&&void 0!==i.extensions[this.name].light&&e._addNodeRef(this.cache,i.extensions[this.name].light)}}_loadLight(e){const r=this.parser,i="light:"+e;let n=r.cache.get(i);if(n)return n;const s=r.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let a;const l=new t.Color(16777215);void 0!==o.color&&l.fromArray(o.color);const c=void 0!==o.range?o.range:0;switch(o.type){case"directional":a=new t.DirectionalLight(l),a.target.position.set(0,0,-1),a.add(a.target);break;case"point":a=new t.PointLight(l),a.distance=c;break;case"spot":a=new t.SpotLight(l),a.distance=c,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,a.angle=o.spot.outerConeAngle,a.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,a.target.position.set(0,0,-1),a.add(a.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return a.position.set(0,0,0),a.decay=2,void 0!==o.intensity&&(a.intensity=o.intensity),a.name=r.createUniqueName(o.name||"light_"+e),n=Promise.resolve(a),r.cache.add(i,n),n}createNodeAttachment(e){const t=this,r=this.parser,i=r.json.nodes[e],n=(i.extensions&&i.extensions[this.name]||{}).light;return void 0===n?null:this._loadLight(n).then((function(e){return r._getNodeRef(t.cache,n,e)}))}}class La{constructor(){this.name=_a.KHR_MATERIALS_UNLIT}getMaterialType(){return t.MeshBasicMaterial}extendParams(e,r,i){const n=[];e.color=new t.Color(1,1,1),e.opacity=1;const s=r.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==s.baseColorTexture&&n.push(i.assignTexture(e,"map",s.baseColorTexture))}return Promise.all(n)}}class Ba{constructor(e){this.parser=e,this.name=_a.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const r=this.parser.json.materials[e];return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,r){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],o=n.extensions[this.name];if(void 0!==o.clearcoatFactor&&(r.clearcoat=o.clearcoatFactor),void 0!==o.clearcoatTexture&&s.push(i.assignTexture(r,"clearcoatMap",o.clearcoatTexture)),void 0!==o.clearcoatRoughnessFactor&&(r.clearcoatRoughness=o.clearcoatRoughnessFactor),void 0!==o.clearcoatRoughnessTexture&&s.push(i.assignTexture(r,"clearcoatRoughnessMap",o.clearcoatRoughnessTexture)),void 0!==o.clearcoatNormalTexture&&(s.push(i.assignTexture(r,"clearcoatNormalMap",o.clearcoatNormalTexture)),void 0!==o.clearcoatNormalTexture.scale)){const e=o.clearcoatNormalTexture.scale;r.clearcoatNormalScale=new t.Vector2(e,-e)}return Promise.all(s)}}class Ia{constructor(e){this.parser=e,this.name=_a.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const r=this.parser.json.materials[e];return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser,i=r.json.materials[e];if(!i.extensions||!i.extensions[this.name])return Promise.resolve();const n=[],s=i.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&n.push(r.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(n)}}class Pa{constructor(e){this.parser=e,this.name=_a.KHR_MATERIALS_VOLUME}getMaterialType(e){const r=this.parser.json.materials[e];return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,r){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],o=n.extensions[this.name];r.thickness=void 0!==o.thicknessFactor?o.thicknessFactor:0,void 0!==o.thicknessTexture&&s.push(i.assignTexture(r,"thicknessMap",o.thicknessTexture)),r.attenuationDistance=o.attenuationDistance||0;const a=o.attenuationColor||[1,1,1];return r.attenuationTint=new t.Color(a[0],a[1],a[2]),Promise.all(s)}}class Ra{constructor(e){this.parser=e,this.name=_a.KHR_MATERIALS_IOR}getMaterialType(e){const r=this.parser.json.materials[e];return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=r.extensions[this.name];return t.ior=void 0!==i.ior?i.ior:1.5,Promise.resolve()}}class Fa{constructor(e){this.parser=e,this.name=_a.KHR_MATERIALS_SPECULAR}getMaterialType(e){const r=this.parser.json.materials[e];return r.extensions&&r.extensions[this.name]?t.MeshPhysicalMaterial:null}extendMaterialParams(e,r){const i=this.parser,n=i.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],o=n.extensions[this.name];r.specularIntensity=void 0!==o.specularFactor?o.specularFactor:1,void 0!==o.specularTexture&&s.push(i.assignTexture(r,"specularIntensityMap",o.specularTexture));const a=o.specularColorFactor||[1,1,1];return r.specularTint=new t.Color(a[0],a[1],a[2]),void 0!==o.specularColorTexture&&s.push(i.assignTexture(r,"specularTintMap",o.specularColorTexture).then((function(e){e.encoding=t.sRGBEncoding}))),Promise.all(s)}}class Ua{constructor(e){this.parser=e,this.name=_a.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,i=r.textures[e];if(!i.extensions||!i.extensions[this.name])return null;const n=i.extensions[this.name],s=r.images[n.source],o=t.options.ktx2Loader;if(!o){if(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s,o)}}class za{constructor(e){this.parser=e,this.name=_a.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,r=this.parser,i=r.json,n=i.textures[e];if(!n.extensions||!n.extensions[t])return null;const s=n.extensions[t],o=i.images[s.source];let a=r.textureLoader;if(o.uri){const e=r.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(n){if(n)return r.loadTextureImage(e,o,a);if(i.extensionsRequired&&i.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class ka{constructor(e){this.name=_a.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const e=r.extensions[this.name],i=this.parser.getDependency("buffer",e.buffer),n=this.parser.options.meshoptDecoder;if(!n||!n.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([i,n.ready]).then((function(t){const r=e.byteOffset||0,i=e.byteLength||0,s=e.count,o=e.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(t[0],r,i);return n.decodeGltfBuffer(new Uint8Array(a),s,o,l,e.mode,e.filter),a}))}return null}}const Ga="glTF",ja=1313821514,Va=5130562;class Ha{constructor(e){this.name=_a.KHR_BINARY_GLTF,this.content=null,this.body=null;const r=new DataView(e,0,12);if(this.header={magic:t.LoaderUtils.decodeText(new Uint8Array(e.slice(0,4))),version:r.getUint32(4,!0),length:r.getUint32(8,!0)},this.header.magic!==Ga)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const i=this.header.length-12,n=new DataView(e,12);let s=0;for(;s<i;){const r=n.getUint32(s,!0);s+=4;const i=n.getUint32(s,!0);if(s+=4,i===ja){const i=new Uint8Array(e,12+s,r);this.content=t.LoaderUtils.decodeText(i)}else if(i===Va){const t=12+s;this.body=e.slice(t,t+r)}s+=r}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Ja{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=_a.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,i=this.dracoLoader,n=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=ll[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const i=ll[t]||t.toLowerCase();if(void 0!==s[t]){const n=r.accessors[e.attributes[t]],s=nl[n.componentType];l[i]=s,a[i]=!0===n.normalized}}return t.getDependency("bufferView",n).then((function(e){return new Promise((function(t){i.decodeDracoFile(e,(function(e){for(const t in e.attributes){const r=e.attributes[t],i=a[t];void 0!==i&&(r.normalized=i)}t(e)}),o,l)}))}))}}class Qa{constructor(){this.name=_a.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Ya extends t.MeshStandardMaterial{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const r=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),i=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),n=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\ttexelSpecular = sRGBToLinear( texelSpecular );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),s=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),o=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.specularRoughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.specularRoughness += geometryRoughness;","material.specularRoughness = min( material.specularRoughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),a={specular:{value:(new t.Color).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=a,this.onBeforeCompile=function(e){for(const t in a)e.uniforms[t]=a[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",r).replace("#include <metalnessmap_pars_fragment>",i).replace("#include <roughnessmap_fragment>",n).replace("#include <metalnessmap_fragment>",s).replace("#include <lights_physical_fragment>",o)},Object.defineProperties(this,{specular:{get:function(){return a.specular.value},set:function(e){a.specular.value=e}},specularMap:{get:function(){return a.specularMap.value},set:function(e){a.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return a.glossiness.value},set:function(e){a.glossiness.value=e}},glossinessMap:{get:function(){return a.glossinessMap.value},set:function(e){a.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Wa{constructor(){this.name=_a.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity","refractionRatio"]}getMaterialType(){return Ya}extendParams(e,r,i){const n=r.extensions[this.name];e.color=new t.Color(1,1,1),e.opacity=1;const s=[];if(Array.isArray(n.diffuseFactor)){const t=n.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==n.diffuseTexture&&s.push(i.assignTexture(e,"map",n.diffuseTexture)),e.emissive=new t.Color(0,0,0),e.glossiness=void 0!==n.glossinessFactor?n.glossinessFactor:1,e.specular=new t.Color(1,1,1),Array.isArray(n.specularFactor)&&e.specular.fromArray(n.specularFactor),void 0!==n.specularGlossinessTexture){const t=n.specularGlossinessTexture;s.push(i.assignTexture(e,"glossinessMap",t)),s.push(i.assignTexture(e,"specularMap",t))}return Promise.all(s)}createMaterial(e){const r=new Ya(e);return r.fog=!0,r.color=e.color,r.map=void 0===e.map?null:e.map,r.lightMap=null,r.lightMapIntensity=1,r.aoMap=void 0===e.aoMap?null:e.aoMap,r.aoMapIntensity=1,r.emissive=e.emissive,r.emissiveIntensity=1,r.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,r.bumpMap=void 0===e.bumpMap?null:e.bumpMap,r.bumpScale=1,r.normalMap=void 0===e.normalMap?null:e.normalMap,r.normalMapType=t.TangentSpaceNormalMap,e.normalScale&&(r.normalScale=e.normalScale),r.displacementMap=null,r.displacementScale=1,r.displacementBias=0,r.specularMap=void 0===e.specularMap?null:e.specularMap,r.specular=e.specular,r.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,r.glossiness=e.glossiness,r.alphaMap=null,r.envMap=void 0===e.envMap?null:e.envMap,r.envMapIntensity=1,r.refractionRatio=.98,r}}class Xa{constructor(){this.name=_a.KHR_MESH_QUANTIZATION}}class Ka extends t.Interpolant{constructor(e,t,r,i){super(e,t,r,i)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,i=this.valueSize,n=e*i*3+i;for(let e=0;e!==i;e++)t[e]=r[n+e];return t}}Ka.prototype.beforeStart_=Ka.prototype.copySampleValue_,Ka.prototype.afterEnd_=Ka.prototype.copySampleValue_,Ka.prototype.interpolate_=function(e,t,r,i){const n=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=i-t,h=(r-t)/c,u=h*h,d=u*h,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let e=0;e!==o;e++){const t=s[f+e+o],r=s[f+e+a]*c,i=s[p+e+o],l=s[p+e]*c;n[e]=v*t+y*r+m*i+g*l}return n};const qa=0,Za=1,$a=2,el=3,tl=4,rl=5,il=6,nl={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},sl={9728:t.NearestFilter,9729:t.LinearFilter,9984:t.NearestMipmapNearestFilter,9985:t.LinearMipmapNearestFilter,9986:t.NearestMipmapLinearFilter,9987:t.LinearMipmapLinearFilter},ol={33071:t.ClampToEdgeWrapping,33648:t.MirroredRepeatWrapping,10497:t.RepeatWrapping},al={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ll={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},cl={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},hl={CUBICSPLINE:void 0,LINEAR:t.InterpolateLinear,STEP:t.InterpolateDiscrete},ul="OPAQUE",dl="MASK",pl="BLEND";function fl(e,t){return"string"!=typeof e||""===e?"":(/^https?:\/\//i.test(t)&&/^\//.test(e)&&(t=t.replace(/(^https?:\/\/[^\/]+).*/i,"$1")),/^(https?:)?\/\//i.test(e)||/^data:.*,.*$/i.test(e)||/^blob:.*$/i.test(e)?e:t+e)}function ml(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new t.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:t.FrontSide})),e.DefaultMaterial}function gl(e,t,r){for(const i in r.extensions)void 0===e[i]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[i]=r.extensions[i])}function vl(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function yl(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,i=t.weights.length;r<i;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){const r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(let t=0,i=r.length;t<i;t++)e.morphTargetDictionary[r[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Al(e){const t=e.extensions&&e.extensions[_a.KHR_DRACO_MESH_COMPRESSION];let r;return r=t?"draco:"+t.bufferView+":"+t.indices+":"+wl(t.attributes):e.indices+":"+wl(e.attributes)+":"+e.mode,r}function wl(e){let t="";const r=Object.keys(e).sort();for(let i=0,n=r.length;i<n;i++)t+=r[i]+":"+e[r[i]]+";";return t}function xl(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class bl{constructor(e={},r={}){this.json=e,this.extensions={},this.plugins={},this.options=r,this.cache=new Ma,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/Firefox/.test(navigator.userAgent)?this.textureLoader=new t.ImageBitmapLoader(this.options.manager):this.textureLoader=new t.TextureLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new t.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const r=this,i=this.json,n=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])})).then((function(t){const s={scene:t[0][i.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:i.asset,parser:r,userData:{}};gl(n,s,i),vl(s,i),Promise.all(r._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let r=0,i=t.length;r<i;r++){const i=t[r].joints;for(let t=0,r=i.length;t<r;t++)e[i[t]].isBone=!0}for(let t=0,i=e.length;t<i;t++){const i=e[t];void 0!==i.mesh&&(this._addNodeRef(this.meshCache,i.mesh),void 0!==i.skin&&(r[i.mesh].isSkinnedMesh=!0)),void 0!==i.camera&&this._addNodeRef(this.cameraCache,i.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const i=r.clone();return i.name+="_instance_"+e.uses[t]++,i}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const i=e(t[r]);if(i)return i}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let i=0;i<t.length;i++){const n=e(t[i]);n&&r.push(n)}return r}getDependency(e,t){const r=e+":"+t;let i=this.cache.get(r);if(!i){switch(e){case"scene":i=this.loadScene(t);break;case"node":i=this.loadNode(t);break;case"mesh":i=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":i=this.loadAccessor(t);break;case"bufferView":i=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":i=this.loadBuffer(t);break;case"material":i=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":i=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":i=this.loadSkin(t);break;case"animation":i=this.loadAnimation(t);break;case"camera":i=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(r,i)}return i}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,i=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(i.map((function(t,i){return r.getDependency(e,i)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[_a.KHR_BINARY_GLTF].body);const i=this.options;return new Promise((function(e,n){r.load(fl(t.uri,i.path),e,void 0,(function(){n(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const r=t.byteLength||0,i=t.byteOffset||0;return e.slice(i,i+r)}))}loadAccessor(e){const r=this,i=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse)return Promise.resolve(null);const s=[];return void 0!==n.bufferView?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),void 0!==n.sparse&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then((function(e){const s=e[0],o=al[n.type],a=nl[n.componentType],l=a.BYTES_PER_ELEMENT,c=l*o,h=n.byteOffset||0,u=void 0!==n.bufferView?i.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;let p,f;if(u&&u!==c){const e=Math.floor(h/u),i="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count;let c=r.cache.get(i);c||(p=new a(s,e*u,n.count*u/l),c=new t.InterleavedBuffer(p,u/l),r.cache.add(i,c)),f=new t.InterleavedBufferAttribute(c,o,h%u/l,d)}else p=null===s?new a(n.count*o):new a(s,h,n.count*o),f=new t.BufferAttribute(p,o,d);if(void 0!==n.sparse){const r=al.SCALAR,i=nl[n.sparse.indices.componentType],l=n.sparse.indices.byteOffset||0,c=n.sparse.values.byteOffset||0,h=new i(e[1],l,n.sparse.count*r),u=new a(e[2],c,n.sparse.count*o);null!==s&&(f=new t.BufferAttribute(f.array.slice(),f.itemSize,f.normalized));for(let e=0,t=h.length;e<t;e++){const t=h[e];if(f.setX(t,u[e*o]),o>=2&&f.setY(t,u[e*o+1]),o>=3&&f.setZ(t,u[e*o+2]),o>=4&&f.setW(t,u[e*o+3]),o>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return f}))}loadTexture(e){const t=this.json,r=this.options,i=t.textures[e],n=t.images[i.source];let s=this.textureLoader;if(n.uri){const e=r.manager.getHandler(n.uri);null!==e&&(s=e)}return this.loadTextureImage(e,n,s)}loadTextureImage(e,r,i){const n=this,s=this.json,o=this.options,a=s.textures[e],l=(r.uri||r.bufferView)+":"+a.sampler;if(this.textureCache[l])return this.textureCache[l];const c=self.URL||self.webkitURL;let h=r.uri||"",u=!1,d=!0;const p=h.search(/\.jpe?g($|\?)/i)>0||0===h.search(/^data\:image\/jpeg/);if(("image/jpeg"===r.mimeType||p)&&(d=!1),void 0!==r.bufferView)h=n.getDependency("bufferView",r.bufferView).then((function(e){if("image/png"===r.mimeType){const t=new DataView(e,25,1).getUint8(0,!1);d=6===t||4===t||3===t}u=!0;const t=new Blob([e],{type:r.mimeType});return h=c.createObjectURL(t),h}));else if(void 0===r.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const f=Promise.resolve(h).then((function(e){return new Promise((function(r,n){let s=r;!0===i.isImageBitmapLoader&&(s=function(e){const i=new t.Texture(e);i.needsUpdate=!0,r(i)}),i.load(fl(e,o.path),s,void 0,n)}))})).then((function(r){!0===u&&c.revokeObjectURL(h),r.flipY=!1,a.name&&(r.name=a.name),d||(r.format=t.RGBFormat);const i=(s.samplers||{})[a.sampler]||{};return r.magFilter=sl[i.magFilter]||t.LinearFilter,r.minFilter=sl[i.minFilter]||t.LinearMipmapLinearFilter,r.wrapS=ol[i.wrapS]||t.RepeatWrapping,r.wrapT=ol[i.wrapT]||t.RepeatWrapping,n.associations.set(r,{type:"textures",index:e}),r})).catch((function(){return console.error("THREE.GLTFLoader: Couldn't load texture",h),null}));return this.textureCache[l]=f,f}assignTexture(e,t,r){const i=this;return this.getDependency("texture",r.index).then((function(n){if(void 0===r.texCoord||0==r.texCoord||"aoMap"===t&&1==r.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+r.texCoord+" for texture "+t+" not yet supported."),i.extensions[_a.KHR_TEXTURE_TRANSFORM]){const e=void 0!==r.extensions?r.extensions[_a.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(n);n=i.extensions[_a.KHR_TEXTURE_TRANSFORM].extendTexture(n,e),i.associations.set(n,t)}}return e[t]=n,n}))}assignFinalMaterial(e){const r=e.geometry;let i=e.material;const n=void 0!==r.attributes.tangent,s=void 0!==r.attributes.color,o=void 0===r.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+i.uuid;let r=this.cache.get(e);r||(r=new t.PointsMaterial,t.Material.prototype.copy.call(r,i),r.color.copy(i.color),r.map=i.map,r.sizeAttenuation=!1,this.cache.add(e,r)),i=r}else if(e.isLine){const e="LineBasicMaterial:"+i.uuid;let r=this.cache.get(e);r||(r=new t.LineBasicMaterial,t.Material.prototype.copy.call(r,i),r.color.copy(i.color),this.cache.add(e,r)),i=r}if(n||s||o){let e="ClonedMaterial:"+i.uuid+":";i.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),n&&(e+="vertex-tangents:"),s&&(e+="vertex-colors:"),o&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=i.clone(),s&&(t.vertexColors=!0),o&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(i))),i=t}i.aoMap&&void 0===r.attributes.uv2&&void 0!==r.attributes.uv&&r.setAttribute("uv2",r.attributes.uv),e.material=i}getMaterialType(){return t.MeshStandardMaterial}loadMaterial(e){const r=this,i=this.json,n=this.extensions,s=i.materials[e];let o;const a={},l=s.extensions||{},c=[];if(l[_a.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=n[_a.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];o=e.getMaterialType(),c.push(e.extendParams(a,s,r))}else if(l[_a.KHR_MATERIALS_UNLIT]){const e=n[_a.KHR_MATERIALS_UNLIT];o=e.getMaterialType(),c.push(e.extendParams(a,s,r))}else{const i=s.pbrMetallicRoughness||{};if(a.color=new t.Color(1,1,1),a.opacity=1,Array.isArray(i.baseColorFactor)){const e=i.baseColorFactor;a.color.fromArray(e),a.opacity=e[3]}void 0!==i.baseColorTexture&&c.push(r.assignTexture(a,"map",i.baseColorTexture)),a.metalness=void 0!==i.metallicFactor?i.metallicFactor:1,a.roughness=void 0!==i.roughnessFactor?i.roughnessFactor:1,void 0!==i.metallicRoughnessTexture&&(c.push(r.assignTexture(a,"metalnessMap",i.metallicRoughnessTexture)),c.push(r.assignTexture(a,"roughnessMap",i.metallicRoughnessTexture))),o=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),c.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,a)}))))}!0===s.doubleSided&&(a.side=t.DoubleSide);const h=s.alphaMode||ul;return h===pl?(a.transparent=!0,a.depthWrite=!1):(a.transparent=!1,h===dl&&(a.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&o!==t.MeshBasicMaterial&&(c.push(r.assignTexture(a,"normalMap",s.normalTexture)),a.normalScale=new t.Vector2(1,-1),void 0!==s.normalTexture.scale&&a.normalScale.set(s.normalTexture.scale,-s.normalTexture.scale)),void 0!==s.occlusionTexture&&o!==t.MeshBasicMaterial&&(c.push(r.assignTexture(a,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(a.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&o!==t.MeshBasicMaterial&&(a.emissive=(new t.Color).fromArray(s.emissiveFactor)),void 0!==s.emissiveTexture&&o!==t.MeshBasicMaterial&&c.push(r.assignTexture(a,"emissiveMap",s.emissiveTexture)),Promise.all(c).then((function(){let i;return i=o===Ya?n[_a.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(a):new o(a),s.name&&(i.name=s.name),i.map&&(i.map.encoding=t.sRGBEncoding),i.emissiveMap&&(i.emissiveMap.encoding=t.sRGBEncoding),vl(i,s),r.associations.set(i,{type:"materials",index:e}),s.extensions&&gl(n,i,s),i}))}createUniqueName(e){const r=t.PropertyBinding.sanitizeNodeName(e||"");let i=r;for(let e=1;this.nodeNamesUsed[i];++e)i=r+"_"+e;return this.nodeNamesUsed[i]=!0,i}loadGeometries(e){const r=this,i=this.extensions,n=this.primitiveCache;function s(e){return i[_a.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,r).then((function(t){return El(t,e,r)}))}const o=[];for(let i=0,a=e.length;i<a;i++){const a=e[i],l=Al(a),c=n[l];if(c)o.push(c.promise);else{let e;e=a.extensions&&a.extensions[_a.KHR_DRACO_MESH_COMPRESSION]?s(a):El(new t.BufferGeometry,a,r),n[l]={primitive:a,promise:e},o.push(e)}}return Promise.all(o)}loadMesh(e){const r=this,i=this.json,n=this.extensions,s=i.meshes[e],o=s.primitives,a=[];for(let e=0,t=o.length;e<t;e++){const t=void 0===o[e].material?ml(this.cache):this.getDependency("material",o[e].material);a.push(t)}return a.push(r.loadGeometries(o)),Promise.all(a).then((function(i){const a=i.slice(0,i.length-1),l=i[i.length-1],c=[];for(let i=0,h=l.length;i<h;i++){const h=l[i],u=o[i];let d;const p=a[i];if(u.mode===tl||u.mode===rl||u.mode===il||void 0===u.mode)d=!0===s.isSkinnedMesh?new t.SkinnedMesh(h,p):new t.Mesh(h,p),!0!==d.isSkinnedMesh||d.geometry.attributes.skinWeight.normalized||d.normalizeSkinWeights(),u.mode===rl?d.geometry=Cl(d.geometry,t.TriangleStripDrawMode):u.mode===il&&(d.geometry=Cl(d.geometry,t.TriangleFanDrawMode));else if(u.mode===Za)d=new t.LineSegments(h,p);else if(u.mode===el)d=new t.Line(h,p);else if(u.mode===$a)d=new t.LineLoop(h,p);else{if(u.mode!==qa)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);d=new t.Points(h,p)}Object.keys(d.geometry.morphAttributes).length>0&&yl(d,s),d.name=r.createUniqueName(s.name||"mesh_"+e),vl(d,s),u.extensions&&gl(n,d,u),r.assignFinalMaterial(d),c.push(d)}if(1===c.length)return c[0];const h=new t.Group;for(let e=0,t=c.length;e<t;e++)h.add(c[e]);return h}))}loadCamera(e){let r;const i=this.json.cameras[e],n=i[i.type];if(n)return"perspective"===i.type?r=new t.PerspectiveCamera(t.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===i.type&&(r=new t.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),i.name&&(r.name=this.createUniqueName(i.name)),vl(r,i),Promise.resolve(r);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],r={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(r):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return r.inverseBindMatrices=e,r}))}loadAnimation(e){const r=this.json.animations[e],i=[],n=[],s=[],o=[],a=[];for(let e=0,t=r.channels.length;e<t;e++){const t=r.channels[e],l=r.samplers[t.sampler],c=t.target,h=void 0!==c.node?c.node:c.id,u=void 0!==r.parameters?r.parameters[l.input]:l.input,d=void 0!==r.parameters?r.parameters[l.output]:l.output;i.push(this.getDependency("node",h)),n.push(this.getDependency("accessor",u)),s.push(this.getDependency("accessor",d)),o.push(l),a.push(c)}return Promise.all([Promise.all(i),Promise.all(n),Promise.all(s),Promise.all(o),Promise.all(a)]).then((function(i){const n=i[0],s=i[1],o=i[2],a=i[3],l=i[4],c=[];for(let e=0,r=n.length;e<r;e++){const r=n[e],i=s[e],h=o[e],u=a[e],d=l[e];if(void 0===r)continue;let p;switch(r.updateMatrix(),r.matrixAutoUpdate=!0,cl[d.path]){case cl.weights:p=t.NumberKeyframeTrack;break;case cl.rotation:p=t.QuaternionKeyframeTrack;break;case cl.position:case cl.scale:default:p=t.VectorKeyframeTrack}const f=r.name?r.name:r.uuid,m=void 0!==u.interpolation?hl[u.interpolation]:t.InterpolateLinear,g=[];cl[d.path]===cl.weights?r.traverse((function(e){!0===e.isMesh&&e.morphTargetInfluences&&g.push(e.name?e.name:e.uuid)})):g.push(f);let v=h.array;if(h.normalized){const e=xl(v.constructor),t=new Float32Array(v.length);for(let r=0,i=v.length;r<i;r++)t[r]=v[r]*e;v=t}for(let e=0,t=g.length;e<t;e++){const t=new p(g[e]+"."+cl[d.path],i.array,v,m);"CUBICSPLINE"===u.interpolation&&(t.createInterpolant=function(e){return new Ka(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),c.push(t)}}const h=r.name?r.name:"animation_"+e;return new t.AnimationClip(h,void 0,c)}))}createNodeMesh(e){const t=this.json,r=this,i=t.nodes[e];return void 0===i.mesh?null:r.getDependency("mesh",i.mesh).then((function(e){const t=r._getNodeRef(r.meshCache,i.mesh,e);return void 0!==i.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,r=i.weights.length;t<r;t++)e.morphTargetInfluences[t]=i.weights[t]})),t}))}loadNode(e){const r=this.json,i=this.extensions,n=this,s=r.nodes[e],o=s.name?n.createUniqueName(s.name):"";return function(){const t=[],r=n._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return r&&t.push(r),void 0!==s.camera&&t.push(n.getDependency("camera",s.camera).then((function(e){return n._getNodeRef(n.cameraCache,s.camera,e)}))),n._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(r){let a;if(a=!0===s.isBone?new t.Bone:r.length>1?new t.Group:1===r.length?r[0]:new t.Object3D,a!==r[0])for(let e=0,t=r.length;e<t;e++)a.add(r[e]);if(s.name&&(a.userData.name=s.name,a.name=o),vl(a,s),s.extensions&&gl(i,a,s),void 0!==s.matrix){const e=new t.Matrix4;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);return n.associations.set(a,{type:"nodes",index:e}),a}))}loadScene(e){const r=this.json,i=this.extensions,n=this.json.scenes[e],s=this,o=new t.Group;n.name&&(o.name=s.createUniqueName(n.name)),vl(o,n),n.extensions&&gl(i,o,n);const a=n.nodes||[],l=[];for(let e=0,t=a.length;e<t;e++)l.push(Sl(a[e],o,r,s));return Promise.all(l).then((function(){return o}))}}function Sl(e,r,i,n){const s=i.nodes[e];return n.getDependency("node",e).then((function(e){if(void 0===s.skin)return e;let r;return n.getDependency("skin",s.skin).then((function(e){r=e;const t=[];for(let e=0,i=r.joints.length;e<i;e++)t.push(n.getDependency("node",r.joints[e]));return Promise.all(t)})).then((function(i){return e.traverse((function(e){if(!e.isMesh)return;const n=[],s=[];for(let e=0,o=i.length;e<o;e++){const o=i[e];if(o){n.push(o);const i=new t.Matrix4;void 0!==r.inverseBindMatrices&&i.fromArray(r.inverseBindMatrices.array,16*e),s.push(i)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',r.joints[e])}e.bind(new t.Skeleton(n,s),e.matrixWorld)})),e}))})).then((function(e){r.add(e);const t=[];if(s.children){const r=s.children;for(let s=0,o=r.length;s<o;s++){const o=r[s];t.push(Sl(o,e,i,n))}}return Promise.all(t)}))}function El(e,r,i){const n=r.attributes,s=[];function o(t,r){return i.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in n){const r=ll[t]||t.toLowerCase();r in e.attributes||s.push(o(n[t],r))}if(void 0!==r.indices&&!e.index){const t=i.getDependency("accessor",r.indices).then((function(t){e.setIndex(t)}));s.push(t)}return vl(e,r),function(e,r,i){const n=r.attributes,s=new t.Box3;if(void 0===n.POSITION)return;{const e=i.json.accessors[n.POSITION],r=e.min,o=e.max;if(void 0===r||void 0===o)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(s.set(new t.Vector3(r[0],r[1],r[2]),new t.Vector3(o[0],o[1],o[2])),e.normalized){const t=xl(nl[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const o=r.targets;if(void 0!==o){const e=new t.Vector3,r=new t.Vector3;for(let t=0,n=o.length;t<n;t++){const n=o[t];if(void 0!==n.POSITION){const t=i.json.accessors[n.POSITION],s=t.min,o=t.max;if(void 0!==s&&void 0!==o){if(r.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),r.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),r.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),t.normalized){const e=xl(nl[t.componentType]);r.multiplyScalar(e)}e.max(r)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}s.expandByVector(e)}e.boundingBox=s;const a=new t.Sphere;s.getCenter(a.center),a.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=a}(e,r,i),Promise.all(s).then((function(){return void 0!==r.targets?function(e,t,r){let i=!1,n=!1;for(let e=0,r=t.length;e<r;e++){const r=t[e];if(void 0!==r.POSITION&&(i=!0),void 0!==r.NORMAL&&(n=!0),i&&n)break}if(!i&&!n)return Promise.resolve(e);const s=[],o=[];for(let a=0,l=t.length;a<l;a++){const l=t[a];if(i){const t=void 0!==l.POSITION?r.getDependency("accessor",l.POSITION):e.attributes.position;s.push(t)}if(n){const t=void 0!==l.NORMAL?r.getDependency("accessor",l.NORMAL):e.attributes.normal;o.push(t)}}return Promise.all([Promise.all(s),Promise.all(o)]).then((function(t){const r=t[0],s=t[1];return i&&(e.morphAttributes.position=r),n&&(e.morphAttributes.normal=s),e.morphTargetsRelative=!0,e}))}(e,r.targets,i):e}))}function Cl(e,r){let i=e.getIndex();if(null===i){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),i=e.getIndex()}const n=i.count-2,s=[];if(r===t.TriangleFanDrawMode)for(let e=1;e<=n;e++)s.push(i.getX(0)),s.push(i.getX(e)),s.push(i.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(s.push(i.getX(e)),s.push(i.getX(e+1)),s.push(i.getX(e+2))):(s.push(i.getX(e+2)),s.push(i.getX(e+1)),s.push(i.getX(e)));s.length/3!==n&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=e.clone();return o.setIndex(s),o}const Tl=new WeakMap;class Ol extends t.Loader{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,r,i,n){const s=new t.FileLoader(this.manager);s.setPath(this.path),s.setResponseType("arraybuffer"),s.setRequestHeader(this.requestHeader),s.setWithCredentials(this.withCredentials),s.load(e,(e=>{const t={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,t).then(r).catch(n)}),i,n)}decodeDracoFile(e,t,r,i){const n={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:i||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,n).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}const r=JSON.stringify(t);if(Tl.has(e)){const t=Tl.get(e);if(t.key===r)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let i;const n=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(n,s).then((r=>(i=r,new Promise(((r,s)=>{i._callbacks[n]={resolve:r,reject:s},i.postMessage({type:"decode",id:n,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{i&&n&&this._releaseTask(i,n)})),Tl.set(e,{key:r,promise:o}),o}_createGeometry(e){const r=new t.BufferGeometry;e.index&&r.setIndex(new t.BufferAttribute(e.index.array,1));for(let i=0;i<e.attributes.length;i++){const n=e.attributes[i],s=n.name,o=n.array,a=n.itemSize;r.setAttribute(s,new t.BufferAttribute(o,a))}return r}_loadLibrary(e,r){const i=new t.FileLoader(this.manager);return i.setPath(this.decoderPath),i.setResponseType(r),i.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{i.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const i=Dl.toString(),n=["/* draco decoder */",r,"","/* worker */",i.substring(i.indexOf("{")+1,i.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([n]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function Dl(){let e,t;function r(e,t,r,i,n,s){const o=s.num_components(),a=r.num_points()*o,l=a*n.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,n),h=e._malloc(l);t.GetAttributeDataArrayForAllPoints(r,s,c,l,h);const u=new n(e.HEAPF32.buffer,h,a).slice();return e._free(h),{name:i,array:u,itemSize:o}}onmessage=function(i){const n=i.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const i=n.buffer,s=n.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(i),i.byteLength);try{const e=function(e,t,i,n){const s=n.attributeIDs,o=n.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(i);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(i,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(i,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const i in s){const l=self[o[i]];let c,u;if(n.useUniqueIDs)u=s[i],c=t.GetAttributeByUniqueId(a,u);else{if(u=t.GetAttributeId(a,e[s[i]]),-1===u)continue;c=t.GetAttribute(a,u)}h.attributes.push(r(e,t,a,i,l,c))}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,r){const i=3*r.num_faces(),n=4*i,s=e._malloc(n);t.GetTrianglesUInt32Array(r,n,s);const o=new Uint32Array(e.HEAPF32.buffer,s,i).slice();return e._free(s),{array:o,itemSize:1}}(e,t,a));return e.destroy(a),h}(t,o,a,s),i=e.attributes.map((e=>e.array.buffer));e.index&&i.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},i)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}var Ml="object"==typeof global&&global&&global.Object===Object&&global,_l="object"==typeof self&&self&&self.Object===Object&&self,Nl=Ml||_l||Function("return this")(),Ll=Nl.Symbol,Bl=Object.prototype,Il=Bl.hasOwnProperty,Pl=Bl.toString,Rl=Ll?Ll.toStringTag:void 0;var Fl=Object.prototype.toString;var Ul=Ll?Ll.toStringTag:void 0;function zl(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Ul&&Ul in Object(e)?function(e){var t=Il.call(e,Rl),r=e[Rl];try{e[Rl]=void 0;var i=!0}catch(e){}var n=Pl.call(e);return i&&(t?e[Rl]=r:delete e[Rl]),n}(e):function(e){return Fl.call(e)}(e)}function kl(e){return null!=e&&"object"==typeof e}function Gl(e){return"symbol"==typeof e||kl(e)&&"[object Symbol]"==zl(e)}function jl(e,t){for(var r=-1,i=null==e?0:e.length,n=Array(i);++r<i;)n[r]=t(e[r],r,e);return n}var Vl=Array.isArray,Hl=Ll?Ll.prototype:void 0,Jl=Hl?Hl.toString:void 0;function Ql(e){if("string"==typeof e)return e;if(Vl(e))return jl(e,Ql)+"";if(Gl(e))return Jl?Jl.call(e):"";var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t}function Yl(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function Wl(e){return e}function Xl(e){if(!Yl(e))return!1;var t=zl(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}var Kl,ql=Nl["__core-js_shared__"],Zl=(Kl=/[^.]+$/.exec(ql&&ql.keys&&ql.keys.IE_PROTO||""))?"Symbol(src)_1."+Kl:"";var $l=Function.prototype.toString;function ec(e){if(null!=e){try{return $l.call(e)}catch(e){}try{return e+""}catch(e){}}return""}var tc=/^\[object .+?Constructor\]$/,rc=Function.prototype,ic=Object.prototype,nc=rc.toString,sc=ic.hasOwnProperty,oc=RegExp("^"+nc.call(sc).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function ac(e){return!(!Yl(e)||(t=e,Zl&&Zl in t))&&(Xl(e)?oc:tc).test(ec(e));var t}function lc(e,t){var r=function(e,t){return null==e?void 0:e[t]}(e,t);return ac(r)?r:void 0}var cc=lc(Nl,"WeakMap"),hc=/^(?:0|[1-9]\d*)$/;function uc(e,t){var r=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==r||"symbol"!=r&&hc.test(e))&&e>-1&&e%1==0&&e<t}function dc(e,t){return e===t||e!=e&&t!=t}function pc(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function fc(e){return null!=e&&pc(e.length)&&!Xl(e)}var mc=Object.prototype;function gc(e){return kl(e)&&"[object Arguments]"==zl(e)}var vc=Object.prototype,yc=vc.hasOwnProperty,Ac=vc.propertyIsEnumerable,wc=gc(function(){return arguments}())?gc:function(e){return kl(e)&&yc.call(e,"callee")&&!Ac.call(e,"callee")};var xc="object"==typeof e&&e&&!e.nodeType&&e,bc=xc&&"object"==typeof module&&module&&!module.nodeType&&module,Sc=bc&&bc.exports===xc?Nl.Buffer:void 0,Ec=(Sc?Sc.isBuffer:void 0)||function(){return!1},Cc={};function Tc(e){return function(t){return e(t)}}Cc["[object Float32Array]"]=Cc["[object Float64Array]"]=Cc["[object Int8Array]"]=Cc["[object Int16Array]"]=Cc["[object Int32Array]"]=Cc["[object Uint8Array]"]=Cc["[object Uint8ClampedArray]"]=Cc["[object Uint16Array]"]=Cc["[object Uint32Array]"]=!0,Cc["[object Arguments]"]=Cc["[object Array]"]=Cc["[object ArrayBuffer]"]=Cc["[object Boolean]"]=Cc["[object DataView]"]=Cc["[object Date]"]=Cc["[object Error]"]=Cc["[object Function]"]=Cc["[object Map]"]=Cc["[object Number]"]=Cc["[object Object]"]=Cc["[object RegExp]"]=Cc["[object Set]"]=Cc["[object String]"]=Cc["[object WeakMap]"]=!1;var Oc="object"==typeof e&&e&&!e.nodeType&&e,Dc=Oc&&"object"==typeof module&&module&&!module.nodeType&&module,Mc=Dc&&Dc.exports===Oc&&Ml.process,_c=function(){try{var e=Dc&&Dc.require&&Dc.require("util").types;return e||Mc&&Mc.binding&&Mc.binding("util")}catch(e){}}(),Nc=_c&&_c.isTypedArray,Lc=Nc?Tc(Nc):function(e){return kl(e)&&pc(e.length)&&!!Cc[zl(e)]},Bc=Object.prototype.hasOwnProperty;function Ic(e,t){var r=Vl(e),i=!r&&wc(e),n=!r&&!i&&Ec(e),s=!r&&!i&&!n&&Lc(e),o=r||i||n||s,a=o?function(e,t){for(var r=-1,i=Array(e);++r<e;)i[r]=t(r);return i}(e.length,String):[],l=a.length;for(var c in e)!t&&!Bc.call(e,c)||o&&("length"==c||n&&("offset"==c||"parent"==c)||s&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||uc(c,l))||a.push(c);return a}var Pc,Rc,Fc=(Pc=Object.keys,Rc=Object,function(e){return Pc(Rc(e))}),Uc=Object.prototype.hasOwnProperty;function zc(e){if(r=(t=e)&&t.constructor,t!==("function"==typeof r&&r.prototype||mc))return Fc(e);var t,r,i=[];for(var n in Object(e))Uc.call(e,n)&&"constructor"!=n&&i.push(n);return i}function kc(e){return fc(e)?Ic(e):zc(e)}var Gc=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,jc=/^\w*$/;function Vc(e,t){if(Vl(e))return!1;var r=typeof e;return!("number"!=r&&"symbol"!=r&&"boolean"!=r&&null!=e&&!Gl(e))||(jc.test(e)||!Gc.test(e)||null!=t&&e in Object(t))}var Hc=lc(Object,"create");var Jc=Object.prototype.hasOwnProperty;var Qc=Object.prototype.hasOwnProperty;function Yc(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}function Wc(e,t){for(var r=e.length;r--;)if(dc(e[r][0],t))return r;return-1}Yc.prototype.clear=function(){this.__data__=Hc?Hc(null):{},this.size=0},Yc.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Yc.prototype.get=function(e){var t=this.__data__;if(Hc){var r=t[e];return"__lodash_hash_undefined__"===r?void 0:r}return Jc.call(t,e)?t[e]:void 0},Yc.prototype.has=function(e){var t=this.__data__;return Hc?void 0!==t[e]:Qc.call(t,e)},Yc.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Hc&&void 0===t?"__lodash_hash_undefined__":t,this};var Xc=Array.prototype.splice;function Kc(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}Kc.prototype.clear=function(){this.__data__=[],this.size=0},Kc.prototype.delete=function(e){var t=this.__data__,r=Wc(t,e);return!(r<0)&&(r==t.length-1?t.pop():Xc.call(t,r,1),--this.size,!0)},Kc.prototype.get=function(e){var t=this.__data__,r=Wc(t,e);return r<0?void 0:t[r][1]},Kc.prototype.has=function(e){return Wc(this.__data__,e)>-1},Kc.prototype.set=function(e,t){var r=this.__data__,i=Wc(r,e);return i<0?(++this.size,r.push([e,t])):r[i][1]=t,this};var qc=lc(Nl,"Map");function Zc(e,t){var r,i,n=e.__data__;return("string"==(i=typeof(r=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==r:null===r)?n["string"==typeof t?"string":"hash"]:n.map}function $c(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var i=e[t];this.set(i[0],i[1])}}$c.prototype.clear=function(){this.size=0,this.__data__={hash:new Yc,map:new(qc||Kc),string:new Yc}},$c.prototype.delete=function(e){var t=Zc(this,e).delete(e);return this.size-=t?1:0,t},$c.prototype.get=function(e){return Zc(this,e).get(e)},$c.prototype.has=function(e){return Zc(this,e).has(e)},$c.prototype.set=function(e,t){var r=Zc(this,e),i=r.size;return r.set(e,t),this.size+=r.size==i?0:1,this};function eh(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new TypeError("Expected a function");var r=function(){var i=arguments,n=t?t.apply(this,i):i[0],s=r.cache;if(s.has(n))return s.get(n);var o=e.apply(this,i);return r.cache=s.set(n,o)||s,o};return r.cache=new(eh.Cache||$c),r}eh.Cache=$c;var th=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,rh=/\\(\\)?/g,ih=function(e){var t=eh(e,(function(e){return 500===r.size&&r.clear(),e})),r=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(th,(function(e,r,i,n){t.push(i?n.replace(rh,"$1"):r||e)})),t}));function nh(e,t){return Vl(e)?e:Vc(e,t)?[e]:ih(function(e){return null==e?"":Ql(e)}(e))}function sh(e){if("string"==typeof e||Gl(e))return e;var t=e+"";return"0"==t&&1/e==-Infinity?"-0":t}function oh(e,t){for(var r=0,i=(t=nh(t,e)).length;null!=e&&r<i;)e=e[sh(t[r++])];return r&&r==i?e:void 0}function ah(e){var t=this.__data__=new Kc(e);this.size=t.size}ah.prototype.clear=function(){this.__data__=new Kc,this.size=0},ah.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},ah.prototype.get=function(e){return this.__data__.get(e)},ah.prototype.has=function(e){return this.__data__.has(e)},ah.prototype.set=function(e,t){var r=this.__data__;if(r instanceof Kc){var i=r.__data__;if(!qc||i.length<199)return i.push([e,t]),this.size=++r.size,this;r=this.__data__=new $c(i)}return r.set(e,t),this.size=r.size,this};var lh=Object.prototype.propertyIsEnumerable,ch=Object.getOwnPropertySymbols,hh=ch?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,i=null==e?0:e.length,n=0,s=[];++r<i;){var o=e[r];t(o,r,e)&&(s[n++]=o)}return s}(ch(e),(function(t){return lh.call(e,t)})))}:function(){return[]};function uh(e){return function(e,t,r){var i=t(e);return Vl(e)?i:function(e,t){for(var r=-1,i=t.length,n=e.length;++r<i;)e[n+r]=t[r];return e}(i,r(e))}(e,kc,hh)}var dh=lc(Nl,"DataView"),ph=lc(Nl,"Promise"),fh=lc(Nl,"Set"),mh="[object Map]",gh="[object Promise]",vh="[object Set]",yh="[object WeakMap]",Ah="[object DataView]",wh=ec(dh),xh=ec(qc),bh=ec(ph),Sh=ec(fh),Eh=ec(cc),Ch=zl;(dh&&Ch(new dh(new ArrayBuffer(1)))!=Ah||qc&&Ch(new qc)!=mh||ph&&Ch(ph.resolve())!=gh||fh&&Ch(new fh)!=vh||cc&&Ch(new cc)!=yh)&&(Ch=function(e){var t=zl(e),r="[object Object]"==t?e.constructor:void 0,i=r?ec(r):"";if(i)switch(i){case wh:return Ah;case xh:return mh;case bh:return gh;case Sh:return vh;case Eh:return yh}return t});var Th=Ch,Oh=Nl.Uint8Array;function Dh(e){var t=-1,r=null==e?0:e.length;for(this.__data__=new $c;++t<r;)this.add(e[t])}function Mh(e,t){for(var r=-1,i=null==e?0:e.length;++r<i;)if(t(e[r],r,e))return!0;return!1}function _h(e,t){return e.has(t)}Dh.prototype.add=Dh.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Dh.prototype.has=function(e){return this.__data__.has(e)};function Nh(e,t,r,i,n,s){var o=1&r,a=e.length,l=t.length;if(a!=l&&!(o&&l>a))return!1;var c=s.get(e),h=s.get(t);if(c&&h)return c==t&&h==e;var u=-1,d=!0,p=2&r?new Dh:void 0;for(s.set(e,t),s.set(t,e);++u<a;){var f=e[u],m=t[u];if(i)var g=o?i(m,f,u,t,e,s):i(f,m,u,e,t,s);if(void 0!==g){if(g)continue;d=!1;break}if(p){if(!Mh(t,(function(e,t){if(!_h(p,t)&&(f===e||n(f,e,r,i,s)))return p.push(t)}))){d=!1;break}}else if(f!==m&&!n(f,m,r,i,s)){d=!1;break}}return s.delete(e),s.delete(t),d}function Lh(e){var t=-1,r=Array(e.size);return e.forEach((function(e,i){r[++t]=[i,e]})),r}function Bh(e){var t=-1,r=Array(e.size);return e.forEach((function(e){r[++t]=e})),r}var Ih=Ll?Ll.prototype:void 0,Ph=Ih?Ih.valueOf:void 0;var Rh=Object.prototype.hasOwnProperty;var Fh="[object Arguments]",Uh="[object Array]",zh="[object Object]",kh=Object.prototype.hasOwnProperty;function Gh(e,t,r,i,n,s){var o=Vl(e),a=Vl(t),l=o?Uh:Th(e),c=a?Uh:Th(t),h=(l=l==Fh?zh:l)==zh,u=(c=c==Fh?zh:c)==zh,d=l==c;if(d&&Ec(e)){if(!Ec(t))return!1;o=!0,h=!1}if(d&&!h)return s||(s=new ah),o||Lc(e)?Nh(e,t,r,i,n,s):function(e,t,r,i,n,s,o){switch(r){case"[object DataView]":if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case"[object ArrayBuffer]":return!(e.byteLength!=t.byteLength||!s(new Oh(e),new Oh(t)));case"[object Boolean]":case"[object Date]":case"[object Number]":return dc(+e,+t);case"[object Error]":return e.name==t.name&&e.message==t.message;case"[object RegExp]":case"[object String]":return e==t+"";case"[object Map]":var a=Lh;case"[object Set]":var l=1&i;if(a||(a=Bh),e.size!=t.size&&!l)return!1;var c=o.get(e);if(c)return c==t;i|=2,o.set(e,t);var h=Nh(a(e),a(t),i,n,s,o);return o.delete(e),h;case"[object Symbol]":if(Ph)return Ph.call(e)==Ph.call(t)}return!1}(e,t,l,r,i,n,s);if(!(1&r)){var p=h&&kh.call(e,"__wrapped__"),f=u&&kh.call(t,"__wrapped__");if(p||f){var m=p?e.value():e,g=f?t.value():t;return s||(s=new ah),n(m,g,r,i,s)}}return!!d&&(s||(s=new ah),function(e,t,r,i,n,s){var o=1&r,a=uh(e),l=a.length;if(l!=uh(t).length&&!o)return!1;for(var c=l;c--;){var h=a[c];if(!(o?h in t:Rh.call(t,h)))return!1}var u=s.get(e),d=s.get(t);if(u&&d)return u==t&&d==e;var p=!0;s.set(e,t),s.set(t,e);for(var f=o;++c<l;){var m=e[h=a[c]],g=t[h];if(i)var v=o?i(g,m,h,t,e,s):i(m,g,h,e,t,s);if(!(void 0===v?m===g||n(m,g,r,i,s):v)){p=!1;break}f||(f="constructor"==h)}if(p&&!f){var y=e.constructor,A=t.constructor;y==A||!("constructor"in e)||!("constructor"in t)||"function"==typeof y&&y instanceof y&&"function"==typeof A&&A instanceof A||(p=!1)}return s.delete(e),s.delete(t),p}(e,t,r,i,n,s))}function jh(e,t,r,i,n){return e===t||(null==e||null==t||!kl(e)&&!kl(t)?e!=e&&t!=t:Gh(e,t,r,i,jh,n))}function Vh(e){return e==e&&!Yl(e)}function Hh(e,t){return function(r){return null!=r&&(r[e]===t&&(void 0!==t||e in Object(r)))}}function Jh(e){var t=function(e){for(var t=kc(e),r=t.length;r--;){var i=t[r],n=e[i];t[r]=[i,n,Vh(n)]}return t}(e);return 1==t.length&&t[0][2]?Hh(t[0][0],t[0][1]):function(r){return r===e||function(e,t,r,i){var n=r.length,s=n,o=!i;if(null==e)return!s;for(e=Object(e);n--;){var a=r[n];if(o&&a[2]?a[1]!==e[a[0]]:!(a[0]in e))return!1}for(;++n<s;){var l=(a=r[n])[0],c=e[l],h=a[1];if(o&&a[2]){if(void 0===c&&!(l in e))return!1}else{var u=new ah;if(i)var d=i(c,h,l,e,t,u);if(!(void 0===d?jh(h,c,3,i,u):d))return!1}}return!0}(r,e,t)}}function Qh(e,t){return null!=e&&t in Object(e)}function Yh(e,t){return null!=e&&function(e,t,r){for(var i=-1,n=(t=nh(t,e)).length,s=!1;++i<n;){var o=sh(t[i]);if(!(s=null!=e&&r(e,o)))break;e=e[o]}return s||++i!=n?s:!!(n=null==e?0:e.length)&&pc(n)&&uc(o,n)&&(Vl(e)||wc(e))}(e,t,Qh)}function Wh(e,t){return Vc(e)&&Vh(t)?Hh(sh(e),t):function(r){var i=function(e,t,r){var i=null==e?void 0:oh(e,t);return void 0===i?r:i}(r,e);return void 0===i&&i===t?Yh(r,e):jh(t,i,3)}}function Xh(e){return Vc(e)?(t=sh(e),function(e){return null==e?void 0:e[t]}):function(e){return function(t){return oh(t,e)}}(e);var t}function Kh(e){return"function"==typeof e?e:null==e?Wl:"object"==typeof e?Vl(e)?Wh(e[0],e[1]):Jh(e):Xh(e)}var qh,Zh=function(e,t,r){for(var i=-1,n=Object(e),s=r(e),o=s.length;o--;){var a=s[qh?o:++i];if(!1===t(n[a],a,n))break}return e};var $h=function(e,t){return function(r,i){if(null==r)return r;if(!fc(r))return e(r,i);for(var n=r.length,s=t?n:-1,o=Object(r);(t?s--:++s<n)&&!1!==i(o[s],s,o););return r}}((function(e,t){return e&&Zh(e,t,kc)}));function eu(e,t){if(e!==t){var r=void 0!==e,i=null===e,n=e==e,s=Gl(e),o=void 0!==t,a=null===t,l=t==t,c=Gl(t);if(!a&&!c&&!s&&e>t||s&&o&&l&&!a&&!c||i&&o&&l||!r&&l||!n)return 1;if(!i&&!s&&!c&&e<t||c&&r&&n&&!i&&!s||a&&r&&n||!o&&n||!l)return-1}return 0}function tu(e,t,r){t=t.length?jl(t,(function(e){return Vl(e)?function(t){return oh(t,1===e.length?e[0]:e)}:e})):[Wl];var i=-1;return t=jl(t,Tc(Kh)),function(e,t){var r=e.length;for(e.sort(t);r--;)e[r]=e[r].value;return e}(function(e,t){var r=-1,i=fc(e)?Array(e.length):[];return $h(e,(function(e,n,s){i[++r]=t(e,n,s)})),i}(e,(function(e,r,n){return{criteria:jl(t,(function(t){return t(e)})),index:++i,value:e}})),(function(e,t){return function(e,t,r){for(var i=-1,n=e.criteria,s=t.criteria,o=n.length,a=r.length;++i<o;){var l=eu(n[i],s[i]);if(l)return i>=a?l:l*("desc"==r[i]?-1:1)}return e.index-t.index}(e,t,r)}))}function ru(e){let t;return e instanceof Array?(t={},e.forEach((e=>{t[e.uuid]=e}))):t=e,t}class iu extends(Ko(t.ObjectLoader)){constructor(){super(...arguments),this.path="",this.resourcePath=""}loadFromFile(e){var t;return er(this,void 0,void 0,(function*(){const r=yield function(e,t,r=Xo.ARRAY_BUFFER){const i=new FileReader;return new Promise(((n,s)=>{const o=()=>{s({error:!0,filename:e.name}),t.itemError(e.name),t.itemEnd(e.name)};switch(i.addEventListener("loadstart",(()=>{t.itemStart(e.name)})),i.addEventListener("load",(e=>{var t;const r=null===(t=e.target)||void 0===t?void 0:t.result;null!=r?n(r):o()}),!1),i.addEventListener("error",o),r){case Xo.TEXT:i.readAsText(e);break;case Xo.BINARY_STRING:if(void 0!==i.readAsBinaryString){i.readAsBinaryString(e);break}case Xo.ARRAY_BUFFER:default:i.readAsArrayBuffer(e)}}))}(e,this.manager,Xo.TEXT),{object:i,materials:n}=this.parse(JSON.parse(r));return i.name=null!==(t=e.name.split(".").shift())&&void 0!==t?t:e.name,this.manager.itemEnd(e.name),{scene:i,materials:n}}))}load(e,r,i,n){const s=""===this.path?t.LoaderUtils.extractUrlBase(e):this.path;this.resourcePath=this.resourcePath||s;const o=new t.FileLoader(this.manager);o.setPath(this.path),o.load(e,(t=>{let i=null;try{i=JSON.parse(t)}catch(t){return void 0!==n&&n(t),console.warn(`ObjectLoader > load: can't parse ${e}.`),void console.error(t)}const s=i.metadata;void 0!==s&&void 0!==s.type&&"geometry"!==s.type.toLowerCase()?this.parse(i,r):console.error("ObjectLoader: Can't load "+e)}),i,n)}parse(e,t){var r;if(!1===Aa(e))return console.error("File can not be parser"),{object:new jo,materials:{}};const i={},n=this.parseGeometries(e.geometries),s=this.loader.parseImages(e.images,(()=>{void 0!==t&&t(h)})),o=this.parseTextures(e.textures,s),a=new Ea;a.init(ru(null!==(r=e.nodes)&&void 0!==r?r:[]),ru(o));const l=ru(this.loader.parseMaterials(e.materials,o)),c=this.customParseMaterials(l,e.materials,a),h=this.parseObject(e.object,n,c,i),u=this.parseInteractionStates(e.interactionStates,a);return this.parseInteractions(e.object,i,u),void 0!==e.images&&0!==e.images.length||void 0!==t&&t(h),{object:h,materials:c}}parseGeometries(e){var t,r;const i={};if(void 0!==e)for(let n=0,s=e.length;n<s;n++){const s=e[n];let o;try{switch(null===(t=s.userData)||void 0===t?void 0:t.type){case void 0:o=this.loader.parseGeometries([s])[s.uuid];break;case"NonParametricGeometry":o=s.vertexData?(new Ca).parse(s):this.loader.parseGeometries([s])[s.uuid],o.userData={};const e=Object.assign({},s.userData,{geometry:o});o=Be.create(e);break;case"SubdivGeometry":o=this.loader.parseGeometries([s])[s.uuid],o=We.create({parameters:s.userData.parameters,geometry:o});break;default:o=Ke(s.userData)}o.uuid=s.uuid,void 0!==s.name&&(o.name=s.name),i[s.uuid]=o}catch(e){console.warn("ObjectLoader > parseGeometries: error parsing geometry of type .",null===(r=s.userData)||void 0===r?void 0:r.type),console.error(e)}}return i}parseAsync(e){var t;return er(this,void 0,void 0,(function*(){if(!1===Aa(e))return console.error("File can not be parser"),new jo;const r=new Ea,i={},n=yield this.parseGeometriesAsync(e.geometries),s=this.loader.parseImages(e.images,(()=>{})),o=this.parseTextures(e.textures,s);r.init(ru(null!==(t=e.nodes)&&void 0!==t?t:[]),ru(o));const a=ru(this.loader.parseMaterials(e.materials,o)),l=this.customParseMaterials(a,e.materials,r),c=this.parseObject(e.object,n,l,i),h=this.parseInteractionStates(e.interactionStates,r);return this.parseInteractions(e.object,i,h),c}))}parseGeometriesAsync(e){var t,r;return er(this,void 0,void 0,(function*(){const i={};if(void 0!==e)for(let l=0,c=e.length;l<c;l++){const c=e[l];let h;try{switch(null===(t=c.userData)||void 0===t?void 0:t.type){case void 0:h=this.loader.parseGeometries([c])[c.uuid];break;case"NonParametricGeometry":if(c.gltf){if(!this.gltfLoader){this.gltfLoader=new Da;const e=new Ol;e.setDecoderPath("https://www.gstatic.com/draco/v1/decoders/"),this.gltfLoader.setDRACOLoader(e)}const e=yield new Promise((e=>{this.gltfLoader.parse(JSON.stringify(c.gltf),"",e)})),t=[];if(e.scene.traverse((e=>{const r=e;r.isMesh&&t.push(r.geometry)})),1===t.length)h=t[0];else{const e=(s=e=>c.gltf.meshes.findIndex((t=>{const r=t.primitives[0].attributes.POSITION;return c.gltf.accessors[r].count===e.index.count})),o=void 0,a=void 0,null==(n=t)?[]:(Vl(s)||(s=null==s?[]:[s]),Vl(o=a?void 0:o)||(o=null==o?[]:[o]),tu(n,s,o)));h=ke.mergeBufferGeometries(e,!0)}}else h=this.loader.parseGeometries([c])[c.uuid];h.userData={};const e=Object.assign({},c.userData,{geometry:h});h=Be.create(e);break;default:h=Ke(c.userData)}h.uuid=c.uuid,void 0!==c.name&&(h.name=c.name),i[c.uuid]=h}catch(e){console.warn("ObjectLoader > parseGeometries: error parsing geometry of type .",null===(r=c.userData)||void 0===r?void 0:r.type),console.error(e)}}var n,s,o,a;return i}))}parseTextures(e,t){const r=this.loader.parseTextures(e,t);return Object.keys(r).forEach((e=>{const t=(new Lt).copy(r[e]);t.uuid=e,r[e]=t})),r}customParseMaterials(e,t,r){const i={};if(void 0!==t)for(let n=0,s=t.length;n<s;n++){const s=t[n],o=e[s.uuid],a=o.userData;if(void 0!==a.type){const e=zr[a.type];i[s.uuid]=e.fromJSON(o,s,r)}}return i}parseObject(e,t,r,i){let n;if(void 0!==e.geometry){const i=function(e,t){return void 0===e[t]&&console.warn("ObjectLoader > getGeometry: undefined geometry",t),e[t]}(t,e.geometry),s=function(e,t){if(void 0!==t){if(t instanceof Array){const r=[];for(let i=0,n=t.length;i<n;i++){const n=t[i];void 0===e[n]&&console.warn("ObjectLoader > getMaterial: undefined material",n),r.push(e[n])}return r}return void 0===e[t]&&console.warn("ObjectLoader > getMaterial: undefined material",t),e[t]}}(r,e.material);if(i){switch(e.objectType){case"Mesh2D":n=new ms(i,s).fromJSON(e);break;case"Mesh3D":n=new gs(i,s).fromJSON(e);break;case"NonParametric":n=new vs(i,s).fromJSON(e);break;case"TextFrame":n=new Qo(i,s),n.fromJSONasync(e).then((()=>{})).catch((()=>{}));break;case"VectorObject":n=new is(i,s).fromJSON(e);break;case"SubdivObject":n=new wa(i,s).fromJSON(e),n.subdivPointer=i.subdivPointer;break;default:return void console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType)}s||(n.name+=" (Recovered)")}else n=(new os).fromJSON(e),n.name+=" (Recovered)",console.warn("An empty object is created instead")}else switch(e.objectType){case"Scene":n=(new jo).fromJSON(e);break;case"CombinedCamera":n=(new ss).fromJSON(e);break;case"LightDirectional":n=(new as).fromJSON(e);break;case"LightPoint":n=(new ls).fromJSON(e);break;case"LightSpot":n=(new ds).fromJSON(e);break;case"EmptyObject":n=(new os).fromJSON(e);break;default:if("HemisphereLight"!==e.type&&"DirectionalLight"!==e.type)return void console.warn("ObjectLoader > parseObject: unsupported object type",e.objectType);n=this.loader.parseObject(e,t,r)}if(Fn(n)&&(i[e.uuid]=n),void 0!==e.children)for(const s of e.children){const e=this.parseObject(s,t,r,i);void 0!==e&&n.add(e)}return n instanceof jo&&n.initFromObjectLoader(e),n}parseInteractionStates(e,t){const r={};if(void 0!==e)for(let i=0,n=e.length;i<n;i++){const n=(new Jr).fromJSON(e[i],t);r[n.uuid]=n}return r}parseInteractions(e,t,r){const i=t[e.uuid];if(void 0!==e.interaction&&void 0!==i&&(i.interaction=new Pn(i).fromJSON(e.interaction,t,r)),void 0!==e.children)for(const i of e.children)this.parseInteractions(i,t,r)}}const nu={type:"change"},su={type:"changeZoom"},ou={type:"start"},au={type:"end"},lu=navigator.platform.toUpperCase().indexOf("MAC")>=0;class cu extends t.EventDispatcher{constructor(e,r){let i,n,s,o,a;super(),void 0===r&&console.warn('THREE.OrbitControls: The second parameter "domElement" is now mandatory.'),r===document&&console.error('THREE.OrbitControls: "document" should not be used as the target "domElement". Please use "renderer.domElement" instead.'),this.object=e,this.domElement=r,this.enabled=!0,this.useKeyEvents=!0,this.target=new t.Vector3,this.object.getTarget(this.target),this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0+1*t.MathUtils.DEG2RAD,this.maxPolarAngle=Math.PI-1*t.MathUtils.DEG2RAD,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.1,this.enableZoom=!0,this.zoomSpeed=2,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.panSpeed=1,this.screenSpacePanning=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.autoRotateClockwise=!0,this.keys={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",BOTTOM:"ArrowDown"},this.mouseButtons={LEFT:t.MOUSE.ROTATE,MIDDLE:t.MOUSE.DOLLY,RIGHT:t.MOUSE.PAN},this.touches={ONE:t.TOUCH.ROTATE,TWO:t.TOUCH.DOLLY_PAN},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return d.phi},this.getAzimuthalAngle=function(){return d.theta},this.saveState=function(){l.target0.copy(l.target),l.position0.copy(l.object.position),l.zoom0=l.object.zoom},this.reset=function(){l.target.copy(l.target0),l.object.position.copy(l.position0),l.object.zoom=l.zoom0,i=0,l.object.updateProjectionMatrix(),l.dispatchEvent(nu),l.update(),h=c.NONE},this.update=function(){const r=new t.Vector3,v=(new t.Quaternion).setFromUnitVectors(e.up,new t.Vector3(0,1,0)),y=v.clone().invert(),A=new t.Vector3,w=new t.Quaternion,x=2*Math.PI;return function(){const e=l.object.position;var t;r.copy(e).sub(l.target),r.applyQuaternion(v),d.setFromVector3(r),l.autoRotate&&h===c.NONE&&(!0===l.autoRotateClockwise?M(O()):(t=O(),p.theta+=t)),l.rotationLimitsMode!==l.rotationLimitsOptions.HORIZONTAL&&(d.phi+=p.phi),l.rotationLimitsMode===l.rotationLimitsOptions.VERTICAL&&!0!==l.autoRotate||(d.theta+=p.theta),l.rotationLimitsMode!==l.rotationLimitsOptions.VERTICAL&&l.rotationLimitsMode!==l.rotationLimitsOptions.BOTH||(d.phi=Math.max(n,Math.min(s,d.phi))),l.rotationLimitsMode!==l.rotationLimitsOptions.HORIZONTAL&&l.rotationLimitsMode!==l.rotationLimitsOptions.BOTH||(i+=p.theta,i>l.rotationHorizontalOffset.max?(d.theta=a,i=l.rotationHorizontalOffset.max):i<-l.rotationHorizontalOffset.min&&(d.theta=o,i=-l.rotationHorizontalOffset.min));let b=l.minAzimuthAngle,S=l.maxAzimuthAngle;return isFinite(b)&&isFinite(S)&&(b<-Math.PI?b+=x:b>Math.PI&&(b-=x),S<-Math.PI?S+=x:S>Math.PI&&(S-=x),d.theta=b<=S?Math.max(b,Math.min(S,d.theta)):d.theta>(b+S)/2?Math.max(b,d.theta):Math.min(S,d.theta)),d.phi=Math.max(l.minPolarAngle,Math.min(l.maxPolarAngle,d.phi)),d.makeSafe(),d.radius*=f,d.radius=Math.max(l.minDistance,Math.min(l.maxDistance,d.radius)),l.target.add(m),r.setFromSpherical(d),r.applyQuaternion(y),e.copy(l.target).add(r),l.object.lookAt(l.target),!0===l.enableDamping?(p.theta*=1-l.dampingFactor,p.phi*=1-l.dampingFactor):p.set(0,0,0),m.set(0,0,0),f=1,!!(g||A.distanceToSquared(l.object.position)>u||8*(1-w.dot(l.object.quaternion))>u)&&(l.dispatchEvent(nu),g&&l.dispatchEvent(su),A.copy(l.object.position),w.copy(l.object.quaternion),g=!1,!0)}}(),this.dispose=function(){l.domElement.removeEventListener("contextmenu",se),l.domElement.removeEventListener("pointerdown",X),l.domElement.removeEventListener("wheel",$),l.domElement.removeEventListener("touchstart",re),l.domElement.removeEventListener("touchend",ne),l.domElement.removeEventListener("touchmove",ie),l.domElement.ownerDocument.removeEventListener("pointermove",K),l.domElement.ownerDocument.removeEventListener("pointerup",q),l.domElement.removeEventListener("gesturestart",z),l.domElement.removeEventListener("gesturechange",z),l.domElement.removeEventListener("gestureend",z),window.removeEventListener("keydown",ee,!1),window.removeEventListener("keyup",te,!1)},this.zoomOut=function(){I(D())},this.zoomIn=function(){P(D())},this.setEnableDampingSpeed=function(e){this.enableDamping=e,this.rotateSpeed=!0===e?.2:1},this.resetTo=function(e,t,r){l.target.copy(e),l.object.position.copy(t),l.object.zoom=r,l.object.updateProjectionMatrix(),l.dispatchEvent(nu),l.update(),h=c.NONE},this.updateTarget=function(){this.object.getTarget(this.target),this.update()},this.rotationVerticalOffset={min:.5*Math.PI,max:.5*Math.PI},this.rotationHorizontalOffset={min:.5*Math.PI,max:.5*Math.PI},this.rotationLimitsOptions={DEFAULT:0,VERTICAL:1,HORIZONTAL:2,BOTH:3},this.rotationLimitsMode=this.rotationLimitsOptions.DEFAULT,this.updateRotationOffetLimits=function(){i=0,n=hu(d.phi-l.rotationVerticalOffset.min),s=hu(d.phi+l.rotationVerticalOffset.max),n<0&&(n=l.minPolarAngle),s<0&&(s=l.maxPolarAngle),o=hu(d.theta-l.rotationHorizontalOffset.min),a=hu(d.theta+l.rotationHorizontalOffset.max)},this.toJSON=function(){const e={};return l.useKeyEvents&&(e.useKeyEvents=!0),l.enableDamping&&(e.enableDamping=!0),l.enablePan&&(e.enablePan=!0),l.enableZoom&&(e.enableZoom=!0),l.enableRotate&&(e.enableRotate=!0),e.rotationLimitsMode=l.rotationLimitsMode,l.rotationLimitsMode!==l.rotationLimitsOptions.VERTICAL&&l.rotationLimitsMode!==l.rotationLimitsOptions.BOTH||(e.rotationVerticalOffset={min:l.rotationVerticalOffset.min,max:l.rotationVerticalOffset.max}),l.rotationLimitsMode!==l.rotationLimitsOptions.HORIZONTAL&&l.rotationLimitsMode!==l.rotationLimitsOptions.BOTH||(e.rotationHorizontalOffset={min:l.rotationHorizontalOffset.min,max:l.rotationHorizontalOffset.max}),l.autoRotate&&(e.autoRotate=!0,e.autoRotateSpeed=l.autoRotateSpeed,l.autoRotateClockwise&&(e.autoRotateClockwise=!0)),e},this.fromJSON=function(e){l.useKeyEvents=!0===e.useKeyEvents,l.setEnableDampingSpeed(!0===e.enableDamping),l.enablePan=!0===e.enablePan,l.enableZoom=!0===e.enableZoom,l.enableRotate=!0===e.enableRotate,void 0!==e.rotationLimitsMode&&(l.rotationLimitsMode=e.rotationLimitsMode),e.rotationVerticalOffset&&(l.rotationVerticalOffset={min:e.rotationVerticalOffset.min,max:e.rotationVerticalOffset.max}),e.rotationHorizontalOffset&&(l.rotationHorizontalOffset={min:e.rotationHorizontalOffset.min,max:e.rotationHorizontalOffset.max}),l.autoRotate=!0===e.autoRotate,e.autoRotateSpeed&&(l.autoRotateSpeed=e.autoRotateSpeed),l.autoRotateClockwise=!0===e.autoRotateClockwise,l.updateRotationOffetLimits()};const l=this,c={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_PAN:4,TOUCH_DOLLY_PAN:5,TOUCH_DOLLY_ROTATE:6};let h=c.NONE;const u=1e-6,d=new t.Spherical,p=new t.Spherical;let f=1;const m=new t.Vector3;let g=!1;const v=new t.Vector2,y=new t.Vector2,A=new t.Vector2,w=new t.Vector2,x=new t.Vector2,b=new t.Vector2,S=new t.Vector2,E=new t.Vector2,C=new t.Vector2;let T={};function O(){return 2*Math.PI/60/60*l.autoRotateSpeed}function D(){return Math.pow(.95,l.zoomSpeed)}function M(e){p.theta-=e}function _(e){p.phi-=e}const N=function(){const e=new t.Vector3;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),m.add(e)}}(),L=function(){const e=new t.Vector3;return function(t,r){!0===l.screenSpacePanning?e.setFromMatrixColumn(r,1):(e.setFromMatrixColumn(r,0),e.crossVectors(l.object.up,e)),e.multiplyScalar(t),m.add(e)}}(),B=function(){const e=new t.Vector3;return function(t,r){const i=l.domElement;if(l.object.isPerspectiveCamera){const n=l.object.position;e.copy(n).sub(l.target);let s=e.length();s*=Math.tan(l.object.fov/2*Math.PI/180),N(2*t*s/i.clientHeight,l.object.matrix),L(2*r*s/i.clientHeight,l.object.matrix)}else l.object.isOrthographicCamera?(N(t*(l.object.right-l.object.left)/l.object.zoom/i.clientWidth,l.object.matrix),L(r*(l.object.top-l.object.bottom)/l.object.zoom/i.clientHeight,l.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),l.enablePan=!1)}}();function I(e){l.object.isPerspectiveCamera?f/=e:l.object.isOrthographicCamera?(l.object.zoom=Math.max(l.minZoom,Math.min(l.maxZoom,l.object.zoom*e)),l.object.updateProjectionMatrix(),g=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),l.enableZoom=!1)}function P(e){l.object.isPerspectiveCamera?f*=e:l.object.isOrthographicCamera?(l.object.zoom=Math.max(l.minZoom,Math.min(l.maxZoom,l.object.zoom/e)),l.object.updateProjectionMatrix(),g=!0):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - dolly/zoom disabled."),l.enableZoom=!1)}function R(e){v.set(e.clientX,e.clientY)}function F(e){w.set(e.clientX,e.clientY)}let U=0;function z(e){if(e.preventDefault(),"gesturechange"===e.type){if(!1===l.enableZoom)return;e.scale>U?P(D()):e.scale<U&&I(D()),U=e.scale}}let k,G,j=!1;function V(e){if(1==e.touches.length)v.set(e.touches[0].pageX,e.touches[0].pageY);else{const t=.5*(e.touches[0].pageX+e.touches[1].pageX),r=.5*(e.touches[0].pageY+e.touches[1].pageY);v.set(t,r)}}function H(e){if(1==e.touches.length)w.set(e.touches[0].pageX,e.touches[0].pageY);else{const t=.5*(e.touches[0].pageX+e.touches[1].pageX),r=.5*(e.touches[0].pageY+e.touches[1].pageY);w.set(t,r)}}function J(e){const t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);S.set(0,i)}function Q(e){if(1==e.touches.length)y.set(e.touches[0].pageX,e.touches[0].pageY);else{const t=.5*(e.touches[0].pageX+e.touches[1].pageX),r=.5*(e.touches[0].pageY+e.touches[1].pageY);y.set(t,r)}A.subVectors(y,v).multiplyScalar(l.rotateSpeed);const t=l.domElement;M(2*Math.PI*A.x/t.clientHeight),_(2*Math.PI*A.y/t.clientHeight),v.copy(y)}function Y(e){if(1==e.touches.length)x.set(e.touches[0].pageX,e.touches[0].pageY);else{const t=.5*(e.touches[0].pageX+e.touches[1].pageX),r=.5*(e.touches[0].pageY+e.touches[1].pageY);x.set(t,r)}b.subVectors(x,w).multiplyScalar(l.panSpeed),B(b.x,b.y),w.copy(x)}function W(e){const t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);E.set(0,i),C.set(0,Math.pow(E.y/S.y,l.zoomSpeed)),I(C.y),S.copy(E)}function X(e){if(!1!==l.enabled)switch(e.pointerType){case"mouse":case"pen":!1===l.useKeyEvents?function(e){let r;switch(e.preventDefault(),l.domElement.focus?l.domElement.focus():window.focus(),e.button){case 0:r=l.mouseButtons.LEFT;break;case 1:r=l.mouseButtons.MIDDLE;break;case 2:r=l.mouseButtons.RIGHT;break;default:r=-1}switch(r){case t.MOUSE.DOLLY:if(!1===l.enablePan)return;F(e),h=c.PAN;break;case t.MOUSE.ROTATE:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===l.enablePan)return;F(e),h=c.PAN}else{if(!1===l.enableRotate)return;R(e),h=c.ROTATE}break;case t.MOUSE.PAN:if(e.ctrlKey||e.metaKey||e.shiftKey){if(!1===l.enableRotate)return;R(e),h=c.ROTATE}else{if(!1===l.enablePan)return;F(e),h=c.PAN}break;default:h=c.NONE}h!==c.NONE&&(l.domElement.ownerDocument.addEventListener("pointermove",K),l.domElement.ownerDocument.addEventListener("pointerup",q),l.dispatchEvent(ou))}(e):function(e){if(!1===l.enabled||!0===l.object.enableableVectorControls||!0===l.object.enableableTransformControls||"Vertex"===l.object.enableableResizeControls||"Face"===l.object.enableableResizeControls||"Edge"===l.object.enableableResizeControls||"Vertex"===l.object.enableableScaleControls||"Face"===l.object.enableableScaleControls||"Edge"===l.object.enableableScaleControls)return;switch(e.preventDefault(),l.domElement.focus?l.domElement.focus():window.focus(),e.button){case l.mouseButtons.MIDDLE:if(!1===l.enablePan)return;F(e),h=c.PAN;break;case l.mouseButtons.LEFT:if(!0!==e.altKey||e.shiftKey||(lu?e.metaKey:e.ctrlKey)){if("Space"===T.code){if(!1===l.enablePan)return;F(e),h=c.PAN}}else{if(!1===l.enableRotate)return;R(e),h=c.ROTATE}break;default:h=c.NONE}h!==c.NONE&&(l.domElement.ownerDocument.addEventListener("pointermove",K),l.domElement.ownerDocument.addEventListener("pointerup",q),l.dispatchEvent(ou))}(e)}}function K(e){if(!1!==l.enabled)switch(e.pointerType){case"mouse":case"pen":!function(e){if(!1===l.enabled)return;switch(e.preventDefault(),h){case c.ROTATE:if(!1===l.enableRotate)return;!function(e){y.set(e.clientX,e.clientY),A.subVectors(y,v).multiplyScalar(l.rotateSpeed);const t=l.domElement;M(2*Math.PI*A.x/t.clientHeight),_(2*Math.PI*A.y/t.clientHeight),v.copy(y),l.update()}(e);break;case c.DOLLY:if(!1===l.enableZoom)return;!function(e){E.set(e.clientX,e.clientY),C.subVectors(E,S),C.y>0?I(D()):C.y<0&&P(D()),S.copy(E),l.update()}(e);break;case c.PAN:if(!1===l.enablePan)return;!function(e){x.set(e.clientX,e.clientY),b.subVectors(x,w).multiplyScalar(l.panSpeed),B(b.x,b.y),w.copy(x),l.update()}(e)}}(e)}}function q(e){switch(e.pointerType){case"mouse":case"pen":Z()}}function Z(e){l.domElement.ownerDocument.removeEventListener("pointermove",K),l.domElement.ownerDocument.removeEventListener("pointerup",q),!1!==l.enabled&&(l.dispatchEvent(au),h=c.NONE)}function $(e){!1===l.enabled||!1===l.enableZoom||h!==c.NONE&&h!==c.ROTATE||(e.preventDefault(),l.dispatchEvent(ou),function(e){if(j){if(!1===G||(lu?e.metaKey:e.ctrlKey)){if(!1===l.enableZoom)return;e.deltaY<0?P(D()):e.deltaY>0&&I(D())}else{if(!1===l.enablePan)return;b.set(-e.deltaX,-e.deltaY).multiplyScalar(l.panSpeed),e.altKey?B(0,b.y):e.shiftKey?B(b.x,0):B(b.x,b.y)}l.update()}else j=!0,G=function(e){return e.wheelDeltaY?e.wheelDeltaY===-3*e.deltaY:0===e.deltaMode}(e);k&&window.clearTimeout(k),k=window.setTimeout((()=>{j=!1,G=void 0}),200)}(e),l.dispatchEvent(au))}function ee(e){!1!==l.enabled&&(T=e)}function te(){!1!==l.enabled&&(T={},h!==c.NONE&&Z(new PointerEvent("pointerover")))}function re(e){if(!1!==l.enabled){switch(e.preventDefault(),e.touches.length){case 1:switch(l.touches.ONE){case t.TOUCH.ROTATE:if(!1===l.enableRotate)return;V(e),h=c.TOUCH_ROTATE;break;case t.TOUCH.PAN:if(!1===l.enablePan)return;H(e),h=c.TOUCH_PAN;break;default:h=c.NONE}break;case 2:switch(l.touches.TWO){case t.TOUCH.DOLLY_PAN:if(!1===l.enableZoom&&!1===l.enablePan)return;!function(e){l.enableZoom&&J(e),l.enablePan&&H(e)}(e),h=c.TOUCH_DOLLY_PAN;break;case t.TOUCH.DOLLY_ROTATE:if(!1===l.enableZoom&&!1===l.enableRotate)return;!function(e){l.enableZoom&&J(e),l.enableRotate&&V(e)}(e),h=c.TOUCH_DOLLY_ROTATE;break;default:h=c.NONE}break;default:h=c.NONE}h!==c.NONE&&l.dispatchEvent(ou)}}function ie(e){if(!1!==l.enabled)switch(e.preventDefault(),h){case c.TOUCH_ROTATE:if(!1===l.enableRotate)return;Q(e),l.update();break;case c.TOUCH_PAN:if(!1===l.enablePan)return;Y(e),l.update();break;case c.TOUCH_DOLLY_PAN:if(!1===l.enableZoom&&!1===l.enablePan)return;!function(e){l.enableZoom&&W(e),l.enablePan&&Y(e)}(e),l.update();break;case c.TOUCH_DOLLY_ROTATE:if(!1===l.enableZoom&&!1===l.enableRotate)return;!function(e){l.enableZoom&&W(e),l.enableRotate&&Q(e)}(e),l.update();break;default:h=c.NONE}}function ne(e){!1!==l.enabled&&(l.dispatchEvent(au),h=c.NONE)}function se(e){!1!==l.enabled&&e.preventDefault()}l.domElement.addEventListener("contextmenu",se),l.domElement.addEventListener("pointerdown",X),l.domElement.addEventListener("wheel",$,{passive:!1}),l.domElement.addEventListener("touchstart",re,{passive:!1}),l.domElement.addEventListener("touchend",ne),l.domElement.addEventListener("touchmove",ie,{passive:!1}),l.domElement.addEventListener("gesturestart",z),l.domElement.addEventListener("gesturechange",z),l.domElement.addEventListener("gestureend",z),window.addEventListener("keydown",ee,!1),window.addEventListener("keyup",te,!1),this.update(),this.updateRotationOffetLimits(),this.setEnableDampingSpeed(!0)}}function hu(e){const t=2*Math.PI;for(;e<=-Math.PI;)e+=t;for(;e>Math.PI;)e-=t;return e}class uu{constructor(e,r,i,n,s){this._aspect=1,this._renderer=e,this._camera=r,this._frameSize=(new t.Vector2).copy(i),this._editorSize=(new t.Vector2).copy(n),this._fov=null!=s?s:r.fov}set frameSize(e){this._frameSize.copy(e)}updateRenderer(){this._renderer&&this._renderer.setSize(this._frameSize.x,this._frameSize.y)}updateViewport(){if(!this._renderer)return;if(!this._camera)return;if("PerspectiveCamera"!==this._camera.cameraType)return;const e=this._frameSize.x,t=this._frameSize.y,r=this._editorSize.x,i=this._editorSize.y;let n=0,s=0,o=e,a=t;e<r&&(n=.5*(r-e),n=-n,o=r),t<i&&(s=.5*(i-t),s=-s,a=i),this._aspect=o/a,this._renderer.setViewport(n,s,o,a)}updateCamera(){var e,t;if(this._camera)if("PerspectiveCamera"===this._camera.cameraType){const r=this._frameSize.y,i=this._editorSize.y;let n=this._fov;if(r>i){n*=r/i,n*=1-((r-(e=1080))/(2160-e)*(15-(t=1))+t)/100}this._camera.aspect=this._aspect,this._camera.fov=n,this._camera.updateProjectionMatrix()}else this._camera.setViewplaneSize(this._frameSize.x,this._frameSize.y)}revert(){const e=window.innerWidth,t=window.innerHeight;this._renderer&&(this._renderer.setViewport(0,0,e,t),this._renderer.setSize(e,t)),this._camera&&(this._camera.aspect=e/t,this._camera.fov=this._fov,this._camera.setViewplaneSize(e,t),this._camera.updateProjectionMatrix())}}var du=/^\s+|\s+$/g,pu=/^[-+]0x[0-9a-f]+$/i,fu=/^0b[01]+$/i,mu=/^0o[0-7]+$/i,gu=parseInt,vu="object"==typeof Yo&&Yo&&Yo.Object===Object&&Yo,yu="object"==typeof self&&self&&self.Object===Object&&self,Au=vu||yu||Function("return this")(),wu=Object.prototype.toString,xu=Math.max,bu=Math.min,Su=function(){return Au.Date.now()};function Eu(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Cu(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==wu.call(e)}(e))return NaN;if(Eu(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=Eu(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(du,"");var r=fu.test(e);return r||mu.test(e)?gu(e.slice(2),r?2:8):pu.test(e)?NaN:+e}var Tu,Ou,Du=function(e,t,r){var i,n,s,o,a,l,c=0,h=!1,u=!1,d=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function p(t){var r=i,s=n;return i=n=void 0,c=t,o=e.apply(s,r)}function f(e){return c=e,a=setTimeout(g,t),h?p(e):o}function m(e){var r=e-l;return void 0===l||r>=t||r<0||u&&e-c>=s}function g(){var e=Su();if(m(e))return v(e);a=setTimeout(g,function(e){var r=t-(e-l);return u?bu(r,s-(e-c)):r}(e))}function v(e){return a=void 0,d&&i?p(e):(i=n=void 0,o)}function y(){var e=Su(),r=m(e);if(i=arguments,n=this,l=e,r){if(void 0===a)return f(l);if(u)return a=setTimeout(g,t),p(l)}return void 0===a&&(a=setTimeout(g,t)),o}return t=Cu(t)||0,Eu(r)&&(h=!!r.leading,s=(u="maxWait"in r)?xu(Cu(r.maxWait)||0,t):s,d="trailing"in r?!!r.trailing:d),y.cancel=function(){void 0!==a&&clearTimeout(a),c=0,i=l=n=a=void 0},y.flush=function(){return void 0===a?o:v(Su())},y};!function(e){e[e.FULLSCREEN=1]="FULLSCREEN",e[e.CUSTOM=2]="CUSTOM"}(Tu||(Tu={}));!function(e){e.ACUTE="´",e.GRAVE="`",e.CIRCUMFLEX="^",e.DIAERESIS="¨",e.TILDE="~"}(Ou||(Ou={}));Object.values(Ou);let Mu;return Jo.FONTS_PATH="_assets/_fonts/",t.ImageUtils.getDataURL=function(e){if(/^data:/i.test(e.src))return e.src;if("undefined"==typeof HTMLCanvasElement)return e.src;let t;if(e instanceof HTMLCanvasElement)t=e;else{void 0===Mu&&(Mu=document.createElementNS("http://www.w3.org/1999/xhtml","canvas")),Mu.width=e.width,Mu.height=e.height;const r=Mu.getContext("2d");e instanceof ImageData?r.putImageData(e,0,0):r.drawImage(e,0,0,e.width,e.height),t=Mu}return t.toDataURL("image/png")},e.Application=class{constructor(){this._viewportMode=Tu.FULLSCREEN,this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._running=!1,window.addEventListener("resize",Du(this.resize.bind(this),200))}start(e){fetch(e).then((e=>e.json())).then((e=>{this._editorData=e.editor;return(new iu).parseAsync(e)})).then((e=>{this._scene=e,this._camera=this._scene.activeCamera,this.init(),this._running=!0,this.run(),this.resize()})).catch((e=>{console.error(e)}))}run(){requestAnimationFrame(this.run.bind(this)),this.render()}render(){var e;this._running&&(this._renderer?(this._controls&&(this._controls.enableDamping||this._controls.autoRotate)&&this._controls.update(),this._playmode&&!this._playmode.isEnable&&this._playmode.activate(),this._scene&&this._camera&&((null===(e=this._scene.postprocessing)||void 0===e?void 0:e.enabled)?(this._renderer.autoClear=!0,this._scene.postprocessing.render()):(this._renderer.autoClear=!0,this._renderer.render(this._scene,this._camera)))):console.error("Application::render >>> tried to renderer without a renderer"))}resize(){var e,r,i;this._running&&this._renderer&&(this._viewportMode===Tu.FULLSCREEN&&(this._viewportWidth=window.innerWidth,this._viewportHeight=window.innerHeight,this._frameView&&(this._frameView.frameSize=new t.Vector2(this._viewportWidth,this._viewportHeight))),null===(e=this._frameView)||void 0===e||e.updateRenderer(),this._viewportMode!==Tu.FULLSCREEN&&(null===(r=this._frameView)||void 0===r||r.updateViewport()),this._camera&&(null===(i=this._frameView)||void 0===i||i.updateCamera(),"PerspectiveCamera"===this._camera.cameraType&&this._viewportMode===Tu.FULLSCREEN&&(this._camera.aspect=this._viewportWidth/this._viewportHeight),this._camera.updateProjectionMatrix()))}init(){var e,r,i,n;const s=document.getElementById("canvas3d");this._scene&&this._camera&&((null===(e=this._scene.postprocessing)||void 0===e?void 0:e.enabled)?(this._renderer=new t.WebGLRenderer({canvas:s,antialias:!1,stencil:!1,depth:!1,powerPreference:"high-performance"}),this._scene.postprocessing.init({renderer:this._renderer,camera:this._camera,scene:this._scene})):this._renderer=new t.WebGLRenderer({canvas:s,antialias:!0,alpha:!0,stencil:!0,depth:!0,powerPreference:"high-performance"}),this._viewportMode=null!==(r=this._scene.canvas.mode)&&void 0!==r?r:Tu.FULLSCREEN,this._viewportWidth=null!==(i=this._scene.canvas.size.width)&&void 0!==i?i:window.innerWidth,this._viewportHeight=null!==(n=this._scene.canvas.size.height)&&void 0!==n?n:window.innerHeight,this._renderer.setPixelRatio(window.devicePixelRatio),this._renderer.setSize(this._viewportWidth,this._viewportHeight),this._renderer.shadowMap.enabled=!0,this._renderer.shadowMap.type=t.PCFSoftShadowMap,this._renderer.setClearColor(this._scene.color,this._scene.alpha),this._frameView=new uu(this._renderer,this._camera,new t.Vector2(this._viewportWidth,this._viewportHeight),new t.Vector2(this._scene.canvas.editorSize.width,this._scene.canvas.editorSize.height)),this._controls=new cu(this._camera,this._renderer.domElement),this._editorData&&(this._controls.fromJSON(this._editorData.orbitControls),this._controls.useKeyEvents=!1),this._playmode=new ys(this._renderer.domElement,this._scene,this._camera))}},Object.defineProperty(e,"__esModule",{value:!0}),e}({},THREE);