mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-12-23 11:33:49 +01:00
remove settings class
This commit is contained in:
parent
622be82706
commit
4a238f9089
@ -1,16 +1,12 @@
|
||||
import 'three.js';
|
||||
import { Settings, defaultSettings, Slicer } from 'src/index.js';
|
||||
import { defaultSettings, Slicer } from 'src/index.js';
|
||||
import { saveAs } from 'file-saver';
|
||||
|
||||
console.log('defaultSettings: ', defaultSettings);
|
||||
|
||||
const settings = {
|
||||
...defaultSettings.base,
|
||||
...defaultSettings.material.pla,
|
||||
...defaultSettings.printer.ultimaker2go,
|
||||
...defaultSettings.quality.high,
|
||||
startCode: '',
|
||||
endCode: ''
|
||||
...defaultSettings.quality.high
|
||||
};
|
||||
|
||||
const jsonLoader = new THREE.JSONLoader();
|
||||
|
@ -28,7 +28,7 @@ stlLoader.load('stl/Airplane.stl', (geometry) => {
|
||||
layerIntersectionPoints={rawData.layerIntersectionPoints}
|
||||
layerShapes={rawData.layerShapes}
|
||||
slices={rawData.slices}
|
||||
settings={settings.config}
|
||||
settings={settings}
|
||||
/>,
|
||||
document.getElementById('container')
|
||||
);
|
||||
|
12
src/GCode.js
12
src/GCode.js
@ -66,7 +66,7 @@ export default class {
|
||||
const {
|
||||
layerHeight,
|
||||
travelSpeed
|
||||
} = this._settings.config;
|
||||
} = this._settings;
|
||||
|
||||
const z = layer * layerHeight + 0.2;
|
||||
const speed = travelSpeed * 60;
|
||||
@ -92,9 +92,9 @@ export default class {
|
||||
nozzleDiameter,
|
||||
filamentThickness,
|
||||
travelSpeed
|
||||
} = this._settings.config;
|
||||
} = this._settings;
|
||||
|
||||
const profile = this._settings.config[(this.bottom ? 'bottom' : type)];
|
||||
const profile = this._settings[(this.bottom ? 'bottom' : type)];
|
||||
|
||||
let {
|
||||
speed,
|
||||
@ -130,7 +130,7 @@ export default class {
|
||||
minDistance: retractionMinDistance,
|
||||
speed: retractionSpeed
|
||||
}
|
||||
} = this._settings.config;
|
||||
} = this._settings;
|
||||
|
||||
if (this._isRetracted && retractionEnabled) {
|
||||
this._isRetracted = false;
|
||||
@ -157,7 +157,7 @@ export default class {
|
||||
minDistance: retractionMinDistance,
|
||||
speed: retractionSpeed
|
||||
}
|
||||
} = this._settings.config;
|
||||
} = this._settings;
|
||||
|
||||
if (!this._isRetracted && retractionEnabled) {
|
||||
this._isRetracted = true;
|
||||
@ -177,6 +177,6 @@ export default class {
|
||||
}
|
||||
|
||||
getGCode() {
|
||||
return this._settings.startCode() + this._gcode + this._settings.endCode();
|
||||
return this._gcode;
|
||||
}
|
||||
}
|
||||
|
@ -1,53 +0,0 @@
|
||||
export default class {
|
||||
constructor(config = {}) {
|
||||
this.config = config;
|
||||
}
|
||||
updateConfig(config) {
|
||||
this.config = { ...this.config, ...config };
|
||||
|
||||
return this;
|
||||
}
|
||||
startCode() {
|
||||
const { startCode } = this.config;
|
||||
const gcode = this._subsituteVariables(startCode);
|
||||
return gcode;
|
||||
}
|
||||
endCode() {
|
||||
const { endCode } = this.config;
|
||||
const gcode = this._subsituteVariables(endCode);
|
||||
return gcode;
|
||||
}
|
||||
_subsituteVariables(gcode) {
|
||||
let {
|
||||
temperature,
|
||||
bedTemperature,
|
||||
heatTemperature,
|
||||
heatBedTemperature,
|
||||
travelSpeed,
|
||||
printerType,
|
||||
heatedBed
|
||||
} = this.config;
|
||||
|
||||
travelSpeed *= 60;
|
||||
|
||||
switch (printerType) {
|
||||
case 'makerbot_replicator2': printerType = 'r2'; break;
|
||||
case 'makerbot_replicator2x': printerType = 'r2x'; break;
|
||||
case 'makerbot_thingomatic': printerType = 't6'; break;
|
||||
case 'makerbot_generic': printerType = 'r2'; break;
|
||||
case '_3Dison_plus': printerType = 'r2'; break;
|
||||
}
|
||||
|
||||
const heatedBedReplacement = heatedBed ? '' : ';';
|
||||
|
||||
gcode = gcode.replace(/{printingTemp}/gi, temperature);
|
||||
gcode = gcode.replace(/{printingBedTemp}/gi, bedTemperature);
|
||||
gcode = gcode.replace(/{preheatTemp}/gi, heatTemperature);
|
||||
gcode = gcode.replace(/{preheatBedTemp}/gi, heatBedTemperature);
|
||||
gcode = gcode.replace(/{printerType}/gi, printerType);
|
||||
gcode = gcode.replace(/{travelSpeed}/gi, travelSpeed);
|
||||
gcode = gcode.replace(/{if heatedBed}/gi, heatedBedReplacement);
|
||||
|
||||
return gcode;
|
||||
}
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
import * as THREE from 'three.js';
|
||||
import Settings from './Settings.js';
|
||||
import slice from './sliceActions/slice.js';
|
||||
import SlicerWorker from './slicerWorker.js!worker';
|
||||
|
||||
@ -29,13 +28,12 @@ export default class {
|
||||
return this;
|
||||
}
|
||||
sliceSync(settings) {
|
||||
return slice(this.geometry, new Settings(settings));
|
||||
return slice(this.geometry, settings);
|
||||
}
|
||||
slice(settings) {
|
||||
const slicerWorker = new SlicerWorker();
|
||||
|
||||
const geometry = this.geometry.toJSON();
|
||||
const { config } = new Settings(settings);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
slicerWorker.onerror = reject;
|
||||
@ -58,7 +56,7 @@ export default class {
|
||||
|
||||
slicerWorker.postMessage({
|
||||
message: 'SLICE',
|
||||
data: { geometry, config }
|
||||
data: { geometry, settings }
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ const offsetOptions = {
|
||||
export default function addBrim(slices, settings) {
|
||||
console.log('add brim');
|
||||
|
||||
let { brim: { offset: brimOffset } } = settings.config;
|
||||
let { brim: { offset: brimOffset } } = settings;
|
||||
brimOffset /= PRECISION;
|
||||
|
||||
const [firstLayer] = slices;
|
||||
|
@ -3,7 +3,7 @@ import * as THREE from 'three.js';
|
||||
export default function calculateLayersIntersections(lines, settings) {
|
||||
console.log('calculating layer intersections');
|
||||
|
||||
const { layerHeight, dimensions: { z: dimensionsZ } } = settings.config;
|
||||
const { layerHeight, dimensions: { z: dimensionsZ } } = settings;
|
||||
|
||||
const numLayers = Math.floor(dimensionsZ / layerHeight);
|
||||
|
||||
|
@ -12,7 +12,7 @@ export default function generateInfills(slices, settings) {
|
||||
top: { thickness: topThickness },
|
||||
nozzleDiameter,
|
||||
fill: { overlap: infillOverlap }
|
||||
} = settings.config;
|
||||
} = settings;
|
||||
|
||||
fillGridSize /= PRECISION;
|
||||
nozzleDiameter /= PRECISION;
|
||||
|
@ -11,7 +11,7 @@ export default function generateInnerLines(slices, settings) {
|
||||
console.log('generating outer lines and inner lines');
|
||||
|
||||
// need to scale up everything because of clipper rounding errors
|
||||
let { layerHeight, nozzleDiameter, shell: { thickness: shellThickness } } = settings.config;
|
||||
let { layerHeight, nozzleDiameter, shell: { thickness: shellThickness } } = settings;
|
||||
nozzleDiameter /= PRECISION;
|
||||
shellThickness /= PRECISION;
|
||||
const nozzleRadius = nozzleDiameter / 2;
|
||||
|
@ -5,7 +5,7 @@ import { PRECISION } from '../constants.js';
|
||||
export default function generateSupport(slices, settings) {
|
||||
console.log('generating support');
|
||||
|
||||
if (!settings.config.support.enabled) return;
|
||||
if (!settings.support.enabled) return;
|
||||
|
||||
let {
|
||||
layerHeight,
|
||||
@ -16,7 +16,7 @@ export default function generateSupport(slices, settings) {
|
||||
distanceY: DistanceY
|
||||
},
|
||||
nozzleDiameter
|
||||
} = settings.config;
|
||||
} = settings;
|
||||
|
||||
supportGridSize /= PRECISION;
|
||||
supportMargin /= PRECISION;
|
||||
|
@ -17,7 +17,7 @@ export default function(geometry, settings, onProgress) {
|
||||
let current = 0;
|
||||
const progressMessage = () => {
|
||||
current ++;
|
||||
postMessage({ message: 'PROGRESS', data: { done: current, total: totalStages } });
|
||||
// postMessage({ message: 'PROGRESS', data: { done: current, total: totalStages } });
|
||||
};
|
||||
|
||||
geometry.computeFaceNormals();
|
||||
|
@ -1,4 +1,3 @@
|
||||
import Settings from './Settings.js';
|
||||
import slice from './sliceActions/slice.js';
|
||||
import * as THREE from 'three.js';
|
||||
|
||||
@ -8,10 +7,9 @@ self.addEventListener('message', (event) => {
|
||||
const { message, data } = event.data;
|
||||
switch (message) {
|
||||
case 'SLICE': {
|
||||
const { geometry: JSONGeometry, config } = data;
|
||||
const { geometry: JSONGeometry, settings } = data;
|
||||
|
||||
const { geometry } = new loader.parse(JSONGeometry.data);
|
||||
const settings = new Settings(config);
|
||||
|
||||
const gcode = slice(geometry, settings);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user