add "random" and "position" sliceLayerStart and fix origin
This commit is contained in:
parent
f5cf5d9238
commit
bfe87bec8b
1 changed files with 25 additions and 1 deletions
|
|
@ -784,9 +784,11 @@ FDM.prepare = async function(widgets, settings, update) {
|
||||||
function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
||||||
const { settings } = print;
|
const { settings } = print;
|
||||||
const { device } = settings;
|
const { device } = settings;
|
||||||
|
const { bedWidth, bedDepth, bedRound } = device;
|
||||||
|
|
||||||
let preout = [],
|
let preout = [],
|
||||||
process = opt.params || settings.process,
|
process = opt.params || settings.process,
|
||||||
|
originCenter = process.outputOriginCenter || bedRound,
|
||||||
extruder = slice.extruder || 0,
|
extruder = slice.extruder || 0,
|
||||||
nozzleSize = process.sliceLineWidth || device.extruders[extruder].extNozzle,
|
nozzleSize = process.sliceLineWidth || device.extruders[extruder].extNozzle,
|
||||||
firstLayer = opt.first || false,
|
firstLayer = opt.first || false,
|
||||||
|
|
@ -810,6 +812,15 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
||||||
antiBacklash = process.antiBacklash,
|
antiBacklash = process.antiBacklash,
|
||||||
wipeDist = process.outputRetractWipe || 0,
|
wipeDist = process.outputRetractWipe || 0,
|
||||||
isBelt = device.bedBelt,
|
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,
|
beltFirst = process.outputBeltFirst || false,
|
||||||
startClone = startPoint.clone(),
|
startClone = startPoint.clone(),
|
||||||
seedPoint = opt.seedPoint || startPoint,
|
seedPoint = opt.seedPoint || startPoint,
|
||||||
|
|
@ -1376,11 +1387,24 @@ function slicePrintPath(print, slice, startPoint, offset, output, opt = {}) {
|
||||||
switch (process.sliceLayerStart) {
|
switch (process.sliceLayerStart) {
|
||||||
case "last":
|
case "last":
|
||||||
break;
|
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":
|
case "center":
|
||||||
startPoint = newPoint(0,0,startPoint.z);
|
startPoint = newPoint(0,0,startPoint.z);
|
||||||
break;
|
break;
|
||||||
case "origin":
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue