@three3d/effect
Version:
@three3d/effect 提供了 ThreeJS 的特效
49 lines (45 loc) • 20.9 kB
JavaScript
(function(a,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@three3d/tools"),require("three")):typeof define=="function"&&define.amd?define(["exports","@three3d/tools","three"],g):(a=typeof globalThis<"u"?globalThis:a||self,g(a.Effect={},a.tools,a.three))})(this,function(a,g,l){"use strict";var de=Object.defineProperty;var pe=(a,g,l)=>g in a?de(a,g,{enumerable:!0,configurable:!0,writable:!0,value:l}):a[g]=l;var B=(a,g,l)=>(pe(a,typeof g!="symbol"?g+"":g,l),l);function Ot(n,s){const t=n.length;let e=1/0,o=0;for(;o<t;){const i=n[o],r=s-i;if(s<i)return-r>e?o-1:o;e=r,o++}return o}function Mt(n,s,t){const e=n.length;let o=0;for(;o<e;){const i=n[o];if(s<i)return t?o:o-1;o++}return t?-1:o}function Gt(n){var e;let s;const t=[];for(let o of n){let i,r=null;if(o instanceof l.Curve?(r=[o],i=o.getPoint(0)):Array.isArray(o)?(o.length>1&&(r=g.createLineCurves(o)),i=o[0]):i=o,s&&!s.equals(i)){const u=g.createLineCurve(s,i);t.push(u)}r&&t.push(...r),s=(e=t.at(-1))==null?void 0:e.getPoint(1)}return t}function Xt(n){let s;const t=[];for(let e of n){if(e instanceof l.Curve){t.push(e),s=e.getPoint(1);continue}else if(Array.isArray(e)){if(e.length>1){const o=g.createLineCurves(e);t.push(...o),s=e.at(-1);continue}e=e[0]}if(s&&!s.equals(e)){const o=g.createLineCurve(s,e);t.push(o)}s=e}return t}function vt(n,s,t){let e,o=[];if(n instanceof l.Curve?(e=n.getPoint(0),o=[n]):Array.isArray(n)?(n.length>1&&(o=g.createLineCurves(n)),e=n[0]):e=n,s&&(t||o.length===0)&&(t||o.length===0)){const i=g.createLineCurve(s,e);o.unshift(i)}return o}function Yt(n,s,t){const e=vt(n,s,t);switch(e.length){case 0:return null;case 1:return e[0]}const o=new l.CurvePath;return o.curves.push(...e),o}function Lt(n){return n instanceof l.Curve?n.getPoint(0):Array.isArray(n)?n[0]:n}function wt(n){return n instanceof l.Curve?n.getPoint(1):Array.isArray(n)?n.at(-1):n}const nt="lineDistance",gt={width:1,sampleLength:1,startLength:0,startColor:65280,endColor:255,autoClose:!1};function Vt(n,s){const{division:t}=g.getCurveDivisionLength({...s,curve:n});return n.getPoints(t)}function Nt(n,s){const{startColor:t,endColor:e,color:o,startLength:i}=s||{},r=o?new l.Color(o):null,u=t?new l.Color(t):r??new l.Color(0,1,0),c=e?new l.Color(e):r??new l.Color(0,0,1),h=i??0,f=[],p=[],d=g.getLinesInfo(n).lengths,y=1/(d.at(-1)+h),C=new l.Color;return n.forEach((v,D)=>{v.toArray(f,D*3);const L=d[D]+h;d[D]=L;const S=L*y;C.lerpColors(u,c,S),C.toArray(p,D*3)}),{color:p,position:f,lineDistance:d,lengths:d,points:n}}class Pt extends l.BufferGeometry{constructor(t){super();B(this,"isPathGeometry",!0);B(this,"_options",null);B(this,"_startDrawLength",0);B(this,"_endDrawLength",1/0);B(this,"_pathData",[]);B(this,"_curves",[]);B(this,"_curvePath",this.generateCurvePath());B(this,"points",[]);B(this,"lengths",[]);t&&(this.options=t)}get globalOptions(){return this.constructor.options}get options(){return this._options??(this._options=structuredClone(this.globalOptions))}set options(t){const e=this.options;this._options=t?Object.assign(e,t):null}get width(){return this.options.width??(this.options.width=this.globalOptions.width??gt.width)}set width(t){this.options.width=t}get sampleLength(){return this.options.sampleLength??(this.options.sampleLength=this.globalOptions.sampleLength??gt.sampleLength)}set sampleLength(t){this.options.sampleLength=t}get sampleNum(){return this.options.sampleNum??(this.options.sampleNum=this.globalOptions.sampleNum)}set sampleNum(t){this.options.sampleNum=t}get autoClose(){return this.options.autoClose??(this.options.autoClose=this.globalOptions.autoClose)}set autoClose(t){this.options.autoClose=t,this.curvePath.autoClose=!!t}get closed(){const{points:t}=this,e=t[0],o=t.at(-1);return e&&o?e.equals(o):!1}get color(){let t=this.options.color;if(!t){const e=this.globalOptions.color;e&&(this.options.color=t=structuredClone(e))}return t}set color(t){this.options.color=t}get startColor(){let t=this.options.startColor;if(!t){const e=this.globalOptions.startColor??gt.startColor;this.options.startColor=t=structuredClone(e)}return t}set startColor(t){this.options.startColor=t}get endColor(){let t=this.options.endColor;if(!t){const e=this.globalOptions.endColor??gt.endColor;this.options.endColor=t=structuredClone(e)}return t}set endColor(t){this.options.endColor=t}get startLength(){return this.options.startLength??(this.options.startLength=this.globalOptions.startLength??0)}set startLength(t){this.options.startLength=t}get endLength(){return this.lengths.at(-1)??this.startLength}get lineDistance(){var t;return(t=this.getAttribute(nt))==null?void 0:t.array}getClosestIndex(t){return Ot(this.lineDistance,t)}getNearbyIndex(t,e){return Mt(this.lineDistance,t,e)}setDrawLength(t,e){const o=this.getClosestIndex(t);let i=1/0;e==null||e===1/0||(i=this.getClosestIndex(e)-o+1),this.setDrawRange(o,i)}get startDrawLength(){return this._startDrawLength}set startDrawLength(t){this._startDrawLength=t,this.setDrawLength(t,this.endDrawLength)}get endDrawLength(){return this._endDrawLength??(this._endDrawLength=1/0)}set endDrawLength(t){this._endDrawLength=t,this.setDrawLength(this.startDrawLength,t)}copy(t){super.copy(t);const{lengths:e,_startDrawLength:o,_endDrawLength:i}=t;return this.lengths=e?[...e]:[],this._startDrawLength=o??0,this._endDrawLength=i||null,this}get vertexCount(){var t;return((t=this.getAttribute("position"))==null?void 0:t.count)??0}get pathData(){return this._pathData}set pathData(t){this._pathData=t,this.curves=Gt(t)}get closedPathData(){let t=this.pathData;if(this.autoClose){const e=Lt(t[0]),o=wt(t.at(-1));e.equals(o)||(t=[...t,e.clone()])}return t}get curves(){return this._curves}set curves(t){this._curves=t,this.curvePath=this.generateCurvePath()}get curvePath(){return this._curvePath}set curvePath(t){this._curvePath=t,this.updateGeometry()}get closedCurvePath(){let t=this.curvePath;return this.autoClose&&(t=t.clone(),g.closeCurvePath(t),t.autoClose=!1),t}generateCurvePath(){const t=new l.CurvePath;return t.curves=this.curves,t.autoClose=!!this.autoClose,t}get length(){return this.endLength-this.startLength}get lastPoint(){return this.curvePath.getPoint(1)}get firstPoint(){return this.curvePath.getPoint(0)}append(t){const e=vt(t,this.lastPoint,!0);this.pathData.push(t),this.curves.push(...e),this.updateGeometry()}set(t){this.pathData=[t],this.updateGeometry()}updateGeometry(){const{curvePath:t,options:e}=this,o=Vt(t,e),i=Nt(o,e);this.resetAttributes(i)}appendAttributes(t){var y,C,v,D,L,S;const{position:e,normal:o,uv:i,lengths:r,lineDistance:u,index:c,color:h,points:f}=t,p=((y=this.getAttribute("position"))==null?void 0:y.array)??[],d=this.lengths,m={position:[...p,...e],lengths:[...d,...r],points:[...this.points,...f]};if(o){const b=((C=this.getAttribute("normal"))==null?void 0:C.array)??[];m.normal=[...b,...o]}if(i){const b=((v=this.getAttribute("uv"))==null?void 0:v.array)??[];m.uv=[...b,...i]}if(c){const b=((D=this.getIndex())==null?void 0:D.array)??[];m.index=[...b,...c]}if(h){const b=((L=this.getAttribute("color"))==null?void 0:L.array)??[];m.color=[...b,...h]}if(u){const b=((S=this.getAttribute(nt))==null?void 0:S.array)??[];m.lineDistance=[...b,...u]}this.resetAttributes(m)}resetAttributes(t){const{position:e,normal:o,uv:i,lineDistance:r,lengths:u,index:c,color:h,points:f}=t;this.setAttribute("position",new l.Float32BufferAttribute(e,3)),c&&this.setIndex(c),o?this.setAttribute("normal",new l.Float32BufferAttribute(o,3)):this.deleteAttribute("normal"),i?this.setAttribute("uv",new l.Float32BufferAttribute(i,2)):this.deleteAttribute("uv"),h?this.setAttribute("color",new l.Float32BufferAttribute(h,3)):this.deleteAttribute("color"),r?this.setAttribute(nt,new l.Float32BufferAttribute(r,1)):this.deleteAttribute(nt),this.lengths=u,this.points=f,this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere()}get lastPosition(){const t=this.getAttribute("position");if(!t)return null;const e=t.count;return new l.Vector3().fromBufferAttribute(t,e-1)}}B(Pt,"options",structuredClone(gt));var Et=(n=>(n.curve="curve",n.polyline="polyline",n.blend="blend",n))(Et||{});const J={up:{x:0,y:1,z:0},useU:!1,fixUp:!1,uvStep:1,drawType:"blend",connectionType:g.LineConnectionType.round,smoothStepAngle:.5};function At(n,s){const{up:t,autoClose:e}=s,{division:o,length:i}=g.getCurveDivisionLength({...s,curve:n}),r=g.computeCurveFrenetFrames(n,o,t,{...s,closed:e});return r.length=i,qt(r,s)}function qt(n,s){const{startColor:t,endColor:e,color:o,preIndex:i,prePoint:r,connectPre:u}=s,c=o?new l.Color(o):null,h=t?new l.Color(t):c??new l.Color(0,1,0),f=e?new l.Color(e):c??new l.Color(0,0,1),p=s.width??1,d=s.preLength??0,{points:m,tangents:y,normals:C,binormals:v,length:D}=n,L=m[0],S=r?L.distanceTo(r):0,b=D+S+d,k=s.uvStep??b,O=m.length-1,K=p/2,X=[],R=[],z=[],st=[],Y=[],V=[],N=1/k,Z=1/b;let x=d;const I=new l.Color;let $=m[0];for(let T=0;T<=O;T++){const U=m[T],rt=C[T],w=v[T];x+=U.distanceTo($),X.push(x),V.push(x,x);const Q=x*N;st.push(0,Q,1,Q);const W=x*Z;I.lerpColors(h,f,W);const H=w.clone().multiplyScalar(K),E=U.clone().sub(H);let A=T*2*3;E.toArray(R,A),rt.toArray(z,A),I.toArray(Y,A);const at=U.clone().add(H);A+=3,at.toArray(R,A),rt.toArray(z,A),I.toArray(Y,A),$=U}const it=R.length/3,tt=i?g.createSymmetricSegmentedTrigonometricIndexs(it,i+1,u):g.createSymmetricSegmentedTrigonometricIndexs(it);return{position:R,normal:z,uv:st,index:tt,color:Y,lineDistance:V,lengths:X,points:m,tangents:y,normals:C,binormals:v}}function Ct(n,s){const{up:t,autoClose:e}=s;if(e){const i=n[0],r=n.at(-1);i.equals(r)||(n=[...n,i.clone()])}const o=s.fixUp?g.computePolylineFrenetFramesByFixUp(n,t):g.computePolylineFrenetFrames(n,t);return o.points=n,xt(o,s)}function xt(n,s){const{startColor:t,endColor:e,color:o,prePoint:i,preIndex:r,connectPre:u}=s,c=o?new l.Color(o):null,h=t?new l.Color(t):c??new l.Color(0,1,0),f=e?new l.Color(e):c??new l.Color(0,0,1),p=s.width??1,d=p/2,m=s.preLength??0,{tangents:y,normals:C,binormals:v,lengths:D,points:L}=n,S=D.at(-1);let b=y[0],k=C[0],O=v[0];const K=L[0],R=(i?K.distanceTo(i):0)+m,z=S+R,st=s.uvStep??z,Y=D.map(w=>w+R),V=[],N=[],Z=[],x=[],I=[],$=1/st,it=1/z,tt=new l.Color,T=L.length-1;let U=0;for(let w=0;w<=T;w++){const Q=Y[w],W=L[w],H=y[w],E=C[w],A=v[w],at=w<T,bt=w>0,Dt=at&&bt;let et,lt,ct;if(Dt){const P={point:W,length:Q,width:p},M={tangent:b,normal:k,binormal:O},F={tangent:H,normal:E,binormal:A};let q=g.createLineConnection(P,M,F,s);et=q.points,lt=q.normals,ct=q.lengths}else{const P=A.clone().multiplyScalar(d),M=W.clone().sub(P),F=W.clone().add(P);et=[M,F],lt=[E,E],ct=[Q,Q]}const ut=et.length;for(let P=0;P<ut;P++){const M=et[P],F=ct[P],q=lt[P],dt=F*it;tt.lerpColors(h,f,dt),tt.toArray(x,U),M.toArray(V,U),q.toArray(N,U),I.push(F);const pt=P%2,mt=F*$;Z.push(pt,mt),U+=3}b=H,k=E,O=A}const rt=r?g.createSymmetricSegmentedTrigonometricIndexsByVertexs(V,r+1,u):g.createSymmetricSegmentedTrigonometricIndexsByVertexs(V);return{position:V,normal:N,uv:Z,color:x,index:rt,lineDistance:I,length,lengths:Y,points:L,tangents:y,normals:C,binormals:v}}var jt=(n=>(n.intact="intact",n.add="add",n.addGap="addGap",n))(jt||{});function kt(n,s,t,e="intact"){let{points:o,index:i,lengths:r,position:u,normal:c,uv:h,color:f,lineDistance:p,tangents:d,normals:m,binormals:y}=n,{points:C,index:v,lengths:D,position:L,normal:S,uv:b,color:k,lineDistance:O,tangents:K,normals:X,binormals:R}=s;const{fixUp:z,up:st}=t,V=i.at(-3)-4,N=o.at(-1),Z=o.at(-2);let x=D.at(-1);const I=C[0],$=C[1];if(e&&e!=="intact"){let _=r.at(-1);e==="addGap"&&(_+=N.distanceTo(I));const ht=_/x;x+=_;let j=O.length;for(let G=0;G<j;G++)O[G]+=_,b[G*2+1]+=ht;j=D.length;for(let G=0;G<j;G++)D[G]+=_}const it=d.at(-1),tt=d.at(-2),T=m.at(-1),U=m.at(-2),rt=y.at(-1),w=y.at(-2),Q=r.at(-1),W=r.at(-2),H=K[0],E=K[1],A=X[0],at=X[1],bt=R[0],Dt=R[1],et=D[0],lt=D[1],ct=N.equals(I),ut=ct?[Z,I,$]:[Z,N,I,$];let P;if(z)P={...g.computePolylineFrenetFramesByFixUp(ut,st),points:ut};else if(ct)P={tangents:[tt,H,E],normals:[U,A,at],binormals:[w,bt,Dt],lengths:[W,et,lt],points:ut};else{const _=I.clone().sub(N).normalize(),ht=new l.Quaternion().setFromUnitVectors(it,_),j=T.clone().applyQuaternion(ht),G=rt.clone().applyQuaternion(ht);P={tangents:[tt,_,H,E],normals:[U,j,A,at],binormals:[w,G,bt,Dt],lengths:[W,Q,et,lt],points:ut}}let{index:M,position:F,normal:q,uv:dt,color:pt,lineDistance:mt}=xt(P,{...t,preLength:void 0,preIndex:V,prePoint:void 0,connectPre:!1});if(u=u.slice(0,-6),c=c.slice(0,-6),h=h.slice(0,-4),f=f.slice(0,-6),p=p.slice(0,-2),F=F.slice(6,-6),q=q.slice(6,-6),dt=dt.slice(4,-4),pt=pt.slice(6,-6),mt=mt.slice(2,-2),M=M.slice(6,-6),L=L.slice(6),S=S.slice(6),b=b.slice(4),k=k.slice(6),O=O.slice(2),t.connectPre){const _=v.length%6;v=v.slice(_)}const Jt=Math.min(...v.slice(0,3)),Kt=Math.max(...M.slice(-3))-1;if(Kt!==Jt){let _=v.length;const ht=Kt-Jt;for(let j=0;j<_;j++)v[j]+=ht}const oe=[...u,...F,...L],se=[...c,...q,...S],ie=[...h,...dt,...b],re=[...f,...pt,...k],ae=[...p,...mt,...O],le=[...i,...M,...v],ce=[...o,...C],ue=[...r,...D],he=[...d,...K],ge=[...m,...X],fe=[...y,...R];return{position:oe,normal:se,uv:ie,color:re,lineDistance:ae,index:le,points:ce,lengths:ue,length:x,tangents:he,normals:ge,binormals:fe}}function _t(n,s,t){let e=t,o;const{autoClose:i}=s;if(i){const r=(t==null?void 0:t.points)??[Lt(n[0]),wt(n.at(-1))],u=r[0],c=r.at(-1);u.equals(c)||n.push(u.clone())}s={...s,autoClose:!1};for(let r of n){let u,c,h=o,f=s;if(e){const{points:m,lengths:y,index:C}=e;u=y.at(-1),c=C.at(-3),h=m.at(-1),f={...s,preLength:u,preIndex:c,prePoint:h,connectPre:!1}}o&&(f={...s,prePoint:h});let p,d;r instanceof l.Curve?d=At(r,f):Array.isArray(r)?(r.length>1&&(d=Ct(r,f)),p=r[0]):p=r,!d&&h&&p&&!h.equals(p)&&(d=Ct([h,p],e?f:s)),d?(e=e?kt(e,d,{...s,connectPre:!1}):d,o=void 0):o=p}return e}class zt extends Pt{constructor(t){super(t);B(this,"isBandGeometry",!0);B(this,"frenetFrames",null)}get up(){return this.options.up??(this.options.up=Object.assign({},this.globalOptions.up??J.up))}set up(t){this.options.up=t}get fixUp(){return this.options.fixUp??(this.options.fixUp=this.globalOptions.fixUp??J.fixUp)}set fixUp(t){this.options.fixUp=t}get useU(){return this.options.useU??(this.options.useU=this.globalOptions.useU??J.useU)}set useU(t){this.options.useU=t}get uvStep(){return this.options.uvStep??(this.options.uvStep=this.globalOptions.uvStep??J.uvStep)}set uvStep(t){this.options.uvStep=t}get drawType(){return this.options.drawType??(this.options.drawType=this.globalOptions.drawType??J.drawType)}set drawType(t){this.options.drawType=t}get connectionType(){return this.options.connectionType??(this.options.connectionType=this.globalOptions.connectionType??J.connectionType)}set connectionType(t){this.options.connectionType=t}get smoothStepLength(){return this.options.smoothStepLength}set smoothStepLength(t){this.options.smoothStepLength=t}get smoothStepAngle(){return this.options.smoothStepAngle}set smoothStepAngle(t){this.options.smoothStepAngle=t}append(t){const{lastPoint:e,endLength:o}=this,i=vt(t,e,!0);if(this.pathData.push(t),this.curves.push(...i),this.drawType!=="blend")return this.updateGeometry();const{openedGeometryData:r,options:u}=this,c=[t],h=new l.Vector3().copy(u.up??{x:0,y:1,z:0}).normalize(),f={...u,preLength:o,up:h,connectPre:!0};if(r){const{lengths:d,index:m,points:y}=r;f.preLength=d.at(-1),f.preIndex=m.at(-3),f.prePoint=y.at(-1)}const p=_t(c,f,r);this.resetAttributes(p)}updateGeometry(){const{closedCurvePath:t,closedPathData:e,endLength:o,drawType:i,options:r}=this,u=new l.Vector3().copy(r.up??{x:0,y:1,z:0}).normalize(),c={...r,preLength:o,autoClose:!1,up:u,connectPre:!0};let h;switch(i){case"curve":{h=At(t,c);break}case"polyline":{const{division:f}=g.getCurveDivisionLength({...c,curve:t}),p=t.getPoints(f);h=Ct(p,c);break}default:{h=_t(e,c);break}}this.resetAttributes(h)}get geometryData(){const t=this.frenetFrames;if(!t)return null;const e=this.getAttribute("position").array,o=this.getAttribute("normal").array,i=this.getAttribute("uv").array,r=this.getIndex().array,u=this.getAttribute("color").array,c=this.getAttribute(nt).array;return{position:e,normal:o,uv:i,index:r,color:u,lineDistance:c,...t}}get openedGeometryData(){const{geometryData:t,closed:e}=this;if(!(t&&e))return t;const{position:o,normal:i,uv:r,index:u,color:c,lineDistance:h,lengths:f,points:p,tangents:d,normals:m,binormals:y}=t,C=-6,v=-1;return{position:o.slice(0,C),normal:i.slice(0,C),uv:r.slice(0,-4),color:c.slice(0,C),lineDistance:h.slice(0,-2),index:u.slice(0,C),lengths:f.slice(0,v),points:p.slice(0,v),tangents:d.slice(0,v),normals:m.slice(0,v),binormals:y.slice(0,v)}}resetAttributes(t){super.resetAttributes(t);const{points:e,tangents:o,normals:i,binormals:r,lengths:u}=t;this.frenetFrames={points:e,tangents:o,normals:i,binormals:r,lengths:u}}getDivisionIndex(t){return Math.floor(t/2)}setDrawLength(t,e){var u;let o=((u=this.getIndex())==null?void 0:u.count)??1;o-=1;let i=this.getClosestIndex(t);i=this.getDivisionIndex(i)*6,i=Math.min(i,o);let r=1/0;if(!(e==null||e===1/0)){let c=this.getClosestIndex(e);c=this.getDivisionIndex(c)*6,c=Math.min(c,o),r=c-i+1}this.setDrawRange(i,r)}}Object.assign(zt.options,J);function Bt(n,s){for(const[t,e]of Object.entries(s))n[t]={value:e};return n}function St(n,s,t){n.uniforms=Bt(t||n.uniforms||{},s);const e={},o=Object.keys(n);for(const[i,r]of Object.entries(s)){if(o.includes(i))continue;const u=function(){return this.uniforms[i].value},c=r.copy?function(h){this.uniforms[i].value.copy(h)}:function(h){this.uniforms[i].value=h};e[i]={configurable:!0,enumerable:!0,get:u,set:c}}return Object.defineProperties(n,e),n}function ot(n,s,t){let e;return t&&s?(St(t,s),e=function(o,...i){const r=o.uniforms;this.uniforms=Bt(r,s),n.call(this,o,...i)}):s?e=function(o,...i){const r=o.uniforms;St(this,s,r),n.call(this,o,...i)}:e=function(o,...i){this.uniforms=o.uniforms,n.call(this,o,...i)},e}const ft=/void\s+main\s*\(\)\s*\{\s*/,It={invert:!1,enableURange:!0,enableVRange:!0,uvMax:new l.Vector2(1e5,1e5),uvMin:new l.Vector2(0,0)},Qt=`
uniform bool invert;
uniform bool enableURange;
uniform bool enableVRange;
uniform vec2 uvMax;
uniform vec2 uvMin;
void main() {
bool isDiscard = false;
#if defined(USE_MAP) || defined(USE_UV)
vec2 rangeUV;
#ifdef USE_MAP
rangeUV = vMapUv;
#else
rangeUV = vUv;
#endif
bool xDiscard = enableURange && ( uvMin.x > rangeUV.x || rangeUV.x > uvMax.x);
bool yDiscard = enableVRange && (uvMin.y > rangeUV.y || rangeUV.y > uvMax.y);
isDiscard = xDiscard || yDiscard;
#endif
if (invert){
isDiscard = !isDiscard;
}
if (isDiscard) discard;
`;function Ut(n){n.fragmentShader=n.fragmentShader.replace(ft,Qt)}const Zt=ot(Ut,It);function $t(n){const s=n.defines??(n.defines={});return s.USE_UV=!0,n.onBeforeCompile=ot(Ut,It,n),n}const yt={invert:!1,enableStart:!0,enableEnd:!0,startLength:0,endLength:1e6},Wt=`
attribute float lineDistance;
varying float vLineDistance;
void main() {
vLineDistance = lineDistance;
`,Ht=`
varying float vLineDistance;
`,Rt=`
uniform bool invert;
uniform bool enableStart;
uniform bool enableEnd;
uniform float startLength;
uniform float endLength;
void main() {
bool startDiscard = enableStart && vLineDistance < startLength;
bool endDiscard = enableEnd && vLineDistance > endLength;
bool isDiscard = startDiscard || endDiscard;
if (invert){
isDiscard = !isDiscard;
}
if (isDiscard) discard;
`;function Tt(n){n.vertexShader=n.vertexShader.replace(ft,Wt);const s=Ht+Rt;n.fragmentShader=n.fragmentShader.replace(ft,s)}function Ft(n){n.fragmentShader=n.fragmentShader.replace(ft,Rt)}const te=ot(Tt,yt),ee=ot(Ft,yt);function ne(n){const s=n.isLineDashedMaterial?Ft:Tt;return n.onBeforeCompile=ot(s,yt,n),n}a.BandGeometry=zt,a.LengthConnectType=jt,a.PathDrawType=Et,a.PathGeometry=Pt,a.addUniformPropertiesOnMaterial=St,a.addUniforms=Bt,a.connectBandGeometryData=kt,a.createBlendBandGeometryData=_t,a.createCurveBandGeometryData=At,a.createCurveBandGeometryDataByFrenetFrames=qt,a.createOnBeforeCompile=ot,a.createPolylineBandGeometryData=Ct,a.createPolylineBandGeometryDataByFrenetFrames=xt,a.createPolylinePathGeometryData=Nt,a.getClosestIndex=Ot,a.getCurvePoints=Vt,a.getNearbyIndex=Mt,a.getPathItemEndPoint=wt,a.getPathItemStartPoint=Lt,a.lengthAttributeName=nt,a.lengthDrawRangeModifier=ne,a.lengthDrawRange_Mender=Tt,a.lengthDrawRange_fragment_mainReplace=Rt,a.lengthDrawRange_fragment_pars_mainReplace=Ht,a.lengthDrawRange_onBeforeCompile=te,a.lengthDrawRange_uniforms=yt,a.lengthDrawRange_vertex_mainReplace=Wt,a.lineDashedLengthDrawRange_Mender=Ft,a.lineDashedLengthDrawRange_onBeforeCompile=ee,a.minFun_Regex=ft,a.pathDataToContinuousCurves=Gt,a.pathDataToCurves=Xt,a.pathItemToCurve=Yt,a.pathItemToCurves=vt,a.uvDrawRangeModifier=$t,a.uvDrawRange_Mender=Ut,a.uvDrawRange_fragment_mainReplace=Qt,a.uvDrawRange_onBeforeCompile=Zt,a.uvDrawRange_uniforms=It,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});