@jscad/core 2.6.12 → 2.6.13

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/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.6.13](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/core@2.6.12...@jscad/core@2.6.13) (2025-09-20)
7
+
8
+ **Note:** Version bump only for package @jscad/core
9
+
10
+
11
+
12
+
13
+
6
14
  ## [2.6.12](https://github.com/jscad/OpenJSCAD.org/compare/@jscad/core@2.6.11...@jscad/core@2.6.12) (2024-12-29)
7
15
 
8
16
  **Note:** Version bump only for package @jscad/core
@@ -26,7 +26,7 @@ var cachedSetTimeout,cachedClearTimeout,process=module.exports={};function defau
26
26
  },{}],8:[function(require,module,exports){
27
27
  module.exports={
28
28
  "name": "@jscad/core",
29
- "version": "2.6.12",
29
+ "version": "2.6.13",
30
30
  "description": "Core functionality for JSCAD Applications",
31
31
  "homepage": "https://openjscad.xyz/",
32
32
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -62,9 +62,9 @@ module.exports={
62
62
  "license": "MIT",
63
63
  "dependencies": {
64
64
  "@jscad/array-utils": "2.1.4",
65
- "@jscad/io": "2.4.11",
66
- "@jscad/io-utils": "2.0.30",
67
- "@jscad/modeling": "2.12.5",
65
+ "@jscad/io": "2.4.12",
66
+ "@jscad/io-utils": "2.0.31",
67
+ "@jscad/modeling": "2.12.6",
68
68
  "json5": "2.2.3",
69
69
  "strip-bom": "4.0.0"
70
70
  },
@@ -196,7 +196,7 @@ const zipSync=require("fflate").zipSync,strToU8=require("fflate").strToU8,string
196
196
  },{"xmlchars/xml/1.0/ed5":42,"xmlchars/xml/1.1/ed2":43,"xmlchars/xmlns/1.0/ed3":44}],46:[function(require,module,exports){
197
197
  module.exports={
198
198
  "name": "@jscad/amf-deserializer",
199
- "version": "2.3.10",
199
+ "version": "2.3.11",
200
200
  "description": "AMF Deserializer for JSCAD",
201
201
  "repository": "https://github.com/jscad/OpenJSCAD.org/",
202
202
  "main": "src/index.js",
@@ -227,8 +227,8 @@ module.exports={
227
227
  ],
228
228
  "license": "MIT",
229
229
  "dependencies": {
230
- "@jscad/io-utils": "2.0.30",
231
- "@jscad/modeling": "2.12.5",
230
+ "@jscad/io-utils": "2.0.31",
231
+ "@jscad/modeling": "2.12.6",
232
232
  "saxes": "5.0.1"
233
233
  },
234
234
  "devDependencies": {
@@ -286,7 +286,7 @@ const{geometries:geometries,maths:maths,primitives:primitives}=require("@jscad/m
286
286
  },{"./helpers":59,"@jscad/modeling":217}],62:[function(require,module,exports){
287
287
  module.exports={
288
288
  "name": "@jscad/dxf-deserializer",
289
- "version": "2.3.27",
289
+ "version": "2.3.28",
290
290
  "description": "DXF Deserializer for JSCAD",
291
291
  "homepage": "https://openjscad.xyz/",
292
292
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -314,8 +314,8 @@ module.exports={
314
314
  ],
315
315
  "license": "MIT",
316
316
  "dependencies": {
317
- "@jscad/io-utils": "2.0.30",
318
- "@jscad/modeling": "2.12.5"
317
+ "@jscad/io-utils": "2.0.31",
318
+ "@jscad/modeling": "2.12.6"
319
319
  },
320
320
  "devDependencies": {
321
321
  "ava": "3.15.0",
@@ -374,7 +374,7 @@ const{flatten:flatten,toArray:toArray}=require("@jscad/array-utils"),{ensureStri
374
374
  },{"./package.json":78,"@jscad/array-utils":533,"@jscad/io-utils":71}],78:[function(require,module,exports){
375
375
  module.exports={
376
376
  "name": "@jscad/json-deserializer",
377
- "version": "2.0.31",
377
+ "version": "2.0.32",
378
378
  "description": "JSON Deserializer for JSCAD",
379
379
  "homepage": "https://openjscad.xyz/",
380
380
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -403,10 +403,10 @@ module.exports={
403
403
  "license": "MIT",
404
404
  "dependencies": {
405
405
  "@jscad/array-utils": "2.1.4",
406
- "@jscad/io-utils": "2.0.30"
406
+ "@jscad/io-utils": "2.0.31"
407
407
  },
408
408
  "devDependencies": {
409
- "@jscad/modeling": "2.12.5",
409
+ "@jscad/modeling": "2.12.6",
410
410
  "ava": "3.15.0",
411
411
  "nyc": "15.1.0"
412
412
  },
@@ -422,7 +422,7 @@ const{colors:colors,primitives:primitives}=require("@jscad/modeling"),{ensureStr
422
422
  },{"./package.json":81,"@jscad/io-utils":71,"@jscad/modeling":217}],81:[function(require,module,exports){
423
423
  module.exports={
424
424
  "name": "@jscad/obj-deserializer",
425
- "version": "2.0.30",
425
+ "version": "2.0.31",
426
426
  "description": "OBJ Deserializer for JSCAD",
427
427
  "homepage": "https://openjscad.xyz/",
428
428
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -454,8 +454,8 @@ module.exports={
454
454
  ],
455
455
  "license": "MIT",
456
456
  "dependencies": {
457
- "@jscad/io-utils": "2.0.30",
458
- "@jscad/modeling": "2.12.5"
457
+ "@jscad/io-utils": "2.0.31",
458
+ "@jscad/modeling": "2.12.6"
459
459
  },
460
460
  "devDependencies": {
461
461
  "ava": "3.15.0",
@@ -473,7 +473,7 @@ const{maths:maths,primitives:primitives}=require("@jscad/modeling"),{BinaryReade
473
473
  },{"./package.json":84,"@jscad/io-utils":71,"@jscad/modeling":217}],84:[function(require,module,exports){
474
474
  module.exports={
475
475
  "name": "@jscad/stl-deserializer",
476
- "version": "2.1.27",
476
+ "version": "2.1.28",
477
477
  "description": "STL Deserializer for JSCAD",
478
478
  "homepage": "https://openjscad.xyz/",
479
479
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -505,8 +505,8 @@ module.exports={
505
505
  ],
506
506
  "license": "MIT",
507
507
  "dependencies": {
508
- "@jscad/io-utils": "2.0.30",
509
- "@jscad/modeling": "2.12.5"
508
+ "@jscad/io-utils": "2.0.31",
509
+ "@jscad/modeling": "2.12.6"
510
510
  },
511
511
  "devDependencies": {
512
512
  "ava": "3.15.0",
@@ -539,7 +539,7 @@ const{geometries:geometries,modifiers:modifiers}=require("@jscad/modeling"),{fla
539
539
  },{"xmlchars/xml/1.0/ed5":88,"xmlchars/xml/1.1/ed2":89,"xmlchars/xmlns/1.0/ed3":90}],92:[function(require,module,exports){
540
540
  module.exports={
541
541
  "name": "@jscad/svg-deserializer",
542
- "version": "2.5.11",
542
+ "version": "2.5.12",
543
543
  "description": "SVG Deserializer for JSCAD",
544
544
  "homepage": "https://openjscad.xyz/",
545
545
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -572,8 +572,8 @@ module.exports={
572
572
  "license": "MIT",
573
573
  "dependencies": {
574
574
  "@jscad/array-utils": "2.1.4",
575
- "@jscad/io-utils": "2.0.30",
576
- "@jscad/modeling": "2.12.5",
575
+ "@jscad/io-utils": "2.0.31",
576
+ "@jscad/modeling": "2.12.6",
577
577
  "saxes": "5.0.1"
578
578
  },
579
579
  "devDependencies": {
@@ -593,7 +593,7 @@ const{inchMM:inchMM,ptMM:ptMM,pcMM:pcMM,svgColors:svgColors}=require("./constant
593
593
  const saxes=require("saxes"),{colors:colors,transforms:transforms}=require("@jscad/modeling"),{toArray:toArray}=require("@jscad/array-utils"),{ensureString:ensureString}=require("@jscad/io-utils"),version=require("../package.json").version,{cagLengthX:cagLengthX,cagLengthY:cagLengthY,svgColorForTarget:svgColorForTarget}=require("./helpers"),{svgSvg:svgSvg,svgRect:svgRect,svgCircle:svgCircle,svgGroup:svgGroup,svgLine:svgLine,svgPath:svgPath,svgEllipse:svgEllipse,svgPolygon:svgPolygon,svgPolyline:svgPolyline,svgUse:svgUse}=require("./svgElementHelpers"),shapesMapGeometry=require("./shapesMapGeometry"),shapesMapJscad=require("./shapesMapJscad"),deserialize=(s,e)=>{const t={addMetaData:!0,filename:"svg",output:"script",pxPmm:require("./constants").pxPmm,segments:32,target:"path",pathSelfClosed:"error",version:version};return s=Object.assign({},t,s),e=ensureString(e),"script"===s.output?translate(e,s):instantiate(e,s)},instantiate=(s,e)=>{const{pxPmm:t}=e;if(e&&e.statusCallback&&e.statusCallback({progress:0}),createSvgParser(s,t),!svgObj)throw new Error("SVG parsing failed, no valid SVG data retrieved");e&&e.statusCallback&&e.statusCallback({progress:50});const n=objectify(e,svgObj);return e&&e.statusCallback&&e.statusCallback({progress:100}),n},translate=(s,e)=>{const{filename:t,version:n,pxPmm:r,addMetaData:o}=e;if(e&&e.statusCallback&&e.statusCallback({progress:0}),createSvgParser(s,r),!svgObj)throw new Error("SVG parsing failed, no valid SVG data retrieved");let a=o?`//\n // producer: JSCAD SVG Deserializer ${n}\n // date: ${new Date}\n // source: ${t}\n //\n`:"";return a+="const { colors, geometries, primitives, transforms } = require('@jscad/modeling')\n\n",e&&e.statusCallback&&e.statusCallback({progress:50}),a+=codify(e,svgObj),a+="\nmodule.exports = { main }",e&&e.statusCallback&&e.statusCallback({progress:100}),a};let svgUnitsX,svgUnitsY,svgUnitsV;const svgObjects=[],svgGroups=[],svgDefs=[];let svgObj,svgInDefs=!1,svgUnitsPmm=[1,1];const objectify=(s,e)=>{const{target:t,segments:n,pathSelfClosed:r}=s,o=svgGroups.length;svgGroups.push(e);let a=o;for(;a>0;)a--;let g=[];const l={svgUnitsPmm:svgUnitsPmm,svgUnitsX:svgUnitsX,svgUnitsY:svgUnitsY,svgUnitsV:svgUnitsV,level:o,target:t,svgGroups:svgGroups,segments:n,pathSelfClosed:r};for(a=0;a<e.objects.length;a++){const s=e.objects[a];let n=toArray(shapesMapGeometry(s,objectify,l));n=n.map(e=>{if("transforms"in s){let t=null,n=null,r=null;for(let e=0;e<s.transforms.length;e++){const o=s.transforms[e];"rotate"in o&&(t=o),"scale"in o&&(n=o),"translate"in o&&(r=o)}if(null!==n){let s=Math.abs(n.scale[0]),t=Math.abs(n.scale[1]);e=transforms.scale([s,t,1],e),s=n.scale[0],t=n.scale[1],s<0&&(e=transforms.mirrorX(e)),t<0&&(e=transforms.mirrorY(e))}if(null!==t){const s=0-.017453292519943295*t.rotate;e=transforms.rotateZ(s,e)}if(null!==r){const s=cagLengthX(r.translate[0],svgUnitsPmm,svgUnitsX),t=0-cagLengthY(r.translate[1],svgUnitsPmm,svgUnitsY);e=transforms.translate([s,t,0],e)}}const n=svgColorForTarget(t,s);return n&&(e=colors.colorize(n,e)),e}),g=g.concat(n)}return svgGroups.pop(),g},codify=(s,e)=>{const{target:t,segments:n}=s,r=svgGroups.length;svgGroups.push(e);let o=" ",a=r;for(;a>0;)o+=" ",a--;let g="";0===r&&(g+="function main(params) {\n let levels = {}\n let paths = {}\n let parts\n");const l="levels.l"+r;for(g+=`${o}${l} = []\n`,a=0;a<e.objects.length;a++){const s=e.objects[a],i="paths.p"+a;if(g+=shapesMapJscad(s,codify,{level:r,indent:o,ln:l,on:i,svgUnitsPmm:svgUnitsPmm,svgUnitsX:svgUnitsX,svgUnitsY:svgUnitsY,svgUnitsV:svgUnitsV,svgGroups:svgGroups,target:t,segments:n}),"transforms"in s){let e=null,t=null,n=null;for(let r=0;r<s.transforms.length;r++){const o=s.transforms[r];"rotate"in o&&(e=o),"scale"in o&&(t=o),"translate"in o&&(n=o)}if(null!==t){let s=Math.abs(t.scale[0]),e=Math.abs(t.scale[1]);g+=`${o}${i} = transforms.scale([${s}, ${e}, 1], ${i})\n`,(s=t.scale[0])<0&&(g+=`${o}${i} = transforms.mirrorX(${i})\n`),(e=t.scale[1])<0&&(g+=`${o}${i} = transforms.mirrorY(${i})\n`)}if(null!==e){g+=`${o}${i} = transforms.rotateZ(${0-.017453292519943295*e.rotate}, ${i})\n`}if(null!==n){g+=`${o}${i} = transforms.translate([${cagLengthX(n.translate[0],svgUnitsPmm,svgUnitsX)}, ${0-cagLengthY(n.translate[1],svgUnitsPmm,svgUnitsY)}, 0], ${i})\n`}}const v=svgColorForTarget(t,s);v&&(g+=`${o}${i} = colors.colorize([${v}], ${i})\n`),g+=`${o}${l} = ${l}.concat(${i})\n\n`}return 0===r&&(g+=o+"return "+l+"\n",g+="}\n"),svgGroups.pop(),g},createSvgParser=(s,e)=>{const t=new saxes.SaxesParser;return void 0!==e&&e>t.pxPmm&&(t.pxPmm=e),t.on("error",s=>{console.log(`ERROR: SVG file, line ${t.line}, column ${t.column}`),console.log(s)}),t.on("opentag",s=>{const n={SVG:svgSvg,G:svgGroup,RECT:svgRect,CIRCLE:svgCircle,ELLIPSE:svgEllipse,LINE:svgLine,POLYLINE:svgPolyline,POLYGON:svgPolygon,PATH:svgPath,USE:svgUse,DEFS:()=>{svgInDefs=!0},DESC:()=>void 0,TITLE:()=>void 0,STYLE:()=>void 0,undefined:()=>console.log("WARNING: unsupported SVG element: "+s.name)};s.attributes.position=[t.line+1,t.column+1];const r=s.name.toUpperCase(),o=n[r]?n[r](s.attributes,{svgObjects:svgObjects,customPxPmm:e}):void 0;if(o)if("id"in o&&(svgObjects[o.id]=o),"svg"===o.type)svgGroups.push(o),svgUnitsPmm=o.unitsPmm,svgUnitsX=o.viewW,svgUnitsY=o.viewH,svgUnitsV=o.viewP;else if(!0===svgInDefs){if(svgDefs.length>0){const s=svgDefs.pop();"objects"in s&&s.objects.push(o),svgDefs.push(s)}"group"===o.type&&svgDefs.push(o)}else{if(svgGroups.length>0){const s=svgGroups.pop();"objects"in s&&s.objects.push(o),svgGroups.push(s)}"group"===o.type&&svgGroups.push(o)}}),t.on("closetag",s=>{const e=()=>!0===svgInDefs?svgDefs.pop():svgGroups.pop(),t={SVG:e,DEFS:()=>{svgInDefs=!1},USE:e,G:e,undefined:()=>{}},n=s.name.toUpperCase(),r=t[n]?t[n]():void 0;0===svgGroups.length&&(svgObj=r)}),t.on("end",()=>{}),t.write(s).close(),t},extension="svg";module.exports={deserialize:deserialize,extension:"svg"};
594
594
 
595
595
  },{"../package.json":92,"./constants":93,"./helpers":94,"./shapesMapGeometry":96,"./shapesMapJscad":97,"./svgElementHelpers":98,"@jscad/array-utils":533,"@jscad/io-utils":71,"@jscad/modeling":217,"saxes":91}],96:[function(require,module,exports){
596
- const{geometries:geometries,primitives:primitives}=require("@jscad/modeling"),{svg2cag:svg2cag,cagLengthX:cagLengthX,cagLengthY:cagLengthY,cagLengthP:cagLengthP,reflect:reflect}=require("./helpers"),shapesMapGeometry=(e,t,s)=>{const{svgUnitsPmm:a,svgUnitsX:o,svgUnitsY:r,svgUnitsV:n,svgGroups:g,target:c,segments:p,pathSelfClosed:i}=s;return{group:e=>t({target:c,segments:p},e),rect:(e,t,s,a,o,r,n)=>{let g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a);const i=cagLengthX(e.width,t,s),l=cagLengthY(e.height,t,a),h=cagLengthX(e.rx,t,s);let m;return i>0&&l>0&&(g+=i/2,p-=l/2,m=0===h?primitives.rectangle({center:[g,p],size:[i,l]}):primitives.roundedRectangle({center:[g,p],segments:n,size:[i,l],roundRadius:h}),"path"===c&&(m=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(m)))),m},circle:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a),i=cagLengthP(e.radius,t,o);let l;return i>0&&(l=primitives.circle({center:[g,p],segments:n,radius:i}),"path"===c&&(l=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(l)))),l},ellipse:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.rx,t,s),p=cagLengthY(e.ry,t,a),i=cagLengthX(e.cx,t,s),l=0-cagLengthY(e.cy,t,a);let h;return g>0&&p>0&&(h=primitives.ellipse({center:[i,l],segments:n,radius:[g,p]}),"path"===c&&(h=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(h)))),h},line:(e,t,s,a,o)=>{const r=cagLengthX(e.x1,t,s),n=0-cagLengthY(e.y1,t,a),g=cagLengthX(e.x2,t,s),c=0-cagLengthY(e.y2,t,a);return primitives.line([[r,n],[g,c]])},polygon:(e,t,s,a)=>{const o=[];for(let r=0;r<e.points.length;r++){const n=e.points[r];if("x"in n&&"y"in n){const e=cagLengthX(n.x,t,s),r=0-cagLengthY(n.y,t,a);o.push([e,r])}}return"geom2"===c?geometries.geom2.fromPoints(o):geometries.path2.fromPoints({},o)},polyline:(e,t,s,a,o)=>{const r=[];for(let o=0;o<e.points.length;o++){const n=e.points[o];if("x"in n&&"y"in n){const e=cagLengthX(n.x,t,s),o=0-cagLengthY(n.y,t,a);r.push([e,o])}}return primitives.line(r)},path:(e,t,s,a,o,r,n)=>{const g=expandPath(e,t,s,a,o,r,n,i);return Object.entries(g).sort((e,t)=>e[0].localeCompare(t[0])).map(e=>{const t=e[1];if("geom2"===c&&t.isClosed){const e=geometries.path2.toPoints(t).slice();return e.push(e[0]),geometries.geom2.fromPoints(e)}return t})}}[e.type](e,a,o,r,n,g,p)};module.exports=shapesMapGeometry;const appendPoints=(e,t)=>t?geometries.path2.appendPoints(e,t):geometries.path2.fromPoints({},e),expandPath=(e,t,s,a,o,r,n,g)=>{const c={};let p=0,i=0,l=0,h=0,m=0,F="path"+m,v=!1,d=0,f=0,P=0,u=0;const L=()=>{F="path"+ ++m,v=!1},k=()=>{c[F]||(c[F]=geometries.path2.fromPoints({},[]))};for(let s=0;s<e.commands.length;s++){const a=e.commands[s],o=a.p;let r=0;switch(a.c){case"m":for(0===s&&(l=0,h=0),o.length>=r+2&&(l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"M":for(o.length>=r+2&&(l=parseFloat(o[r++]),h=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"a":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"A":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"c":for(;o.length>=r+6;){const e=l+parseFloat(o[r++]),s=h+parseFloat(o[r++]);d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"C":for(;o.length>=r+6;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]);d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"q":for(;o.length>=r+4;){const e=[l,h];P=l+parseFloat(o[r++]),u=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"Q":for(;o.length>=r+4;){const e=[l,h];P=parseFloat(o[r++]),u=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"t":for(;o.length>=r+2;){const e=[l,h];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"T":for(;o.length>=r+2;){const e=[l,h];l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"s":for(;o.length>=r+4;){const e=d,s=f;d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"S":for(;o.length>=r+4;){const e=d,s=f;d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"h":for(;o.length>=r+1;)l+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"H":for(;o.length>=r+1;)l=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"l":for(;o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"L":for(;o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"v":for(;o.length>=r+1;)h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"V":for(;o.length>=r+1;)h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"z":case"Z":c[F]=geometries.path2.close(c[F]),l=p,h=i,v=!0;break;default:console.log("Warning: Unknow PATH command ["+a.c+"]")}const m=e=>"z"===e||"Z"===e;if(!0!==v&&c[F]&&c[F].isClosed){let t=e.commands[s+1];if(t&&!m(t.c))if("trim"===g)for(;t&&!m(t.c);)s++,t=e.commands[s+1];else{if("split"!==g)throw new Error(`Malformed svg path at ${e.position[0]}:${a.pos}. Path closed itself with command #${s} ${a.c}${o.join(" ")}`);L()}}}return c};
596
+ const{geometries:geometries,primitives:primitives}=require("@jscad/modeling"),{svg2cag:svg2cag,cagLengthX:cagLengthX,cagLengthY:cagLengthY,cagLengthP:cagLengthP,reflect:reflect}=require("./helpers"),shapesMapGeometry=(e,t,s)=>{const{svgUnitsPmm:a,svgUnitsX:o,svgUnitsY:r,svgUnitsV:n,svgGroups:g,target:c,segments:p,pathSelfClosed:i}=s;return{group:e=>t({target:c,segments:p},e),rect:(e,t,s,a,o,r,n)=>{let g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a);const i=cagLengthX(e.width,t,s),l=cagLengthY(e.height,t,a),h=cagLengthX(e.rx,t,s);let m;return i>0&&l>0&&(g+=i/2,p-=l/2,m=0===h?primitives.rectangle({center:[g,p],size:[i,l]}):primitives.roundedRectangle({center:[g,p],segments:n,size:[i,l],roundRadius:h}),"path"===c&&(m=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(m)))),m},circle:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.x,t,s),p=0-cagLengthY(e.y,t,a),i=cagLengthP(e.radius,t,o);let l;return i>0&&(l=primitives.circle({center:[g,p],segments:n,radius:i}),"path"===c&&(l=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(l)))),l},ellipse:(e,t,s,a,o,r,n)=>{const g=cagLengthX(e.rx,t,s),p=cagLengthY(e.ry,t,a),i=cagLengthX(e.cx,t,s),l=0-cagLengthY(e.cy,t,a);let h;return g>0&&p>0&&(h=primitives.ellipse({center:[i,l],segments:n,radius:[g,p]}),"path"===c&&(h=geometries.path2.fromPoints({closed:!0},geometries.geom2.toPoints(h)))),h},line:(e,t,s,a,o)=>{const r=cagLengthX(e.x1,t,s),n=0-cagLengthY(e.y1,t,a),g=cagLengthX(e.x2,t,s),c=0-cagLengthY(e.y2,t,a);return primitives.line([[r,n],[g,c]])},polygon:(e,t,s,a)=>{const o=[];for(let r=0;r<e.points.length;r++){const n=e.points[r];if("x"in n&&"y"in n){const e=cagLengthX(n.x,t,s),r=0-cagLengthY(n.y,t,a);o.push([e,r])}}return"geom2"===c?geometries.geom2.fromPoints(o):geometries.path2.fromPoints({},o)},polyline:(e,t,s,a,o)=>{const r=[];for(let o=0;o<e.points.length;o++){const n=e.points[o];if("x"in n&&"y"in n){const e=cagLengthX(n.x,t,s),o=0-cagLengthY(n.y,t,a);r.push([e,o])}}return primitives.line(r)},path:(e,t,s,a,o,r,n)=>{const g=expandPath(e,t,s,a,o,r,n,i),p=Object.entries(g).sort((e,t)=>e[0].localeCompare(t[0]));if("geom2"===c){const e=[];return p.forEach(t=>{const s=t[1];if(s.isClosed){const t=geometries.path2.toPoints(s);e.push(t)}}),0===e.length?[]:geometries.geom2.create(e)}return p.map(e=>e[1])}}[e.type](e,a,o,r,n,g,p)};module.exports=shapesMapGeometry;const appendPoints=(e,t)=>t?geometries.path2.appendPoints(e,t):geometries.path2.fromPoints({},e),expandPath=(e,t,s,a,o,r,n,g)=>{const c={};let p=0,i=0,l=0,h=0,m=0,F="path"+m,v=!1,d=0,f=0,P=0,u=0;const L=()=>{F="path"+ ++m,v=!1},k=()=>{c[F]||(c[F]=geometries.path2.fromPoints({},[]))};for(let s=0;s<e.commands.length;s++){const a=e.commands[s],o=a.p;let r=0;switch(a.c){case"m":for(0===s&&(l=0,h=0),o.length>=r+2&&(l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"M":for(o.length>=r+2&&(l=parseFloat(o[r++]),h=parseFloat(o[r++]),L(),c[F]=appendPoints([svg2cag([l,h],t)]),p=l,i=h);o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"a":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"A":for(;o.length>=r+7;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]),a=0-.017453292519943295*parseFloat(o[r++]),g="1"===o[r++],p="1"===o[r++];l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendArc({segments:n,endpoint:svg2cag([l,h],t),radius:svg2cag([e,s],t),xaxisrotation:a,clockwise:p,large:g},c[F])}break;case"c":for(;o.length>=r+6;){const e=l+parseFloat(o[r++]),s=h+parseFloat(o[r++]);d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"C":for(;o.length>=r+6;){const e=parseFloat(o[r++]),s=parseFloat(o[r++]);d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"q":for(;o.length>=r+4;){const e=[l,h];P=l+parseFloat(o[r++]),u=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"Q":for(;o.length>=r+4;){const e=[l,h];P=parseFloat(o[r++]),u=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"t":for(;o.length>=r+2;){const e=[l,h];l+=parseFloat(o[r++]),h+=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"T":for(;o.length>=r+2;){const e=[l,h];l=parseFloat(o[r++]),h=parseFloat(o[r++]);const s=[e[0]+2/3*(P-e[0]),e[1]+2/3*(u-e[1])],a=[s[0]+1/3*(l-e[0]),s[1]+1/3*(h-e[1])];k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag(s,t),svg2cag(a,t),svg2cag([l,h],t)]},c[F]);const g=reflect(P,u,l,h);P=g[0],u=g[1]}break;case"s":for(;o.length>=r+4;){const e=d,s=f;d=l+parseFloat(o[r++]),f=h+parseFloat(o[r++]),l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"S":for(;o.length>=r+4;){const e=d,s=f;d=parseFloat(o[r++]),f=parseFloat(o[r++]),l=parseFloat(o[r++]),h=parseFloat(o[r++]),k(),c[F]=geometries.path2.appendBezier({segments:n,controlPoints:[svg2cag([e,s],t),svg2cag([d,f],t),svg2cag([l,h],t)]},c[F]);const a=reflect(d,f,l,h);d=a[0],f=a[1]}break;case"h":for(;o.length>=r+1;)l+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"H":for(;o.length>=r+1;)l=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"l":for(;o.length>=r+2;)l+=parseFloat(o[r++]),h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"L":for(;o.length>=r+2;)l=parseFloat(o[r++]),h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"v":for(;o.length>=r+1;)h+=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"V":for(;o.length>=r+1;)h=parseFloat(o[r++]),c[F]=appendPoints([svg2cag([l,h],t)],c[F]);break;case"z":case"Z":c[F]=geometries.path2.close(c[F]),l=p,h=i,v=!0;break;default:console.log("Warning: Unknown PATH command ["+a.c+"]")}const m=e=>"z"===e||"Z"===e;if(!0!==v&&c[F]&&c[F].isClosed){let t=e.commands[s+1];if(t&&!m(t.c))if("trim"===g)for(;t&&!m(t.c);)s++,t=e.commands[s+1];else{if("split"!==g)throw new Error(`Malformed svg path at ${e.position[0]}:${a.pos}. Path closed itself with command #${s} ${a.c}${o.join(" ")}`);L()}}}return c};
597
597
 
598
598
  },{"./helpers":94,"@jscad/modeling":217}],97:[function(require,module,exports){
599
599
  const{svg2cag:svg2cag,cagLengthX:cagLengthX,cagLengthY:cagLengthY,cagLengthP:cagLengthP,reflect:reflect}=require("./helpers"),shapesMap=(e,t,s)=>{const{level:a,indent:n,on:o,svgUnitsPmm:r,svgUnitsX:g,svgUnitsY:i,svgUnitsV:$,svgGroups:p,target:c,segments:h}=s;return{group:e=>{let s=t({target:c,segments:h},e);return s+=`${n}${o} = levels.l${a+1}\n`},rect:(e,t,s,a,r,g,i,$)=>{let p=cagLengthX(e.x,t,s),h=0-cagLengthY(e.y,t,a);const l=cagLengthX(e.width,t,s),f=cagLengthY(e.height,t,a),m=cagLengthX(e.rx,t,s);let F;return l>0&&f>0&&(p=(p+l/2).toFixed(4),h=(h-f/2).toFixed(4),F=0===m?`${n}${o} = primitives.rectangle({center: [${p}, ${h}], size: [${l}, ${f}]}) // line ${e.position}\n`:`${n}${o} = primitives.roundedRectangle({center: [${p}, ${h}], segments: ${$}, size: [${l}, ${f}], roundRadius: ${m}}) // line ${e.position}\n`,"path"===c&&(F+=`${n}${o} = geometries.path2.fromPoints({closed: true}, geometries.geom2.toPoints(${o}))\n`)),F},circle:(e,t,s,a,r,g,i,$)=>{const p=cagLengthX(e.x,t,s),h=0-cagLengthY(e.y,t,a),l=cagLengthP(e.radius,t,r);let f;return l>0&&(f=`${n}${o} = primitives.circle({center: [${p}, ${h}], segments: ${$}, radius: ${l}}) // line ${e.position}\n`,"path"===c&&(f+=`${n}${o} = geometries.path2.fromPoints({closed: true}, geometries.geom2.toPoints(${o}))\n`)),f},ellipse:(e,t,s,a,r,g,i,$)=>{const p=cagLengthX(e.rx,t,s),h=cagLengthY(e.ry,t,a),l=cagLengthX(e.cx,t,s),f=0-cagLengthY(e.cy,t,a);let m;return p>0&&h>0&&(m=`${n}${o} = primitives.ellipse({center: [${l}, ${f}], segments: ${$}, radius: [${p}, ${h}]}) // line ${e.position}\n`,"path"===c&&(m+=`${n}${o} = geometries.path2.fromPoints({closed: true}, geometries.geom2.toPoints(${o}))\n`)),m},line:(e,t,s,a,r)=>{const g=cagLengthX(e.x1,t,s),i=0-cagLengthY(e.y1,t,a),$=cagLengthX(e.x2,t,s),p=0-cagLengthY(e.y2,t,a);return`${n}${o} = primitives.line([[${g}, ${i}], [${$}, ${p}]]) // line ${e.position}\n`},polygon:(e,t,s,a)=>{let r=`${n}${o} = primitives.polygon({points: [\n`;for(let o=0;o<e.points.length;o++){const g=e.points[o];if("x"in g&&"y"in g){const e=cagLengthX(g.x,t,s),o=0-cagLengthY(g.y,t,a);r+=`${n} [${e}, ${o}],\n`}}return r+=`${n}]}) // line ${e.position}\n`,"path"===c&&(r+=`${n}${o} = geometries.path2.fromPoints({closed: true}, geometries.geom2.toPoints(${o}))\n`),r},polyline:(e,t,s,a,r)=>{let g=`${n}${o} = geometries.path2.fromPoints({}, [\n`;for(let o=0;o<e.points.length;o++){const r=e.points[o];if("x"in r&&"y"in r){const e=cagLengthX(r.x,t,s),o=0-cagLengthY(r.y,t,a);g+=`${n} [${e}, ${o}],\n`}}return g+=`${n}]) // line ${e.position}\n`},path:path}[e.type](e,r,g,i,$,s,p,h)};module.exports=shapesMap;const path=(e,t,s,a,n,o,r,g)=>{const{indent:i,on:$,target:p}=o;let c=`${i}parts = [] // line ${e.position}\n`,h=0,l=0,f=0,m=0,F=0,v=$+F,d=!1,P=0,u=0,L=0,k=0;for(let s=0;s<e.commands.length;s++){const a=e.commands[s],n=a.p;switch(a.c){case"m":for(0===s&&(f=0,m=0),F>0&&!1===d&&(c+=`${i}parts.push(${v})\n`),n.length>=2&&(f+=parseFloat(n.shift()),m+=parseFloat(n.shift()),d=!1,c+=`${i}${v=$+ ++F} = geometries.path2.fromPoints({}, [[${svg2cag([f,m],t)}]])\n`,h=f,l=m);n.length>=2;)f+=parseFloat(n.shift()),m+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([${svg2cag([f,m],t)}], ${v})\n`;break;case"M":for(F>0&&!1===d&&(c+=`${i}parts.push(${v})\n`),n.length>=2&&(f=parseFloat(n.shift()),m=parseFloat(n.shift()),d=!1,c+=`${i}${v=$+ ++F} = geometries.path2.fromPoints({}, [[${svg2cag([f,m],t)}]])\n`,h=f,l=m);n.length>=2;)f=parseFloat(n.shift()),m=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([${svg2cag([f,m],t)}], ${v})\n`;break;case"a":for(;n.length>=7;){const e=parseFloat(n.shift()),s=parseFloat(n.shift()),a=0-.017453292519943295*parseFloat(n.shift()),o="1"===n.shift(),r="1"===n.shift();f+=parseFloat(n.shift()),m+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendArc({segments: ${g}, endpoint: [${svg2cag([f,m],t)}], radius: [${svg2cag([e,s],t)}], xaxisrotation: ${a}, clockwise: ${r}, large: ${o}}, ${v})\n`}break;case"A":for(;n.length>=7;){const e=parseFloat(n.shift()),s=parseFloat(n.shift()),a=0-.017453292519943295*parseFloat(n.shift()),o="1"===n.shift(),r="1"===n.shift();f=parseFloat(n.shift()),m=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendArc({segments: ${g}, endpoint: [${svg2cag([f,m],t)}], radius: [${svg2cag([e,s],t)}], xaxisrotation: ${a}, clockwise: ${r}, large: ${o}}, ${v})\n`}break;case"c":for(;n.length>=6;){const e=f+parseFloat(n.shift()),s=m+parseFloat(n.shift());P=f+parseFloat(n.shift()),u=m+parseFloat(n.shift()),f+=parseFloat(n.shift()),m+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[${svg2cag([e,s],t)}], [${svg2cag([P,u],t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const a=reflect(P,u,f,m);P=a[0],u=a[1]}break;case"C":for(;n.length>=6;){const e=parseFloat(n.shift()),s=parseFloat(n.shift());P=parseFloat(n.shift()),u=parseFloat(n.shift()),f=parseFloat(n.shift()),m=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[${svg2cag([e,s],t)}], [${svg2cag([P,u],t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const a=reflect(P,u,f,m);P=a[0],u=a[1]}break;case"q":for(;n.length>=4;){const e=[f,m];L=f+parseFloat(n.shift()),k=m+parseFloat(n.shift()),f+=parseFloat(n.shift()),m+=parseFloat(n.shift());const s=[e[0]+2/3*(L-e[0]),e[1]+2/3*(k-e[1])],a=[s[0]+1/3*(f-e[0]),s[1]+1/3*(m-e[1])];c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[${svg2cag(s,t)}], [${svg2cag(a,t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const o=reflect(L,k,f,m);L=o[0],k=o[1]}break;case"Q":for(;n.length>=4;){const e=[f,m];L=parseFloat(n.shift()),k=parseFloat(n.shift()),f=parseFloat(n.shift()),m=parseFloat(n.shift());const s=[e[0]+2/3*(L-e[0]),e[1]+2/3*(k-e[1])],a=[s[0]+1/3*(f-e[0]),s[1]+1/3*(m-e[1])];c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[${svg2cag(s,t)}], [${svg2cag(a,t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const o=reflect(L,k,f,m);L=o[0],k=o[1]}break;case"t":for(;n.length>=2;){const e=[f,m];f+=parseFloat(n.shift()),m+=parseFloat(n.shift());const s=[e[0]+2/3*(L-e[0]),e[1]+2/3*(k-e[1])],a=[s[0]+1/3*(f-e[0]),s[1]+1/3*(m-e[1])];c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[[${svg2cag(s,t)}], [${svg2cag(a,t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const o=reflect(L,k,f,m);L=o[0],k=o[1]}break;case"T":for(;n.length>=2;){const e=[f,m];f=parseFloat(n.shift()),m=parseFloat(n.shift());const s=[e[0]+2/3*(L-e[0]),e[1]+2/3*(k-e[1])],a=[s[0]+1/3*(f-e[0]),s[1]+1/3*(m-e[1])];c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[[${svg2cag(s,t)}], [${svg2cag(a,t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const o=reflect(L,k,f,m);L=o[0],k=o[1]}break;case"s":for(;n.length>=4;){const e=P,s=u;P=f+parseFloat(n.shift()),u=m+parseFloat(n.shift()),f+=parseFloat(n.shift()),m+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[${svg2cag([e,s],t)}], [${svg2cag([P,u],t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const a=reflect(P,u,f,m);P=a[0],u=a[1]}break;case"S":for(;n.length>=4;){const e=P,s=u;P=parseFloat(n.shift()),u=parseFloat(n.shift()),f=parseFloat(n.shift()),m=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendBezier({segments: ${g}, controlPoints: [[${svg2cag([e,s],t)}], [${svg2cag([P,u],t)}], [${svg2cag([f,m],t)}]]}, ${v})\n`;const a=reflect(P,u,f,m);P=a[0],u=a[1]}break;case"h":for(;n.length>=1;)f+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([[${svg2cag([f,m],t)}]], ${v})\n`;break;case"H":for(;n.length>=1;)f=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([[${svg2cag([f,m],t)}]], ${v})\n`;break;case"l":for(;n.length>=2;)f+=parseFloat(n.shift()),m+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([[${svg2cag([f,m],t)}]], ${v})\n`;break;case"L":for(;n.length>=2;)f=parseFloat(n.shift()),m=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([[${svg2cag([f,m],t)}]], ${v})\n`;break;case"v":for(;n.length>=1;)m+=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([[${svg2cag([f,m],t)}]], ${v})\n`;break;case"V":for(;n.length>=1;)m=parseFloat(n.shift()),c+=`${i}${v} = geometries.path2.appendPoints([[${svg2cag([f,m],t)}]], ${v})\n`;break;case"z":case"Z":c+=`${i}${v} = geometries.path2.close(${v})\n`,"geom2"===p&&(c+=`${i}${v} = geometries.geom2.fromPoints(geometries.path2.toPoints(${v}))\n`),c+=`${i}parts.push(${v})\n`,f=h,m=l,d=!0;break;default:console.log("Warning: Unknow PATH command ["+a.c+"]")}}return F>0&&!1===d&&(c+=`${i}parts.push(${v})\n`),c+=`${i}${$} = parts\n`};
@@ -610,7 +610,7 @@ const{geometries:geometries,maths:maths,measurements:measurements,utils:utils}=r
610
610
  },{}],101:[function(require,module,exports){
611
611
  module.exports={
612
612
  "name": "@jscad/svg-serializer",
613
- "version": "2.3.18",
613
+ "version": "2.3.19",
614
614
  "description": "SVG Serializer for JSCAD",
615
615
  "homepage": "https://openjscad.xyz/",
616
616
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -642,7 +642,7 @@ module.exports={
642
642
  ],
643
643
  "license": "MIT",
644
644
  "dependencies": {
645
- "@jscad/modeling": "2.12.5",
645
+ "@jscad/modeling": "2.12.6",
646
646
  "onml": "1.3.0"
647
647
  },
648
648
  "devDependencies": {
@@ -667,7 +667,7 @@ module.exports={
667
667
  },{"xmlchars/xml/1.0/ed5":102,"xmlchars/xml/1.1/ed2":103,"xmlchars/xmlns/1.0/ed3":104}],106:[function(require,module,exports){
668
668
  module.exports={
669
669
  "name": "@jscad/x3d-deserializer",
670
- "version": "2.2.10",
670
+ "version": "2.2.11",
671
671
  "description": "X3D Deserializer for JSCAD",
672
672
  "repository": "https://github.com/jscad/OpenJSCAD.org/",
673
673
  "main": "src/index.js",
@@ -694,8 +694,8 @@ module.exports={
694
694
  },
695
695
  "dependencies": {
696
696
  "@jscad/array-utils": "2.1.4",
697
- "@jscad/io-utils": "2.0.30",
698
- "@jscad/modeling": "2.12.5",
697
+ "@jscad/io-utils": "2.0.31",
698
+ "@jscad/modeling": "2.12.6",
699
699
  "saxes": "5.0.1"
700
700
  },
701
701
  "devDependencies": {
@@ -1686,7 +1686,7 @@ const pointInTriangle=(n,a,e,r,i,o,t,x)=>(i-t)*(a-x)-(n-t)*(o-x)>=0&&(n-t)*(r-x)
1686
1686
  const mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),slice=require("./slice"),repairSlice=require("./slice/repair"),extrudeWalls=require("./extrudeWalls"),defaultCallback=(e,r,l)=>{let t=null;return geom2.isA(l)&&(t=slice.fromSides(geom2.toSides(l))),poly3.isA(l)&&(t=slice.fromPoints(poly3.toPoints(l))),0===e||1===e?slice.transform(mat4.fromTranslation(mat4.create(),[0,0,e]),t):null},extrudeFromSlices=(e,r)=>{const l={numberOfSlices:2,capStart:!0,capEnd:!0,close:!1,repair:!0,callback:defaultCallback},{numberOfSlices:t,capStart:o,capEnd:c,close:s,repair:i,callback:a}=Object.assign({},l,e);if(t<2)throw new Error("numberOfSlices must be 2 or more");i&&(r=repairSlice(r));const n=t-1;let u=null,m=null,f=null,g=[];for(let e=0;e<t;e++){const l=a(e/n,e,r);if(l){if(!slice.isA(l))throw new Error("the callback function must return slice objects");if(0===slice.toEdges(l).length)throw new Error("the callback function must return slices with one or more edges");f&&(g=g.concat(extrudeWalls(f,l))),0===e&&(u=l),e===t-1&&(m=l),f=l}}if(c){const e=slice.toPolygons(m);g=g.concat(e)}if(o){const e=slice.toPolygons(u).map(poly3.invert);g=g.concat(e)}return o||c||s&&!slice.equals(m,u)&&(g=g.concat(extrudeWalls(m,u))),geom3.create(g)};module.exports=extrudeFromSlices;
1687
1687
 
1688
1688
  },{"../../geometries/geom2":150,"../../geometries/geom3":166,"../../geometries/poly3":204,"../../maths/mat4":268,"./extrudeWalls":442,"./slice":451,"./slice/repair":453}],434:[function(require,module,exports){
1689
- const{TAU:TAU}=require("../../maths/constants"),slice=require("./slice"),mat4=require("../../maths/mat4"),extrudeFromSlices=require("./extrudeFromSlices"),geom2=require("../../geometries/geom2"),extrudeHelical=(e,t)=>{const r={angle:TAU,startAngle:0,pitch:10,endOffset:0,segmentsPerRotation:32},{angle:a,endOffset:s,segmentsPerRotation:o,startAngle:i}=Object.assign({},r,e);let n;n=!e.pitch&&e.height?e.height/(a/TAU):e.pitch?e.pitch:r.pitch;if(o<3)throw new Error("The number of segments per rotation needs to be at least 3.");const m=geom2.toSides(t);if(0===m.length)throw new Error("the given geometry cannot be empty");const c=m.filter(e=>e[0][0]>=0);let l=slice.fromSides(m);0===c.length&&(l=slice.reverse(l));const h=Math.round(o/TAU*Math.abs(a)),g=h>=2?h:2,u=mat4.create();let f;return extrudeFromSlices({numberOfSlices:g+1,callback:(e,t,r)=>{const o=i+a/g*t,m=s/g*t,c=(o-i)/TAU*n;return mat4.multiply(u,mat4.fromTranslation(mat4.create(),[m,0,c*Math.sign(a)]),mat4.fromXRotation(mat4.create(),-TAU/4*Math.sign(a))),f=mat4.create(),mat4.multiply(f,mat4.fromZRotation(mat4.create(),o),u),slice.transform(f,r)}},l)};module.exports=extrudeHelical;
1689
+ const{TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),extrudeFromSlices=require("./extrudeFromSlices"),slice=require("./slice"),extrudeHelical=(e,t)=>{const r={angle:TAU,startAngle:0,pitch:10,height:0,endOffset:0,segmentsPerRotation:32};let{angle:a,startAngle:s,pitch:o,height:n,endOffset:i,segmentsPerRotation:m}=Object.assign({},r,e);0!=n&&(o=n/(a/TAU));if(m<3)throw new Error("The number of segments per rotation needs to be at least 3.");const l=geom2.toSides(t);if(0===l.length)throw new Error("The given geometry cannot be empty");const c=l.filter(e=>e[0][0]>=0);let g=slice.fromSides(l);0===c.length&&(g=slice.reverse(g));const h=Math.round(m/TAU*Math.abs(a)),u=h>=2?h:2,f=mat4.create(),d=mat4.create();return extrudeFromSlices({numberOfSlices:u+1,callback:(e,t,r)=>{const n=s+a/u*t,m=i/u*t,l=(n-s)/TAU*o;return mat4.multiply(f,mat4.fromTranslation(mat4.create(),[m,0,l*Math.sign(a)]),mat4.fromXRotation(mat4.create(),-TAU/4*Math.sign(a))),mat4.multiply(d,mat4.fromZRotation(mat4.create(),n),f),slice.transform(d,r)}},g)};module.exports=extrudeHelical;
1690
1690
 
1691
1691
  },{"../../geometries/geom2":150,"../../maths/constants":219,"../../maths/mat4":268,"./extrudeFromSlices":433,"./slice":451}],435:[function(require,module,exports){
1692
1692
  const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeLinearPath2=require("./extrudeLinearPath2"),extrudeLinear=(e,...t)=>{const{height:r,twistAngle:i,twistSteps:n,repair:a}=Object.assign({},{height:1,twistAngle:0,twistSteps:1,repair:!0},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");e={offset:[0,0,r],twistAngle:i,twistSteps:n,repair:a};const s=t.map(t=>path2.isA(t)?extrudeLinearPath2(e,t):geom2.isA(t)?extrudeLinearGeom2(e,t):t);return 1===s.length?s[0]:s};module.exports=extrudeLinear;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jscad/core",
3
- "version": "2.6.12",
3
+ "version": "2.6.13",
4
4
  "description": "Core functionality for JSCAD Applications",
5
5
  "homepage": "https://openjscad.xyz/",
6
6
  "repository": "https://github.com/jscad/OpenJSCAD.org",
@@ -36,9 +36,9 @@
36
36
  "license": "MIT",
37
37
  "dependencies": {
38
38
  "@jscad/array-utils": "2.1.4",
39
- "@jscad/io": "2.4.11",
40
- "@jscad/io-utils": "2.0.30",
41
- "@jscad/modeling": "2.12.5",
39
+ "@jscad/io": "2.4.12",
40
+ "@jscad/io-utils": "2.0.31",
41
+ "@jscad/modeling": "2.12.6",
42
42
  "json5": "2.2.3",
43
43
  "strip-bom": "4.0.0"
44
44
  },
@@ -53,5 +53,5 @@
53
53
  "url": "https://opencollective.com/openjscad",
54
54
  "logo": "https://opencollective.com/openjscad/logo.txt"
55
55
  },
56
- "gitHead": "d8010c4f1d70685404a510d604f8b6d5c362f93a"
56
+ "gitHead": "11a9a2d9235d804360116f776076c9f3237a3eb0"
57
57
  }