patch up laser mode
This commit is contained in:
parent
1ad6749c68
commit
c5d9442fe6
6 changed files with 57 additions and 45 deletions
|
|
@ -78,6 +78,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"setup": "npm i && cd mods && npm i",
|
"setup": "npm i && cd mods && npm i",
|
||||||
|
"setup2": "npm run setup && npm run dev -- --dryrun && npm run preinstall2",
|
||||||
"dev": "gs-app-server --debug",
|
"dev": "gs-app-server --debug",
|
||||||
"prod": "gs-app-server",
|
"prod": "gs-app-server",
|
||||||
"prod-dryrun": "gs-app-server --dryrun",
|
"prod-dryrun": "gs-app-server --dryrun",
|
||||||
|
|
|
||||||
5
src2/kiri-mode/laser/client.js
Normal file
5
src2/kiri-mode/laser/client.js
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
|
export function init() {
|
||||||
|
// TODO
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||||
|
|
||||||
import { api } from '../../kiri/api.js';
|
import { base } from '../../geo/base.js';
|
||||||
import { Packer } from '../../kiri/pack.js';
|
import { Packer } from '../../kiri/pack.js';
|
||||||
|
import { newBounds } from '../../geo/bounds.js';
|
||||||
import { newPoint } from '../../geo/point.js';
|
import { newPoint } from '../../geo/point.js';
|
||||||
|
import { newPrint } from '../../kiri/print.js';
|
||||||
|
import { newSlopeFromAngle } from '../../geo/slope.js';
|
||||||
import { polygons as POLY } from '../../geo/polygons.js';
|
import { polygons as POLY } from '../../geo/polygons.js';
|
||||||
import { render } from '../../kiri/render.js';
|
import { render } from '../../kiri/render.js';
|
||||||
import { Slice, newSlice } from '../../kiri/slice.js';
|
import { slicer } from '../../geo/slicer.js';
|
||||||
|
import { newSlice } from '../../kiri/slice.js';
|
||||||
|
|
||||||
const TYPE = {
|
const TYPE = {
|
||||||
LASER: 0,
|
LASER: 0,
|
||||||
|
|
@ -14,23 +18,8 @@ const TYPE = {
|
||||||
WEDM: 3
|
WEDM: 3
|
||||||
};
|
};
|
||||||
|
|
||||||
export const driver = {
|
function init(worker) {
|
||||||
TYPE,
|
// console.log({ LASER_INIT: worker });
|
||||||
type: TYPE.LASER,
|
|
||||||
name: 'Laser',
|
|
||||||
init,
|
|
||||||
slice,
|
|
||||||
prepare,
|
|
||||||
export: exportLaser,
|
|
||||||
exportGCode,
|
|
||||||
exportSVG,
|
|
||||||
exportDXF,
|
|
||||||
};
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
api.event.on("settings.saved", settings => {
|
|
||||||
// TODO
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function polyLabel(poly, label) {
|
function polyLabel(poly, label) {
|
||||||
|
|
@ -121,7 +110,7 @@ function arc(center, rad, s1, s2, out) {
|
||||||
out.push( center.projectOnSlope(s1, rad) );
|
out.push( center.projectOnSlope(s1, rad) );
|
||||||
}
|
}
|
||||||
while (ticks-- > 0) {
|
while (ticks-- > 0) {
|
||||||
out.push( center.projectOnSlope(base.newSlopeFromAngle(a1 + off), rad) );
|
out.push( center.projectOnSlope(newSlopeFromAngle(a1 + off), rad) );
|
||||||
a1 += step * dir;
|
a1 += step * dir;
|
||||||
}
|
}
|
||||||
out.push( center.projectOnSlope(s2, rad) );
|
out.push( center.projectOnSlope(s2, rad) );
|
||||||
|
|
@ -179,7 +168,7 @@ function addKnifeRadii(poly, tipoff) {
|
||||||
* @param {Function} onupdate (called with % complete and optional message)
|
* @param {Function} onupdate (called with % complete and optional message)
|
||||||
* @param {Function} ondone (called when complete with an array of Slice objects)
|
* @param {Function} ondone (called when complete with an array of Slice objects)
|
||||||
*/
|
*/
|
||||||
function slice(settings, widget, onupdate, ondone) {
|
function laser_slice(settings, widget, onupdate, ondone) {
|
||||||
let proc = settings.process;
|
let proc = settings.process;
|
||||||
let offset = proc.ctSliceKerf || 0;
|
let offset = proc.ctSliceKerf || 0;
|
||||||
let color = settings.controller.dark ? 0xbbbbbb : 0;
|
let color = settings.controller.dark ? 0xbbbbbb : 0;
|
||||||
|
|
@ -193,7 +182,7 @@ function slice(settings, widget, onupdate, ondone) {
|
||||||
let points = widget.getPoints();
|
let points = widget.getPoints();
|
||||||
let indices = [];
|
let indices = [];
|
||||||
|
|
||||||
base.slice(points, {
|
slicer.slice(points, {
|
||||||
zMin: bounds.min.z,
|
zMin: bounds.min.z,
|
||||||
zMax: bounds.max.z,
|
zMax: bounds.max.z,
|
||||||
zGen(zopt) {
|
zGen(zopt) {
|
||||||
|
|
@ -255,13 +244,14 @@ function slice(settings, widget, onupdate, ondone) {
|
||||||
* @param {Object} print state object
|
* @param {Object} print state object
|
||||||
* @param {Function} update incremental callback
|
* @param {Function} update incremental callback
|
||||||
*/
|
*/
|
||||||
async function prepare(widgets, settings, update) {
|
async function laser_prepare(widgets, settings, update) {
|
||||||
let device = settings.device,
|
let worker = self.kiri_worker.current,
|
||||||
|
device = settings.device,
|
||||||
process = settings.process,
|
process = settings.process,
|
||||||
print = self.worker.print = newPrint(settings, widgets),
|
print = worker.print = newPrint(settings, widgets),
|
||||||
isWire = self.worker.mode === 'WEDM',
|
isWire = worker.mode === 'WEDM',
|
||||||
isKnife = self.worker.mode === 'DRAG',
|
isKnife = worker.mode === 'DRAG',
|
||||||
isLaser = self.worker.mode === 'LASER',
|
isLaser = worker.mode === 'LASER',
|
||||||
output = print.output = [],
|
output = print.output = [],
|
||||||
totalSlices = 0,
|
totalSlices = 0,
|
||||||
slices = 0,
|
slices = 0,
|
||||||
|
|
@ -384,7 +374,7 @@ async function prepare(widgets, settings, update) {
|
||||||
|
|
||||||
// compute tile bounds
|
// compute tile bounds
|
||||||
for (let tile of tiles) {
|
for (let tile of tiles) {
|
||||||
let bounds = base.newBounds();
|
let bounds = newBounds();
|
||||||
tile.forEach(rec => bounds.merge(rec.poly.bounds));
|
tile.forEach(rec => bounds.merge(rec.poly.bounds));
|
||||||
tile.w = bounds.width();
|
tile.w = bounds.width();
|
||||||
tile.h = bounds.height();
|
tile.h = bounds.height();
|
||||||
|
|
@ -407,7 +397,7 @@ async function prepare(widgets, settings, update) {
|
||||||
y: fit.y - (tp.max.h / 2) - bounds.miny,
|
y: fit.y - (tp.max.h / 2) - bounds.miny,
|
||||||
z: 0}, true);
|
z: 0}, true);
|
||||||
}
|
}
|
||||||
tile.bounds = base.newBounds();
|
tile.bounds = newBounds();
|
||||||
for (let { poly } of tile) {
|
for (let { poly } of tile) {
|
||||||
tile.bounds.merge(poly.bounds);
|
tile.bounds.merge(poly.bounds);
|
||||||
}
|
}
|
||||||
|
|
@ -468,7 +458,7 @@ async function prepare(widgets, settings, update) {
|
||||||
}, { thin: true, z: ctOutStack ? undefined : 0, action: "cut", moves: process.isKnife });
|
}, { thin: true, z: ctOutStack ? undefined : 0, action: "cut", moves: process.isKnife });
|
||||||
};
|
};
|
||||||
|
|
||||||
function exportLaser(print, online, ondone) {
|
function laser_export(print, online, ondone) {
|
||||||
ondone(print.output);
|
ondone(print.output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -505,7 +495,7 @@ function exportElements(settings, output, onpre, onpoly, onpost, onpoint, onlaye
|
||||||
size.w = max.x - min.x;
|
size.w = max.x - min.x;
|
||||||
size.h = max.y - min.y;
|
size.h = max.y - min.y;
|
||||||
|
|
||||||
let bounds = base.newBounds();
|
let bounds = newBounds();
|
||||||
if (ctOriginCenter) {
|
if (ctOriginCenter) {
|
||||||
// place origin at geometric center of all points
|
// place origin at geometric center of all points
|
||||||
// regardless of workspace size
|
// regardless of workspace size
|
||||||
|
|
@ -855,3 +845,16 @@ function exportDXF(settings, data) {
|
||||||
|
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const LASER = {
|
||||||
|
TYPE,
|
||||||
|
type: TYPE.LASER,
|
||||||
|
name: 'Laser',
|
||||||
|
init,
|
||||||
|
slice: laser_slice,
|
||||||
|
prepare: laser_prepare,
|
||||||
|
export: laser_export,
|
||||||
|
exportGCode,
|
||||||
|
exportDXF,
|
||||||
|
exportSVG
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { broker } from '../moto/broker.js';
|
||||||
import { codec } from '../kiri/codec.js';
|
import { codec } from '../kiri/codec.js';
|
||||||
import { util } from '../geo/base.js';
|
import { util } from '../geo/base.js';
|
||||||
import { newPoint } from '../geo/point.js';
|
import { newPoint } from '../geo/point.js';
|
||||||
import { polygons } from '../geo/polygons.js';
|
import { polygons as POLY } from '../geo/polygons.js';
|
||||||
import { newPrint } from '../kiri/print.js';
|
import { newPrint } from '../kiri/print.js';
|
||||||
import { render } from '../kiri/render.js';
|
import { render } from '../kiri/render.js';
|
||||||
import { wasm_ctrl } from '../geo/wasm.js';
|
import { wasm_ctrl } from '../geo/wasm.js';
|
||||||
|
|
@ -18,15 +18,15 @@ import { Widget, newWidget } from '../kiri/widget.js';
|
||||||
|
|
||||||
import { CAM } from '../kiri-mode/cam/driver-be.js';
|
import { CAM } from '../kiri-mode/cam/driver-be.js';
|
||||||
import { FDM } from '../kiri-mode/fdm/driver-be.js';
|
import { FDM } from '../kiri-mode/fdm/driver-be.js';
|
||||||
|
import { LASER } from '../kiri-mode/laser/driver.js';
|
||||||
|
|
||||||
// const CAM = {};
|
|
||||||
const { time } = util;
|
const { time } = util;
|
||||||
const POLY = polygons;
|
|
||||||
|
|
||||||
let debug = (self.debug === true),
|
let debug = (self.debug === true),
|
||||||
drivers = {
|
drivers = {
|
||||||
CAM,
|
CAM,
|
||||||
FDM
|
FDM,
|
||||||
|
LASER
|
||||||
},
|
},
|
||||||
ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 0,
|
ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 0,
|
||||||
concurrent = Math.min(4, self.Worker && ccvalue > 3 ? ccvalue - 1 : 0),
|
concurrent = Math.min(4, self.Worker && ccvalue > 3 ? ccvalue - 1 : 0),
|
||||||
|
|
@ -495,17 +495,17 @@ const dispatch = {
|
||||||
send.data({debug});
|
send.data({debug});
|
||||||
});
|
});
|
||||||
|
|
||||||
//export in different modes, based on device type
|
// export in different modes, based on device type
|
||||||
if(mode.toUpperCase() === "LASER"){
|
if (mode.toUpperCase() === "LASER") {
|
||||||
let FExt = data.settings.device.gcodeFExt.toUpperCase();
|
let FExt = data.settings.device.gcodeFExt.toUpperCase();
|
||||||
if(FExt === "DXF"){
|
if (FExt === "DXF"){
|
||||||
let dxf = driver.exportDXF(data.settings, current.print.output);
|
let dxf = driver.exportDXF(data.settings, current.print.output);
|
||||||
send.data({line:dxf});
|
send.data({line:dxf});
|
||||||
}else if(FExt === "SVG"){
|
} else if(FExt === "SVG") {
|
||||||
let svg = driver.exportSVG(data.settings, current.print.output);
|
let svg = driver.exportSVG(data.settings, current.print.output);
|
||||||
send.data({line:svg});
|
send.data({line:svg});
|
||||||
}else{
|
} else {
|
||||||
//if not svg or dxf, default to gcode
|
// if not svg or dxf, default to gcode
|
||||||
let gcode = driver.exportGCode(data.settings, current.print.output);
|
let gcode = driver.exportGCode(data.settings, current.print.output);
|
||||||
send.data({line:gcode});
|
send.data({line:gcode});
|
||||||
}
|
}
|
||||||
|
|
@ -756,5 +756,6 @@ const worker = self.kiri_worker = {
|
||||||
// initilize driver mode handlers
|
// initilize driver mode handlers
|
||||||
CAM.init(worker);
|
CAM.init(worker);
|
||||||
FDM.init(worker);
|
FDM.init(worker);
|
||||||
|
LASER.init(worker);
|
||||||
|
|
||||||
broker.publish("worker.started", { dispatch, minions: minwork });
|
broker.publish("worker.started", { dispatch, minions: minwork });
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { client } from './client.js';
|
||||||
import { local } from '../data/local.js';
|
import { local } from '../data/local.js';
|
||||||
import { util } from '../geo/base.js';
|
import { util } from '../geo/base.js';
|
||||||
import { MODES } from './consts.js';
|
import { MODES } from './consts.js';
|
||||||
import { driver as laser_driver } from '../kiri-mode/laser/driver.js';
|
import { LASER as laser_driver } from '../kiri-mode/laser/driver.js';
|
||||||
import { client as sla_client } from '../kiri-mode/sla/client.js';
|
import { client as sla_client } from '../kiri-mode/sla/client.js';
|
||||||
|
|
||||||
let printSeq = parseInt(local['kiri-print-seq'] || local['print-seq'] || "0") + 1;
|
let printSeq = parseInt(local['kiri-print-seq'] || local['print-seq'] || "0") + 1;
|
||||||
|
|
|
||||||
|
|
@ -7,10 +7,11 @@ import { local as sdb } from '../data/local.js';
|
||||||
import { space } from '../moto/space.js';
|
import { space } from '../moto/space.js';
|
||||||
import { LOCAL, SETUP } from './main.js';
|
import { LOCAL, SETUP } from './main.js';
|
||||||
import { VIEWS, MODES, SEED } from '../kiri/consts.js';
|
import { VIEWS, MODES, SEED } from '../kiri/consts.js';
|
||||||
import { init as initCAM } from '../kiri-mode/cam/client.js';
|
|
||||||
import { init as initFDM } from '../kiri-mode/fdm/client.js';
|
|
||||||
import { beta, version } from '../moto/license.js';
|
import { beta, version } from '../moto/license.js';
|
||||||
import { settings as set_ctrl } from './settings.js';
|
import { settings as set_ctrl } from './settings.js';
|
||||||
|
import { init as initCAM } from '../kiri-mode/cam/client.js';
|
||||||
|
import { init as initFDM } from '../kiri-mode/fdm/client.js';
|
||||||
|
import { init as initLaser } from '../kiri-mode/laser/client.js';
|
||||||
|
|
||||||
let { CAM, SLA, FDM, LASER, DRAG, WJET, WEDM } = MODES,
|
let { CAM, SLA, FDM, LASER, DRAG, WJET, WEDM } = MODES,
|
||||||
{ consts, client, catalog, platform, selection } = api,
|
{ consts, client, catalog, platform, selection } = api,
|
||||||
|
|
@ -1364,6 +1365,7 @@ function init_one() {
|
||||||
// run client mode initializations right after UI is bound
|
// run client mode initializations right after UI is bound
|
||||||
initFDM();
|
initFDM();
|
||||||
initCAM();
|
initCAM();
|
||||||
|
initLaser();
|
||||||
|
|
||||||
// override old style settings two-button menu
|
// override old style settings two-button menu
|
||||||
ui.settingsSave.onclick = () => {
|
ui.settingsSave.onclick = () => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue