add missing laser mode subclasses
This commit is contained in:
parent
ac8b3b834f
commit
18440bce2e
11 changed files with 170 additions and 154 deletions
5
src2/kiri-mode/drag/client.js
Normal file
5
src2/kiri-mode/drag/client.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
export function init() {
|
||||
// TODO
|
||||
}
|
||||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
export function init() {
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
98
src2/kiri-mode/wedm/client.js
Normal file
98
src2/kiri-mode/wedm/client.js
Normal 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;
|
||||
}
|
||||
|
||||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
5
src2/kiri-mode/wjet/client.js
Normal file
5
src2/kiri-mode/wjet/client.js
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/** Copyright Stewart Allen <sa@grid.space> -- All Rights Reserved */
|
||||
|
||||
export function init() {
|
||||
// TODO
|
||||
}
|
||||
|
|
@ -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
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue