From 0cd3bd7c9ca96028b7d10ddd1dc43d76c7deeab9 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 9 Jul 2025 11:36:12 -0400 Subject: [PATCH] add const config for cam slicer Z to 3 decimals --- bin/webpack-three.js | 45 ------------------------------------- src/kiri-mode/cam/slicer.js | 21 ++++++++--------- 2 files changed, 11 insertions(+), 55 deletions(-) delete mode 100644 bin/webpack-three.js diff --git a/bin/webpack-three.js b/bin/webpack-three.js deleted file mode 100644 index f6b28e4e..00000000 --- a/bin/webpack-three.js +++ /dev/null @@ -1,45 +0,0 @@ -const TerserPlugin = require("terser-webpack-plugin"); -const path = require('path'); - -module.exports = { - mode: 'production', - entry: "./bin/webpack-three-bundle.js", - output: { - path: path.resolve('src/ext'), - filename: 'three.js', - library: 'ThreeBundle', - libraryTarget: 'umd', - globalObject: 'this' - }, - resolve: { - extensions: ['.mjs', '.js'], - }, - module: { - rules: [ - { - test: /\.m?js$/, - resolve: { - fullySpecified: false, - }, - }, - ], - }, - optimization: { - minimize: false, - minimizer: [ - new TerserPlugin({ - extractComments: false, - terserOptions: { - format: { - comments: false, - }, - }, - }), - ], - }, - performance: { - hints: false, - maxAssetSize: 2 * 1024 * 1024, - maxEntrypointSize: 2 * 1024 * 1024, - }, -}; diff --git a/src/kiri-mode/cam/slicer.js b/src/kiri-mode/cam/slicer.js index 7c749cd9..eca790ec 100644 --- a/src/kiri-mode/cam/slicer.js +++ b/src/kiri-mode/cam/slicer.js @@ -11,6 +11,7 @@ import { slicer } from '../../geo/slicer.js'; const { sliceConnect, sliceDedup } = slicer; const { config } = base; const timing = false; +const zDecimal = 3; const begin = function () { if (timing) console.time(...arguments); @@ -66,7 +67,7 @@ export class Slicer { const zList = this.zList; function countZ(z) { - z = z.round(5); + z = z.round(zDecimal); zList[z] = (zList[z] || 0) + 1; } @@ -75,7 +76,7 @@ export class Slicer { p3 = newPoint(0, 0, 0); // for (let i = 0, il = points.length; i < il; i++) { - // points[i] = points[i].round(5); + // points[i] = points[i].round(zDecimal); // } for (let i = 0, il = points.length; i < il;) { @@ -95,7 +96,7 @@ export class Slicer { // use co-flat and co-line detection to adjust slice Z if (p1.z === p2.z && p2.z === p3.z) { // detect zFlat faces to avoid slicing directly on them - let zkey = p1.z.toFixed(5), + let zkey = p1.z.toFixed(zDecimal), area = Math.abs(util.area2(p1, p2, p3)) / 2; if (!zFlat[zkey]) { zFlat[zkey] = area; @@ -106,17 +107,17 @@ export class Slicer { // detect zLine (curved region tops/bottoms) // in cam used for ball and v mill tracing if (p1.z === p2.z) { - let zkey = p1.z.toFixed(5); + let zkey = p1.z.toFixed(zDecimal); let zval = zLine[zkey]; zLine[zkey] = (zval || 0) + 1; } if (p2.z === p3.z) { - let zkey = p2.z.toFixed(5); + let zkey = p2.z.toFixed(zDecimal); let zval = zLine[zkey]; zLine[zkey] = (zval || 0) + 1; } if (p3.z === p1.z) { - let zkey = p3.z.toFixed(5); + let zkey = p3.z.toFixed(zDecimal); let zval = zLine[zkey]; zLine[zkey] = (zval || 0) + 1; } @@ -155,7 +156,7 @@ export class Slicer { if (!flatoff) { return z; } - const znorm = z.toFixed(5); + const znorm = z.toFixed(zDecimal); return this.zFlat[znorm] ? z + flatoff : z; }); @@ -395,10 +396,10 @@ export class Slicer { } // filter duplicate values - array = array.map(v => v.round(5)).filter((e, i, a) => i < 1 || a[i - 1] !== a[i]); + array = array.map(v => v.round(zDecimal)).filter((e, i, a) => i < 1 || a[i - 1] !== a[i]); - // return array.map(v => Math.abs(parseFloat(v.toFixed(5)))); - return array.map(v => parseFloat(v.toFixed(5))); + // return array.map(v => Math.abs(parseFloat(v.toFixed(zDecimal)))); + return array.map(v => parseFloat(v.toFixed(zDecimal))); } }