add missing laser mode subclasses

This commit is contained in:
Stewart Allen 2025-07-06 21:19:35 -04:00
commit 18440bce2e
11 changed files with 170 additions and 154 deletions

View file

@ -0,0 +1,5 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
export function init() {
// TODO
}

View file

@ -1,11 +1,13 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { driver } from '../kiri-mode/laser/driver.js';
import { LASER, TYPE } from '../laser/driver.js';
const DRIVERS = root.kiri.driver; function init(worker) {
const { LASER } = DRIVERS; // console.log({ DRAGKNIFE_INIT: worker });
const { TYPE } = LASER; }
DRIVERS.DRAG = Object.assign({}, LASER, { name: "DragKnife", type: TYPE.DRAG });
export const DRAG = Object.assign({}, LASER, {
export { DRIVERS }; type: TYPE.DRAG,
name: 'DragKnife',
init
});

View file

@ -2,4 +2,4 @@
export function init() { export function init() {
// TODO // TODO
} }

View file

@ -11,7 +11,7 @@ import { render } from '../../kiri/render.js';
import { slicer } from '../../geo/slicer.js'; import { slicer } from '../../geo/slicer.js';
import { newSlice } from '../../kiri/slice.js'; import { newSlice } from '../../kiri/slice.js';
const TYPE = { export const TYPE = {
LASER: 0, LASER: 0,
DRAG: 1, DRAG: 1,
WJET: 2, WJET: 2,

View file

@ -0,0 +1,98 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { api } from '../../kiri/api.js';
const state = {
api: undefined,
alert: undefined,
radians: 0,
surfaces: [],
selecting: false
};
export function init() {
api.event.on("key.esc", () => {
if (state.selecting) {
faceDone();
}
});
// api.event.on("mode.set", (mode) => { });
// api.event.on("view.set", (mode) => { });
api.event.on("preview.view", view => {
const process = api.conf.get().process;
if (!process.ctOriginBounds) return;
const bounds = new THREE.Box3().expandByObject(view);
api.platform.set_bounds(new THREE.Box3(
new THREE.Vector3(bounds.min.x, bounds.min.z, bounds.min.y),
new THREE.Vector3(bounds.max.x, bounds.max.z, bounds.max.y),
));
});
// Surface Selection Buttons
api.event.on("button.click", target => {
let process = api.conf.get().process;
switch (target) {
case api.ui.faceAdd:
target.classList.add('editing');
return faceAdd();
case api.ui.faceDun:
return faceDone();
case api.ui.faceClr:
api.uc.confirm("clear surface selection?").then(ok => {
// todo
});
break;
}
});
}
function faceAdd() {
if (state.selecting) return faceDone();
const { api, radians, surfaces } = state;
CAM.surface_prep(radians, () => {
api.hide.alert(alert);
state.alert = api.show.alert("[esc] cancels surface selection");
for (let [wid, arr] of Object.entries(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget && arr.length)
for (let faceid of arr) {
CAM.surface_toggle(widget, faceid, radians, faceids => {
// surfaces[widget.id] = faceids;
});
}
}
api.feature.on_mouse_up = (obj, ev) => {
let { face } = obj;
let min = Math.min(face.a, face.b, face.c);
let faceid = min / 3;
let widget = obj.object.widget;
CAM.surface_toggle(widget, faceid, radians, faceids => {
surfaces[widget.id] = faceids;
});
};
state.selecting = true;
});
}
function faceDone() {
if (!state.selecting) return;
const { api, alert, surfaces } = state;
for (let wid of Object.keys(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget) {
CAM.surface_clear(widget);
} else {
delete surfaces[wid];
}
}
api.hide.alert(alert);
api.feature.on_mouse_up = undefined;
api.ui.faceAdd.classList.remove('editing')
state.selecting = false;
}

View file

@ -1,129 +1,21 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { driver } from '../kiri-mode/laser/driver.js';
import { LASER, TYPE } from '../laser/driver.js';
const { kiri, moto } = root;
const DRIVERS = kiri.driver;
const { CAM, LASER } = DRIVERS;
const { TYPE } = LASER;
const WEDM = DRIVERS.WEDM = Object.assign({}, LASER, {
name: "WireEDM",
type: TYPE.WEDM,
init,
prepare
});
const DEG2RAD = Math.PI / 180; const DEG2RAD = Math.PI / 180;
const state = { function init(worker) {
api: undefined, // console.log({ WIREEDM_INIT: worker });
alert: undefined,
radians: 0,
surfaces: [],
selecting: false
};
function faceAdd() {
if (state.selecting) return faceDone();
const { api, radians, surfaces } = state;
CAM.surface_prep(radians, () => {
api.hide.alert(alert);
state.alert = api.show.alert("[esc] cancels surface selection");
for (let [wid, arr] of Object.entries(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget && arr.length)
for (let faceid of arr) {
CAM.surface_toggle(widget, faceid, radians, faceids => {
// surfaces[widget.id] = faceids;
});
}
}
api.feature.on_mouse_up = (obj, ev) => {
let { face } = obj;
let min = Math.min(face.a, face.b, face.c);
let faceid = min / 3;
let widget = obj.object.widget;
CAM.surface_toggle(widget, faceid, radians, faceids => {
surfaces[widget.id] = faceids;
});
};
state.selecting = true;
});
} }
function faceDone() {
if (!state.selecting) return;
const { api, alert, surfaces } = state;
for (let wid of Object.keys(surfaces)) {
let widget = api.widgets.forid(wid);
if (widget) {
CAM.surface_clear(widget);
} else {
delete surfaces[wid];
}
}
api.hide.alert(alert);
api.feature.on_mouse_up = undefined;
api.ui.faceAdd.classList.remove('editing')
state.selecting = false;
}
function init(kiri, api, driver) {
LASER.init(kiri, api, driver);
state.api = api;
api.event.on("key.esc", () => {
if (state.selecting) {
faceDone();
}
});
// api.event.on("mode.set", (mode) => { });
// api.event.on("view.set", (mode) => { });
api.event.on("preview.view", view => {
const process = api.conf.get().process;
if (!process.ctOriginBounds) return;
const bounds = new THREE.Box3().expandByObject(view);
api.platform.set_bounds(new THREE.Box3(
new THREE.Vector3(bounds.min.x, bounds.min.z, bounds.min.y),
new THREE.Vector3(bounds.max.x, bounds.max.z, bounds.max.y),
));
});
// Surface Selection Buttons
api.event.on("button.click", target => {
let process = api.conf.get().process;
switch (target) {
case api.ui.faceAdd:
target.classList.add('editing');
return faceAdd();
case api.ui.faceDun:
return faceDone();
case api.ui.faceClr:
api.uc.confirm("clear surface selection?").then(ok => {
// todo
});
break;
}
});
};
async function prepare(widgets, settings, update) { async function prepare(widgets, settings, update) {
// let device = settings.device,
// process = settings.process,
// print = self.worker.print = kiri.newPrint(settings, widgets),
// output = print.output = [];
// filter ignored widgets
widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled); widgets = widgets.filter(w => !w.track.ignore && !w.meta.disabled);
LASER.prepare(widgets, settings, update); LASER.prepare(widgets, settings, update);
} }
export const WEDM = Object.assign({}, LASER, {
export { faceAdd, faceDone, init, prepare, DRIVERS, WEDM, DEG2RAD, state, widget, min, faceid, process, bounds, device }; type: TYPE.WEDM,
name: 'WireEDM',
init,
prepare
});

View file

@ -0,0 +1,5 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
export function init() {
// TODO
}

View file

@ -1,11 +1,13 @@
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */ /** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
import { driver } from '../kiri-mode/laser/driver.js';
import { LASER, TYPE } from '../laser/driver.js';
const DRIVERS = root.kiri.driver; function init(worker) {
const { LASER } = DRIVERS; // console.log({ WATERJET_INIT: worker });
const { TYPE } = LASER; }
DRIVERS.WJET = Object.assign({}, LASER, { name: 'WaterJet', type: TYPE.WJET });
export const WJET = Object.assign({}, LASER, {
export { DRIVERS }; type: TYPE.WJET,
name: 'WaterJet',
init
});

View file

@ -18,18 +18,24 @@ import { version } from '../moto/license.js';
import { Widget, newWidget } from '../kiri/widget.js'; 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 { DRAG } from '../kiri-mode/drag/driver.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'; import { LASER } from '../kiri-mode/laser/driver.js';
import { SLA } from '../kiri-mode/sla/driver.js'; import { SLA } from '../kiri-mode/sla/driver.js';
import { WEDM } from '../kiri-mode/wedm/driver.js';
import { WJET } from '../kiri-mode/wjet/driver.js';
const { time } = util; const { time } = util;
let debug = (self.debug === true), let debug = (self.debug === true),
drivers = { drivers = {
DRAG,
CAM, CAM,
FDM, FDM,
LASER, LASER,
SLA SLA,
WEDM,
WJET
}, },
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),

View file

@ -44,7 +44,7 @@ let UC = UI.prefix('kiri').inputAction(settings.conf.update),
on_mouse_up: und, // function intercepts mouse up select on_mouse_up: und, // function intercepts mouse up select
on_mouse_down: und, // function intercepts mouse down on_mouse_down: und, // function intercepts mouse down
work_alerts: true, // allow disabling work progress alerts work_alerts: true, // allow disabling work progress alerts
pmode: consts.PMODES.SPEED, // preview modes pmode: consts.PMODES.SPEED, // preview modes
// hover: false, // when true fires mouse hover events // hover: false, // when true fires mouse hover events
get hover() { get hover() {
return isHover; return isHover;
@ -72,7 +72,7 @@ let UC = UI.prefix('kiri').inputAction(settings.conf.update),
let proc = api.conf.get().process, let proc = api.conf.get().process,
size = proc.sliceHeight || proc.slaSlice || 1, size = proc.sliceHeight || proc.slaSlice || 1,
base = (proc.firstSliceHeight || size); base = (proc.firstSliceHeight || size);
layers = Array.isArray(layers) ? layers : [ layers ]; layers = Array.isArray(layers) ? layers : [layers];
proc.xray = layers.map(l => raw ? l : base + l * size - size / 2); proc.xray = layers.map(l => raw ? l : base + l * size - size / 2);
proc.xrayi = layers.slice(); proc.xrayi = layers.slice();
api.function.slice(); api.function.slice();
@ -91,8 +91,8 @@ let UC = UI.prefix('kiri').inputAction(settings.conf.update),
set: (key, val) => localSet(key, val), set: (key, val) => localSet(key, val),
}, },
tweak = { tweak = {
line_precision(v) { api.work.config({base:{clipperClean: v}}) }, line_precision(v) { api.work.config({ base: { clipperClean: v } }) },
gcode_decimals(v) { api.work.config({base:{gcode_decimals: v}}) } gcode_decimals(v) { api.work.config({ base: { gcode_decimals: v } }) }
}; };
function clip(text) { function clip(text) {
@ -113,16 +113,16 @@ function localSet(key, val) {
} }
export const api = { export const api = {
ajax, // via utils ajax,
alerts, // alerts.js alerts,
busy, busy,
catalog, catalog,
client: work, // alias for "work" client: work,
clip, clip,
clone, clone,
color, color,
conf: settings.conf, conf: settings.conf,
const: { LANG, LISTS: lists, LOCAL, MODES, SETUP, SECURE, STACKS, VIEWS }, const: { LANG, LISTS: lists, LOCAL, MODES, SETUP, SECURE, STACKS, VIEWS },
devel, devel,
device, device,
devices, devices,
@ -130,36 +130,36 @@ export const api = {
doit, doit,
event, event,
feature, feature,
function: functions, function: functions,
group, group,
help, help,
hide, hide,
image, image,
js2o, // via utils js2o,
language: LANG, language: LANG,
lists, lists,
local, local,
modal, modal,
mode, mode,
noop, noop,
o2js, // via utils o2js,
onkey, onkey,
platform, platform,
probe, probe,
process, process,
sdb: dataLocal, sdb: dataLocal,
selection, selection,
settings, settings,
show, show,
space, space,
stacks: STACKS, stacks: STACKS,
stats, stats,
tool: { tool: {
update: updateTool update: updateTool
}, },
tweak, tweak,
uc: UC, uc: UC,
ui: {}, // init.js ui: {},
util, util,
var: { var: {
layer_lo: 0, layer_lo: 0,
@ -168,7 +168,7 @@ export const api = {
}, },
view, view,
widgets, widgets,
work, // message worker work,
}; };
// allow widget to straddle client / worker FOR NOW // allow widget to straddle client / worker FOR NOW

View file

@ -10,9 +10,12 @@ import { VIEWS, MODES, SEED } from '../kiri/consts.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 initCAM } from '../kiri-mode/cam/client.js';
import { init as initDRAG } from '../kiri-mode/drag/client.js';
import { init as initFDM } from '../kiri-mode/fdm/client.js'; import { init as initFDM } from '../kiri-mode/fdm/client.js';
import { init as initLaser } from '../kiri-mode/laser/client.js'; import { init as initLaser } from '../kiri-mode/laser/client.js';
import { init as initSLA } from '../kiri-mode/sla/client.js'; import { init as initSLA } from '../kiri-mode/sla/client.js';
import { init as initWEDM } from '../kiri-mode/wedm/client.js';
import { init as initWJET } from '../kiri-mode/wjet/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,10 +1367,13 @@ function init_one() {
}); });
// run client mode initializations right after UI is bound // run client mode initializations right after UI is bound
initFDM();
initCAM(); initCAM();
initDRAG();
initFDM();
initLaser(); initLaser();
initSLA(); initSLA();
initWEDM();
initWJET();
// override old style settings two-button menu // override old style settings two-button menu
ui.settingsSave.onclick = () => { ui.settingsSave.onclick = () => {