From 1d573b1605df50515dab7a51d4402b80cc55632b Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 9 Nov 2020 19:22:28 -0500 Subject: [PATCH] codec and color cleanup --- notes.md | 3 ++- src/kiri/codec.js | 30 +++++++----------------------- src/kiri/render.js | 4 +++- src/kiri/stacks.js | 10 +++++----- src/kiri/worker.js | 2 +- src/mode/fdm/prepare.js | 8 ++++++-- src/mode/fdm/slice.js | 6 +++--- src/mode/laser/driver.js | 9 ++------- 8 files changed, 29 insertions(+), 43 deletions(-) diff --git a/notes.md b/notes.md index 0d71c1ea..5ee0100e 100644 --- a/notes.md +++ b/notes.md @@ -3,7 +3,6 @@ ## `C` cosmetic, `F` functional, `P` performance, `B` bug fix * `F` detect and report slow framerates -* `F` gcode generation progress bar * `F` implement an in-app bug reporting system. add workspace to export option. * `F` extend mesh object to store raw + annotations (rot,scale,pos) * share raw data w/ dups, encode/decode @@ -12,6 +11,8 @@ * `F` 2D image import * `P` improve decimation speed by avoiding in/out of Point? * `P` duplicate objects should share same slice data unless rotated or scaled +* `P` worker state cache cleanup and organization +* `P` client/worker interface normalization and cleanup # FDM diff --git a/src/kiri/codec.js b/src/kiri/codec.js index f4525bdf..713368b0 100644 --- a/src/kiri/codec.js +++ b/src/kiri/codec.js @@ -127,6 +127,7 @@ for (let i=0; i { mat.push(createLineMaterial({ color: c })) }); + if (cpoly) { + cpoly.forEach(c => { mat.push(createLineMaterial({ color: c })) }); } else { mat.push(createLineMaterial(data)); } @@ -128,8 +128,8 @@ vert.push(new THREE.Vector3(p.x, p.y, p.z)); } if (vert.length) { - if (cpath) { - cpath.forEach((c, i) => geo.addGroup(c.start, c.count, i)); + if (cpoly) { + cpoly.forEach((c, i) => geo.addGroup(c.start, c.count, i)); } else { geo.addGroup(0, Infinity, 0); } diff --git a/src/kiri/worker.js b/src/kiri/worker.js index b56cae08..4c66ab79 100644 --- a/src/kiri/worker.js +++ b/src/kiri/worker.js @@ -172,7 +172,7 @@ KIRI.worker = { }, done => { const layers = KIRI.driver.FDM.prepareRender(done.output, progress => { send.data({ progress: 0.5 + progress * 0.5 }); - }, { thin, tools }); + }, { thin, tools, xspeed: mode === 'FDM' }); send.done({parsed: KIRI.codec.encode(layers)}); }, { fdm : mode === 'FDM' }); }, diff --git a/src/mode/fdm/prepare.js b/src/mode/fdm/prepare.js index 56e015cf..9c557141 100644 --- a/src/mode/fdm/prepare.js +++ b/src/mode/fdm/prepare.js @@ -415,6 +415,10 @@ const cn_len = new Counter(); const cn_col = new Counter(); + function color(point) { + return hsv2rgb({h:point.speed / maxspd, s:1, v:0.75}, true); + } + levels.forEach((level, index) => { const prints = {}; const moves = []; @@ -444,7 +448,7 @@ if (!lastOut.emit || (ckspeed && out.speed !== lastOut.speed)) { current = newPolygon().setOpen(); current.push(lastOut.point); - current.color = hsv2rgb({h:out.speed/maxspd, s:1, v:0.75}, true); + current.color = color(out); pushPrint(out.tool, current); } current.push(out.point); @@ -460,7 +464,7 @@ current = newPolygon().setOpen(); current.push(out.point); if (out.emit) { - current.color = hsv2rgb({h:out.speed/maxspd, s:1, v:1}, true); + current.color = color(out); pushPrint(out.tool, current); } else { moves.push(current); diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index 6b37d953..f0531c42 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -18,9 +18,9 @@ FILL = KIRI.fill, FILLFIXED = KIRI.fill_fixed, COLOR = { - shell: { face: 0x003399, line: 0x003399, opacity: 1 }, - fill: { face: 0x003399, line: 0x003399, opacity: 1 }, - infill: { face: 0x003399, line: 0x003399, opacity: 1 }, + shell: { face: 0x0077bb, line: 0x0077bb, opacity: 1 }, + fill: { face: 0x0077bb, line: 0x0077bb, opacity: 1 }, + infill: { face: 0x0077bb, line: 0x0077bb, opacity: 1 }, support: { face: 0x006699, line: 0x006699, opacity: 1 } }; diff --git a/src/mode/laser/driver.js b/src/mode/laser/driver.js index 3aea0a0f..1a1ac37e 100644 --- a/src/mode/laser/driver.js +++ b/src/mode/laser/driver.js @@ -17,7 +17,6 @@ slice, prepare, export: exportLaser, - printRender, exportGCode, exportSVG, exportDXF @@ -256,8 +255,8 @@ min.y = 0; } else { // normalize against center of build area - let w = print.settings.device.bedWidth; - let h = print.settings.device.bedDepth; + let w = settings.device.bedWidth; + let h = settings.device.bedDepth; output.forEach(function(layer) { layer.forEach(function(out) { point = out.point; @@ -495,8 +494,4 @@ return lines.join('\n'); }; - function printRender(print) { - return KIRI.driver.FDM.printRender(print, {aslines: true, nomoves: true, flat: true}); - } - })();