diff --git a/.github/workflows/node.yml b/.github/workflows/node.yml
index 465729713..64c0deea5 100644
--- a/.github/workflows/node.yml
+++ b/.github/workflows/node.yml
@@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- node: [ '14', '16' ]
+ node: [ '16', '18' ]
name: Node ${{ matrix.node }} test
steps:
- uses: actions/checkout@v2
diff --git a/package.json b/package.json
index 7bec30774..798b8cfa3 100644
--- a/package.json
+++ b/package.json
@@ -59,7 +59,8 @@
"**/old/",
"**/ui/csg-viewer",
"**/io/scad-deserializer",
- "**/io/gcode-deserializer"
+ "**/io/gcode-deserializer",
+ "**/desktop"
],
"env": {
"browser": true,
diff --git a/packages/cli/cli.conversions.test.js b/packages/cli/cli.conversions.test.js
index 271882d74..81041b1bb 100644
--- a/packages/cli/cli.conversions.test.js
+++ b/packages/cli/cli.conversions.test.js
@@ -82,47 +82,46 @@ const main = () => {
module.exports = { main }
`
- const fileName = `./test${id}-import.jscad`;
- const filePath = path.resolve(__dirname, fileName);
- fs.writeFileSync(filePath, jscadScript);
- return filePath;
+ const fileName = `./test${id}-import.jscad`
+ const filePath = path.resolve(__dirname, fileName)
+ fs.writeFileSync(filePath, jscadScript)
+ return filePath
}
const testBackImport = (t, testID, extension) => {
- const cliPath = t.context.cliPath;
+ const cliPath = t.context.cliPath
- const file4Path = createImportJscad(testID, extension);
- t.context.file4Path = file4Path;
- t.true(fs.existsSync(file4Path));
+ const file4Path = createImportJscad(testID, extension)
+ t.context.file4Path = file4Path
+ t.true(fs.existsSync(file4Path))
- const file5Name = `./test${testID}-import.stl`;
- const file5Path = path.resolve(__dirname, file5Name);
- t.context.file5Path = file5Path;
- t.false(fs.existsSync(file5Path));
+ const file5Name = `./test${testID}-import.stl`
+ const file5Path = path.resolve(__dirname, file5Name)
+ t.context.file5Path = file5Path
+ t.false(fs.existsSync(file5Path))
- cmd = `node ${cliPath} ${file4Path}`
+ const cmd = `node ${cliPath} ${file4Path}`
execSync(cmd, { stdio: [0, 1, 2] })
- t.true(fs.existsSync(file5Path));
+ t.true(fs.existsSync(file5Path))
}
const runOnFixture = (t, fixtureName) => {
const inputFile = path.resolve(
__dirname,
- path.join('test_fixtures', fixtureName, 'index.js'));
+ path.join('test_fixtures', fixtureName, 'index.js'))
- const outputFile = inputFile.replace('.js', '.stl');
- t.context.file1Path = outputFile;
+ const outputFile = inputFile.replace('.js', '.stl')
+ t.context.file1Path = outputFile
- t.false(fs.existsSync(outputFile));
+ t.false(fs.existsSync(outputFile))
const cmd = `node ${t.context.cliPath} ${inputFile}`
- execSync(cmd, { stdio: [0, 1, 2] });
+ execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(outputFile))
- return outputFile;
+ return outputFile
}
-
test('cli (conversions STL)', (t) => {
const testID = 11
@@ -142,20 +141,20 @@ test('cli (conversions STL)', (t) => {
let cmd = `node ${cliPath} ${file1Path}`
execSync(cmd, { stdio: [0, 1, 2] })
- t.true(fs.existsSync(file2Path));
+ t.true(fs.existsSync(file2Path))
// convert from STL to JSCAD script
const file3Name = `./test${testID}.js`
const file3Path = path.resolve(__dirname, file3Name)
- t.false(fs.existsSync(file3Path));
+ t.false(fs.existsSync(file3Path))
t.context.file3Path = file3Path
cmd = `node ${cliPath} ${file2Path} -o ${file3Path} -v -add-metadata false`
execSync(cmd, { stdio: [0, 1, 2] })
- t.true(fs.existsSync(file3Path));
+ t.true(fs.existsSync(file3Path))
- testBackImport(t, testID, 'stl');
+ testBackImport(t, testID, 'stl')
})
test('cli (conversions DXF)', (t) => {
@@ -190,7 +189,7 @@ test('cli (conversions DXF)', (t) => {
execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(file3Path))
- testBackImport(t, testID, 'dxf');
+ testBackImport(t, testID, 'dxf')
})
test('cli (conversions AMF)', (t) => {
@@ -225,7 +224,7 @@ test('cli (conversions AMF)', (t) => {
execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(file3Path))
- testBackImport(t, testID, 'amf');
+ testBackImport(t, testID, 'amf')
})
test('cli (conversions JSON)', (t) => {
@@ -260,7 +259,7 @@ test('cli (conversions JSON)', (t) => {
execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(file3Path))
- testBackImport(t, testID, 'json');
+ testBackImport(t, testID, 'json')
})
test('cli (conversions SVG)', (t) => {
@@ -328,11 +327,11 @@ test('cli (conversions X3D)', (t) => {
execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(file3Path))
- testBackImport(t, testID, 'x3d');
+ testBackImport(t, testID, 'x3d')
})
test('cli (import STL)', (t) => {
- const testID = 17
+ // const testID = 17
runOnFixture(t, 'stl_import')
})
diff --git a/packages/cli/cli.js b/packages/cli/cli.js
index f6c305240..e4bf632b0 100644
--- a/packages/cli/cli.js
+++ b/packages/cli/cli.js
@@ -76,13 +76,13 @@ generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputForm
if (err) {
console.error(err)
} else {
- logFileOutput(zipFilename)
+ logFileOutput(zipFilename)
}
})
})
} else {
for (let i = 0; i < outputData.length; i++) {
- const filename = outputFile.replace(/\.(\w+)$/, `-part-${i + 1}-of-${outputData.length}.$1`)
+ const filename = outputFile.replace(/\.(\w+)$/, `-part-${i + 1}-of-${outputData.length}.$1`)
logFileOutput(filename)
writeOutput(filename, outputData[i])
}
@@ -97,7 +97,7 @@ generateOutputData(src, params, { outputFile, outputFormat, inputFile, inputForm
if (err) {
console.error(err)
} else {
- logFileOutput(zipFilename)
+ logFileOutput(zipFilename)
}
})
})
diff --git a/packages/cli/cli.parameters.test.js b/packages/cli/cli.parameters.test.js
index 0b6108992..819cdec98 100644
--- a/packages/cli/cli.parameters.test.js
+++ b/packages/cli/cli.parameters.test.js
@@ -58,7 +58,7 @@ const main = (params) => {
let ageom2 = primitives.ellipse()
let ageom3 = primitives.ellipsoid()
- ${multipart ? `return [ageom3, ageom3, ageom3]` : `return [apath2, ageom2, ageom3]`}
+ ${multipart ? 'return [ageom3, ageom3, ageom3]' : 'return [apath2, ageom2, ageom3]'}
}
module.exports = { main, getParameterDefinitions }
@@ -215,7 +215,6 @@ test('cli (single input file, invalid jscad)', (t) => {
})
})
-
test('cli (single input file, multiple output files)', (t) => {
const testID = 7
@@ -239,7 +238,7 @@ test('cli (single input file, multiple output files)', (t) => {
const cliPath = t.context.cliPath
const cmd = `node ${cliPath} ${inputPath} -gp`
- execSync(cmd, { stdio: [0,1,2] })
+ execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(outputPath1))
t.true(fs.existsSync(outputPath2))
t.true(fs.existsSync(outputPath3))
@@ -257,13 +256,13 @@ test('cli (single multipart input file, zipped output file)', async (t) => {
const outputPath = path.resolve(__dirname, outputName)
t.false(fs.existsSync(outputPath))
-
+
t.context.outputPath = outputPath
const cliPath = t.context.cliPath
const cmd = `node ${cliPath} ${inputPath} -gp -z`
- execSync(cmd, { stdio: [0,1,2] })
+ execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(outputPath))
// check contents of zip file
@@ -281,18 +280,18 @@ test('cli (single input file, zipped output file)', async (t) => {
t.true(fs.existsSync(inputPath))
t.context.inputPath = inputPath
-
+
const outputName = `./test${testID}.zip`
const outputPath = path.resolve(__dirname, outputName)
t.false(fs.existsSync(outputPath))
-
+
t.context.outputPath = outputPath
const cliPath = t.context.cliPath
const cmd = `node ${cliPath} ${inputPath} -z`
- execSync(cmd, { stdio: [0,1,2] })
+ execSync(cmd, { stdio: [0, 1, 2] })
t.true(fs.existsSync(outputPath))
// check contents of zip file
diff --git a/packages/cli/src/generateOutputData.js b/packages/cli/src/generateOutputData.js
index 0990bd379..180fc12fb 100644
--- a/packages/cli/src/generateOutputData.js
+++ b/packages/cli/src/generateOutputData.js
@@ -64,7 +64,7 @@ const generateOutputData = (source, params, options) => {
.then((solids) => {
const serializerOptions = Object.assign({ format: outputFormat }, params)
if (generateParts) {
- let blobs = []
+ const blobs = []
for (let i = 0; i < solids.length; i++) {
blobs.push(solidsAsBlob(solids[i], serializerOptions))
}
diff --git a/packages/cli/test_fixtures/stl_import/index.js b/packages/cli/test_fixtures/stl_import/index.js
index 457a15ddc..0eba1aa51 100644
--- a/packages/cli/test_fixtures/stl_import/index.js
+++ b/packages/cli/test_fixtures/stl_import/index.js
@@ -1,6 +1,4 @@
-function main() {
- return require('./binary_stl.stl');
-}
+const main = () => require('./binary_stl.stl')
-module.exports = { main }
\ No newline at end of file
+module.exports = { main }
diff --git a/packages/core/src/io/registerExtensions.js b/packages/core/src/io/registerExtensions.js
index 301fa3c8e..1adc61984 100644
--- a/packages/core/src/io/registerExtensions.js
+++ b/packages/core/src/io/registerExtensions.js
@@ -16,15 +16,15 @@ const registerDeserializer = (extension, fs, _require) => {
const deserializer = deserializers[extension]
const fileExtension = '.' + extension
_require.extensions[fileExtension] = (module, filename) => {
- const fileReadResult = fs.readFileSync(filename);
+ const fileReadResult = fs.readFileSync(filename)
- // https://nodejs.org/api/buffer.html#bufbuffer: Buffer.buffer is not
- // guaranteed to correspond exactly to the original Buffer.
+ // https://nodejs.org/api/buffer.html#bufbuffer: Buffer.buffer is not
+ // guaranteed to correspond exactly to the original Buffer.
const fileContent = fileReadResult.buffer
? fileReadResult.buffer.slice(
- fileReadResult.byteOffset,
- fileReadResult.byteOffset + fileReadResult.length)
- : fileReadResult;
+ fileReadResult.byteOffset,
+ fileReadResult.byteOffset + fileReadResult.length)
+ : fileReadResult
const parsed = deserializer({ filename, output: 'geometry' }, fileContent)
module.exports = parsed
diff --git a/packages/io/3mf-serializer/src/index.js b/packages/io/3mf-serializer/src/index.js
index 59aa3f006..426460b91 100644
--- a/packages/io/3mf-serializer/src/index.js
+++ b/packages/io/3mf-serializer/src/index.js
@@ -30,7 +30,6 @@ Notes:
* const { serializer, mimeType } = require('@jscad/3mf-serializer')
*/
-
const zipSync = require('fflate').zipSync
const strToU8 = require('fflate').strToU8
@@ -39,7 +38,6 @@ const stringify = require('onml/lib/stringify')
const { colors, geometries, modifiers } = require('@jscad/modeling')
const { flatten, toArray } = require('@jscad/array-utils')
-
const mimeType = 'model/3mf'
const fileExtension = '3mf'
@@ -61,7 +59,7 @@ const serialize = (options, ...objects) => {
const defaults = {
unit: 'millimeter', // micron, millimeter, centimeter, inch, foot, meter
metadata: true,
- defaultcolor: [255/255, 160/255, 0, 1], // JSCAD Orange
+ defaultcolor: [255 / 255, 160 / 255, 0, 1], // JSCAD Orange
compress: true
}
options = Object.assign({}, defaults, options)
@@ -69,7 +67,7 @@ const serialize = (options, ...objects) => {
objects = flatten(objects)
// convert only 3D geometries
- let objects3d = objects.filter((object) => geometries.geom3.isA(object))
+ const objects3d = objects.filter((object) => geometries.geom3.isA(object))
if (objects3d.length === 0) throw new Error('only 3D geometries can be serialized to 3MF')
if (objects.length !== objects3d.length) console.warn('some objects could not be serialized to 3MF')
diff --git a/packages/io/3mf-serializer/tests/serialize.test.js b/packages/io/3mf-serializer/tests/serialize.test.js
index fa3edc60f..87abe3539 100644
--- a/packages/io/3mf-serializer/tests/serialize.test.js
+++ b/packages/io/3mf-serializer/tests/serialize.test.js
@@ -26,18 +26,18 @@ test('serialize (single, color)', (t) => {
test('serialize (multiple, color)', (t) => {
let cube1 = primitives.cuboid({ size: [4, 5, 6], center: [5, 5, 5] })
cube1 = colors.colorize([0.0, 0.0, 1.0, 0.8], cube1)
- cube1.name = "CUBE A"
+ cube1.name = 'CUBE A'
const cube2 = primitives.cube()
- cube2.name = "CUBE B"
+ cube2.name = 'CUBE B'
const buffer = serializer.serialize({ metadata: false, compress: false, defaultcolor: [1, 0, 0, 1] }, cube1, cube2)
t.deepEqual(buffer, expected4)
})
test('serialize (multiple, compress)', (t) => {
const cube1 = colors.colorize([1.0, 0.0, 0.5, 0.8], primitives.cube())
- cube1.name = "CUBE A"
+ cube1.name = 'CUBE A'
const cube2 = primitives.cuboid({ size: [4, 5, 6], center: [5, 5, 5] })
- cube2.name = "CUBE B"
+ cube2.name = 'CUBE B'
const results = serializer.serialize({ compress: true }, cube1, cube2)
t.is(results.length, 1)
diff --git a/packages/io/amf-deserializer/src/index.js b/packages/io/amf-deserializer/src/index.js
index 3db063927..0c7b03a4c 100644
--- a/packages/io/amf-deserializer/src/index.js
+++ b/packages/io/amf-deserializer/src/index.js
@@ -50,7 +50,7 @@ const deserialize = (options, input) => {
}
options = Object.assign({}, defaults, options)
- input = ensureString(input);
+ input = ensureString(input)
return options.output === 'script' ? translate(options, input) : instantiate(options, input)
}
diff --git a/packages/io/dxf-deserializer/index.js b/packages/io/dxf-deserializer/index.js
index 28be06f5d..5616119c3 100644
--- a/packages/io/dxf-deserializer/index.js
+++ b/packages/io/dxf-deserializer/index.js
@@ -604,7 +604,7 @@ const deserialize = (options, src) => {
}
options = Object.assign({}, defaults, options)
- src = ensureString(src);
+ src = ensureString(src)
return options.output === 'script' ? translate(src, options) : instantiate(src, options)
}
diff --git a/packages/io/io-utils/ensureString.js b/packages/io/io-utils/ensureString.js
index f15eae94e..1d42dd1ae 100644
--- a/packages/io/io-utils/ensureString.js
+++ b/packages/io/io-utils/ensureString.js
@@ -1,9 +1,9 @@
const ensureString = (stringOrArrayBuffer, defaultBinaryEncoding = 'utf-8') => {
if (typeof (stringOrArrayBuffer) === 'string') {
- return stringOrArrayBuffer;
+ return stringOrArrayBuffer
}
- return new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer));
+ return new TextDecoder(defaultBinaryEncoding).decode(new Uint8Array(stringOrArrayBuffer))
}
-module.exports = ensureString;
\ No newline at end of file
+module.exports = ensureString
diff --git a/packages/io/json-deserializer/index.js b/packages/io/json-deserializer/index.js
index dd6f20ff8..ac19c6863 100644
--- a/packages/io/json-deserializer/index.js
+++ b/packages/io/json-deserializer/index.js
@@ -46,7 +46,7 @@ const deserialize = (options, input) => {
options = Object.assign({}, defaults, options)
// convert the JSON notation into anonymous object(s)
- input = ensureString(input);
+ input = ensureString(input)
let objects = JSON.parse(input)
// cleanup the objects
diff --git a/packages/io/obj-deserializer/index.js b/packages/io/obj-deserializer/index.js
index 11ab47cee..96c626234 100644
--- a/packages/io/obj-deserializer/index.js
+++ b/packages/io/obj-deserializer/index.js
@@ -33,7 +33,7 @@ const deserialize = (options, input) => {
options = Object.assign({}, defaults, options)
const { output } = options
- input = ensureString(input);
+ input = ensureString(input)
options && options.statusCallback && options.statusCallback({ progress: 0 })
diff --git a/packages/io/svg-deserializer/src/index.js b/packages/io/svg-deserializer/src/index.js
index 879d6f6f8..6a2fc9689 100644
--- a/packages/io/svg-deserializer/src/index.js
+++ b/packages/io/svg-deserializer/src/index.js
@@ -23,7 +23,6 @@ const { svgSvg, svgRect, svgCircle, svgGroup, svgLine, svgPath, svgEllipse, svgP
const shapesMapGeometry = require('./shapesMapGeometry')
const shapesMapJscad = require('./shapesMapJscad')
-
/**
* Deserializer of SVG source data to JSCAD geometries.
* @see {@link https://github.com/jscad/OpenJSCAD.org/blob/master/packages/io/svg-deserializer/README.md|README} for supported conversion of SVG elements.
@@ -60,7 +59,7 @@ const deserialize = (options, input) => {
version
}
options = Object.assign({}, defaults, options)
- input = ensureString(input);
+ input = ensureString(input)
return options.output === 'script' ? translate(input, options) : instantiate(input, options)
}
diff --git a/packages/io/svg-deserializer/src/shapesMapGeometry.js b/packages/io/svg-deserializer/src/shapesMapGeometry.js
index 2331ffdf9..af1acd000 100644
--- a/packages/io/svg-deserializer/src/shapesMapGeometry.js
+++ b/packages/io/svg-deserializer/src/shapesMapGeometry.js
@@ -330,8 +330,8 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
qy = cy + parseFloat(pts[i++])
cx = cx + parseFloat(pts[i++])
cy = cy + parseFloat(pts[i++])
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
ensurePath()
paths[pathName] = geometries.path2.appendBezier({
segments,
@@ -353,8 +353,8 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
qy = parseFloat(pts[i++])
cx = parseFloat(pts[i++])
cy = parseFloat(pts[i++])
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
ensurePath()
paths[pathName] = geometries.path2.appendBezier({
segments,
@@ -374,8 +374,8 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
const p0 = [cx, cy] // previous point
cx = cx + parseFloat(pts[i++])
cy = cy + parseFloat(pts[i++])
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
ensurePath()
paths[pathName] = geometries.path2.appendBezier({
segments,
@@ -395,8 +395,8 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
const p0 = [cx, cy] // previous point
cx = parseFloat(pts[i++])
cy = parseFloat(pts[i++])
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
ensurePath()
paths[pathName] = geometries.path2.appendBezier({
segments,
@@ -420,13 +420,13 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
cx = cx + parseFloat(pts[i++])
cy = cy + parseFloat(pts[i++])
ensurePath()
- paths[pathName] = geometries.path2.appendBezier({
- segments, controlPoints: [
- svg2cag([x1, y1], svgUnitsPmm),
- svg2cag([bx, by], svgUnitsPmm),
- svg2cag([cx, cy], svgUnitsPmm)
- ]
- }, paths[pathName])
+ paths[pathName] = geometries.path2.appendBezier(
+ {
+ segments,
+ controlPoints: [svg2cag([x1, y1], svgUnitsPmm), svg2cag([bx, by], svgUnitsPmm), svg2cag([cx, cy], svgUnitsPmm)]
+ },
+ paths[pathName]
+ )
const rf = reflect(bx, by, cx, cy)
bx = rf[0]
by = rf[1]
@@ -509,7 +509,7 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
if (pc !== true && paths[pathName] && paths[pathName].isClosed) {
let coNext = obj.commands[j + 1]
// allow self close in the last command #1135 (coNext is null or undefined)
- // if do have a next command use pathSelfClosed to decide how to react to closing in the middle of a path
+ // if do have a next command use pathSelfClosed to decide how to react to closing in the middle of a path
if (coNext && !isCloseCmd(coNext.c)) {
if (pathSelfClosed === 'trim') {
while (coNext && !isCloseCmd(coNext.c)) {
@@ -518,7 +518,7 @@ const expandPath = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, svgGroups
}
} else if (pathSelfClosed === 'split') {
newPath()
- }else{
+ } else {
throw new Error(`Malformed svg path at ${obj.position[0]}:${co.pos}. Path closed itself with command #${j} ${co.c}${pts.join(' ')}`)
}
}
diff --git a/packages/io/svg-deserializer/src/shapesMapJscad.js b/packages/io/svg-deserializer/src/shapesMapJscad.js
index 05571dc93..6b2ab0a8a 100644
--- a/packages/io/svg-deserializer/src/shapesMapJscad.js
+++ b/packages/io/svg-deserializer/src/shapesMapJscad.js
@@ -260,8 +260,8 @@ const path = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, params, svgGrou
qy = cy + parseFloat(pts.shift())
cx = cx + parseFloat(pts.shift()) // end point
cy = cy + parseFloat(pts.shift())
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
tmpCode += `${indent}${pathName} = geometries.path2.appendBezier({segments: ${segments}, controlPoints: [[${svg2cag(q1, svgUnitsPmm)}], [${svg2cag(q2, svgUnitsPmm)}], [${svg2cag([cx, cy], svgUnitsPmm)}]]}, ${pathName})\n`
const rf = reflect(qx, qy, cx, cy)
qx = rf[0]
@@ -275,8 +275,8 @@ const path = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, params, svgGrou
qy = parseFloat(pts.shift())
cx = parseFloat(pts.shift()) // end point
cy = parseFloat(pts.shift())
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
tmpCode += `${indent}${pathName} = geometries.path2.appendBezier({segments: ${segments}, controlPoints: [[${svg2cag(q1, svgUnitsPmm)}], [${svg2cag(q2, svgUnitsPmm)}], [${svg2cag([cx, cy], svgUnitsPmm)}]]}, ${pathName})\n`
const rf = reflect(qx, qy, cx, cy)
qx = rf[0]
@@ -288,8 +288,8 @@ const path = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, params, svgGrou
const p0 = [cx, cy] // previous point
cx = cx + parseFloat(pts.shift()) // end point
cy = cy + parseFloat(pts.shift())
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
tmpCode += `${indent}${pathName} = geometries.path2.appendBezier({segments: ${segments}, controlPoints: [[[${svg2cag(q1, svgUnitsPmm)}], [${svg2cag(q2, svgUnitsPmm)}], [${svg2cag([cx, cy], svgUnitsPmm)}]]}, ${pathName})\n`
const rf = reflect(qx, qy, cx, cy)
qx = rf[0]
@@ -301,8 +301,8 @@ const path = (obj, svgUnitsPmm, svgUnitsX, svgUnitsY, svgUnitsV, params, svgGrou
const p0 = [cx, cy] // previous point
cx = parseFloat(pts.shift()) // end point
cy = parseFloat(pts.shift())
- const q1 = [p0[0] + (2/3) * (qx - p0[0]), p0[1] + (2/3) * (qy - p0[1])]
- const q2 = [q1[0] + (1/3) * (cx - p0[0]), q1[1] + (1/3) * (cy - p0[1])]
+ const q1 = [p0[0] + (2 / 3) * (qx - p0[0]), p0[1] + (2 / 3) * (qy - p0[1])]
+ const q2 = [q1[0] + (1 / 3) * (cx - p0[0]), q1[1] + (1 / 3) * (cy - p0[1])]
tmpCode += `${indent}${pathName} = geometries.path2.appendBezier({segments: ${segments}, controlPoints: [[[${svg2cag(q1, svgUnitsPmm)}], [${svg2cag(q2, svgUnitsPmm)}], [${svg2cag([cx, cy], svgUnitsPmm)}]]}, ${pathName})\n`
const rf = reflect(qx, qy, cx, cy)
qx = rf[0]
diff --git a/packages/io/svg-deserializer/tests/issue.1135.test.js b/packages/io/svg-deserializer/tests/issue.1135.test.js
index b04f2bf38..c77615110 100644
--- a/packages/io/svg-deserializer/tests/issue.1135.test.js
+++ b/packages/io/svg-deserializer/tests/issue.1135.test.js
@@ -3,8 +3,8 @@ const test = require('ava')
const deserializer = require('../src/index.js')
test('deserialize issue 885 do not fail on close at the end', (t) => {
- const svg = ``
+ const svg = ''
- shapes = deserializer.deserialize({ output: 'geometry', pathSelfClosed: 'error' }, svg)
+ const shapes = deserializer.deserialize({ output: 'geometry', pathSelfClosed: 'error' }, svg)
t.is(shapes.length, 1)
-})
\ No newline at end of file
+})
diff --git a/packages/io/x3d-deserializer/src/index.js b/packages/io/x3d-deserializer/src/index.js
index 4413cf749..02e5399f2 100644
--- a/packages/io/x3d-deserializer/src/index.js
+++ b/packages/io/x3d-deserializer/src/index.js
@@ -27,7 +27,6 @@ const version = require('../package.json').version
const translate = require('./translate')
const instantiate = require('./instantiate')
-
/**
* Deserialize the given X3D source (XML Encoding) into either a script or an array of geometry
* @see {@link https://www.web3d.org/documents/specifications/19776-1/V3.3/index.html|X3D File Format}
@@ -50,7 +49,7 @@ const deserialize = (options, input) => {
addMetaData: true
}
options = Object.assign({}, defaults, options)
- input = ensureString(input);
+ input = ensureString(input)
return options.output === 'script' ? translate(options, input) : instantiate(options, input)
}
diff --git a/packages/modeling/src/geometries/geom3/fromPointsConvex.test.js b/packages/modeling/src/geometries/geom3/fromPointsConvex.test.js
index 0b8709502..d29e7a49b 100644
--- a/packages/modeling/src/geometries/geom3/fromPointsConvex.test.js
+++ b/packages/modeling/src/geometries/geom3/fromPointsConvex.test.js
@@ -3,24 +3,29 @@ const test = require('ava')
const { fromPointsConvex, validate } = require('./index')
test('fromPointsConvex (uniquePoints)', (t) => {
- let out = []
- for(x=-9;x<=9;++x)
- for(y=-9;y<=9;++y)
- for(z=-9;z<=9;++z)
- if (x*x+y*y+z*z <= 96)
- out.push([x,y,z])
+ const out = []
+ for (let x = -9; x <= 9; ++x) {
+ for (let y = -9; y <= 9; ++y) {
+ for (let z = -9; z <= 9; ++z) {
+ if (x * x + y * y + z * z <= 96) out.push([x, y, z])
+ }
+ }
+ }
- let obs = fromPointsConvex(out)
+ const obs = fromPointsConvex(out)
validate(obs)
+
t.is(obs.polygons.length, 170)
- t.true(obs.polygons.every((f) => ([3,4,8,9].indexOf(f.vertices.length) !== -1)))
- let c = [0,0,0,0,0,0,0,0,0,0]
+ t.true(obs.polygons.every((f) => ([3, 4, 8, 9].indexOf(f.vertices.length) !== -1)))
+
+ const c = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
obs.polygons.forEach((f) => c[f.vertices.length]++)
- t.is(c[3], 120);
- t.is(c[4], 24);
- t.is(c[8], 18);
- t.is(c[9], 8);
- let edges2 = 336*2
+ t.is(c[3], 120)
+ t.is(c[4], 24)
+ t.is(c[8], 18)
+ t.is(c[9], 8)
+
+ let edges2 = 336 * 2
obs.polygons.forEach((f) => edges2 -= f.vertices.length)
- t.is(edges2, 0);
+ t.is(edges2, 0)
})
diff --git a/packages/modeling/src/maths/OrthoNormalBasis.js b/packages/modeling/src/maths/OrthoNormalBasis.js
index f69d1dc45..a794a0b2e 100644
--- a/packages/modeling/src/maths/OrthoNormalBasis.js
+++ b/packages/modeling/src/maths/OrthoNormalBasis.js
@@ -21,128 +21,6 @@ const OrthoNormalBasis = function (plane, rightvector) {
this.planeorigin = vec3.scale(vec3.create(), plane, plane[3])
}
-// Get an orthonormal basis for the standard XYZ planes.
-// Parameters: the names of two 3D axes. The 2d x axis will map to the first given 3D axis, the 2d y
-// axis will map to the second.
-// Prepend the axis with a "-" to invert the direction of this axis.
-// For example: OrthoNormalBasis.GetCartesian("-Y","Z")
-// will return an orthonormal basis where the 2d X axis maps to the 3D inverted Y axis, and
-// the 2d Y axis maps to the 3D Z axis.
-OrthoNormalBasis.GetCartesian = function (xaxisid, yaxisid) {
- const axisid = xaxisid + '/' + yaxisid
- let planenormal, rightvector
- if (axisid === 'X/Y') {
- planenormal = [0, 0, 1]
- rightvector = [1, 0, 0]
- } else if (axisid === 'Y/-X') {
- planenormal = [0, 0, 1]
- rightvector = [0, 1, 0]
- } else if (axisid === '-X/-Y') {
- planenormal = [0, 0, 1]
- rightvector = [-1, 0, 0]
- } else if (axisid === '-Y/X') {
- planenormal = [0, 0, 1]
- rightvector = [0, -1, 0]
- } else if (axisid === '-X/Y') {
- planenormal = [0, 0, -1]
- rightvector = [-1, 0, 0]
- } else if (axisid === '-Y/-X') {
- planenormal = [0, 0, -1]
- rightvector = [0, -1, 0]
- } else if (axisid === 'X/-Y') {
- planenormal = [0, 0, -1]
- rightvector = [1, 0, 0]
- } else if (axisid === 'Y/X') {
- planenormal = [0, 0, -1]
- rightvector = [0, 1, 0]
- } else if (axisid === 'X/Z') {
- planenormal = [0, -1, 0]
- rightvector = [1, 0, 0]
- } else if (axisid === 'Z/-X') {
- planenormal = [0, -1, 0]
- rightvector = [0, 0, 1]
- } else if (axisid === '-X/-Z') {
- planenormal = [0, -1, 0]
- rightvector = [-1, 0, 0]
- } else if (axisid === '-Z/X') {
- planenormal = [0, -1, 0]
- rightvector = [0, 0, -1]
- } else if (axisid === '-X/Z') {
- planenormal = [0, 1, 0]
- rightvector = [-1, 0, 0]
- } else if (axisid === '-Z/-X') {
- planenormal = [0, 1, 0]
- rightvector = [0, 0, -1]
- } else if (axisid === 'X/-Z') {
- planenormal = [0, 1, 0]
- rightvector = [1, 0, 0]
- } else if (axisid === 'Z/X') {
- planenormal = [0, 1, 0]
- rightvector = [0, 0, 1]
- } else if (axisid === 'Y/Z') {
- planenormal = [1, 0, 0]
- rightvector = [0, 1, 0]
- } else if (axisid === 'Z/-Y') {
- planenormal = [1, 0, 0]
- rightvector = [0, 0, 1]
- } else if (axisid === '-Y/-Z') {
- planenormal = [1, 0, 0]
- rightvector = [0, -1, 0]
- } else if (axisid === '-Z/Y') {
- planenormal = [1, 0, 0]
- rightvector = [0, 0, -1]
- } else if (axisid === '-Y/Z') {
- planenormal = [-1, 0, 0]
- rightvector = [0, -1, 0]
- } else if (axisid === '-Z/-Y') {
- planenormal = [-1, 0, 0]
- rightvector = [0, 0, -1]
- } else if (axisid === 'Y/-Z') {
- planenormal = [-1, 0, 0]
- rightvector = [0, 1, 0]
- } else if (axisid === 'Z/Y') {
- planenormal = [-1, 0, 0]
- rightvector = [0, 0, 1]
- } else {
- throw new Error('OrthoNormalBasis.GetCartesian: invalid combination of axis identifiers. Should pass two string arguments from [X,Y,Z,-X,-Y,-Z], being two different axes.')
- }
- return new OrthoNormalBasis(new Plane(new Vector3D(planenormal), 0), new Vector3D(rightvector))
-}
-
-/*
-// test code for OrthoNormalBasis.GetCartesian()
-OrthoNormalBasis.GetCartesian_Test=function() {
- let axisnames=["X","Y","Z","-X","-Y","-Z"];
- let axisvectors=[[1,0,0], [0,1,0], [0,0,1], [-1,0,0], [0,-1,0], [0,0,-1]];
- for(let axis1=0; axis1 < 3; axis1++) {
- for(let axis1inverted=0; axis1inverted < 2; axis1inverted++) {
- let axis1name=axisnames[axis1+3*axis1inverted];
- let axis1vector=axisvectors[axis1+3*axis1inverted];
- for(let axis2=0; axis2 < 3; axis2++) {
- if(axis2 != axis1) {
- for(let axis2inverted=0; axis2inverted < 2; axis2inverted++) {
- let axis2name=axisnames[axis2+3*axis2inverted];
- let axis2vector=axisvectors[axis2+3*axis2inverted];
- let orthobasis=OrthoNormalBasis.GetCartesian(axis1name, axis2name);
- let test1=orthobasis.to3D(new Vector2D([1,0]));
- let test2=orthobasis.to3D(new Vector2D([0,1]));
- let expected1=new Vector3D(axis1vector);
- let expected2=new Vector3D(axis2vector);
- let d1=test1.distanceTo(expected1);
- let d2=test2.distanceTo(expected2);
- if( (d1 > 0.01) || (d2 > 0.01) ) {
- throw new Error("Wrong!");
- }}}}}}
- throw new Error("OK");
-};
-*/
-
-// The z=0 plane, with the 3D x and y vectors mapped to the 2D x and y vector
-OrthoNormalBasis.Z0Plane = function () {
- const plane = new Plane(new Vector3D([0, 0, 1]), 0)
- return new OrthoNormalBasis(plane, new Vector3D([1, 0, 0]))
-}
-
OrthoNormalBasis.prototype = {
getProjectionMatrix: function () {
@@ -175,32 +53,6 @@ OrthoNormalBasis.prototype = {
const v3 = vec3.add(v1, v1, this.planeorigin)
const v4 = vec3.add(v2, v2, v3)
return v4
- },
-
- line3Dto2D: function (line3d) {
- const a = line3d.point
- const b = line3d.direction.plus(a)
- const a2d = this.to2D(a)
- const b2d = this.to2D(b)
- return Line2D.fromPoints(a2d, b2d)
- },
-
- line2Dto3D: function (line2d) {
- const a = line2d.origin()
- const b = line2d.direction().plus(a)
- const a3d = this.to3D(a)
- const b3d = this.to3D(b)
- return Line3D.fromPoints(a3d, b3d)
- },
-
- transform: function (matrix4x4) {
- // todo: this may not work properly in case of mirroring
- const newplane = this.plane.transform(matrix4x4)
- const rightpointTransformed = this.u.transform(matrix4x4)
- const originTransformed = new Vector3D(0, 0, 0).transform(matrix4x4)
- const newrighthandvector = rightpointTransformed.minus(originTransformed)
- const newbasis = new OrthoNormalBasis(newplane, newrighthandvector)
- return newbasis
}
}
diff --git a/packages/modeling/src/primitives/polygon.js b/packages/modeling/src/primitives/polygon.js
index fb752ae8e..78b2179d7 100644
--- a/packages/modeling/src/primitives/polygon.js
+++ b/packages/modeling/src/primitives/polygon.js
@@ -71,8 +71,8 @@ const polygon = (options) => {
})
// convert the list of sides into a geometry
- let geometry = geom2.create(sides)
- if (orientation == "clockwise") {
+ let geometry = geom2.create(sides)
+ if (orientation === 'clockwise') {
geometry = geom2.reverse(geometry)
}
return geometry
diff --git a/packages/modeling/src/primitives/polygon.test.js b/packages/modeling/src/primitives/polygon.test.js
index a1c45fa58..8fdc08fbe 100644
--- a/packages/modeling/src/primitives/polygon.test.js
+++ b/packages/modeling/src/primitives/polygon.test.js
@@ -56,7 +56,7 @@ test('polygon: providing object.points (array) and object.path (array) creates e
test('polygon: clockwise points', (t) => {
const poly = polygon({
points: [[-10, -0], [-10, -10], [-15, -5]],
- orientation: "clockwise",
+ orientation: 'clockwise'
})
t.is(poly.sides.length, 3)
t.is(measureArea(poly), 25)