checkpoint sla work
This commit is contained in:
parent
3d1ad7169c
commit
1e98f81cc6
14 changed files with 643 additions and 486 deletions
|
|
@ -124,4 +124,16 @@
|
|||
return this.split('').reverse().join('');
|
||||
};
|
||||
|
||||
/** ******************************************************************
|
||||
* Object static helpers
|
||||
******************************************************************* */
|
||||
|
||||
Object.clone = function(o) {
|
||||
return o ? JSON.parse(JSON.stringify(o)) : o;
|
||||
};
|
||||
|
||||
Math.bound = function(val,min,max) {
|
||||
return Math.max(min,Math.min(max,val));
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
706
js/kiri-conf.js
706
js/kiri-conf.js
|
|
@ -6,11 +6,12 @@ let gs_kiri_conf = exports;
|
|||
|
||||
(function() {
|
||||
|
||||
if (!self.kiri) self.kiri = { };
|
||||
if (!self.kiri) self.kiri = {};
|
||||
if (self.kiri.conf) return;
|
||||
|
||||
let KIRI = self.kiri,
|
||||
CVER = 185;
|
||||
CVER = 185,
|
||||
clone = Object.clone;
|
||||
|
||||
function genID() {
|
||||
while (true) {
|
||||
|
|
@ -19,37 +20,47 @@ let gs_kiri_conf = exports;
|
|||
}
|
||||
}
|
||||
|
||||
// add fields to o(bject) from t(arget) that are missing
|
||||
// remove fields from o(bject) that don't exist in f(ilter)
|
||||
function fill_cull(o, t, f) {
|
||||
if (!o) return;
|
||||
// add fields to o(bject) from d(efault) that are missing
|
||||
// remove fields from o(bject) that don't exist in d(efault)
|
||||
function fill_cull_once(obj, def) {
|
||||
if (!obj) return;
|
||||
// add missing
|
||||
for (let k in t) {
|
||||
if (!t.hasOwnProperty(k)) {
|
||||
continue;
|
||||
}
|
||||
let okv = o[k];
|
||||
if (f[k] !== undefined && (okv === undefined || okv === null)) {
|
||||
// console.log({fill: k});
|
||||
o[k] = t[k];
|
||||
for (let k in def) {
|
||||
if (def.hasOwnProperty(k)) {
|
||||
let okv = obj[k];
|
||||
if ((okv === undefined || okv === null)) {
|
||||
// console.log({fill: k});
|
||||
obj[k] = def[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
// remove invalid
|
||||
for (let k in o) {
|
||||
if (!o.hasOwnProperty(k)) {
|
||||
continue;
|
||||
}
|
||||
if (!f.hasOwnProperty(k)) {
|
||||
for (let k in obj) {
|
||||
if (!def.hasOwnProperty(k)) {
|
||||
// console.log({cull: k});
|
||||
delete o[k];
|
||||
delete obj[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fill_cull_many(map, def) {
|
||||
forValues(map, (obj) => { fill_cull_once(obj, def) });
|
||||
}
|
||||
|
||||
function objectMap(o, fn) {
|
||||
for (let [key, val] of Object.entries(o)) {
|
||||
o[key] = fn(val) || val;
|
||||
}
|
||||
}
|
||||
|
||||
function valueOf(val, dv) {
|
||||
return typeof(val) !== 'undefined' ? val : dv;
|
||||
}
|
||||
|
||||
function forValues(o, fn) {
|
||||
Object.values(o).forEach(v => fn(v));
|
||||
}
|
||||
|
||||
function device_v1_to_v2(device) {
|
||||
if (device && device.filamentSize) {
|
||||
device.extruders = [{
|
||||
|
|
@ -74,6 +85,8 @@ let gs_kiri_conf = exports;
|
|||
set = code.settings || {},
|
||||
ext = code.extruders;
|
||||
|
||||
// currently causes unecessary fills and culls because
|
||||
// it's not mode and device type sensitive
|
||||
let device = {
|
||||
mode: mode || code.mode || '',
|
||||
internal: 0,
|
||||
|
|
@ -106,7 +119,7 @@ let gs_kiri_conf = exports;
|
|||
if (ext) {
|
||||
// synthesize extruders from new style settings
|
||||
ext.forEach(rec => {
|
||||
let e = API.clone(CONF.template.device.extruders[0]);
|
||||
let e = API.clone(CONF.defaults.fdm.d.extruders[0]);
|
||||
if (rec.nozzle) e.extNozzle = rec.nozzle;
|
||||
if (rec.filament) e.extFilament = rec.filament;
|
||||
if (rec.offset_x) e.extOffsetX = rec.offset_x;
|
||||
|
|
@ -116,7 +129,7 @@ let gs_kiri_conf = exports;
|
|||
});
|
||||
} else {
|
||||
// synthesize extruders from old style settings
|
||||
device.extruders = [API.clone(CONF.template.device.extruders[0])];
|
||||
device.extruders = [API.clone(CONF.defaults.fdm.d.extruders[0])];
|
||||
device.extruders[0].extNozzle = valueOf(set.nozzle_size, 0.4);
|
||||
device.extruders[0].extFilament = valueOf(set.filament_diameter, 1.75);
|
||||
}
|
||||
|
|
@ -124,36 +137,14 @@ let gs_kiri_conf = exports;
|
|||
return device;
|
||||
}
|
||||
|
||||
function objectMap(o, fn) {
|
||||
for (let [key, val] of Object.entries(o)) {
|
||||
o[key] = fn(val) || val;
|
||||
}
|
||||
}
|
||||
|
||||
function forValues(o, fn) {
|
||||
Object.values(o).forEach(v => fn(v));
|
||||
}
|
||||
|
||||
// ensure settings structure is up-to-date
|
||||
function normalize(settings) {
|
||||
let API = KIRI.api,
|
||||
filter = CONF.filter,
|
||||
defaults = CONF.template,
|
||||
filter_dev = filter.fdm.d,
|
||||
filter_pro = filter.fdm.p;
|
||||
|
||||
switch (settings.mode) {
|
||||
case 'FDM':
|
||||
break;
|
||||
case 'CAM':
|
||||
filter_dev = filter.cam.d;
|
||||
filter_pro = filter.cam.p;
|
||||
break;
|
||||
case 'LASER':
|
||||
filter_dev = filter.laser.d;
|
||||
filter_pro = filter.laser.p;
|
||||
break;
|
||||
}
|
||||
defaults = CONF.defaults,
|
||||
template = CONF.template,
|
||||
mode = settings.mode.toLowerCase(),
|
||||
default_dev = defaults[mode].d,
|
||||
default_pro = defaults[mode].p;
|
||||
|
||||
// v1 to v2 changed FDM extruder / nozzle / filament structure
|
||||
if (settings.ver != CVER) {
|
||||
|
|
@ -167,22 +158,22 @@ let gs_kiri_conf = exports;
|
|||
settings.ver = CVER;
|
||||
}
|
||||
|
||||
fill_cull(settings, defaults, defaults);
|
||||
fill_cull(settings.device, defaults.device, filter_dev);
|
||||
fill_cull(settings.process, defaults.process, filter_pro);
|
||||
fill_cull(settings.cdev.FDM, defaults.device, filter.fdm.d);
|
||||
forValues(settings.sproc.FDM, proc => {
|
||||
fill_cull(proc, defaults.process, filter.fdm.p);
|
||||
});
|
||||
fill_cull(settings.cdev.CAM, defaults.device, filter.cam.d);
|
||||
forValues(settings.sproc.CAM, proc => {
|
||||
fill_cull(proc, defaults.process, filter.cam.p);
|
||||
});
|
||||
fill_cull(settings.cdev.LASER, defaults.device, filter.laser.d);
|
||||
forValues(settings.sproc.LASER, proc => {
|
||||
fill_cull(proc, defaults.process, filter.laser.p);
|
||||
});
|
||||
fill_cull(settings.controller, defaults.controller, defaults.controller);
|
||||
fill_cull_once(settings, template);
|
||||
fill_cull_once(settings.device, default_dev);
|
||||
fill_cull_once(settings.process, default_pro);
|
||||
fill_cull_once(settings.cdev, template.cdev);
|
||||
fill_cull_once(settings.cproc, template.cproc);
|
||||
fill_cull_once(settings.sproc, template.sproc);
|
||||
fill_cull_once(settings.defaults, template.defaults);
|
||||
fill_cull_once(settings.cdev.FDM, defaults.fdm.d);
|
||||
fill_cull_once(settings.cdev.SLA, defaults.sla.d);
|
||||
fill_cull_once(settings.cdev.CAM, defaults.cam.d);
|
||||
fill_cull_once(settings.cdev.LASER, defaults.laser.d);
|
||||
fill_cull_many(settings.sproc.FDM, defaults.fdm.p);
|
||||
fill_cull_many(settings.sproc.SLA, defaults.sla.p);
|
||||
fill_cull_many(settings.sproc.CAM, defaults.cam.p);
|
||||
fill_cull_many(settings.sproc.LASER, defaults.laser.p);
|
||||
fill_cull_once(settings.controller, template.controller);
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
|
@ -194,210 +185,237 @@ let gs_kiri_conf = exports;
|
|||
// ---------------
|
||||
MODES: {
|
||||
FDM: 1, // fused deposition modeling (also FFF)
|
||||
LASER: 2, // laser cutting
|
||||
CAM: 3 // 3 axis milling/machining
|
||||
LASER: 2, // laser cutters
|
||||
CAM: 3, // 3 axis milling/machining
|
||||
SLA: 4 // cured resin printers
|
||||
},
|
||||
VIEWS: {
|
||||
ARRANGE: 1,
|
||||
SLICE: 2,
|
||||
PREVIEW: 3
|
||||
},
|
||||
// --------------- settings field filters
|
||||
filter: {
|
||||
// --------------- device and process defaults
|
||||
defaults: {
|
||||
fdm:{
|
||||
// fields permitted in FDM:Device
|
||||
// device defaults FDM:Device
|
||||
d:{
|
||||
mode: 1,
|
||||
internal: 1,
|
||||
bedWidth: 1,
|
||||
bedDepth: 1,
|
||||
bedHeight: 1,
|
||||
bedRound: 1,
|
||||
maxHeight: 1,
|
||||
extrudeAbs: 1,
|
||||
originCenter: 1,
|
||||
gcodePre: 1,
|
||||
gcodePost: 1,
|
||||
gcodeProc: 1,
|
||||
gcodePause: 1,
|
||||
gcodeFExt: 1,
|
||||
gcodeFan: 1,
|
||||
gcodeTrack: 1,
|
||||
gcodeLayer: 1,
|
||||
extruders: 1
|
||||
mode: "",
|
||||
internal: 0,
|
||||
bedWidth: 300,
|
||||
bedDepth: 175,
|
||||
bedHeight: 2.5,
|
||||
bedRound: false,
|
||||
originCenter: false,
|
||||
maxHeight: 150,
|
||||
gcodePre: [],
|
||||
gcodePost: [],
|
||||
gcodePause: [],
|
||||
gcodeProc: "",
|
||||
gcodeFan: "",
|
||||
gcodeTrack: "",
|
||||
gcodeLayer: [],
|
||||
gcodeFExt: "",
|
||||
extruders:[{
|
||||
extFilament: 1.75,
|
||||
extNozzle: 0.4,
|
||||
extSelect: ["T0"],
|
||||
extOffsetX: 0,
|
||||
extOffsetY: 0
|
||||
}]
|
||||
},
|
||||
// fields permitted in FDM:Process
|
||||
// process defaults FDM:Process
|
||||
p:{
|
||||
processName: 1,
|
||||
sliceHeight: 1,
|
||||
sliceShells: 1,
|
||||
sliceFillAngle: 1,
|
||||
sliceFillOverlap: 1,
|
||||
sliceFillSparse: 1,
|
||||
sliceFillType: 1,
|
||||
sliceSupportEnable: 1,
|
||||
sliceSupportDensity: 1,
|
||||
sliceSupportOffset: 1,
|
||||
processName: "default",
|
||||
sliceHeight: 0.25,
|
||||
sliceShells: 3,
|
||||
sliceFillAngle: 45,
|
||||
sliceFillOverlap: 0.3,
|
||||
sliceFillSparse: 0.5,
|
||||
sliceFillType: "hex",
|
||||
sliceSupportEnable: false,
|
||||
sliceSupportDensity: 0.25,
|
||||
sliceSupportOffset: 1.0,
|
||||
sliceSupportGap: 1,
|
||||
sliceSupportSize: 1,
|
||||
sliceSupportSize: 10,
|
||||
sliceSupportArea: 1,
|
||||
sliceSupportExtra: 1,
|
||||
sliceSupportSpan: 1,
|
||||
sliceSupportNozzle: 1,
|
||||
sliceSupportExtra: 0,
|
||||
sliceSupportSpan: 6,
|
||||
sliceSupportNozzle: 0,
|
||||
sliceSolidMinArea: 1,
|
||||
sliceSolidLayers: 1,
|
||||
sliceBottomLayers: 1,
|
||||
sliceTopLayers: 1,
|
||||
firstSliceHeight: 1,
|
||||
firstLayerRate: 1,
|
||||
firstLayerFillRate: 1,
|
||||
firstLayerPrintMult: 1,
|
||||
firstLayerNozzleTemp: 1,
|
||||
firstLayerBedTemp: 1,
|
||||
outputRaft: 1,
|
||||
outputRaftSpacing: 1,
|
||||
outputTemp: 1,
|
||||
outputFanMax: 1,
|
||||
outputBedTemp: 1,
|
||||
outputFeedrate: 1,
|
||||
outputFinishrate: 1,
|
||||
outputSeekrate: 1,
|
||||
outputShellMult: 1,
|
||||
outputFillMult: 1,
|
||||
outputSparseMult: 1,
|
||||
sliceSolidLayers: 3,
|
||||
sliceBottomLayers: 3,
|
||||
sliceTopLayers: 3,
|
||||
firstSliceHeight: 0.25,
|
||||
firstLayerRate: 30,
|
||||
firstLayerFillRate: 40,
|
||||
firstLayerPrintMult: 1.0,
|
||||
firstLayerNozzleTemp: 0,
|
||||
firstLayerBedTemp: 0,
|
||||
outputRaft: false,
|
||||
outputRaftSpacing: 0.2,
|
||||
outputTemp: 200,
|
||||
outputFanMax: 255,
|
||||
outputBedTemp: 0,
|
||||
outputFeedrate: 80,
|
||||
outputFinishrate: 60,
|
||||
outputSeekrate: 100,
|
||||
outputShellMult: 1.2,
|
||||
outputFillMult: 1.2,
|
||||
outputSparseMult: 1.2,
|
||||
outputFanLayer: 1,
|
||||
outputRetractDist: 1,
|
||||
outputRetractSpeed: 1,
|
||||
outputRetractDwell: 1,
|
||||
outputBrimCount: 1,
|
||||
outputBrimOffset: 1,
|
||||
outputShortPoly: 1,
|
||||
outputMinSpeed: 1,
|
||||
outputCoastDist: 1,
|
||||
outputWipeDistance: 1,
|
||||
sliceMinHeight: 1,
|
||||
// detectThinWalls: 1,
|
||||
outputRetractDist: 1.0,
|
||||
outputRetractSpeed: 40,
|
||||
outputRetractDwell: 30,
|
||||
outputBrimCount: 2,
|
||||
outputBrimOffset: 2,
|
||||
outputShortPoly: 50.0,
|
||||
outputMinSpeed: 15.0,
|
||||
outputCoastDist: 0,
|
||||
outputWipeDistance: 0,
|
||||
sliceMinHeight: 0,
|
||||
detectThinWalls: false,
|
||||
antiBacklash: 1,
|
||||
zHopDistance: 1,
|
||||
// polishLayers: 1,
|
||||
// polishSpeed: 1,
|
||||
outputLayerRetract: 1,
|
||||
gcodePauseLayers: 1,
|
||||
outputClockwise: 1,
|
||||
outputOriginCenter: 1,
|
||||
outputInvertX: 1,
|
||||
outputInvertY: 1
|
||||
zHopDistance: 0.2,
|
||||
outputLayerRetract: false,
|
||||
gcodePause: "",
|
||||
outputOriginCenter: true,
|
||||
outputInvertX: false,
|
||||
outputInvertY: false,
|
||||
}
|
||||
},
|
||||
sla:{
|
||||
// device defaults SLA:Device
|
||||
d:{
|
||||
mode: "",
|
||||
internal: 0,
|
||||
bedWidth: 150,
|
||||
bedDepth: 150,
|
||||
bedHeight: 2.5,
|
||||
maxHeight: 150,
|
||||
originCenter: false
|
||||
},
|
||||
// process defaults SLA:Process
|
||||
p:{
|
||||
processName: "default",
|
||||
slaSlice: 0.05,
|
||||
slaSupportEnable: false,
|
||||
slaSupportDensity: 0.5,
|
||||
slaSupportSize: 2,
|
||||
slaSupportArea: 1,
|
||||
slaSupportSpan: 2,
|
||||
slaSolidLayers: 5,
|
||||
slaBottomLayers: 5,
|
||||
slaTopLayers: 5
|
||||
}
|
||||
},
|
||||
cam:{
|
||||
// fields permitted in CAM:Device
|
||||
// device defaults CAM:Device
|
||||
d:{
|
||||
mode: 1,
|
||||
internal: 1,
|
||||
bedWidth: 1,
|
||||
bedDepth: 1,
|
||||
bedHeight: 1,
|
||||
originCenter: 1,
|
||||
spindleMax: 1,
|
||||
gcodePre: 1,
|
||||
gcodePost: 1,
|
||||
gcodeDwell: 1,
|
||||
gcodeChange: 1,
|
||||
gcodeSpindle: 1,
|
||||
gcodeFExt: 1,
|
||||
gcodeSpace: 1,
|
||||
gcodeStrip: 1
|
||||
mode: "",
|
||||
internal: 0,
|
||||
bedWidth: 300,
|
||||
bedDepth: 175,
|
||||
bedHeight: 2.5,
|
||||
originCenter: false,
|
||||
spindleMax: 0,
|
||||
gcodePre: [],
|
||||
gcodePost: [],
|
||||
gcodeFExt: "",
|
||||
gcodeSpace: true,
|
||||
gcodeStrip: true,
|
||||
gcodeDwell: ["G4 P{time}"],
|
||||
gcodeChange: ["M6 T{tool}"],
|
||||
gcodeSpindle: ["M3 S{speed}"]
|
||||
},
|
||||
// fields permitted in CAM:Process
|
||||
// process defaults CAM:Process
|
||||
p:{
|
||||
processName: 1,
|
||||
camFastFeed: 1,
|
||||
roughingTool: 1,
|
||||
roughingSpindle: 1,
|
||||
roughingDown: 1,
|
||||
roughingOver: 1,
|
||||
roughingSpeed: 1,
|
||||
roughingPlunge: 1,
|
||||
roughingStock: 1,
|
||||
camPocketOnlyRough: 1,
|
||||
roughingOn: 1,
|
||||
finishingTool: 1,
|
||||
finishingSpindle: 1,
|
||||
finishingDown: 1,
|
||||
finishingOver: 1,
|
||||
finishingAngle: 1,
|
||||
finishingSpeed: 1,
|
||||
finishingPlunge: 1,
|
||||
finishingOn: 1,
|
||||
finishingXOn: 1,
|
||||
finishingYOn: 1,
|
||||
finishCurvesOnly: 1,
|
||||
camPocketOnlyFinish: 1,
|
||||
drillTool: 1,
|
||||
drillSpindle: 1,
|
||||
drillDownSpeed: 1,
|
||||
drillDown: 1,
|
||||
drillDwell: 1,
|
||||
drillLift: 1,
|
||||
drillingOn: 1,
|
||||
camTabsAngle: 1,
|
||||
camTabsCount: 1,
|
||||
camTabsWidth: 1,
|
||||
camTabsHeight: 1,
|
||||
camTabsOn: 1,
|
||||
camPocketOnly: 1,
|
||||
camDepthFirst: 0,
|
||||
camEaseDown: 1,
|
||||
camOriginTop: 1,
|
||||
camTolerance: 1,
|
||||
camZTopOffset: 1,
|
||||
camZBottom: 1,
|
||||
processName: "default",
|
||||
camFastFeed: 6000,
|
||||
roughingTool: 1000,
|
||||
roughingSpindle: 1000,
|
||||
roughingDown: 2,
|
||||
roughingOver: 0.5,
|
||||
roughingSpeed: 1000,
|
||||
roughingPlunge: 250,
|
||||
roughingStock: 0,
|
||||
camPocketOnlyRough: false,
|
||||
roughingOn: true,
|
||||
finishingTool: 1000,
|
||||
finishingSpindle: 1000,
|
||||
finishingDown: 3,
|
||||
finishingOver: 0.5,
|
||||
finishingAngle: 85,
|
||||
finishingSpeed: 800,
|
||||
finishingPlunge: 250,
|
||||
finishingOn: true,
|
||||
finishingXOn: true,
|
||||
finishingYOn: true,
|
||||
finishCurvesOnly: false,
|
||||
camPocketOnlyFinish: false,
|
||||
drillTool: 1000,
|
||||
drillSpindle: 1000,
|
||||
drillDownSpeed: 250,
|
||||
drillDown: 5,
|
||||
drillDwell: 250,
|
||||
drillLift: 2,
|
||||
drillingOn: false,
|
||||
camTabsAngle: 0,
|
||||
camTabsCount: 4,
|
||||
camTabsWidth: 5,
|
||||
camTabsHeight: 5,
|
||||
camTabsOn: false,
|
||||
camPocketOnly: false,
|
||||
camDepthFirst: false,
|
||||
camEaseDown: false,
|
||||
camOriginTop: true,
|
||||
camTolerance: 0.15,
|
||||
camZTopOffset: 0,
|
||||
camZBottom: 0,
|
||||
camZClearance: 1,
|
||||
camStockX: 1,
|
||||
camStockY: 1,
|
||||
camStockZ: 1,
|
||||
camStockOffset: 1,
|
||||
outputClockwise: 1,
|
||||
outputOriginCenter: 1,
|
||||
outputInvertX: 1,
|
||||
outputInvertY: 1
|
||||
camStockX: 0,
|
||||
camStockY: 0,
|
||||
camStockZ: 0,
|
||||
camStockOffset: true,
|
||||
outputClockwise: false,
|
||||
outputOriginCenter: true,
|
||||
outputInvertX: false,
|
||||
outputInvertY: false
|
||||
}
|
||||
},
|
||||
laser: {
|
||||
// fields permitted in Laser:Device
|
||||
// device defaults Laser:Device
|
||||
d:{
|
||||
mode: 1,
|
||||
internal: 1,
|
||||
bedWidth: 1,
|
||||
bedDepth: 1,
|
||||
bedHeight: 1,
|
||||
gcodePre: 1,
|
||||
gcodePost: 1,
|
||||
gcodeFExt: 1,
|
||||
gcodeSpace: 1,
|
||||
gcodeLaserOn: 1,
|
||||
gcodeLaserOff: 1
|
||||
mode: "",
|
||||
internal: 0,
|
||||
bedWidth: 300,
|
||||
bedDepth: 175,
|
||||
bedHeight: 2.5,
|
||||
gcodePre: [],
|
||||
gcodePost: [],
|
||||
gcodeFExt: "",
|
||||
gcodeSpace: true,
|
||||
gcodeLaserOn: ["M106 S{power}"],
|
||||
gcodeLaserOff: ["M107"]
|
||||
},
|
||||
// fields permitted in Laser:Process
|
||||
// process defaults Laser:Process
|
||||
p:{
|
||||
processName: 1,
|
||||
laserOffset: 1,
|
||||
processName: "default",
|
||||
laserOffset: 0.25,
|
||||
laserSliceHeight: 1,
|
||||
laserSliceSingle: 1,
|
||||
laserSliceSingle: false,
|
||||
outputTileSpacing: 1,
|
||||
outputTileScaling: 1,
|
||||
outputLaserPower: 1,
|
||||
outputLaserSpeed: 1,
|
||||
outputLaserGroup: 1,
|
||||
outputLaserMerged: 1,
|
||||
outputOriginBounds: 1,
|
||||
outputOriginCenter: 1,
|
||||
outputInvertX: 1,
|
||||
outputInvertY: 1
|
||||
outputLaserPower: 100,
|
||||
outputLaserSpeed: 1000,
|
||||
outputLaserGroup: true,
|
||||
outputLaserMerged: false,
|
||||
outputOriginCenter: true,
|
||||
outputInvertX: false,
|
||||
outputInvertY: false
|
||||
}
|
||||
}
|
||||
},
|
||||
// --------------- default settings
|
||||
// --------------- settings template
|
||||
template: {
|
||||
// CAM only
|
||||
bounds: {},
|
||||
|
|
@ -444,198 +462,44 @@ let gs_kiri_conf = exports;
|
|||
taper_tip: 0,
|
||||
}
|
||||
],
|
||||
// FDM/CAM/Laser merged
|
||||
device:{
|
||||
mode: "", // device local
|
||||
internal: 0, // device edit state
|
||||
bedWidth: 300, // FDM/CAM/Laser
|
||||
bedDepth: 175, // FDM/CAM/Laser
|
||||
bedHeight: 2.5, // display only (deprecate)
|
||||
bedRound: false, // FDM
|
||||
originCenter: false,// FDM/CAM
|
||||
maxHeight: 150, // FDM
|
||||
spindleMax: 0, // CAM
|
||||
gcodePre: [], // FDM/CAM header script
|
||||
gcodePost: [], // FDM/CAM footer script
|
||||
gcodePause: [], // FDM pause script
|
||||
gcodeProc: "", // FDM post processor script (encoding, etc)
|
||||
gcodeFan: "", // FDM fan command
|
||||
gcodeTrack: "", // FDM progress command
|
||||
gcodeLayer: [], // FDM layer output
|
||||
gcodeFExt: "", // CAM file extension
|
||||
gcodeSpace: true, // CAM token spacing
|
||||
gcodeStrip: true, // CAM strip comments
|
||||
gcodeDwell: ["G4 P{time}"], // CAM dwell script
|
||||
gcodeChange: ["M6 T{tool}"], // CAM tool change script
|
||||
gcodeSpindle: ["M3 S{speed}"], // CAM spindle speed
|
||||
gcodeLaserOn: ["M106 S{power}"],// LASER turn on
|
||||
gcodeLaserOff: ["M107"], // LASER turn off
|
||||
extruders:[{ // FDM extruders structure
|
||||
extFilament: 1.75,
|
||||
extNozzle: 0.4,
|
||||
extSelect: ["T0"],
|
||||
extOffsetX: 0,
|
||||
extOffsetY: 0
|
||||
}]
|
||||
},
|
||||
// FDM/CAM/Laser merged
|
||||
process:{
|
||||
// --- shared ---
|
||||
processName: "default",
|
||||
outputOriginBounds: true,
|
||||
outputOriginCenter: true,
|
||||
outputInvertX: false,
|
||||
outputInvertY: false,
|
||||
|
||||
// --- FDM ---
|
||||
sliceHeight: 0.25,
|
||||
sliceShells: 3,
|
||||
sliceFillAngle: 45,
|
||||
sliceFillOverlap: 0.3,
|
||||
sliceFillSparse: 0.5,
|
||||
sliceFillType: "hex",
|
||||
sliceSupportEnable: false,
|
||||
sliceSupportDensity: 0.25,
|
||||
sliceSupportOffset: 1.0,
|
||||
sliceSupportGap: 1,
|
||||
sliceSupportSize: 10,
|
||||
sliceSupportArea: 1,
|
||||
sliceSupportExtra: 0,
|
||||
sliceSupportSpan: 6,
|
||||
sliceSupportNozzle: 0,
|
||||
sliceSolidMinArea: 1,
|
||||
sliceSolidLayers: 3,
|
||||
sliceBottomLayers: 3,
|
||||
sliceTopLayers: 3,
|
||||
firstSliceHeight: 0.25,
|
||||
firstLayerRate: 30,
|
||||
firstLayerFillRate: 40,
|
||||
firstLayerPrintMult: 1.0,
|
||||
firstLayerNozzleTemp: 0,
|
||||
firstLayerBedTemp: 0,
|
||||
outputRaft: false,
|
||||
outputRaftSpacing: 0.2,
|
||||
outputTemp: 200,
|
||||
outputFanMax: 255,
|
||||
outputBedTemp: 0,
|
||||
outputFeedrate: 80,
|
||||
outputFinishrate: 60,
|
||||
outputSeekrate: 100,
|
||||
outputShellMult: 1.2,
|
||||
outputFillMult: 1.2,
|
||||
outputSparseMult: 1.2,
|
||||
outputFanLayer: 1,
|
||||
outputRetractDist: 1.0,
|
||||
outputRetractSpeed: 40,
|
||||
outputRetractDwell: 30,
|
||||
outputBrimCount: 2,
|
||||
outputBrimOffset: 2,
|
||||
outputShortPoly: 50.0,
|
||||
outputMinSpeed: 15.0,
|
||||
outputCoastDist: 0,
|
||||
outputWipeDistance: 0,
|
||||
sliceMinHeight: 0,
|
||||
detectThinWalls: false,
|
||||
antiBacklash: 1,
|
||||
zHopDistance: 0.2,
|
||||
// polishLayers: 0,
|
||||
// polishSpeed: 40,
|
||||
outputLayerRetract: false,
|
||||
gcodePauseLayers: "",
|
||||
|
||||
// --- LASER ---
|
||||
laserOffset: 0.25,
|
||||
laserSliceHeight: 1,
|
||||
laserSliceSingle: false,
|
||||
outputTileSpacing: 1,
|
||||
outputTileScaling: 1,
|
||||
outputLaserPower: 100,
|
||||
outputLaserSpeed: 1000,
|
||||
outputLaserGroup: true,
|
||||
outputLaserMerged: false,
|
||||
|
||||
// --- CAM ---
|
||||
camFastFeed: 6000,
|
||||
roughingTool: 1000,
|
||||
roughingSpindle: 1000,
|
||||
roughingDown: 2,
|
||||
roughingOver: 0.5,
|
||||
roughingSpeed: 1000,
|
||||
roughingPlunge: 250,
|
||||
roughingStock: 0,
|
||||
camPocketOnlyRough: false,
|
||||
roughingOn: true,
|
||||
finishingTool: 1000,
|
||||
finishingSpindle: 1000,
|
||||
finishingDown: 3,
|
||||
finishingOver: 0.5,
|
||||
finishingAngle: 85,
|
||||
finishingSpeed: 800,
|
||||
finishingPlunge: 250,
|
||||
finishingOn: true,
|
||||
finishingXOn: true,
|
||||
finishingYOn: true,
|
||||
finishCurvesOnly: false,
|
||||
camPocketOnlyFinish: false,
|
||||
drillTool: 1000,
|
||||
drillSpindle: 1000,
|
||||
drillDownSpeed: 250,
|
||||
drillDown: 5,
|
||||
drillDwell: 250,
|
||||
drillLift: 2,
|
||||
drillingOn: false,
|
||||
camTabsAngle: 0,
|
||||
camTabsCount: 4,
|
||||
camTabsWidth: 5,
|
||||
camTabsHeight: 5,
|
||||
camTabsOn: false,
|
||||
camPocketOnly: false,
|
||||
camDepthFirst: false,
|
||||
camEaseDown: false,
|
||||
camOriginTop: true,
|
||||
camTolerance: 0.15,
|
||||
camZTopOffset: 0,
|
||||
camZBottom: 0,
|
||||
camZClearance: 1,
|
||||
camStockX: 0,
|
||||
camStockY: 0,
|
||||
camStockZ: 0,
|
||||
camStockOffset: true,
|
||||
outputClockwise: false,
|
||||
},
|
||||
// current process name
|
||||
// currently selected device
|
||||
device:{},
|
||||
// currently selected process
|
||||
process:{},
|
||||
// current process name by mode
|
||||
cproc:{
|
||||
FDM: "default",
|
||||
SLA: "default",
|
||||
CAM: "default",
|
||||
LASER: "default"
|
||||
},
|
||||
// saved processes by name
|
||||
// stored processes by mode
|
||||
sproc:{
|
||||
FDM: {},
|
||||
SLA: {},
|
||||
CAM: {},
|
||||
LASER: {}
|
||||
},
|
||||
// cached device settings by mode
|
||||
cdev: {
|
||||
FDM: null,
|
||||
CAM: null,
|
||||
LASER: null
|
||||
},
|
||||
// now they're called devices instead of gcode filters
|
||||
// current device name by mode
|
||||
filter:{
|
||||
FDM: "Any.Generic.Marlin",
|
||||
SLA: "Any.Generic.SLA",
|
||||
CAM: "Any.Generic.Grbl",
|
||||
LASER: "Any.Generic.Laser"
|
||||
},
|
||||
// custom devices by name
|
||||
devices:{
|
||||
},
|
||||
// favorite devices
|
||||
favorites:{
|
||||
// stored device by mode
|
||||
cdev: {
|
||||
FDM: null,
|
||||
SLA: null,
|
||||
CAM: null,
|
||||
LASER: null
|
||||
},
|
||||
// custom devices by name (all modes)
|
||||
devices:{},
|
||||
// favorited devices (all modes)
|
||||
favorites:{},
|
||||
// map of device to last process setting (name)
|
||||
devproc: {
|
||||
},
|
||||
devproc: {},
|
||||
layers:{
|
||||
layerOutline: true,
|
||||
layerTrace: true,
|
||||
|
|
@ -652,9 +516,6 @@ let gs_kiri_conf = exports;
|
|||
layerPrint: false,
|
||||
layerMoves: false
|
||||
},
|
||||
// for passing temporary slice hints (topo currently)
|
||||
synth: {
|
||||
},
|
||||
controller:{
|
||||
view: null,
|
||||
dark: false,
|
||||
|
|
@ -668,13 +529,26 @@ let gs_kiri_conf = exports;
|
|||
alignTop: true,
|
||||
units: "mm"
|
||||
},
|
||||
// widget extra info for slicing (like extruder mapping)
|
||||
widget: {
|
||||
},
|
||||
// for passing temporary slice hints (topo currently)
|
||||
synth: {},
|
||||
// widget extra info for slicing (extruder mapping)
|
||||
widget: {},
|
||||
mode: 'FDM',
|
||||
id: genID(),
|
||||
ver: CVER
|
||||
}
|
||||
};
|
||||
|
||||
let settings = CONF.template;
|
||||
|
||||
// seed defaults. will get culled on save
|
||||
settings.sproc.FDM.default = clone(settings.process);
|
||||
settings.sproc.SLA.default = clone(settings.process);
|
||||
settings.sproc.CAM.default = clone(settings.process);
|
||||
settings.sproc.LASER.default = clone(settings.process);
|
||||
settings.cdev.FDM = clone(settings.device);
|
||||
settings.cdev.SLA = clone(settings.device);
|
||||
settings.cdev.CAM = clone(settings.device);
|
||||
settings.cdev.LASER = clone(settings.device);
|
||||
|
||||
})();
|
||||
|
|
|
|||
226
js/kiri-driver-sla.js
Normal file
226
js/kiri-driver-sla.js
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
/** Copyright 2014-2019 Stewart Allen -- All Rights Reserved */
|
||||
|
||||
"use strict";
|
||||
|
||||
let gs_kiri_sla = exports;
|
||||
|
||||
(function() {
|
||||
|
||||
if (!self.kiri) self.kiri = { };
|
||||
if (!self.kiri.driver) self.kiri.driver = { };
|
||||
if (self.kiri.driver.SLA) return;
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
DBUG = BASE.debug,
|
||||
UTIL = BASE.util,
|
||||
CONF = BASE.config,
|
||||
POLY = BASE.polygons,
|
||||
SLA = KIRI.driver.SLA = {
|
||||
slice,
|
||||
printSetup,
|
||||
printExport
|
||||
},
|
||||
SLICER = KIRI.slicer,
|
||||
newPoint = BASE.newPoint;
|
||||
|
||||
/**
|
||||
* DRIVER SLICE CONTRACT
|
||||
*
|
||||
* @param {Object} settings
|
||||
* @param {Widget} Widget
|
||||
* @param {Function} onupdate (called with % complete and optional message)
|
||||
* @param {Function} ondone (called when complete with an array of Slice objects)
|
||||
*/
|
||||
function slice(settings, widget, onupdate, ondone) {
|
||||
let process = settings.process,
|
||||
device = settings.device;
|
||||
|
||||
SLICER.sliceWidget(widget, { height: sliceHeight }, onSliceDone, onSliceUpdate);
|
||||
|
||||
function onSliceUpdate(update) {
|
||||
return onupdate(0.0 + update * 0.5);
|
||||
}
|
||||
|
||||
function onSliceDone(slices) {
|
||||
widget.slices = slices;
|
||||
|
||||
if (!slices) return;
|
||||
|
||||
// calculate % complete and call onupdate()
|
||||
function doupdate(index, from, to, msg) {
|
||||
onupdate(0.5 + (from + ((index/slices.length) * (to-from))) * 0.5, msg);
|
||||
}
|
||||
|
||||
// for each slice, performe a function and call doupdate()
|
||||
function forSlices(from, to, fn, msg) {
|
||||
slices.forEach(function(slice) {
|
||||
fn(slice);
|
||||
doupdate(slice.index, from, to, msg)
|
||||
});
|
||||
}
|
||||
|
||||
// report slicing complete
|
||||
ondone();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* DRIVER PRINT CONTRACT
|
||||
*
|
||||
* @param {Object} print state object
|
||||
* @param {Function} update incremental callback
|
||||
*/
|
||||
function printSetup(print, update) {
|
||||
let widgets = print.widgets,
|
||||
settings = print.settings,
|
||||
device = settings.device,
|
||||
process = settings.process,
|
||||
output = print.output,
|
||||
bounds = settings.bounds,
|
||||
printPoint = newPoint(0,0,0);
|
||||
|
||||
// increment layer count until no widget has remaining slices
|
||||
for (;;) {
|
||||
// create list of mesh slice arrays with their platform offsets
|
||||
for (meshIndex = 0; meshIndex < widgets.length; meshIndex++) {
|
||||
let mesh = widgets[meshIndex].mesh;
|
||||
if (!mesh.widget) {
|
||||
continue;
|
||||
}
|
||||
let mslices = mesh.widget.slices;
|
||||
if (mslices && mslices[layer]) {
|
||||
slices.push({slice:mslices[layer], offset:mesh.position});
|
||||
}
|
||||
}
|
||||
|
||||
// exit if no slices
|
||||
if (slices.length === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
// track purge blocks generated for each layer
|
||||
let track = extruders.slice();
|
||||
let lastOut;
|
||||
let lastExt;
|
||||
|
||||
// iterate over layer slices, find closest widget, print, eliminate
|
||||
for (;;) {
|
||||
closest = null;
|
||||
mindist = Infinity;
|
||||
let order = [];
|
||||
// select slices of the same extruder type first then distance
|
||||
for (meshIndex = 0; meshIndex < slices.length; meshIndex++) {
|
||||
sliceEntry = slices[meshIndex];
|
||||
if (sliceEntry) {
|
||||
find = sliceEntry.slice.findClosestPointTo(printPoint.sub(sliceEntry.offset));
|
||||
if (find) {
|
||||
let ext = sliceEntry.slice.extruder;
|
||||
let lex = lastOut ? lastOut.extruder : ext;
|
||||
let dst = Math.abs(find.distance);
|
||||
if (ext !== lex) dst *= 10000;
|
||||
order.push({dst,sliceEntry,meshIndex});
|
||||
}
|
||||
}
|
||||
}
|
||||
order.sort((a,b) => {
|
||||
return a.dst - b.dst;
|
||||
});
|
||||
if (order.length) {
|
||||
let find = order.shift();
|
||||
closest = find.sliceEntry;
|
||||
minidx = find.meshIndex;
|
||||
}
|
||||
if (!closest) {
|
||||
if (sliceEntry) lastOut = sliceEntry.slice;
|
||||
break;
|
||||
}
|
||||
// retract between widgets
|
||||
if (layerout.length && minidx !== lastIndex) {
|
||||
layerout.last().retract = true;
|
||||
}
|
||||
layerout.height = layerout.height || closest.slice.height;
|
||||
slices[minidx] = null;
|
||||
closest.offset.z = zoff;
|
||||
// detect extruder change and print purge block
|
||||
if (!lastOut || lastOut.extruder !== closest.slice.extruder) {
|
||||
printPoint = purge(closest.slice.extruder, track, layerout, printPoint, closest.slice.z);
|
||||
}
|
||||
// output seek to start point between mesh slices if previous data
|
||||
printPoint = print.slicePrintPath(
|
||||
closest.slice,
|
||||
printPoint.sub(closest.offset),
|
||||
closest.offset,
|
||||
layerout,
|
||||
{ first: closest.slice.index === 0 }
|
||||
);
|
||||
lastOut = closest.slice;
|
||||
lastExt = lastOut.ext
|
||||
lastIndex = minidx;
|
||||
}
|
||||
|
||||
// if a declared extruder isn't used in a layer, use selected
|
||||
// extruder to fill the relevant purge blocks for later support
|
||||
track.forEach(ext => {
|
||||
if (ext) {
|
||||
printPoint = purge(ext.extruder, track, layerout, printPoint, lastOut.z, lastExt);
|
||||
}
|
||||
});
|
||||
|
||||
// if layer produced output, append to output array
|
||||
if (layerout.length) output.append(layerout);
|
||||
|
||||
// notify progress
|
||||
layerout.layer = layer++;
|
||||
update(layer / maxLayers);
|
||||
|
||||
// retract after last layer
|
||||
if (layer === maxLayers && layerout.length) {
|
||||
layerout.last().retract = true;
|
||||
}
|
||||
|
||||
slices = [];
|
||||
layerout = [];
|
||||
lastOut = undefined;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* DRIVER PRINT CONTRACT
|
||||
*
|
||||
* @returns {Array} gcode lines
|
||||
*/
|
||||
function printExport(print, online) {
|
||||
let layers = print.output,
|
||||
settings = print.settings,
|
||||
device = settings.device,
|
||||
process = settings.process,
|
||||
append,
|
||||
output = [];
|
||||
|
||||
if (online) {
|
||||
append = function(line) {
|
||||
if (line) {
|
||||
output.append(line);
|
||||
}
|
||||
if (!line || output.length > 1000) {
|
||||
online(output.join("\n"));
|
||||
output = [];
|
||||
}
|
||||
};
|
||||
} else {
|
||||
append = function(line) {
|
||||
if (!line) return;
|
||||
output.append(line);
|
||||
}
|
||||
}
|
||||
|
||||
// print.distance = emitted;
|
||||
// print.lines = lines;
|
||||
// print.bytes = bytes + lines - 1;
|
||||
// print.time = time;
|
||||
|
||||
return online ? null : output.join("\n");
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
@ -30,13 +30,14 @@ var gs_kiri_init = exports;
|
|||
SPACE = KIRI.space,
|
||||
STATS = API.stats,
|
||||
DEG = Math.PI/180,
|
||||
ALL = [MODES.FDM, MODES.LASER, MODES.CAM],
|
||||
ALL = [MODES.FDM, MODES.LASER, MODES.CAM, MODES.SLA],
|
||||
CAM = [MODES.CAM],
|
||||
FDM = [MODES.FDM],
|
||||
FDM_CAM = [MODES.CAM,MODES.FDM],
|
||||
FDM_LASER = [MODES.LASER,MODES.FDM],
|
||||
CAM_LASER = [MODES.LASER,MODES.CAM],
|
||||
LASER = [MODES.LASER],
|
||||
GCODE = [MODES.FDM, MODES.LASER, MODES.CAM],
|
||||
CATALOG = API.catalog,
|
||||
platform = API.platform,
|
||||
selection = API.selection,
|
||||
|
|
@ -637,6 +638,7 @@ var gs_kiri_init = exports;
|
|||
console.log({error:e, device:code, devicename});
|
||||
API.show.alert(`invalid or deprecated device: "${devicename}"`, 10);
|
||||
API.show.alert(`please select a new device`, 10);
|
||||
throw e;
|
||||
showDevices();
|
||||
}
|
||||
API.function.clear();
|
||||
|
|
@ -1157,7 +1159,7 @@ var gs_kiri_init = exports;
|
|||
UI.extNext = UC.newButton(">")
|
||||
]], {modes:FDM, expert:true}),
|
||||
|
||||
gcode: UC.newGroup(LANG.dv_gr_gco, $('device'), {group:"dgco", nocompact:true}),
|
||||
gcode: UC.newGroup(LANG.dv_gr_gco, $('device'), {group:"dgco", nocompact:true, modes:GCODE}),
|
||||
gcodeFan: UC.newInput(LANG.dv_fanp_s, {title:LANG.dv_fanp_l, modes:FDM, size:"40%", text:true}),
|
||||
gcodeTrack: UC.newInput(LANG.dv_prog_s, {title:LANG.dv_prog_l, modes:FDM, size:"40%", text:true}),
|
||||
gcodeLayer: UC.newText(LANG.dv_layr_s, {title:LANG.dv_layr_l, modes:FDM, size:14, height: 2}),
|
||||
|
|
@ -1170,14 +1172,17 @@ var gs_kiri_init = exports;
|
|||
gcodePause: UC.newText(LANG.dv_paus_s, {title:LANG.dv_paus_l, modes:FDM, size:14, height:3}),
|
||||
gcodeLaserOn: UC.newText(LANG.dv_lzon_s, {title:LANG.dv_lzon_l, modes:LASER, size:14, height:3}),
|
||||
gcodeLaserOff: UC.newText(LANG.dv_lzof_s, {title:LANG.dv_lzof_l, modes:LASER, size:14, height:3}),
|
||||
gcodePre: UC.newText(LANG.dv_head_s, {title:LANG.dv_head_l, modes:ALL, size:14, height:3}),
|
||||
gcodePost: UC.newText(LANG.dv_foot_s, {title:LANG.dv_foot_l, modes:ALL, size:14, height:3}),
|
||||
gcodePre: UC.newText(LANG.dv_head_s, {title:LANG.dv_head_l, modes:GCODE, size:14, height:3}),
|
||||
gcodePost: UC.newText(LANG.dv_foot_s, {title:LANG.dv_foot_l, modes:GCODE, size:14, height:3}),
|
||||
|
||||
mode: UC.newGroup(LANG.mo_menu, assets, {region:"left"}),
|
||||
modeTable: UC.newTableRow([
|
||||
[
|
||||
UI.modeFDM =
|
||||
UC.newButton(LANG.mo_fdmp, function() { API.mode.set('FDM',null,platform.update_size) }),
|
||||
],[
|
||||
UI.modeSLA =
|
||||
UC.newButton(LANG.mo_slap, function() { API.mode.set('SLA',null,platform.update_size) }),
|
||||
],[
|
||||
UI.modeLASER =
|
||||
UC.newButton(LANG.mo_lazr, function() { API.mode.set('LASER',null,platform.update_size) }),
|
||||
|
|
@ -1423,12 +1428,14 @@ var gs_kiri_init = exports;
|
|||
zHopDistance: UC.newInput(LANG.ad_zhop_s, {title:LANG.ad_zhop_l, bound:UC.bound(0,3.0), convert:UC.toFloat, modes:FDM, expert:true}),
|
||||
antiBacklash: UC.newInput(LANG.ad_abkl_s, {title:LANG.ad_abkl_l, bound:UC.bound(0,3), convert:UC.toInt, modes:FDM, expert:true}),
|
||||
// detectThinWalls: UC.newBoolean("thin wall fill", onBooleanClick, {title: "detect and fill thin openings\nbetween shells walls", modes:FDM, expert:true})
|
||||
// polishLayers: LOCAL ? UC.newInput(LANG.ad_play_s, {title:LANG.ad_play_l, bound:UC.bound(0,10), convert:UC.toFloat, modes:FDM, expert:true}) : null,
|
||||
// polishSpeed: LOCAL ? UC.newInput(LANG.ad_pspd_s, {title:LANG.ad_pspd_l, bound:UC.bound(10,2000), convert:UC.toInt, modes:FDM, expert:true}) : null,
|
||||
gcodePauseLayers: UC.newInput(LANG.ag_paws_s, {title:LANG.ag_paws_l, modes:FDM, expert:true}),
|
||||
outputLayerRetract: UC.newBoolean(LANG.ad_lret_s, onBooleanClick, {title:LANG.ad_lret_l, modes:FDM, expert:true})
|
||||
});
|
||||
|
||||
if (!LOCAL) {
|
||||
UI.modeSLA.style.display = 'none';
|
||||
}
|
||||
|
||||
if (!lang_set) {
|
||||
// for english only, add underlined labels for hotkeys
|
||||
UI.setupDevices.innerHTML = "D<u>e</u>vices";
|
||||
|
|
|
|||
|
|
@ -323,15 +323,42 @@ let gs_kiri_print = exports;
|
|||
return a !== undefined ? a : b;
|
||||
}
|
||||
|
||||
function rgb2hsv(ir, ig, ib) {
|
||||
let H = 0,
|
||||
S = 0,
|
||||
V = 0,
|
||||
r = ir / 255,
|
||||
g = ig / 255,
|
||||
b = ib / 255;
|
||||
|
||||
let minRGB = Math.min(r, Math.min(g, b)),
|
||||
maxRGB = Math.max(r, Math.max(g, b));
|
||||
|
||||
// Black-gray-white
|
||||
if (minRGB == maxRGB) {
|
||||
V = minRGB;
|
||||
return [0, 0, V];
|
||||
}
|
||||
|
||||
// Colors other than black-gray-white:
|
||||
let d = (r == minRGB) ? g - b : ((b == minRGB) ? r - g : b - r),
|
||||
h = (r == minRGB) ? 3 : ((b == minRGB) ? 1 : 5);
|
||||
|
||||
H = 60 * (h - d / (maxRGB - minRGB));
|
||||
S = (maxRGB - minRGB) / maxRGB;
|
||||
V = maxRGB;
|
||||
|
||||
return [H, S, V];
|
||||
}
|
||||
|
||||
// hsv values all = 0 to 1
|
||||
function hsv2rgb(hsv) {
|
||||
let seg = Math.floor(hsv.h * 6);
|
||||
let rem = hsv.h - (seg * (1/6));
|
||||
let out = {};
|
||||
|
||||
let p = hsv.v * (1.0 - (hsv.s) );
|
||||
let q = hsv.v * (1.0 - (hsv.s * rem) );
|
||||
let t = hsv.v * (1.0 - (hsv.s * (1.0 - rem)));
|
||||
let seg = Math.floor(hsv.h * 6),
|
||||
rem = hsv.h - (seg * (1/6)),
|
||||
p = hsv.v * (1.0 - (hsv.s)),
|
||||
q = hsv.v * (1.0 - (hsv.s * rem)),
|
||||
t = hsv.v * (1.0 - (hsv.s * (1.0 - rem))),
|
||||
out = {};
|
||||
|
||||
switch (seg) {
|
||||
case 0:
|
||||
|
|
|
|||
|
|
@ -11,31 +11,15 @@ let gs_kiri_widget = exports;
|
|||
|
||||
let KIRI = self.kiri,
|
||||
DRIVERS = KIRI.driver,
|
||||
CAM = DRIVERS.CAM,
|
||||
FDM = DRIVERS.FDM,
|
||||
LASER = DRIVERS.LASER,
|
||||
CPRO = CAM.process,
|
||||
BASE = self.base,
|
||||
CONF = BASE.config,
|
||||
DBUG = BASE.debug,
|
||||
UTIL = BASE.util,
|
||||
POLY = BASE.polygons,
|
||||
MATH = Math,
|
||||
ABS = MATH.abs,
|
||||
MIN = MATH.min,
|
||||
MAX = MATH.max,
|
||||
SQRT = MATH.sqrt,
|
||||
CEIL = MATH.ceil,
|
||||
FLOOR = MATH.floor,
|
||||
ROUND = MATH.round,
|
||||
SLICER = KIRI.slicer,
|
||||
newLine = BASE.newLine,
|
||||
newPoint = BASE.newPoint,
|
||||
newSlice = KIRI.newSlice,
|
||||
newPolygon = BASE.newPolygon,
|
||||
newOrderedLine = BASE.newOrderedLine,
|
||||
time = UTIL.time,
|
||||
PRO = Widget.prototype,
|
||||
time = UTIL.time,
|
||||
solid_opacity = 1.0,
|
||||
nextId = 0,
|
||||
groups = [];
|
||||
|
|
@ -226,7 +210,7 @@ let gs_kiri_widget = exports;
|
|||
newpoints;
|
||||
// replace point objects with their equivalents
|
||||
while (i < array.length) {
|
||||
let p = newPoint(array[i++], array[i++], array[i++]),
|
||||
let p = BASE.newPoint(array[i++], array[i++], array[i++]),
|
||||
k = p.key,
|
||||
m = hash[k];
|
||||
if (!m) {
|
||||
|
|
@ -707,13 +691,7 @@ let gs_kiri_widget = exports;
|
|||
onupdate(progress, message);
|
||||
};
|
||||
|
||||
let driver = null;
|
||||
|
||||
switch (settings.mode) {
|
||||
case 'LASER': driver = LASER; break;
|
||||
case 'FDM': driver = FDM; break;
|
||||
case 'CAM': driver = CAM; break;
|
||||
}
|
||||
let driver = DRIVERS[settings.mode.toUpperCase()];
|
||||
|
||||
if (driver) {
|
||||
driver.slice(settings, widget, catchupdate, catchdone);
|
||||
|
|
|
|||
33
js/kiri.js
33
js/kiri.js
|
|
@ -35,6 +35,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
CONF = KIRI.conf,
|
||||
MODES = CONF.MODES,
|
||||
VIEWS = CONF.VIEWS,
|
||||
clone = Object.clone,
|
||||
settings = clone(CONF.template),
|
||||
settingsDefault = clone(settings),
|
||||
// ---------------
|
||||
|
|
@ -61,13 +62,6 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
alerts = [],
|
||||
grouping = false;
|
||||
|
||||
// seed defaults. will get culled on save
|
||||
settings.sproc.FDM.default = clone(settings.process);
|
||||
settings.sproc.CAM.default = clone(settings.process);
|
||||
settings.sproc.LASER.default = clone(settings.process);
|
||||
settings.cdev.FDM = clone(settings.device);
|
||||
settings.cdev.CAM = clone(settings.device);
|
||||
|
||||
if (SETUP.rm) renderMode = parseInt(SETUP.rm[0]);
|
||||
DBUG.enable();
|
||||
|
||||
|
|
@ -322,10 +316,6 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
* Utility Functions
|
||||
******************************************************************* */
|
||||
|
||||
function clone(o) {
|
||||
return o ? JSON.parse(JSON.stringify(o)) : o;
|
||||
}
|
||||
|
||||
function unitScale() {
|
||||
return settings.controller.units === 'in' ? 25.4 : 1;
|
||||
}
|
||||
|
|
@ -1396,9 +1386,10 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
}
|
||||
|
||||
function saveSettings() {
|
||||
// store camera view
|
||||
let view = SPACE.view.save();
|
||||
if (view.left || view.up) settings.controller.view = view;
|
||||
if (view.left || view.up) {
|
||||
settings.controller.view = view;
|
||||
}
|
||||
SDB.setItem('ws-settings', JSON.stringify(settings));
|
||||
}
|
||||
|
||||
|
|
@ -1498,16 +1489,13 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
}
|
||||
|
||||
function restoreSettings(save) {
|
||||
let newset = ls2o('ws-settings'),
|
||||
camera = ls2o('ws-camera');
|
||||
let newset = ls2o('ws-settings');
|
||||
|
||||
if (newset) {
|
||||
settings = CONF.normalize(newset);
|
||||
// override camera from settings
|
||||
if (settings.controller.view) {
|
||||
camera = settings.controller.view;
|
||||
SDB.removeItem('ws-camera');
|
||||
// UI.reverseZoom.checked = settings.controller.reverseZoom;
|
||||
}
|
||||
// merge custom filters from localstorage into settings
|
||||
localFilters.forEach(function(fname) {
|
||||
|
|
@ -1519,15 +1507,14 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
// save updated settings
|
||||
if (save) API.conf.save();
|
||||
}
|
||||
|
||||
return {newset, camera};
|
||||
return newset;
|
||||
}
|
||||
|
||||
function restoreWorkspace(ondone, skip_widget_load) {
|
||||
let {newset, camera} = restoreSettings(true);
|
||||
|
||||
let loaded = 0,
|
||||
let newset = restoreSettings(true),
|
||||
camera = newset.controller.view,
|
||||
toload = ls2o('ws-widgets',[]),
|
||||
loaded = 0,
|
||||
position = true;
|
||||
|
||||
updateFields();
|
||||
|
|
@ -1535,7 +1522,6 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
platform.update_stock();
|
||||
|
||||
SPACE.view.reset();
|
||||
|
||||
if (camera) SPACE.view.load(camera);
|
||||
else setTimeout(SPACE.view.home, 100);
|
||||
|
||||
|
|
@ -1872,6 +1858,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
clearWidgetCache();
|
||||
SPACE.update();
|
||||
UI.modeFDM.setAttribute('class', MODE === MODES.FDM ? 'buton' : '');
|
||||
UI.modeSLA.setAttribute('class', MODE === MODES.SLA ? 'buton' : '');
|
||||
UI.modeCAM.setAttribute('class', MODE === MODES.CAM ? 'buton' : '');
|
||||
UI.modeLASER.setAttribute('class', MODE === MODES.LASER ? 'buton' : '');
|
||||
UI.mode.style.display = lock ? 'none' : '';
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
var exports = {
|
||||
COPYRIGHT:"Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
||||
LICENSE:"See the license.md file included with the source distribution",
|
||||
VERSION:"1.8.3"
|
||||
VERSION:"1.8.4"
|
||||
};
|
||||
if (!module) var module = {};
|
||||
module.exports = exports;
|
||||
|
|
|
|||
|
|
@ -147,6 +147,9 @@ function prepareScripts() {
|
|||
fs.readdir("./web/kiri/filter/FDM", function(err, files) {
|
||||
filters_fdm = files || filters_fdm;
|
||||
});
|
||||
fs.readdir("./web/kiri/filter/SLA", function(err, files) {
|
||||
filters_sla = files || filters_sla;
|
||||
});
|
||||
fs.readdir("./web/kiri/filter/CAM", function(err, files) {
|
||||
filters_cam = files || filters_cam;
|
||||
});
|
||||
|
|
@ -787,6 +790,7 @@ let ver = require('../js/license.js'),
|
|||
fileCache = {},
|
||||
fileMap = {},
|
||||
filters_fdm = [],
|
||||
filters_sla = [],
|
||||
filters_cam = [],
|
||||
filters_laser = [],
|
||||
modPaths = [],
|
||||
|
|
@ -826,6 +830,7 @@ let ver = require('../js/license.js'),
|
|||
"kiri-slice",
|
||||
"kiri-slicer",
|
||||
"kiri-driver-fdm",
|
||||
"kiri-driver-sla",
|
||||
"kiri-driver-cam",
|
||||
"kiri-driver-laser",
|
||||
"kiri-pack",
|
||||
|
|
@ -887,6 +892,7 @@ let ver = require('../js/license.js'),
|
|||
"kiri-slice",
|
||||
"kiri-slicer",
|
||||
"kiri-driver-fdm",
|
||||
"kiri-driver-sla",
|
||||
"kiri-driver-cam",
|
||||
"kiri-driver-laser",
|
||||
"kiri-pack",
|
||||
|
|
@ -968,6 +974,11 @@ const api = {
|
|||
res.end(obj2string(filters_fdm));
|
||||
},
|
||||
|
||||
"filters-sla": (req, res, next) => {
|
||||
res.setHeader("Content-Type", "application/javascript");
|
||||
res.end(obj2string(filters_sla));
|
||||
},
|
||||
|
||||
"filters-cam": (req, res, next) => {
|
||||
res.setHeader("Content-Type", "application/javascript");
|
||||
res.end(obj2string(filters_cam));
|
||||
|
|
|
|||
11
web/kiri/filter/SLA/Any.Generic.SLA
Normal file
11
web/kiri/filter/SLA/Any.Generic.SLA
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"pre":[],
|
||||
"post":[],
|
||||
"cmd":{},
|
||||
"settings":{
|
||||
"bed_width": 115,
|
||||
"bed_depth": 65,
|
||||
"max_height": 155,
|
||||
"origin_center": true
|
||||
}
|
||||
}
|
||||
11
web/kiri/filter/SLA/Anycubic.Photon
Normal file
11
web/kiri/filter/SLA/Anycubic.Photon
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"pre":[],
|
||||
"post":[],
|
||||
"cmd":{},
|
||||
"settings":{
|
||||
"bed_width": 115,
|
||||
"bed_depth": 65,
|
||||
"max_height": 155,
|
||||
"origin_center": true
|
||||
}
|
||||
}
|
||||
11
web/kiri/filter/SLA/Anycubic.Photon.S
Normal file
11
web/kiri/filter/SLA/Anycubic.Photon.S
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"pre":[],
|
||||
"post":[],
|
||||
"cmd":{},
|
||||
"settings":{
|
||||
"bed_width": 115,
|
||||
"bed_depth": 65,
|
||||
"max_height": 165,
|
||||
"origin_center": true
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ kiri.lang['da-dk'] = {
|
|||
// MODE
|
||||
mo_menu: "Teknologi",
|
||||
mo_fdmp: "FDM Print",
|
||||
mo_slap: "SLA Print",
|
||||
mo_lazr: "Laser skær",
|
||||
mo_cncm: "CNC fræs",
|
||||
|
||||
|
|
|
|||
|
|
@ -17,14 +17,14 @@ kiri.lang['en-us'] = {
|
|||
dv_fila_l: "diameter in millimeters",
|
||||
dv_nozl_s: "nozzle",
|
||||
dv_nozl_l: "diameter in millimeters",
|
||||
dv_bedw_s: "bed width",
|
||||
dv_bedw_s: "width",
|
||||
dv_bedw_l: "millimeters",
|
||||
dv_bedd_s: "bed depth",
|
||||
dv_bedd_s: "depth",
|
||||
dv_bedd_l: "millimeters",
|
||||
dv_bedh_s: "max height",
|
||||
dv_bedh_s: "height",
|
||||
dv_bedh_l: "max build height\nin millimeters",
|
||||
dv_spmx_s: "max spindle rpm",
|
||||
dv_spmx_l: "max spindle speed\n0 to disable",
|
||||
dv_spmx_s: "max spindle",
|
||||
dv_spmx_l: "max spindle rpm speed\n0 to disable",
|
||||
dv_xtab_s: "absolute positioning",
|
||||
dv_xtab_l: "extrusion moves absolute",
|
||||
dv_orgc_s: "origin center",
|
||||
|
|
@ -72,9 +72,10 @@ kiri.lang['en-us'] = {
|
|||
|
||||
// MODE
|
||||
mo_menu: "mode",
|
||||
mo_fdmp: "FDM Printing",
|
||||
mo_lazr: "Laser Cutting",
|
||||
mo_cncm: "CNC Milling",
|
||||
mo_fdmp: "FDM Print",
|
||||
mo_slap: "SLA Print",
|
||||
mo_lazr: "Laser Cut",
|
||||
mo_cncm: "CNC Mill",
|
||||
|
||||
// SETUP
|
||||
su_menu: "setup",
|
||||
|
|
|
|||
Loading…
Reference in a new issue