@sienci/gviewer 0.1.29 → 0.1.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -2
- package/dist/{GCodeSVGRenderer-BezIPixY.js → GCodeSVGRenderer-D4QGoHWJ.js} +2686 -2491
- package/dist/{GCodeSVGRenderer-cfCcKFfP.cjs → GCodeSVGRenderer-i9duYU8q.cjs} +3 -3
- package/dist/gviewer.cjs +1 -1
- package/dist/gviewer.js +412 -407
- package/dist/react.cjs +1 -1
- package/dist/react.js +40 -34
- package/dist/types/geometry.d.ts +23 -5
- package/dist/types/types.d.ts +23 -0
- package/dist/types/viewer/GCodeViewer.d.ts +61 -7
- package/dist/types/viewer/camera/camera.d.ts +59 -1
- package/dist/types/viewer/index.d.ts +1 -1
- package/dist/types/viewer/toolpath/streams.d.ts +4 -0
- package/dist/types/viewer/types.d.ts +10 -0
- package/dist/viewcube.css +50 -0
- package/dist/viewer.cjs +1 -1
- package/dist/viewer.js +1 -1
- package/package.json +1 -1
package/dist/gviewer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=/([A-Za-z])\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+))/g;class C{parseLine(e){const o=[],t=this.stripComments(e,o),s=this.parseWords(t),r=s.filter(a=>{const c=a.letter.toUpperCase();return c==="G"||c==="M"}),i=s.filter(a=>{const c=a.letter.toUpperCase();return c!=="G"&&c!=="M"});return{raw:e,words:s,gcodes:r,params:i,comments:o}}stripComments(e,o){let t="",s=!1,r=-1,i="";for(let a=0;a<e.length;a+=1){const c=e[a];if(!s&&c===";"){const u=e.slice(a+1);o.push({type:"semicolon",text:u,start:a,end:e.length});break}if(c==="("){s?i+=c:(s=!0,r=a,i="");continue}if(c===")"&&s){o.push({type:"paren",text:i,start:r,end:a+1}),s=!1,r=-1,i="";continue}if(s){i+=c;continue}t+=c}return s&&o.push({type:"paren",text:i,start:r,end:e.length}),t}parseWords(e){const o=[];for(const t of e.matchAll($)){const s=t[0],r=t[1].toUpperCase(),i=Number(t[2]),a=t.index??0,c=a+s.length;o.push({letter:r,value:i,raw:s,start:a,end:c})}return o}}const g=["X","Y","Z","A","B","C"],Z={motion:"G0",distance:"G90",plane:"G17",units:"G21",feedMode:"G94",feedRate:null,spindleSpeed:null,tool:null,coolant:null,spindle:null,coordinateSystem:"G54"};class I{constructor(e={}){this.parser=new C,this.modals={...Z},this.position={X:0,Y:0,Z:0,A:0,B:0,C:0},this.callbacks=e,this.feedRates=new Set,this.spindleSpeeds=new Set,this.tools=new Set}setCallbacks(e){this.callbacks=e}getModals(){return{...this.modals}}getPosition(){return{...this.position}}getUniqueFeedRates(){return Array.from(this.feedRates)}getUniqueSpindleSpeeds(){return Array.from(this.spindleSpeeds)}getUniqueTools(){return Array.from(this.tools)}reset(){this.modals={...Z},this.position={X:0,Y:0,Z:0,A:0,B:0,C:0},this.feedRates.clear(),this.spindleSpeeds.clear(),this.tools.clear()}processLine(e){const o=this.parser.parseLine(e),t={...this.position};this.updateModals(o);const s=this.modals.motion,r=this.modals.plane;let i=this.applyAxes(o,t),a,c,u="none";return s==="G0"||s==="G1"?N(t,i)||(u="linear",this.position={...i},this.emitLinear({start:t,end:i})):(s==="G2"||s==="G3")&&(N(t,i)||(u="arc",c=this.arcCenter(o,t,i,r),a=this.computeArcMax(t,i,s,r,c),this.position={...i},this.emitArc({start:t,end:i,max:a,center:c,plane:r,motion:s}))),{parsed:o,modals:{...this.modals},start:t,end:i,movement:u,arcMax:a}}unitsScale(){return this.modals.units==="G20"?25.4:1}updateModals(e){for(const o of e.gcodes){if(o.letter.toUpperCase()==="G"){const t=`G${Math.trunc(o.value)}`;(t==="G0"||t==="G1"||t==="G2"||t==="G3")&&(this.modals.motion=t),(t==="G90"||t==="G91")&&(this.modals.distance=t),(t==="G17"||t==="G18"||t==="G19")&&(this.modals.plane=t),(t==="G20"||t==="G21")&&(this.modals.units=t),(t==="G93"||t==="G94")&&(this.modals.feedMode=t),(t==="G54"||t==="G55"||t==="G56"||t==="G57"||t==="G58"||t==="G59")&&(this.modals.coordinateSystem=t)}if(o.letter.toUpperCase()==="M"){const t=`M${Math.trunc(o.value)}`;(t==="M7"||t==="M8"||t==="M9")&&(this.modals.coolant=t),(t==="M3"||t==="M4"||t==="M5")&&(this.modals.spindle=t)}}for(const o of e.params){const t=o.letter.toUpperCase();t==="F"&&(this.modals.feedRate=o.value,this.feedRates.add(o.value)),t==="S"&&(this.modals.spindleSpeed=o.value,this.spindleSpeeds.add(o.value)),t==="T"&&(this.modals.tool=o.value,this.tools.add(o.value))}}applyAxes(e,o){const t={...o},s=this.unitsScale();for(const r of g){const i=e.params.find(c=>c.letter.toUpperCase()===r);if(!i)continue;const a=r==="X"||r==="Y"||r==="Z"?i.value*s:i.value;this.modals.distance==="G90"?t[r]=a:t[r]=t[r]+a}return t}computeArcMax(e,o,t,s,r){const{primary:i,secondary:a,tertiary:c}=X(s),u=q(e[i],e[a],r[i],r[a]),f=Math.atan2(e[a]-r[a],e[i]-r[i]),d=Math.atan2(o[a]-r[a],o[i]-r[i]),M=W(f,d,t);let l=Number.NEGATIVE_INFINITY,m=Number.NEGATIVE_INFINITY;for(const x of M){const w=r[i]+u*Math.cos(x),h=r[a]+u*Math.sin(x);w>l&&(l=w),h>m&&(m=h)}const A={...e};A[i]=l,A[a]=m,A[c]=Math.max(e[c],o[c]);for(const x of g)x!==i&&x!==a&&x!==c&&(A[x]=Math.max(e[x],o[x]));return A}arcCenter(e,o,t,s){const{primary:r,secondary:i}=X(s),a={...o},c=this.unitsScale(),u=b(e,"R"),f=j(e,s),d=f.primary===null?null:f.primary*c,M=f.secondary===null?null:f.secondary*c;if(d!==null||M!==null)return a[r]=o[r]+(d??0),a[i]=o[i]+(M??0),a;if(u===null)return a;const l=u*c,m=o[r],A=o[i],x=t[r],w=t[i],h=x-m,G=w-A,L=Math.hypot(h,G);if(L===0)return a;const P=Math.abs(l),p=Math.sqrt(Math.max(0,P*P-L/2*(L/2))),y=(m+x)/2,v=(A+w)/2,S=-G/L,E=h/L,Y=l>=0?1:-1;return a[r]=y+Y*S*p,a[i]=v+Y*E*p,a}emitLinear(e){const o=this.callbacks.onLinearMove;if(!o)return;const t=e.end.A-e.start.A,s=Math.max(1,Math.ceil(Math.abs(t)/D));let r={...e.start};for(let i=1;i<=s;i+=1){const a=i/s,c=K(e.start,e.end,a),u=V(r),f=V(c);o({modals:{...this.modals},start:{...r},end:{...c},transformedStart:u,transformedEnd:f}),r=c}}emitArc(e){const o=this.callbacks.onArcMove;if(!o)return;const t=V(e.start),s=V(e.end),r=V(e.max),i=V(e.center);o({modals:{...this.modals},start:{...e.start},end:{...e.end},max:{...e.max},center:{...e.center},plane:e.plane,motion:e.motion,transformedStart:t,transformedEnd:s,transformedMax:r,transformedCenter:i})}}function b(n,e){const o=n.params.find(t=>t.letter.toUpperCase()===e);return o?o.value:null}function X(n){return n==="G18"?{primary:"Z",secondary:"X",tertiary:"Y"}:n==="G19"?{primary:"Y",secondary:"Z",tertiary:"X"}:{primary:"X",secondary:"Y",tertiary:"Z"}}function j(n,e){const o=b(n,"I"),t=b(n,"J"),s=b(n,"K");return e==="G18"?{primary:s,secondary:o}:e==="G19"?{primary:t,secondary:s}:{primary:o,secondary:t}}function W(n,e,o){const t=Math.PI*2;let s=T(n),r=T(e);const i=[0,Math.PI/2,Math.PI,3*Math.PI/2,t];if(o==="G2"){s<r&&(s+=t);const c=[s,r];for(const u of i){let f=u;f<r&&(f+=t),f<=s&&f>=r&&c.push(f)}return c}r<s&&(r+=t);const a=[s,r];for(const c of i){let u=c;u<s&&(u+=t),u>=s&&u<=r&&a.push(u)}return a}function T(n){const e=Math.PI*2;let o=n%e;return o<0&&(o+=e),o}function q(n,e,o,t){return Math.hypot(n-o,e-t)}function N(n,e){return g.every(o=>n[o]===e[o])}const D=5;function K(n,e,o){return{X:n.X+(e.X-n.X)*o,Y:n.Y+(e.Y-n.Y)*o,Z:n.Z+(e.Z-n.Z)*o,A:n.A+(e.A-n.A)*o,B:n.B+(e.B-n.B)*o,C:n.C+(e.C-n.C)*o}}function V(n){const e=n.A*Math.PI/180,o=Math.cos(e),t=Math.sin(e),s=n.Y*o-n.Z*t,r=n.Y*t+n.Z*o;return{...n,Y:s,Z:r}}function H(n,e={}){const o=[],t=e.arcSegments??30,s=e.collector??{},r=new I({onLinearMove:i=>{(s.onLinearMove??U)(i,o)},onArcMove:i=>{(s.onArcMove??((c,u)=>{F(c,u,t)}))(i,o)}});for(const i of n)i&&r.processLine(i);return Float32Array.from(o)}function J(n,e={}){const o=[],t=[],s=e.arcSegments??30,r=new I({onLinearMove:i=>{const a=i.transformedStart??i.start,c=i.transformedEnd??i.end;(i.modals.motion==="G0"?o:t).push(a.X,a.Y,a.Z,c.X,c.Y,c.Z)},onArcMove:i=>{const a=i.modals.motion==="G0"?o:t;F(i,a,s)}});for(const i of n)i&&r.processLine(i);return{rapid:Float32Array.from(o),cutting:Float32Array.from(t)}}async function Q(n,e={}){var M;const o=[],t=[],s=e.arcSegments??30,r=e.batch,i=Math.max(1,Math.floor((r==null?void 0:r.everyLines)??5e3)),a=Math.max(0,Math.floor((r==null?void 0:r.yieldEveryLines)??5e4));let c=i,u=a>0?a:Number.POSITIVE_INFINITY;const f=new I({onLinearMove:l=>{const m=l.transformedStart??l.start,A=l.transformedEnd??l.end;(l.modals.motion==="G0"?o:t).push(m.X,m.Y,m.Z,A.X,A.Y,A.Z)},onArcMove:l=>{const m=l.modals.motion==="G0"?o:t;F(l,m,s)}}),d=n.length;for(let l=0;l<d;l+=1){if((M=r==null?void 0:r.shouldAbort)!=null&&M.call(r))throw new Error("Aborted.");const m=n[l];if(!m){r!=null&&r.onProgress&&(l+1===d||l+1===c)&&(r.onProgress(l+1,d),c+=i),a>0&&(l+1===d||l+1===u)&&(await new Promise(A=>{setTimeout(A,0)}),u+=a);continue}f.processLine(m),r!=null&&r.onProgress&&(l+1===d||l+1===c)&&(r.onProgress(l+1,d),c+=i),a>0&&(l+1===d||l+1===u)&&(await new Promise(A=>{setTimeout(A,0)}),u+=a)}return{rapid:Float32Array.from(o),cutting:Float32Array.from(t)}}async function ee(n,e={}){var w;const o=[],t=e.arcSegments??30,s=e.batch,r=Math.max(1,Math.floor((s==null?void 0:s.everyLines)??5e3)),i=Math.max(0,Math.floor((s==null?void 0:s.yieldEveryLines)??5e4));let a=r,c=i>0?i:Number.POSITIVE_INFINITY;const u=new Int32Array(n.length);u.fill(-1);const f=new Int32Array(n.length);f.fill(-1);const d=new Uint8Array(n.length),M=new Int32Array(n.length);let l=-1,m=0;const A=new I({onLinearMove:h=>{const G=h.modals.motion==="G0"?1:2;l>=0&&(m===0?m=G:m!==G&&(m=3)),U(h,o)},onArcMove:h=>{const G=h.modals.motion==="G0"?1:2;l>=0&&(m===0?m=G:m!==G&&(m=3)),F(h,o,t)}}),x=n.length;for(let h=0;h<x;h+=1){if((w=s==null?void 0:s.shouldAbort)!=null&&w.call(s))throw new Error("Aborted.");const G=o.length/3;l=h,m=0;const L=n[h];L&&A.processLine(L),l=-1;const P=o.length/3;P>G&&(u[h]=G,f[h]=P,d[h]=m),M[h]=P,s!=null&&s.onProgress&&(h+1===x||h+1===a)&&(s.onProgress(h+1,x),a+=r),i>0&&(h+1===x||h+1===c)&&(await new Promise(p=>{setTimeout(p,0)}),c+=i)}return{positions:Float32Array.from(o),lineStartVertex:u,lineEndVertex:f,lineKind:d,prefixEndVertex:M}}function te(n,e={}){const o=e.arcSegments??30,t=Math.max(1,Math.floor(e.bucketCount??16)),s=e.baseOpacity??.9,{minPower:r,maxPower:i}=ae(n),a=[],c=Array.from({length:t},()=>[]),u=new I({onLinearMove:d=>{const M=d.transformedStart??d.start,l=d.transformedEnd??d.end;if(d.modals.motion==="G0"){a.push(M.X,M.Y,M.Z,l.X,l.Y,l.Z);return}const m=R(d.modals.spindleSpeed,r,i,t);c[m].push(M.X,M.Y,M.Z,l.X,l.Y,l.Z)},onArcMove:d=>{if(d.modals.motion==="G0")return;const M=R(d.modals.spindleSpeed,r,i,t),l=c[M];F(d,l,o)}});for(const d of n)d&&u.processLine(d);const f=c.map((d,M)=>({opacity:_(M,t,s),vertices:Float32Array.from(d)}));return{rapid:Float32Array.from(a),buckets:f,minPower:r,maxPower:i}}async function ne(n,e={}){const o=await O(n,e);return{rapid:o.rapidPositions,buckets:o.buckets.map(t=>({opacity:t.opacity,vertices:t.positions})),minPower:o.minPower,maxPower:o.maxPower}}async function z(n,e={}){var L,P;const o=e.arcSegments??30,t=Math.max(1,Math.floor(e.bucketCount??16)),s=!!e.laserMode,r=e.batch,i=n.length*(s?2:1),a=Math.max(1,Math.floor((r==null?void 0:r.everyLines)??5e3)),c=Math.max(0,Math.floor((r==null?void 0:r.yieldEveryLines)??5e4));let u=a,f=c>0?c:Number.POSITIVE_INFINITY,d=Number.NEGATIVE_INFINITY,M=!1;if(s){const p=new C;for(const y of n){if(!y)continue;if(p.parseLine(y).gcodes.some(E=>{if(E.letter!=="M")return!1;const Y=Math.trunc(E.value);return Y===3||Y===4||Y===5})){M=!1;break}M=!0}}const l=p=>p.spindle==="M5"||!(p.spindle==="M3"||p.spindle==="M4"||M&&p.spindle===null)?!1:p.spindleSpeed===null?!0:p.spindleSpeed>0;if(s){const p=new I({onLinearMove:y=>{if(!l(y.modals))return;const v=y.modals.spindleSpeed;v===null||v<=0||(d=Math.max(d,v))},onArcMove:y=>{if(!l(y.modals))return;const v=y.modals.spindleSpeed;v===null||v<=0||(d=Math.max(d,v))}});for(let y=0;y<n.length;y+=1){if((L=r==null?void 0:r.shouldAbort)!=null&&L.call(r))throw new Error("Aborted.");const v=n[y];v&&p.processLine(v);const S=y+1;r!=null&&r.onProgress&&(S===i||S===u)&&(r.onProgress(S,i),u+=a),c>0&&(S===i||S===f)&&(await new Promise(E=>{setTimeout(E,0)}),f+=c)}Number.isFinite(d)||(d=0)}else d=0;const m=p=>{if(t<=1)return 0;if(p===null)return t-1;const y=p;if(y<=0)return 0;if(d<=0)return t-1;const v=Math.min(1,Math.max(0,y/d)),S=1+Math.floor(v*(t-2));return Math.min(t-1,Math.max(1,S))},A=[],x=s?Array.from({length:t},()=>[]):[new Array],w=new Int32Array(n.length),h=Array.from({length:s?t:1},()=>new Int32Array(n.length)),G=new I({onLinearMove:p=>{const y=p.transformedStart??p.start,v=p.transformedEnd??p.end;if(p.modals.motion==="G0"){A.push(y.X,y.Y,y.Z,v.X,v.Y,v.Z);return}if(s&&!l(p.modals))return;const S=s?m(p.modals.spindleSpeed):0;x[S].push(y.X,y.Y,y.Z,v.X,v.Y,v.Z)},onArcMove:p=>{if(p.modals.motion==="G0"||s&&!l(p.modals))return;const y=s?m(p.modals.spindleSpeed):0,v=x[y];F(p,v,o)}});for(let p=0;p<n.length;p+=1){if((P=r==null?void 0:r.shouldAbort)!=null&&P.call(r))throw new Error("Aborted.");const y=n[p];y&&G.processLine(y),w[p]=A.length/3;for(let S=0;S<x.length;S+=1)h[S][p]=x[S].length/3;const v=s?n.length+p+1:p+1;r!=null&&r.onProgress&&(v===i||v===u)&&(r.onProgress(v,i),u+=a),c>0&&(v===i||v===f)&&(await new Promise(S=>{setTimeout(S,0)}),f+=c)}return{rapid:{positions:Float32Array.from(A),prefixEndVertex:w},cuts:x.map((p,y)=>({positions:Float32Array.from(p),prefixEndVertex:h[y]})),cutBucketCount:x.length,minPower:0,maxPower:d}}async function O(n,e={}){const o=Math.max(1,Math.floor(e.bucketCount??16)),t=e.baseOpacity??.9,s=await z(n,{arcSegments:e.arcSegments,bucketCount:o,laserMode:!0,batch:e.batch}),r=s.cuts.map((i,a)=>({opacity:_(a,o,t),positions:i.positions,prefixEndVertex:i.prefixEndVertex}));return{rapidPositions:s.rapid.positions,rapidPrefixEndVertex:s.rapid.prefixEndVertex,buckets:r,minPower:0,maxPower:s.maxPower}}function oe(n,e){n.push(e.X,e.Y,e.Z)}function U(n,e){const o=n.transformedStart??n.start,t=n.transformedEnd??n.end;e.push(o.X,o.Y,o.Z,t.X,t.Y,t.Z)}function F(n,e,o){const t=Math.max(1,Math.floor(o)),{primary:s,secondary:r}=re(n.plane),i=se(n.start[s],n.start[r],n.center[s],n.center[r]),a=Math.atan2(n.start[r]-n.center[r],n.start[s]-n.center[s]),c=Math.atan2(n.end[r]-n.center[r],n.end[s]-n.center[s]),u=Math.PI*2;let f=B(a),d=B(c);n.motion==="G2"?f<=d&&(f+=u):d<=f&&(d+=u);const M=n.motion==="G2"?f-d:d-f;let l={...n.start};for(let m=1;m<=t;m+=1){const A=m/t,x=n.motion==="G2"?f-M*A:f+M*A,w=ie(n.start,n.end,A);w[s]=n.center[s]+i*Math.cos(x),w[r]=n.center[r]+i*Math.sin(x);const h=k(l),G=k(w);e.push(h.X,h.Y,h.Z,G.X,G.Y,G.Z),l=w}}function k(n){const e=n.A*Math.PI/180,o=Math.cos(e),t=Math.sin(e),s=n.Y*o-n.Z*t,r=n.Y*t+n.Z*o;return{...n,Y:s,Z:r}}function re(n){return n==="G18"?{primary:"Z",secondary:"X"}:n==="G19"?{primary:"Y",secondary:"Z"}:{primary:"X",secondary:"Y"}}function B(n){const e=Math.PI*2;let o=n%e;return o<0&&(o+=e),o}function se(n,e,o,t){return Math.hypot(n-o,e-t)}function ie(n,e,o){return{X:n.X+(e.X-n.X)*o,Y:n.Y+(e.Y-n.Y)*o,Z:n.Z+(e.Z-n.Z)*o,A:n.A+(e.A-n.A)*o,B:n.B+(e.B-n.B)*o,C:n.C+(e.C-n.C)*o}}function ae(n){let e=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const t=new I({onLinearMove:s=>{const r=s.modals.spindleSpeed;r!==null&&(e=Math.min(e,r),o=Math.max(o,r))},onArcMove:s=>{const r=s.modals.spindleSpeed;r!==null&&(e=Math.min(e,r),o=Math.max(o,r))}});for(const s of n)s&&t.processLine(s);return!Number.isFinite(e)||!Number.isFinite(o)?{minPower:0,maxPower:0}:{minPower:e,maxPower:o}}function R(n,e,o,t){if(t<=1)return 0;const s=n??e;if(o<=e)return t-1;const r=(s-e)/(o-e),i=Math.floor(r*(t-1));return Math.min(t-1,Math.max(0,i))}function _(n,e,o){if(e<=1)return o;const t=n/(e-1);return o*t}function ce(n){const e=new Float32Array(n.vertices),o=new Uint32Array(n.frames),t=new Float32Array(n.colorArrayBuffer),{verticesLen:s,framesLen:r}=n,i=new Map;for(let a=0;a<r;a++){const c=o[a],u=a<r-1?o[a+1]:s/3;if(u<=c+1)continue;const f=c*4,d=t[f],M=t[f+1],l=t[f+2],m=t[f+3],A=le(d,M,l),x=`${A}|${Math.round(m*100)}`;let w=i.get(x);w||(w={hexColor:A,opacity:m,pos:[],rgb:[]},i.set(x,w));for(let h=c;h<u-1;h++){const G=h*3,L=(h+1)*3;w.pos.push(e[G],e[G+1],e[G+2],e[L],e[L+1],e[L+2]),w.rgb.push(d,M,l,d,M,l)}}return Array.from(i.values()).map(({hexColor:a,opacity:c,pos:u,rgb:f})=>({hexColor:a,opacity:c,positions:new Float32Array(u),rgbColors:new Float32Array(f)}))}function le(n,e,o){const t=s=>Math.round(Math.min(1,Math.max(0,s))*255).toString(16).padStart(2,"0");return`#${t(n)}${t(e)}${t(o)}`}function de(n){const e=new Float32Array(n.vertices),o=new Uint32Array(n.frames),t=new Float32Array(n.colorArrayBuffer),r=(n.isLaser&&n.savedColorsBuffer&&n.savedColorLen?new Float32Array(n.savedColorsBuffer):null)??t,{verticesLen:i,framesLen:a}=n,c=[],u=[],f=[],d=[],M=new Int32Array(a),l=new Int32Array(a);for(let m=0;m<a;m++){const A=o[m],x=m<a-1?o[m+1]:i/3;if(x>A+1){const w=t[A*4+3]<.75,h=w?c:f,G=w?u:d;for(let L=A;L<x-1;L++){const P=L*3,p=(L+1)*3;h.push(e[P],e[P+1],e[P+2],e[p],e[p+1],e[p+2]);const y=L*4,v=(L+1)*4;G.push(r[y],r[y+1],r[y+2],r[v],r[v+1],r[v+2])}}M[m]=c.length/3,l[m]=f.length/3}return{rapid:{positions:Float32Array.from(c),colors:Float32Array.from(u),prefixEndVertex:M},cut:{positions:Float32Array.from(f),colors:Float32Array.from(d),prefixEndVertex:l}}}exports.GCodeParser=C;exports.GCodeVirtualizer=I;exports.buildLaserGeometryFromLinesBatched=O;exports.buildLaserVerticesFromLines=te;exports.buildLaserVerticesFromLinesBatched=ne;exports.buildMovementGeometryFromLinesBatched=ee;exports.buildMovementVerticesFromLines=J;exports.buildMovementVerticesFromLinesBatched=Q;exports.buildToolpathGeometryFromLinesBatched=z;exports.buildVerticesFromLines=H;exports.buildWorkerSegmentGroups=ce;exports.buildWorkerToolpathStreams=de;exports.pushXYZ=oe;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const K=/([A-Za-z])\s*([+-]?(?:\d+(?:\.\d*)?|\.\d+))/g;class N{parseLine(e){const t=[],n=this.stripComments(e,t),s=this.parseWords(n),r=s.filter(a=>{const c=a.letter.toUpperCase();return c==="G"||c==="M"}),i=s.filter(a=>{const c=a.letter.toUpperCase();return c!=="G"&&c!=="M"});return{raw:e,words:s,gcodes:r,params:i,comments:t}}stripComments(e,t){let n="",s=!1,r=-1,i="";for(let a=0;a<e.length;a+=1){const c=e[a];if(!s&&c===";"){const d=e.slice(a+1);t.push({type:"semicolon",text:d,start:a,end:e.length});break}if(c==="("){s?i+=c:(s=!0,r=a,i="");continue}if(c===")"&&s){t.push({type:"paren",text:i,start:r,end:a+1}),s=!1,r=-1,i="";continue}if(s){i+=c;continue}n+=c}return s&&t.push({type:"paren",text:i,start:r,end:e.length}),n}parseWords(e){const t=[];for(const n of e.matchAll(K)){const s=n[0],r=n[1].toUpperCase(),i=Number(n[2]),a=n.index??0,c=a+s.length;t.push({letter:r,value:i,raw:s,start:a,end:c})}return t}}const T=["X","Y","Z","A","B","C"],B={motion:"G0",distance:"G90",plane:"G17",units:"G21",feedMode:"G94",feedRate:null,spindleSpeed:null,tool:null,coolant:null,spindle:null,coordinateSystem:"G54"};class g{constructor(e={}){this.parser=new N,this.modals={...B},this.position={X:0,Y:0,Z:0,A:0,B:0,C:0},this.callbacks=e,this.feedRates=new Set,this.spindleSpeeds=new Set,this.tools=new Set}setCallbacks(e){this.callbacks=e}getModals(){return{...this.modals}}getPosition(){return{...this.position}}getUniqueFeedRates(){return Array.from(this.feedRates)}getUniqueSpindleSpeeds(){return Array.from(this.spindleSpeeds)}getUniqueTools(){return Array.from(this.tools)}reset(){this.modals={...B},this.position={X:0,Y:0,Z:0,A:0,B:0,C:0},this.feedRates.clear(),this.spindleSpeeds.clear(),this.tools.clear()}processLine(e){const t=this.parser.parseLine(e),n={...this.position};this.updateModals(t);const s=this.modals.motion,r=this.modals.plane;let i=this.applyAxes(t,n),a,c,d="none";return s==="G0"||s==="G1"?O(n,i)||(d="linear",this.position={...i},this.emitLinear({start:n,end:i})):(s==="G2"||s==="G3")&&(O(n,i)||(d="arc",c=this.arcCenter(t,n,i,r),a=this.computeArcMax(n,i,s,r,c),this.position={...i},this.emitArc({start:n,end:i,max:a,center:c,plane:r,motion:s}))),{parsed:t,modals:{...this.modals},start:n,end:i,movement:d,arcMax:a}}unitsScale(){return this.modals.units==="G20"?25.4:1}updateModals(e){for(const t of e.gcodes){if(t.letter.toUpperCase()==="G"){const n=`G${Math.trunc(t.value)}`;(n==="G0"||n==="G1"||n==="G2"||n==="G3")&&(this.modals.motion=n),(n==="G90"||n==="G91")&&(this.modals.distance=n),(n==="G17"||n==="G18"||n==="G19")&&(this.modals.plane=n),(n==="G20"||n==="G21")&&(this.modals.units=n),(n==="G93"||n==="G94")&&(this.modals.feedMode=n),(n==="G54"||n==="G55"||n==="G56"||n==="G57"||n==="G58"||n==="G59")&&(this.modals.coordinateSystem=n)}if(t.letter.toUpperCase()==="M"){const n=`M${Math.trunc(t.value)}`;(n==="M7"||n==="M8"||n==="M9")&&(this.modals.coolant=n),(n==="M3"||n==="M4"||n==="M5")&&(this.modals.spindle=n)}}for(const t of e.params){const n=t.letter.toUpperCase();n==="F"&&(this.modals.feedRate=t.value,this.feedRates.add(t.value)),n==="S"&&(this.modals.spindleSpeed=t.value,this.spindleSpeeds.add(t.value)),n==="T"&&(this.modals.tool=t.value,this.tools.add(t.value))}}applyAxes(e,t){const n={...t},s=this.unitsScale();for(const r of T){const i=e.params.find(c=>c.letter.toUpperCase()===r);if(!i)continue;const a=r==="X"||r==="Y"||r==="Z"?i.value*s:i.value;this.modals.distance==="G90"?n[r]=a:n[r]=n[r]+a}return n}computeArcMax(e,t,n,s,r){const{primary:i,secondary:a,tertiary:c}=R(s),d=Q(e[i],e[a],r[i],r[a]),m=Math.atan2(e[a]-r[a],e[i]-r[i]),u=Math.atan2(t[a]-r[a],t[i]-r[i]),A=J(m,u,n);let l=Number.NEGATIVE_INFINITY,h=Number.NEGATIVE_INFINITY;for(const x of A){const L=r[i]+d*Math.cos(x),y=r[a]+d*Math.sin(x);L>l&&(l=L),y>h&&(h=y)}const v={...e};v[i]=l,v[a]=h,v[c]=Math.max(e[c],t[c]);for(const x of T)x!==i&&x!==a&&x!==c&&(v[x]=Math.max(e[x],t[x]));return v}arcCenter(e,t,n,s){const{primary:r,secondary:i}=R(s),a={...t},c=this.unitsScale(),d=F(e,"R"),m=H(e,s),u=m.primary===null?null:m.primary*c,A=m.secondary===null?null:m.secondary*c;if(u!==null||A!==null)return a[r]=t[r]+(u??0),a[i]=t[i]+(A??0),a;if(d===null)return a;const l=d*c,h=t[r],v=t[i],x=n[r],L=n[i],y=x-h,S=L-v,P=Math.hypot(y,S);if(P===0)return a;const G=Math.abs(l),f=Math.sqrt(Math.max(0,G*G-P/2*(P/2))),M=(h+x)/2,p=(v+L)/2,w=-S/P,I=y/P,E=l>=0?1:-1;return a[r]=M+E*w*f,a[i]=p+E*I*f,a}emitLinear(e){const t=this.callbacks.onLinearMove;if(!t)return;const n=e.end.A-e.start.A,s=Math.max(1,Math.ceil(Math.abs(n)/ee));let r={...e.start};for(let i=1;i<=s;i+=1){const a=i/s,c=te(e.start,e.end,a),d=V(r),m=V(c);t({modals:{...this.modals},start:{...r},end:{...c},transformedStart:d,transformedEnd:m}),r=c}}emitArc(e){const t=this.callbacks.onArcMove;if(!t)return;const n=V(e.start),s=V(e.end),r=V(e.max),i=V(e.center);t({modals:{...this.modals},start:{...e.start},end:{...e.end},max:{...e.max},center:{...e.center},plane:e.plane,motion:e.motion,transformedStart:n,transformedEnd:s,transformedMax:r,transformedCenter:i})}}function F(o,e){const t=o.params.find(n=>n.letter.toUpperCase()===e);return t?t.value:null}function R(o){return o==="G18"?{primary:"Z",secondary:"X",tertiary:"Y"}:o==="G19"?{primary:"Y",secondary:"Z",tertiary:"X"}:{primary:"X",secondary:"Y",tertiary:"Z"}}function H(o,e){const t=F(o,"I"),n=F(o,"J"),s=F(o,"K");return e==="G18"?{primary:s,secondary:t}:e==="G19"?{primary:n,secondary:s}:{primary:t,secondary:n}}function J(o,e,t){const n=Math.PI*2;let s=z(o),r=z(e);const i=[0,Math.PI/2,Math.PI,3*Math.PI/2,n];if(t==="G2"){s<r&&(s+=n);const c=[s,r];for(const d of i){let m=d;m<r&&(m+=n),m<=s&&m>=r&&c.push(m)}return c}r<s&&(r+=n);const a=[s,r];for(const c of i){let d=c;d<s&&(d+=n),d>=s&&d<=r&&a.push(d)}return a}function z(o){const e=Math.PI*2;let t=o%e;return t<0&&(t+=e),t}function Q(o,e,t,n){return Math.hypot(o-t,e-n)}function O(o,e){return T.every(t=>o[t]===e[t])}const ee=5;function te(o,e,t){return{X:o.X+(e.X-o.X)*t,Y:o.Y+(e.Y-o.Y)*t,Z:o.Z+(e.Z-o.Z)*t,A:o.A+(e.A-o.A)*t,B:o.B+(e.B-o.B)*t,C:o.C+(e.C-o.C)*t}}function V(o){const e=o.A*Math.PI/180,t=Math.cos(e),n=Math.sin(e),s=o.Y*t-o.Z*n,r=o.Y*n+o.Z*t;return{...o,Y:s,Z:r}}function ne(o,e={}){const t=[],n=e.arcSegments??30,s=e.collector??{},r=new g({onLinearMove:i=>{(s.onLinearMove??q)(i,t)},onArcMove:i=>{(s.onArcMove??((c,d)=>{b(c,d,n)}))(i,t)}});for(const i of o)i&&r.processLine(i);return Float32Array.from(t)}function oe(o,e={}){const t=[],n=[],s=e.arcSegments??30,r=new g({onLinearMove:i=>{const a=i.transformedStart??i.start,c=i.transformedEnd??i.end;(i.modals.motion==="G0"?t:n).push(a.X,a.Y,a.Z,c.X,c.Y,c.Z)},onArcMove:i=>{const a=i.modals.motion==="G0"?t:n;b(i,a,s)}});for(const i of o)i&&r.processLine(i);return{rapid:Float32Array.from(t),cutting:Float32Array.from(n)}}async function re(o,e={}){var A;const t=[],n=[],s=e.arcSegments??30,r=e.batch,i=Math.max(1,Math.floor((r==null?void 0:r.everyLines)??5e3)),a=Math.max(0,Math.floor((r==null?void 0:r.yieldEveryLines)??5e4));let c=i,d=a>0?a:Number.POSITIVE_INFINITY;const m=new g({onLinearMove:l=>{const h=l.transformedStart??l.start,v=l.transformedEnd??l.end;(l.modals.motion==="G0"?t:n).push(h.X,h.Y,h.Z,v.X,v.Y,v.Z)},onArcMove:l=>{const h=l.modals.motion==="G0"?t:n;b(l,h,s)}}),u=o.length;for(let l=0;l<u;l+=1){if((A=r==null?void 0:r.shouldAbort)!=null&&A.call(r))throw new Error("Aborted.");const h=o[l];if(!h){r!=null&&r.onProgress&&(l+1===u||l+1===c)&&(r.onProgress(l+1,u),c+=i),a>0&&(l+1===u||l+1===d)&&(await new Promise(v=>{setTimeout(v,0)}),d+=a);continue}m.processLine(h),r!=null&&r.onProgress&&(l+1===u||l+1===c)&&(r.onProgress(l+1,u),c+=i),a>0&&(l+1===u||l+1===d)&&(await new Promise(v=>{setTimeout(v,0)}),d+=a)}return{rapid:Float32Array.from(t),cutting:Float32Array.from(n)}}async function se(o,e={}){var L;const t=[],n=e.arcSegments??30,s=e.batch,r=Math.max(1,Math.floor((s==null?void 0:s.everyLines)??5e3)),i=Math.max(0,Math.floor((s==null?void 0:s.yieldEveryLines)??5e4));let a=r,c=i>0?i:Number.POSITIVE_INFINITY;const d=new Int32Array(o.length);d.fill(-1);const m=new Int32Array(o.length);m.fill(-1);const u=new Uint8Array(o.length),A=new Int32Array(o.length);let l=-1,h=0;const v=new g({onLinearMove:y=>{const S=y.modals.motion==="G0"?1:2;l>=0&&(h===0?h=S:h!==S&&(h=3)),q(y,t)},onArcMove:y=>{const S=y.modals.motion==="G0"?1:2;l>=0&&(h===0?h=S:h!==S&&(h=3)),b(y,t,n)}}),x=o.length;for(let y=0;y<x;y+=1){if((L=s==null?void 0:s.shouldAbort)!=null&&L.call(s))throw new Error("Aborted.");const S=t.length/3;l=y,h=0;const P=o[y];P&&v.processLine(P),l=-1;const G=t.length/3;G>S&&(d[y]=S,m[y]=G,u[y]=h),A[y]=G,s!=null&&s.onProgress&&(y+1===x||y+1===a)&&(s.onProgress(y+1,x),a+=r),i>0&&(y+1===x||y+1===c)&&(await new Promise(f=>{setTimeout(f,0)}),c+=i)}return{positions:Float32Array.from(t),lineStartVertex:d,lineEndVertex:m,lineKind:u,prefixEndVertex:A}}function ie(o,e={}){const t=e.arcSegments??30,n=Math.max(1,Math.floor(e.bucketCount??16)),s=e.baseOpacity??.9,{minPower:r,maxPower:i}=fe(o),a=[],c=Array.from({length:n},()=>[]),d=new g({onLinearMove:u=>{const A=u.transformedStart??u.start,l=u.transformedEnd??u.end;if(u.modals.motion==="G0"){a.push(A.X,A.Y,A.Z,l.X,l.Y,l.Z);return}const h=$(u.modals.spindleSpeed,r,i,n);c[h].push(A.X,A.Y,A.Z,l.X,l.Y,l.Z)},onArcMove:u=>{if(u.modals.motion==="G0")return;const A=$(u.modals.spindleSpeed,r,i,n),l=c[A];b(u,l,t)}});for(const u of o)u&&d.processLine(u);const m=c.map((u,A)=>({opacity:D(A,n,s),vertices:Float32Array.from(u)}));return{rapid:Float32Array.from(a),buckets:m,minPower:r,maxPower:i}}async function ae(o,e={}){const t=await W(o,e);return{rapid:t.rapidPositions,buckets:t.buckets.map(n=>({opacity:n.opacity,vertices:n.positions})),minPower:t.minPower,maxPower:t.maxPower}}async function j(o,e={}){var P,G;const t=e.arcSegments??30,n=Math.max(1,Math.floor(e.bucketCount??16)),s=!!e.laserMode,r=e.batch,i=o.length*(s?2:1),a=Math.max(1,Math.floor((r==null?void 0:r.everyLines)??5e3)),c=Math.max(0,Math.floor((r==null?void 0:r.yieldEveryLines)??5e4));let d=a,m=c>0?c:Number.POSITIVE_INFINITY,u=Number.NEGATIVE_INFINITY,A=!1;if(s){const f=new N;for(const M of o){if(!M)continue;if(f.parseLine(M).gcodes.some(I=>{if(I.letter!=="M")return!1;const E=Math.trunc(I.value);return E===3||E===4||E===5})){A=!1;break}A=!0}}const l=f=>f.spindle==="M5"||!(f.spindle==="M3"||f.spindle==="M4"||A&&f.spindle===null)?!1:f.spindleSpeed===null?!0:f.spindleSpeed>0;if(s){const f=new g({onLinearMove:M=>{if(!l(M.modals))return;const p=M.modals.spindleSpeed;p===null||p<=0||(u=Math.max(u,p))},onArcMove:M=>{if(!l(M.modals))return;const p=M.modals.spindleSpeed;p===null||p<=0||(u=Math.max(u,p))}});for(let M=0;M<o.length;M+=1){if((P=r==null?void 0:r.shouldAbort)!=null&&P.call(r))throw new Error("Aborted.");const p=o[M];p&&f.processLine(p);const w=M+1;r!=null&&r.onProgress&&(w===i||w===d)&&(r.onProgress(w,i),d+=a),c>0&&(w===i||w===m)&&(await new Promise(I=>{setTimeout(I,0)}),m+=c)}Number.isFinite(u)||(u=0)}else u=0;const h=f=>{if(n<=1)return 0;if(f===null)return n-1;const M=f;if(M<=0)return 0;if(u<=0)return n-1;const p=Math.min(1,Math.max(0,M/u)),w=1+Math.floor(p*(n-2));return Math.min(n-1,Math.max(1,w))},v=[],x=s?Array.from({length:n},()=>[]):[new Array],L=new Int32Array(o.length),y=Array.from({length:s?n:1},()=>new Int32Array(o.length)),S=new g({onLinearMove:f=>{const M=f.transformedStart??f.start,p=f.transformedEnd??f.end;if(f.modals.motion==="G0"){v.push(M.X,M.Y,M.Z,p.X,p.Y,p.Z);return}if(s&&!l(f.modals))return;const w=s?h(f.modals.spindleSpeed):0;x[w].push(M.X,M.Y,M.Z,p.X,p.Y,p.Z)},onArcMove:f=>{if(f.modals.motion==="G0"||s&&!l(f.modals))return;const M=s?h(f.modals.spindleSpeed):0,p=x[M];b(f,p,t)}});for(let f=0;f<o.length;f+=1){if((G=r==null?void 0:r.shouldAbort)!=null&&G.call(r))throw new Error("Aborted.");const M=o[f];M&&S.processLine(M),L[f]=v.length/3;for(let w=0;w<x.length;w+=1)y[w][f]=x[w].length/3;const p=s?o.length+f+1:f+1;r!=null&&r.onProgress&&(p===i||p===d)&&(r.onProgress(p,i),d+=a),c>0&&(p===i||p===m)&&(await new Promise(w=>{setTimeout(w,0)}),m+=c)}return{rapid:{positions:Float32Array.from(v),prefixEndVertex:L},cuts:x.map((f,M)=>({positions:Float32Array.from(f),prefixEndVertex:y[M]})),cutBucketCount:x.length,minPower:0,maxPower:u}}async function W(o,e={}){const t=Math.max(1,Math.floor(e.bucketCount??16)),n=e.baseOpacity??.9,s=await j(o,{arcSegments:e.arcSegments,bucketCount:t,laserMode:!0,batch:e.batch}),r=s.cuts.map((i,a)=>({opacity:D(a,t,n),positions:i.positions,prefixEndVertex:i.prefixEndVertex}));return{rapidPositions:s.rapid.positions,rapidPrefixEndVertex:s.rapid.prefixEndVertex,buckets:r,minPower:0,maxPower:s.maxPower}}function ce(o,e){o.push(e.X,e.Y,e.Z)}function q(o,e){const t=o.transformedStart??o.start,n=o.transformedEnd??o.end;e.push(t.X,t.Y,t.Z,n.X,n.Y,n.Z)}function b(o,e,t){const n=Math.max(1,Math.floor(t)),{primary:s,secondary:r}=le(o.plane),i=ue(o.start[s],o.start[r],o.center[s],o.center[r]),a=Math.atan2(o.start[r]-o.center[r],o.start[s]-o.center[s]),c=Math.atan2(o.end[r]-o.center[r],o.end[s]-o.center[s]),d=Math.PI*2;let m=_(a),u=_(c);o.motion==="G2"?m<=u&&(m+=d):u<=m&&(u+=d);const A=o.motion==="G2"?m-u:u-m;let l={...o.start};for(let h=1;h<=n;h+=1){const v=h/n,x=o.motion==="G2"?m-A*v:m+A*v,L=de(o.start,o.end,v);L[s]=o.center[s]+i*Math.cos(x),L[r]=o.center[r]+i*Math.sin(x);const y=U(l),S=U(L);e.push(y.X,y.Y,y.Z,S.X,S.Y,S.Z),l=L}}function U(o){const e=o.A*Math.PI/180,t=Math.cos(e),n=Math.sin(e),s=o.Y*t-o.Z*n,r=o.Y*n+o.Z*t;return{...o,Y:s,Z:r}}function le(o){return o==="G18"?{primary:"Z",secondary:"X"}:o==="G19"?{primary:"Y",secondary:"Z"}:{primary:"X",secondary:"Y"}}function _(o){const e=Math.PI*2;let t=o%e;return t<0&&(t+=e),t}function ue(o,e,t,n){return Math.hypot(o-t,e-n)}function de(o,e,t){return{X:o.X+(e.X-o.X)*t,Y:o.Y+(e.Y-o.Y)*t,Z:o.Z+(e.Z-o.Z)*t,A:o.A+(e.A-o.A)*t,B:o.B+(e.B-o.B)*t,C:o.C+(e.C-o.C)*t}}function fe(o){let e=Number.POSITIVE_INFINITY,t=Number.NEGATIVE_INFINITY;const n=new g({onLinearMove:s=>{const r=s.modals.spindleSpeed;r!==null&&(e=Math.min(e,r),t=Math.max(t,r))},onArcMove:s=>{const r=s.modals.spindleSpeed;r!==null&&(e=Math.min(e,r),t=Math.max(t,r))}});for(const s of o)s&&n.processLine(s);return!Number.isFinite(e)||!Number.isFinite(t)?{minPower:0,maxPower:0}:{minPower:e,maxPower:t}}function $(o,e,t,n){if(n<=1)return 0;const s=o??e;if(t<=e)return n-1;const r=(s-e)/(t-e),i=Math.floor(r*(n-1));return Math.min(n-1,Math.max(0,i))}function D(o,e,t){if(e<=1)return t;const n=o/(e-1);return t*n}function me(o){const e=new Float32Array(o.vertices),t=new Uint32Array(o.frames),n=new Float32Array(o.colorArrayBuffer),{verticesLen:s,framesLen:r}=o,i=new Map;for(let a=0;a<r;a++){const c=t[a],d=a<r-1?t[a+1]:s/3;if(d<=c+1)continue;const m=c*4,u=n[m],A=n[m+1],l=n[m+2],h=n[m+3],v=pe(u,A,l),x=`${v}|${Math.round(h*100)}`;let L=i.get(x);L||(L={hexColor:v,opacity:h,pos:[],rgb:[]},i.set(x,L));for(let y=c;y<d-1;y++){const S=y*3,P=(y+1)*3;L.pos.push(e[S],e[S+1],e[S+2],e[P],e[P+1],e[P+2]),L.rgb.push(u,A,l,u,A,l)}}return Array.from(i.values()).map(({hexColor:a,opacity:c,pos:d,rgb:m})=>({hexColor:a,opacity:c,positions:new Float32Array(d),rgbColors:new Float32Array(m)}))}function pe(o,e,t){const n=s=>Math.round(Math.min(1,Math.max(0,s))*255).toString(16).padStart(2,"0");return`#${n(o)}${n(e)}${n(t)}`}function he(o,e){const t=new Float32Array(o.vertices),n=new Uint32Array(o.frames),s=new Float32Array(o.colorArrayBuffer),i=(o.isLaser&&o.savedColorsBuffer&&o.savedColorLen?new Float32Array(o.savedColorsBuffer):null)??s,{verticesLen:a,framesLen:c}=o,d=(e==null?void 0:e.lineGroups)??[],m=d.length,u=m+1,A=new Int32Array(c).fill(m);for(let G=d.length-1;G>=0;G--){const f=Math.max(0,Math.floor(d[G].start)),M=Math.min(c-1,Math.floor(d[G].end));for(let p=f;p<=M;p++)A[p]=G}const l=G=>Array.from({length:u},G),h=l(()=>[]),v=l(()=>[]),x=l(()=>[]),L=l(()=>[]),y=l(()=>new Int32Array(c)),S=l(()=>new Int32Array(c));for(let G=0;G<c;G++){const f=n[G],M=G<c-1?n[G+1]:a/3;if(M>f+1){const p=s[f*4+3]<.75,w=A[G],I=p?h[w]:x[w],E=p?v[w]:L[w];for(let Y=f;Y<M-1;Y++){const C=Y*3,Z=(Y+1)*3;I.push(t[C],t[C+1],t[C+2],t[Z],t[Z+1],t[Z+2]);const X=Y*4,k=(Y+1)*4;E.push(i[X],i[X+1],i[X+2],i[k],i[k+1],i[k+2])}}for(let p=0;p<u;p++)y[p][G]=h[p].length/3,S[p][G]=x[p].length/3}const P=(G,f,M)=>G.map((p,w)=>({positions:Float32Array.from(p),colors:Float32Array.from(f[w]),prefixEndVertex:M[w],lineGroupIndex:w===m?null:w}));return{rapids:P(h,v,y),cuts:P(x,L,S)}}exports.GCodeParser=N;exports.GCodeVirtualizer=g;exports.buildLaserGeometryFromLinesBatched=W;exports.buildLaserVerticesFromLines=ie;exports.buildLaserVerticesFromLinesBatched=ae;exports.buildMovementGeometryFromLinesBatched=se;exports.buildMovementVerticesFromLines=oe;exports.buildMovementVerticesFromLinesBatched=re;exports.buildToolpathGeometryFromLinesBatched=j;exports.buildVerticesFromLines=ne;exports.buildWorkerSegmentGroups=me;exports.buildWorkerToolpathStreams=he;exports.pushXYZ=ce;
|