apply offset after parsing gcode to allow rotations
This commit is contained in:
parent
7c99a9a7ac
commit
4f300c622a
1 changed files with 24 additions and 13 deletions
|
|
@ -14,6 +14,8 @@ const { paths, util, newPoint, Polygon } = base;
|
||||||
const { tip2tipEmit } = paths;
|
const { tip2tipEmit } = paths;
|
||||||
const { numOrDefault } = util;
|
const { numOrDefault } = util;
|
||||||
const { beltfact } = kiri.consts;
|
const { beltfact } = kiri.consts;
|
||||||
|
const XAXIS = new THREE.Vector3(1,0,0);
|
||||||
|
const DEG2RAD = Math.PI / 180;
|
||||||
|
|
||||||
class Print {
|
class Print {
|
||||||
constructor(settings, widgets, id) {
|
constructor(settings, widgets, id) {
|
||||||
|
|
@ -221,6 +223,7 @@ class Print {
|
||||||
.replace("X", " X")
|
.replace("X", " X")
|
||||||
.replace("Y", " Y")
|
.replace("Y", " Y")
|
||||||
.replace("Z", " Z")
|
.replace("Z", " Z")
|
||||||
|
.replace("A", " A")
|
||||||
.replace("E", " E")
|
.replace("E", " E")
|
||||||
.replace("F", " F")
|
.replace("F", " F")
|
||||||
.replace(" ", " ")
|
.replace(" ", " ")
|
||||||
|
|
@ -237,6 +240,7 @@ class Print {
|
||||||
X: 0.0,
|
X: 0.0,
|
||||||
Y: 0.0,
|
Y: 0.0,
|
||||||
Z: 0.0,
|
Z: 0.0,
|
||||||
|
A: 0.0,
|
||||||
F: 0.0,
|
F: 0.0,
|
||||||
E: 0.0
|
E: 0.0
|
||||||
},
|
},
|
||||||
|
|
@ -357,9 +361,9 @@ class Print {
|
||||||
});
|
});
|
||||||
|
|
||||||
const point = newPoint(
|
const point = newPoint(
|
||||||
factor * pos.X + off.X + xoff.X,
|
factor * pos.X + xoff.X,
|
||||||
factor * pos.Y + off.Y + xoff.Y,
|
factor * pos.Y + xoff.Y,
|
||||||
factor * pos.Z + off.Z + xoff.Z + dz
|
factor * pos.Z + xoff.Z + dz
|
||||||
);
|
);
|
||||||
|
|
||||||
if (morph && belt) {
|
if (morph && belt) {
|
||||||
|
|
@ -367,6 +371,14 @@ class Print {
|
||||||
point.z *= beltfact;
|
point.z *= beltfact;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pos.A) {
|
||||||
|
let ip = new THREE.Vector3(pos.X, pos.Y, pos.Z)
|
||||||
|
.applyAxisAngle(XAXIS, pos.A * DEG2RAD);
|
||||||
|
point.x = ip.x;
|
||||||
|
point.y = ip.y;
|
||||||
|
point.z = ip.z;
|
||||||
|
}
|
||||||
|
|
||||||
const retract = (fdm && pos.E < 0) || undefined;
|
const retract = (fdm && pos.E < 0) || undefined;
|
||||||
const moving = g0 || (fdm && (pos.E <= 0 || !(axes.X || axes.Y || axes.Z)));
|
const moving = g0 || (fdm && (pos.E <= 0 || !(axes.X || axes.Y || axes.Z)));
|
||||||
|
|
||||||
|
|
@ -512,16 +524,15 @@ class Print {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// recenter for visualization
|
// apply origin offset
|
||||||
// if (false && morph && belt) {
|
for (let layer of output) {
|
||||||
// for (let layer of output) {
|
for (let rec of layer) {
|
||||||
// for (let rec of layer) {
|
let point = rec.point;
|
||||||
// let point = rec.point;
|
point.x += off.X;
|
||||||
// point.y -= bounds.min.z;
|
point.y += off.Y;
|
||||||
// point.z += bounds.min.y;
|
point.z += off.Z;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
scope.imported = gcode;
|
scope.imported = gcode;
|
||||||
scope.lines = lines.length;
|
scope.lines = lines.length;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue