mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-22 05:37:55 +01:00
move casting to string in slice.js
This commit is contained in:
parent
6a63077b55
commit
bc06f703ac
@ -11,9 +11,6 @@ export const POSITION_Y = 'Y';
|
||||
export const POSITION_Z = 'Z';
|
||||
|
||||
const PRECISION_INVERSE = 1 / PRECISION;
|
||||
function toFixedTrimmed(value) {
|
||||
return (Math.round(value * PRECISION_INVERSE) / PRECISION_INVERSE).toString();
|
||||
}
|
||||
|
||||
export default class {
|
||||
constructor(layerHeight) {
|
||||
@ -64,10 +61,10 @@ export default class {
|
||||
|
||||
this._addGCode({
|
||||
[MOVE]: 0,
|
||||
[POSITION_X]: toFixedTrimmed(newNozzlePosition.x),
|
||||
[POSITION_Y]: toFixedTrimmed(newNozzlePosition.y),
|
||||
[POSITION_Z]: toFixedTrimmed(z),
|
||||
[SPEED]: toFixedTrimmed(speed * 60)
|
||||
[POSITION_X]: newNozzlePosition.x,
|
||||
[POSITION_Y]: newNozzlePosition.y,
|
||||
[POSITION_Z]: z,
|
||||
[SPEED]: speed * 60
|
||||
});
|
||||
|
||||
this._nozzlePosition = newNozzlePosition;
|
||||
@ -84,11 +81,11 @@ export default class {
|
||||
|
||||
this._addGCode({
|
||||
[MOVE]: 1,
|
||||
[POSITION_X]: toFixedTrimmed(newNozzlePosition.x),
|
||||
[POSITION_Y]: toFixedTrimmed(newNozzlePosition.y),
|
||||
[POSITION_Z]: toFixedTrimmed(z),
|
||||
[SPEED]: toFixedTrimmed(speed * 60),
|
||||
[EXTRUDER]: toFixedTrimmed(this._extruder)
|
||||
[POSITION_X]: newNozzlePosition.x,
|
||||
[POSITION_Y]: newNozzlePosition.y,
|
||||
[POSITION_Z]: z,
|
||||
[SPEED]: speed * 60,
|
||||
[EXTRUDER]: this._extruder
|
||||
});
|
||||
|
||||
this._nozzlePosition = newNozzlePosition;
|
||||
@ -105,8 +102,8 @@ export default class {
|
||||
|
||||
this._addGCode({
|
||||
[MOVE]: 0,
|
||||
[EXTRUDER]: toFixedTrimmed(this._extruder),
|
||||
[SPEED]: toFixedTrimmed(speed * 60)
|
||||
[EXTRUDER]: this._extruder,
|
||||
[SPEED]: speed * 60
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -123,8 +120,8 @@ export default class {
|
||||
|
||||
this._addGCode({
|
||||
[MOVE]: 0,
|
||||
[EXTRUDER]: toFixedTrimmed(this._extruder - amount),
|
||||
[SPEED]: toFixedTrimmed(speed * 60)
|
||||
[EXTRUDER]: this._extruder - amount,
|
||||
[SPEED]: speed * 60
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ import optimizePaths from './optimizePaths.js';
|
||||
import shapesToSlices from './shapesToSlices.js';
|
||||
import slicesToGCode from './slicesToGCode.js';
|
||||
import applyPrecision from './applyPrecision.js';
|
||||
import { PRECISION } from '../constants.js';
|
||||
// // import removePrecision from './removePrecision.js';
|
||||
|
||||
export default function(settings, geometry, openObjectIndexes, constructLinePreview, onProgress) {
|
||||
@ -68,6 +69,11 @@ export default function(settings, geometry, openObjectIndexes, constructLinePrev
|
||||
return gcode;
|
||||
}
|
||||
|
||||
const PRECISION_INVERSE = 1 / PRECISION;
|
||||
function toFixedTrimmed(value) {
|
||||
return (Math.round(value * PRECISION_INVERSE) / PRECISION_INVERSE).toString();
|
||||
}
|
||||
|
||||
function gcodeToString(gcode) {
|
||||
const currentValues = {};
|
||||
return gcode.reduce((string, command) => {
|
||||
@ -76,7 +82,7 @@ function gcodeToString(gcode) {
|
||||
} else {
|
||||
let first = true;
|
||||
for (const action in command) {
|
||||
const value = command[action];
|
||||
const value = toFixedTrimmed(command[action]);
|
||||
const currentValue = currentValues[action];
|
||||
if (first) {
|
||||
string += `${action}${value}`;
|
||||
|
Loading…
Reference in New Issue
Block a user