complete sla hollow feature

This commit is contained in:
Stewart Allen 2020-04-15 15:20:02 -04:00
commit d53b53db47
6 changed files with 64 additions and 26 deletions

View file

@ -45,8 +45,8 @@ let gs_kiri_sla = exports;
// for each slice, performe a function and call doupdate() // for each slice, performe a function and call doupdate()
function forSlices(slices, from, to, fn, msg) { function forSlices(slices, from, to, fn, msg) {
slices.forEach(function(slice) { slices.forEach(function(slice,index) {
fn(slice); fn(slice,index);
doupdate(slices, slice.index, from, to, msg) doupdate(slices, slice.index, from, to, msg)
}); });
} }
@ -54,7 +54,7 @@ let gs_kiri_sla = exports;
SLICER.sliceWidget(widget, { SLICER.sliceWidget(widget, {
height: process.slaSlice || 0.05 height: process.slaSlice || 0.05
}, function(slices) { }, function(slices) {
widget.slices = slices; widget.slices = slices.filter(slice => slice.tops.length);
// reset for solids and support projections // reset for solids and support projections
slices.forEach(function(slice) { slices.forEach(function(slice) {
slice.invalidateFill(); slice.invalidateFill();
@ -62,20 +62,35 @@ let gs_kiri_sla = exports;
slice.invalidateSupports(); slice.invalidateSupports();
slice.isSolidFill = false; slice.isSolidFill = false;
}); });
forSlices(slices, 0.0, 0.2, (slice) => { let solidLayers = Math.round(process.slaShell / process.slaSlice);
slice.doShells(1, 0); forSlices(slices, 0.0, 0.2, (slice,index) => {
// slice.tops.forEach(top => { top.solids = [] }); if (process.slaShell) {
slice.doShells(2, 0, process.slaShell);
} else {
slice.doShells(1, 0);
}
}, "slice"); }, "slice");
forSlices(slices, 0.2, 0.4, (slice) => { forSlices(slices, 0.2, 0.4, (slice) => {
slice.doDiff(0.00001, 0.005, true); slice.doDiff(0.00001, 0.005, true);
}, "delta"); }, "delta");
forSlices(slices, 0.4, 0.5, (slice) => { if (solidLayers) {
slice.projectFlats(process.slaSolids || 5); forSlices(slices, 0.4, 0.5, (slice) => {
slice.projectBridges(process.slaSolids || 5); slice.projectFlats(solidLayers);
}, "project"); slice.projectBridges(solidLayers);
forSlices(slices, 0.5, 0.6, (slice) => { }, "project");
slice.doSolidsFill(undefined, undefined, 0.00001); forSlices(slices, 0.5, 0.6, (slice) => {
}, "solid"); slice.doSolidsFill(undefined, undefined, 0.001);
let traces = POLY.nest(POLY.flatten(slice.gatherTraces([])));
let trims = slice.solids.trimmed || [];
traces.appendAll(trims);
let union = POLY.union(traces);
slice.solids.unioned = union;
}, "solid");
} else {
forSlices(slices, 0.4, 0.6, (slice) => {
slice.solids.unioned = slice.gatherTopPolys([]);
})
}
ondone(); ondone();
}, function(update) { }, function(update) {
return onupdate(0.0 + update * 0.5); return onupdate(0.0 + update * 0.5);
@ -124,7 +139,9 @@ let gs_kiri_sla = exports;
widgets.forEach(widget => { widgets.forEach(widget => {
let slice = widget.slices[index]; let slice = widget.slices[index];
if (slice) { if (slice) {
slice.tops.map(top => top.poly).forEach(poly => { let traces = POLY.flatten(slice.gatherTraces([]));
let polys = slice.solids.unioned;
polys.forEach(poly => {
ctx.beginPath(); ctx.beginPath();
polyout(poly.setClockwise(), ctx); polyout(poly.setClockwise(), ctx);
if (poly.inner) { if (poly.inner) {
@ -183,7 +200,9 @@ let gs_kiri_sla = exports;
if (!slice) { if (!slice) {
return; return;
} }
slice.tops.map(top => top.poly).forEach(poly => { // let polys = slice.gatherTraces([]);
let polys = slice.solids.unioned;
polys.forEach(poly => {
layer.poly(poly, 0x888888, true, false); layer.poly(poly, 0x888888, true, false);
count++; count++;
}); });

View file

@ -1438,7 +1438,7 @@ var gs_kiri_init = exports;
// SLA // SLA
slaProc: UC.newGroup('slice', null, {modes:SLA, group:"sla-slice"}), slaProc: UC.newGroup('slice', null, {modes:SLA, group:"sla-slice"}),
slaSlice: UC.newInput('layer height', {title:'slice height', convert:UC.toFloat, modes:SLA}), slaSlice: UC.newInput('layer height', {title:'slice height', convert:UC.toFloat, modes:SLA}),
slaShell: UC.newInput('hollow shell', {title:'shell thickness in mm\nuse multiple of layer height\nuse 0 for solid', convert:UC.toInt, modes:SLA}), slaShell: UC.newInput('hollow shell', {title:'shell thickness in mm\nuse multiple of layer height\nuse 0 for solid', convert:UC.toFloat, modes:SLA}),
slaOpenTop: UC.newBoolean('open top', onBooleanClick, {title:'solid layers', modes:SLA}), slaOpenTop: UC.newBoolean('open top', onBooleanClick, {title:'solid layers', modes:SLA}),
slaOpenBase: UC.newBoolean('open base', onBooleanClick, {title:'bottom layers', modes:SLA}), slaOpenBase: UC.newBoolean('open base', onBooleanClick, {title:'bottom layers', modes:SLA}),
slaOutput: UC.newGroup('output', null, {modes:SLA, group:"sla-output"}), slaOutput: UC.newGroup('output', null, {modes:SLA, group:"sla-output"}),
@ -1695,6 +1695,8 @@ var gs_kiri_init = exports;
let current = settings(), let current = settings(),
control = current.controller; control = current.controller;
SPACE.scene.freeze(true);
platform.deselect(); platform.deselect();
CATALOG.addFileListener(updateCatalog); CATALOG.addFileListener(updateCatalog);
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed); SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
@ -1801,6 +1803,8 @@ var gs_kiri_init = exports;
// send init-done event // send init-done event
API.event.emit('init-done', STATS); API.event.emit('init-done', STATS);
SPACE.scene.freeze(false);
} }
// if a language needs to load, the script is injected and loaded // if a language needs to load, the script is injected and loaded

View file

@ -442,8 +442,7 @@ let gs_kiri_slice = exports;
// top.thinner = []; // top.thinner = [];
top.traces = []; top.traces = [];
top.inner = []; top.inner = [];
let last = [], let last = [], z = top.poly.getZ();
z = top.poly.getZ();
if (opt.thin) { if (opt.thin) {
top.thin_fill = []; top.thin_fill = [];
@ -451,7 +450,7 @@ let gs_kiri_slice = exports;
if (count) { if (count) {
// permit offset of 0 for laser // permit offset of 0 for laser
if (offset1 === 0) { if (offset1 === 0 && count === 1) {
last = top_poly.clone(true); last = top_poly.clone(true);
top.traces = last; top.traces = last;
} else { } else {
@ -925,7 +924,9 @@ let gs_kiri_slice = exports;
}); });
// for SLA to bypass line infill // for SLA to bypass line infill
if (isSLA) return true; if (isSLA) {
return true;
}
// create empty filled line array for each top // create empty filled line array for each top
tops.forEach(function(top) { tops.forEach(function(top) {

View file

@ -924,18 +924,20 @@ self.kiri.copyright = exports.COPYRIGHT;
} }
function platformUpdateSize() { function platformUpdateSize() {
let frozen = SPACE.scene.freeze(true);
let dev = settings.device, let dev = settings.device,
width, depth, width, depth,
height = Math.round(Math.max(dev.bedHeight, dev.bedWidth/100, dev.bedDepth/100)); height = Math.round(Math.max(dev.bedHeight, dev.bedWidth/100, dev.bedDepth/100));
SPACE.platform.setRound(dev.bedRound); SPACE.platform.setRound(dev.bedRound);
SPACE.platform.setGZOff(height/2 - 0.1);
SPACE.platform.setSize( SPACE.platform.setSize(
width = parseInt(dev.bedWidth), width = parseInt(dev.bedWidth),
depth = parseInt(dev.bedDepth), depth = parseInt(dev.bedDepth),
height = parseFloat(dev.bedHeight) height = parseFloat(dev.bedHeight)
); );
SPACE.platform.setGZOff(height/2 - 0.1);
SPACE.platform.setHidden(width > 500 || depth > 500); SPACE.platform.setHidden(width > 500 || depth > 500);
platform.update_origin(); platform.update_origin();
SPACE.scene.freeze(frozen);
} }
function platformUpdateBounds() { function platformUpdateBounds() {
@ -1520,9 +1522,14 @@ self.kiri.copyright = exports.COPYRIGHT;
platform.update_size(); platform.update_size();
platform.update_stock(); platform.update_stock();
let fz = SPACE.scene.freeze(true);
SPACE.view.reset(); SPACE.view.reset();
if (camera) SPACE.view.load(camera); if (camera) {
else setTimeout(SPACE.view.home, 100); SPACE.view.load(camera);
} else {
SPACE.view.home();
}
SPACE.scene.freeze(fz);
if (skip_widget_load) return; if (skip_widget_load) return;

View file

@ -1,7 +1,7 @@
var exports = { var exports = {
COPYRIGHT:"Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved", COPYRIGHT:"Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
LICENSE:"See the license.md file included with the source distribution", LICENSE:"See the license.md file included with the source distribution",
VERSION:"1.8.4" VERSION:"1.8.5"
}; };
if (!module) var module = {}; if (!module) var module = {};
module.exports = exports; module.exports = exports;

View file

@ -63,6 +63,7 @@ var MOTO = window.moto = window.moto || {};
camera, camera,
renderer, renderer,
container, container,
freeze = false,
isRound = false, isRound = false,
platformMaterial = new THREE.MeshPhongMaterial({ platformMaterial = new THREE.MeshPhongMaterial({
color: 0xcccccc, color: 0xcccccc,
@ -198,8 +199,8 @@ var MOTO = window.moto = window.moto || {};
} }
function setGrid(unitMajor, unitMinor, colorMajor, colorMinor) { function setGrid(unitMajor, unitMinor, colorMajor, colorMinor) {
if (gridView) Space.scene.remove(gridView);
if (!unitMajor) return; if (!unitMajor) return;
let oldGridView = gridView;
gridView = new THREE.Group(); gridView = new THREE.Group();
gridUnitMajor = unitMajor; gridUnitMajor = unitMajor;
gridUnitMinor = unitMinor; gridUnitMinor = unitMinor;
@ -233,6 +234,7 @@ var MOTO = window.moto = window.moto || {};
} }
gridView.add(makeLinesFromPoints(majors, gridColorMajor || 0x999999, 1)); gridView.add(makeLinesFromPoints(majors, gridColorMajor || 0x999999, 1));
if (minors) gridView.add(makeLinesFromPoints(minors, gridColorMinor || 0xcccccc, 1)); if (minors) gridView.add(makeLinesFromPoints(minors, gridColorMinor || 0xcccccc, 1));
if (oldGridView) Space.scene.remove(oldGridView);
Space.scene.add(gridView); Space.scene.add(gridView);
} }
@ -560,6 +562,11 @@ var MOTO = window.moto = window.moto || {};
}, },
remove: function (o) { remove: function (o) {
return SCENE.remove(o); return SCENE.remove(o);
},
freeze: function (b) {
let fz = freeze;
freeze = b;
return fz;
} }
}, },
@ -737,7 +744,7 @@ var MOTO = window.moto = window.moto || {};
function animate() { function animate() {
requestAnimationFrame(animate); requestAnimationFrame(animate);
renderer.render(SCENE, camera); if (!freeze) renderer.render(SCENE, camera);
} }
animate(); animate();