move z offset to constant

This commit is contained in:
casperlamboo 2018-01-18 14:24:01 +01:00
parent 60c70cdbd5
commit 0bb646a5ac
4 changed files with 11 additions and 11 deletions

View File

@ -1,3 +1,4 @@
export const PRECISION = 0.01;
export const VERSION = '0.0.18';
export const LOCAL_STORAGE_KEY = 'PRINTER_SETTINGS';
export const Z_OFFSET = 0.3;

View File

@ -1,4 +1,3 @@
zOffset: 0.3
dimensions:
x: 200
y: 200

View File

@ -1,11 +1,12 @@
import { Z_OFFSET } from '../constants.js';
export default function calculateLayersIntersections(lines, settings) {
const {
dimensions: { z: dimensionsZ },
layerHeight,
zOffset
layerHeight
} = settings;
const numLayers = Math.floor((dimensionsZ - zOffset) / layerHeight);
const numLayers = Math.floor((dimensionsZ - Z_OFFSET) / layerHeight);
const layers = Array.from(Array(numLayers)).map(() => ({
points: {},
@ -15,12 +16,12 @@ export default function calculateLayersIntersections(lines, settings) {
for (let lineIndex = 0; lineIndex < lines.length; lineIndex ++) {
const { line, faces } = lines[lineIndex];
const min = Math.ceil((Math.min(line.start.y, line.end.y) - zOffset) / layerHeight);
const max = Math.floor((Math.max(line.start.y, line.end.y) - zOffset) / layerHeight);
const min = Math.ceil((Math.min(line.start.y, line.end.y) - Z_OFFSET) / layerHeight);
const max = Math.floor((Math.max(line.start.y, line.end.y) - Z_OFFSET) / layerHeight);
for (let layerIndex = min; layerIndex <= max; layerIndex ++) {
if (layerIndex >= 0 && layerIndex < numLayers) {
const y = layerIndex * layerHeight + zOffset;
const y = layerIndex * layerHeight + Z_OFFSET;
let x, z;
if (line.start.y === line.end.y) {

View File

@ -1,6 +1,6 @@
import GCode from './helpers/GCode.js';
import comb from './helpers/comb.js';
import { PRECISION } from '../constants.js';
import { PRECISION, Z_OFFSET } from '../constants.js';
const PROFILE_TYPES = ['support', 'innerShell', 'outerShell', 'innerInfill', 'outerInfill', 'brim'];
@ -12,8 +12,7 @@ export default function slicesToGCode(slices, settings) {
travelSpeed,
retraction,
travel,
combing,
zOffset
combing
} = settings;
const filamentSurfaceArea = Math.pow((filamentThickness / 2), 2) * Math.PI;
@ -32,7 +31,7 @@ export default function slicesToGCode(slices, settings) {
let isFirstLayer = true;
for (let layer = 0; layer < slices.length; layer ++) {
const slice = slices[layer];
const z = layer * layerHeight + zOffset;
const z = layer * layerHeight + Z_OFFSET;
if (layer === 1) {
gcode.turnFanOn();