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 */
import { driver } from '../kiri-mode/laser/driver.js';
import { LASER, TYPE } from '../laser/driver.js';
const DRIVERS = root.kiri.driver;
const { LASER } = DRIVERS;
const { TYPE } = LASER;
DRIVERS.DRAG = Object.assign({}, LASER, { name: "DragKnife", type: TYPE.DRAG });
function init(worker) {
// console.log({ DRAGKNIFE_INIT: worker });
}
export { DRIVERS };
export const DRAG = Object.assign({}, LASER, {
type: TYPE.DRAG,
name: 'DragKnife',
init
});

View file

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

View file

@ -11,7 +11,7 @@ import { render } from '../../kiri/render.js';
import { slicer } from '../../geo/slicer.js';
import { newSlice } from '../../kiri/slice.js';
const TYPE = {
export const TYPE = {
LASER: 0,
DRAG: 1,
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 */
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 state = {
api: undefined,
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 init(worker) {
// console.log({ WIREEDM_INIT: worker });
}
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) {
// 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);
LASER.prepare(widgets, settings, update);
}
export { faceAdd, faceDone, init, prepare, DRIVERS, WEDM, DEG2RAD, state, widget, min, faceid, process, bounds, device };
export const WEDM = Object.assign({}, LASER, {
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 */
import { driver } from '../kiri-mode/laser/driver.js';
import { LASER, TYPE } from '../laser/driver.js';
const DRIVERS = root.kiri.driver;
const { LASER } = DRIVERS;
const { TYPE } = LASER;
DRIVERS.WJET = Object.assign({}, LASER, { name: 'WaterJet', type: TYPE.WJET });
function init(worker) {
// console.log({ WATERJET_INIT: worker });
}
export { DRIVERS };
export const WJET = Object.assign({}, LASER, {
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 { 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 { LASER } from '../kiri-mode/laser/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;
let debug = (self.debug === true),
drivers = {
DRAG,
CAM,
FDM,
LASER,
SLA
SLA,
WEDM,
WJET
},
ccvalue = self.navigator ? self.navigator.hardwareConcurrency || 0 : 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_down: und, // function intercepts mouse down
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
get hover() {
return isHover;
@ -72,7 +72,7 @@ let UC = UI.prefix('kiri').inputAction(settings.conf.update),
let proc = api.conf.get().process,
size = proc.sliceHeight || proc.slaSlice || 1,
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.xrayi = layers.slice();
api.function.slice();
@ -91,8 +91,8 @@ let UC = UI.prefix('kiri').inputAction(settings.conf.update),
set: (key, val) => localSet(key, val),
},
tweak = {
line_precision(v) { api.work.config({base:{clipperClean: v}}) },
gcode_decimals(v) { api.work.config({base:{gcode_decimals: v}}) }
line_precision(v) { api.work.config({ base: { clipperClean: v } }) },
gcode_decimals(v) { api.work.config({ base: { gcode_decimals: v } }) }
};
function clip(text) {
@ -113,16 +113,16 @@ function localSet(key, val) {
}
export const api = {
ajax, // via utils
alerts, // alerts.js
ajax,
alerts,
busy,
catalog,
client: work, // alias for "work"
client: work,
clip,
clone,
color,
conf: settings.conf,
const: { LANG, LISTS: lists, LOCAL, MODES, SETUP, SECURE, STACKS, VIEWS },
conf: settings.conf,
const: { LANG, LISTS: lists, LOCAL, MODES, SETUP, SECURE, STACKS, VIEWS },
devel,
device,
devices,
@ -130,36 +130,36 @@ export const api = {
doit,
event,
feature,
function: functions,
function: functions,
group,
help,
hide,
image,
js2o, // via utils
language: LANG,
js2o,
language: LANG,
lists,
local,
modal,
mode,
noop,
o2js, // via utils
o2js,
onkey,
platform,
probe,
process,
sdb: dataLocal,
sdb: dataLocal,
selection,
settings,
show,
space,
stacks: STACKS,
stacks: STACKS,
stats,
tool: {
update: updateTool
update: updateTool
},
tweak,
uc: UC,
ui: {}, // init.js
uc: UC,
ui: {},
util,
var: {
layer_lo: 0,
@ -168,7 +168,7 @@ export const api = {
},
view,
widgets,
work, // message worker
work,
};
// 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 { settings as set_ctrl } from './settings.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 initLaser } from '../kiri-mode/laser/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,
{ consts, client, catalog, platform, selection } = api,
@ -1364,10 +1367,13 @@ function init_one() {
});
// run client mode initializations right after UI is bound
initFDM();
initCAM();
initDRAG();
initFDM();
initLaser();
initSLA();
initWEDM();
initWJET();
// override old style settings two-button menu
ui.settingsSave.onclick = () => {