Merge pull request #226 from Tibus/master

Add "random" and "position" (hidden) to sliceLayerStart and fix origin
This commit is contained in:
Stewart Allen 2022-10-29 14:42:14 -04:00 • committed by GitHub
commit d9504dd98c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View file

@ -784,9 +784,11 @@ FDM.prepare = async function(widgets, settings, update) {
function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
const { settings } = print;
const { device } = settings;
const { bedWidth, bedDepth, bedRound } = device;
let preout = [],
process = opt.params || settings.process,
originCenter = process.outputOriginCenter || bedRound,
extruder = slice.extruder || 0,
nozzleSize = process.sliceLineWidth || device.extruders[extruder].extNozzle,
firstLayer = opt.first || false,
@ -810,6 +812,15 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
antiBacklash = process.antiBacklash,
wipeDist = process.outputRetractWipe || 0,
isBelt = device.bedBelt,
bedOffset = originCenter ? {
x: 0,
y: 0,
z: 0
} : {
x: bedWidth/2,
y: isBelt ? 0 : bedDepth/2,
z: 0
},
beltFirst = process.outputBeltFirst || false,
startClone = startPoint.clone(),
seedPoint = opt.seedPoint || startPoint,
@ -1376,11 +1387,24 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
switch (process.sliceLayerStart) {
case "last":
break;
case "random":
let bounds = top.poly.bounds;
let center = bounds.center();
let radius = Math.max(bounds.width(), bounds.height());
let angle = Math.random()*Math.PI*2;
let x = center.x + Math.cos(angle)*radius;
let y = center.y + Math.sin(angle)*radius;
startPoint = newPoint(x,y,startPoint.z);
break;
case "center":
startPoint = newPoint(0,0,startPoint.z);
break;
case "origin":
startPoint = origin.clone();
startPoint = newPoint(-bedOffset.x, -bedOffset.y, startPoint.z);
break;
case "position":
startPoint = newPoint(-bedOffset.x+process.sliceLayerStartX, -bedOffset.y+process.sliceLayerStartY, startPoint.z);
console.log("startPoint", top);
break;
}

View file

@ -302,6 +302,8 @@ const conf = exports({
sliceShells: 3,
sliceShellOrder: "in-out",
sliceLayerStart: "last",
sliceLayerStartX: 0,
sliceLayerStartY: 0,
sliceLineWidth: 0,
sliceFillGrow: 0,
sliceFillAngle: 45,

View file

@ -29,6 +29,7 @@ const LISTS = {
{ name: "last" },
{ name: "center" },
{ name: "origin" },
{ name: "random" },
],
infill: [
{ name: "hex" },