update laser driver code format
This commit is contained in:
parent
836d53aad5
commit
e22fe7d483
1 changed files with 613 additions and 615 deletions
|
|
@ -2,18 +2,18 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
(function() {
|
// dep: base.polygons
|
||||||
|
// dep: base.point
|
||||||
|
// dep: kiri.slice
|
||||||
|
gapp.register("kiri-mode.laser.driver", [], (root, exports) => {
|
||||||
|
|
||||||
if (!self.kiri.driver) self.kiri.driver = { };
|
const { base, kiri } = root;
|
||||||
if (self.kiri.driver.LASER) return;
|
const { driver, newSlice } = kiri;
|
||||||
|
const { FDM, CAM } = driver;
|
||||||
|
const { polygons, newPoint } = base;
|
||||||
|
|
||||||
let KIRI = self.kiri,
|
const POLY = polygons;
|
||||||
BASE = self.base,
|
const LASER = driver.LASER = {
|
||||||
UTIL = BASE.util,
|
|
||||||
POLY = BASE.polygons,
|
|
||||||
FDM = KIRI.driver.FDM,
|
|
||||||
CAM = KIRI.driver.CAM,
|
|
||||||
LASER = KIRI.driver.LASER = {
|
|
||||||
init,
|
init,
|
||||||
slice,
|
slice,
|
||||||
prepare,
|
prepare,
|
||||||
|
|
@ -21,14 +21,12 @@
|
||||||
exportGCode,
|
exportGCode,
|
||||||
exportSVG,
|
exportSVG,
|
||||||
exportDXF
|
exportDXF
|
||||||
},
|
};
|
||||||
newSlice = KIRI.newSlice,
|
|
||||||
newPoint = BASE.newPoint;
|
|
||||||
|
|
||||||
function init(kiri, api) {
|
function init(kiri, api) {
|
||||||
api.event.on("settings.saved", (settings) => {
|
api.event.on("settings.saved", (settings) => {
|
||||||
let UI = kiri.api.ui;
|
let ui = kiri.api.ui;
|
||||||
UI.knife.marker.style.display = UI.knifeOn.checked ? '' : 'none';
|
ui.knife.marker.style.display = ui.knifeOn.checked ? '' : 'none';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -54,7 +52,7 @@
|
||||||
let points = widget.getPoints();
|
let points = widget.getPoints();
|
||||||
let indices = [];
|
let indices = [];
|
||||||
|
|
||||||
BASE.slice(points, {
|
base.slice(points, {
|
||||||
zMin: bounds.min.z,
|
zMin: bounds.min.z,
|
||||||
zMax: bounds.max.z,
|
zMax: bounds.max.z,
|
||||||
zGen(zopt) {
|
zGen(zopt) {
|
||||||
|
|
@ -175,7 +173,7 @@
|
||||||
function prepare(widgets, settings, update) {
|
function prepare(widgets, settings, update) {
|
||||||
let device = settings.device,
|
let device = settings.device,
|
||||||
process = settings.process,
|
process = settings.process,
|
||||||
print = self.worker.print = KIRI.newPrint(settings, widgets),
|
print = self.worker.print = kiri.newPrint(settings, widgets),
|
||||||
knifeOn = process.knifeOn,
|
knifeOn = process.knifeOn,
|
||||||
knifeDepth = process.outputKnifeDepth,
|
knifeDepth = process.outputKnifeDepth,
|
||||||
knifePasses = process.outputKnifePasses,
|
knifePasses = process.outputKnifePasses,
|
||||||
|
|
@ -201,7 +199,7 @@
|
||||||
out.push( center.projectOnSlope(s1, knifeTipOff) );
|
out.push( center.projectOnSlope(s1, knifeTipOff) );
|
||||||
}
|
}
|
||||||
while (ticks-- > 0) {
|
while (ticks-- > 0) {
|
||||||
out.push( center.projectOnSlope(BASE.newSlopeFromAngle(a1 + off), knifeTipOff) );
|
out.push( center.projectOnSlope(base.newSlopeFromAngle(a1 + off), knifeTipOff) );
|
||||||
a1 += step * dir;
|
a1 += step * dir;
|
||||||
}
|
}
|
||||||
out.push( center.projectOnSlope(s2, knifeTipOff) );
|
out.push( center.projectOnSlope(s2, knifeTipOff) );
|
||||||
|
|
@ -342,14 +340,14 @@
|
||||||
dh = device.bedDepth / 2,
|
dh = device.bedDepth / 2,
|
||||||
sort = !process.outputLaserLayer,
|
sort = !process.outputLaserLayer,
|
||||||
// sort objects by size when not using laser layer ordering
|
// sort objects by size when not using laser layer ordering
|
||||||
c = sort ? output.sort(KIRI.Sort) : output,
|
c = sort ? output.sort(kiri.Sort) : output,
|
||||||
p = new KIRI.Pack(dw, dh, process.outputTileSpacing).fit(c, !sort);
|
p = new kiri.Pack(dw, dh, process.outputTileSpacing).fit(c, !sort);
|
||||||
|
|
||||||
// test different ratios until packed
|
// test different ratios until packed
|
||||||
while (!p.packed) {
|
while (!p.packed) {
|
||||||
dw *= 1.1;
|
dw *= 1.1;
|
||||||
dh *= 1.1;
|
dh *= 1.1;
|
||||||
p = new KIRI.Pack(dw, dh, process.outputTileSpacing).fit(c ,!sort);
|
p = new kiri.Pack(dw, dh, process.outputTileSpacing).fit(c ,!sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pack)
|
if (pack)
|
||||||
|
|
@ -591,7 +589,7 @@
|
||||||
},
|
},
|
||||||
function(point) {
|
function(point) {
|
||||||
z = point.z;
|
z = point.z;
|
||||||
return UTIL.round(point.x - dx, 3) + "," + UTIL.round(my - point.y - dy, 3);
|
return util.round(point.x - dx, 3) + "," + util.round(my - point.y - dy, 3);
|
||||||
},
|
},
|
||||||
function(layer, z, thick, layers) {
|
function(layer, z, thick, layers) {
|
||||||
if (zcolor) {
|
if (zcolor) {
|
||||||
|
|
@ -675,4 +673,4 @@
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue