From 06c61a3cf61c34cf665bc2e8f517259e7ab5374d Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Sun, 8 May 2016 10:31:00 +0200 Subject: [PATCH] move set settings to constructor --- src/gcode.js | 6 +++++- src/sliceActions/slicesToGCode.js | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gcode.js b/src/gcode.js index efba660..506f05e 100644 --- a/src/gcode.js +++ b/src/gcode.js @@ -10,7 +10,7 @@ const POSITION_Y = 'Y'; const POSITION_Z = 'Z'; export default class { - constructor () { + constructor (settings) { this.gcode = ''; this.current = {}; @@ -19,6 +19,10 @@ export default class { this.isRetracted = false; this.isFanOn = false; this._nozzlePosition = new THREE.Vector2(0, 0); + + if (settings !== undefined) { + this.setSettings(settings); + } } _addGCode (command) { diff --git a/src/sliceActions/slicesToGCode.js b/src/sliceActions/slicesToGCode.js index 7ab7df9..cfa6f5e 100644 --- a/src/sliceActions/slicesToGCode.js +++ b/src/sliceActions/slicesToGCode.js @@ -3,7 +3,7 @@ import GCode from '../gcode.js'; export default function slicesToGCode(slices, settings) { console.log('slices to gcode'); - const gcode = new GCode().setSettings(settings); + const gcode = new GCode(settings); for (let layer = 0; layer < slices.length; layer ++) { const slice = slices[layer];