improve sla visualization. remove slice view in sla mode
This commit is contained in:
parent
109f27e2e3
commit
21fbb9f88a
6 changed files with 94 additions and 25 deletions
|
|
@ -240,10 +240,12 @@ let gs_kiri_sla = exports;
|
||||||
}
|
}
|
||||||
let polys = slice.solids.unioned;
|
let polys = slice.solids.unioned;
|
||||||
polys.forEach(poly => {
|
polys.forEach(poly => {
|
||||||
layer.poly(poly, 0x888888, true, false);
|
layer.poly(poly, 0x222222, true);
|
||||||
|
layer.solid(poly, 0x00bbee);
|
||||||
count++;
|
count++;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
layer.renderSolid();
|
||||||
layer.render();
|
layer.render();
|
||||||
|
|
||||||
if (count === 0) {
|
if (count === 0) {
|
||||||
|
|
|
||||||
|
|
@ -313,7 +313,9 @@ var gs_kiri_init = exports;
|
||||||
API.function.slice();
|
API.function.slice();
|
||||||
break;
|
break;
|
||||||
case cca('p'): // prepare print
|
case cca('p'): // prepare print
|
||||||
|
if (API.mode.get() !== 'SLA') {
|
||||||
API.function.print();
|
API.function.print();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case cca('P'): // position widget
|
case cca('P'): // position widget
|
||||||
positionSelection();
|
positionSelection();
|
||||||
|
|
@ -653,7 +655,6 @@ var gs_kiri_init = exports;
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDeviceName() {
|
function updateDeviceName() {
|
||||||
console.log('update device name');
|
|
||||||
let newname = UI.deviceName.value,
|
let newname = UI.deviceName.value,
|
||||||
selected = API.device.get(),
|
selected = API.device.get(),
|
||||||
devs = settings().devices;
|
devs = settings().devices;
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,17 @@ let gs_kiri_layer = exports;
|
||||||
KIRI.Layer = Layer;
|
KIRI.Layer = Layer;
|
||||||
KIRI.newLayer = function(view) { return new Layer(view) };
|
KIRI.newLayer = function(view) { return new Layer(view) };
|
||||||
|
|
||||||
function materialFor(color) {
|
function materialFor(color, mesh, linewidth) {
|
||||||
let m = mcache[color];
|
let m = mcache[color];
|
||||||
if (!m) {
|
if (!m) {
|
||||||
m = mcache[color] = new THREE.LineBasicMaterial({
|
m = mcache[color] = mesh ? new THREE.MeshPhongMaterial({
|
||||||
|
specular: 0x181818,
|
||||||
|
shininess: 100,
|
||||||
|
transparent: true,
|
||||||
|
opacity: 0.15,
|
||||||
|
color: color,
|
||||||
|
side: THREE.DoubleSide
|
||||||
|
}) : new THREE.LineBasicMaterial({
|
||||||
fog: false,
|
fog: false,
|
||||||
color: color,
|
color: color,
|
||||||
linewidth: 1
|
linewidth: 1
|
||||||
|
|
@ -55,18 +62,29 @@ let gs_kiri_layer = exports;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addSolid(arr, poly) {
|
||||||
|
let faces = poly.earcut();
|
||||||
|
faces.forEach(p => {
|
||||||
|
p.forEachPoint(p => {
|
||||||
|
arr.push(p.x, p.y, p.z);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {THREE.Group} view
|
* @param {THREE.Group} view
|
||||||
*/
|
*/
|
||||||
function Layer(view) {
|
function Layer(view) {
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
this.group = null;
|
this.group = null;
|
||||||
|
this.solids = null;
|
||||||
this.view = view;
|
this.view = view;
|
||||||
this.bycolor = {};
|
this.bycolor = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
LP.setVisible = function(vis) {
|
LP.setVisible = function(vis) {
|
||||||
if (this.group) this.group.visible = vis;
|
if (this.group) this.group.visible = vis;
|
||||||
|
if (this.solids) this.solids.visible = vis;
|
||||||
};
|
};
|
||||||
|
|
||||||
LP.clear = function() {
|
LP.clear = function() {
|
||||||
|
|
@ -90,6 +108,11 @@ let gs_kiri_layer = exports;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LP.solid = function(poly, color) {
|
||||||
|
this.add(color, {solid: poly});
|
||||||
|
this.changed = true;
|
||||||
|
};
|
||||||
|
|
||||||
LP.points = function(points, color, size, opacity) {
|
LP.points = function(points, color, size, opacity) {
|
||||||
let layer = this,
|
let layer = this,
|
||||||
sz = size/2;
|
sz = size/2;
|
||||||
|
|
@ -130,6 +153,32 @@ let gs_kiri_layer = exports;
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
LP.renderSolid = function() {
|
||||||
|
if (!(this.view)) return;
|
||||||
|
if (this.solids) this.view.remove(this.solids);
|
||||||
|
this.solids = this.view.newGroup();
|
||||||
|
|
||||||
|
let bycolor = this.bycolor;
|
||||||
|
|
||||||
|
for (let key in bycolor) {
|
||||||
|
if (!bycolor.hasOwnProperty(key)) continue;
|
||||||
|
|
||||||
|
let arr = [], mat = materialFor(parseInt(key), true);
|
||||||
|
|
||||||
|
bycolor[key].forEach(function(obj) {
|
||||||
|
if (obj.solid) {
|
||||||
|
addSolid(arr, obj.solid);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (arr.length > 0) {
|
||||||
|
let geo = new THREE.BufferGeometry();
|
||||||
|
geo.setAttribute('position', new THREE.BufferAttribute(arr.toFloat32(), 3));
|
||||||
|
this.solids.add(new THREE.Mesh(geo, mat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
LP.render = function() {
|
LP.render = function() {
|
||||||
if (!(this.view && this.changed)) return;
|
if (!(this.view && this.changed)) return;
|
||||||
if (this.group) this.view.remove(this.group);
|
if (this.group) this.view.remove(this.group);
|
||||||
|
|
|
||||||
26
js/kiri.js
26
js/kiri.js
|
|
@ -638,6 +638,10 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
function preparePrint(callback) {
|
function preparePrint(callback) {
|
||||||
|
let isSLA = MODE === MODES.SLA,
|
||||||
|
tpFactor = isSLA ? 0.5 : 1,
|
||||||
|
tpBase = isSLA ? 0.5 : 0;
|
||||||
|
|
||||||
// kick off slicing it hasn't been done already
|
// kick off slicing it hasn't been done already
|
||||||
for (let i=0; i < WIDGETS.length; i++) {
|
for (let i=0; i < WIDGETS.length; i++) {
|
||||||
if (!WIDGETS[i].slices || WIDGETS[i].isModified()) {
|
if (!WIDGETS[i].slices || WIDGETS[i].isModified()) {
|
||||||
|
|
@ -661,16 +665,21 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
forAllWidgets(function(widget) {
|
forAllWidgets(function(widget) {
|
||||||
widget.setColor(color.cam_preview);
|
widget.setColor(color.cam_preview);
|
||||||
});
|
});
|
||||||
} else {
|
} else if (!isSLA) {
|
||||||
setOpacity(color.preview_opacity);
|
setOpacity(color.preview_opacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentPrint = kiri.newPrint(settings, WIDGETS);
|
currentPrint = kiri.newPrint(settings, WIDGETS);
|
||||||
currentPrint.setup(true, function(update, status) {
|
currentPrint.setup(true, function(update, status) {
|
||||||
// on update
|
// on update
|
||||||
setProgress(update, status);
|
setProgress(tpBase + update * tpFactor, status);
|
||||||
}, function() {
|
}, function() {
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
|
|
||||||
|
if (isSLA) {
|
||||||
|
setOpacity(0);
|
||||||
|
}
|
||||||
|
|
||||||
currentPrint.render();
|
currentPrint.render();
|
||||||
|
|
||||||
// on done
|
// on done
|
||||||
|
|
@ -729,6 +738,8 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
countdown = WIDGETS.length,
|
countdown = WIDGETS.length,
|
||||||
preserveMax = API.var.layer_max,
|
preserveMax = API.var.layer_max,
|
||||||
preserveLayer = API.var.layer_at,
|
preserveLayer = API.var.layer_at,
|
||||||
|
isSLA = MODE === MODES.SLA,
|
||||||
|
tpFactor = isSLA ? 0.5 : 1,
|
||||||
totalProgress,
|
totalProgress,
|
||||||
track = {};
|
track = {};
|
||||||
|
|
||||||
|
|
@ -749,12 +760,14 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
widget.setColor(color.slicing);
|
widget.setColor(color.slicing);
|
||||||
widget.slice(settings, function(sliced, error) {
|
widget.slice(settings, function(sliced, error) {
|
||||||
let mark = UTIL.time();
|
let mark = UTIL.time();
|
||||||
|
if (!isSLA) {
|
||||||
// on done
|
// on done
|
||||||
widget.render(renderMode, MODE === MODES.CAM);
|
widget.render(renderMode, MODE === MODES.CAM);
|
||||||
// clear wireframe
|
// clear wireframe
|
||||||
widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
|
widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
|
||||||
widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
||||||
widget.setColor(color.deselected);
|
widget.setColor(color.deselected);
|
||||||
|
}
|
||||||
// update UI info
|
// update UI info
|
||||||
if (sliced) {
|
if (sliced) {
|
||||||
// update segment time
|
// update segment time
|
||||||
|
|
@ -769,6 +782,9 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
}
|
}
|
||||||
// on the last exit, update ui and call the callback
|
// on the last exit, update ui and call the callback
|
||||||
if (--countdown === 0 || error || errored) {
|
if (--countdown === 0 || error || errored) {
|
||||||
|
if (isSLA) {
|
||||||
|
preparePrint(callback);
|
||||||
|
} else {
|
||||||
setProgress(0);
|
setProgress(0);
|
||||||
showSlices(preserveLayer);
|
showSlices(preserveLayer);
|
||||||
setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
||||||
|
|
@ -776,6 +792,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// update slider window
|
// update slider window
|
||||||
API.dialog.update();
|
API.dialog.update();
|
||||||
// handle slicing errors
|
// handle slicing errors
|
||||||
|
|
@ -800,7 +817,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
forAllWidgets(function(w) {
|
forAllWidgets(function(w) {
|
||||||
totalProgress += (track[w.id] || 0);
|
totalProgress += (track[w.id] || 0);
|
||||||
});
|
});
|
||||||
setProgress(totalProgress / WIDGETS.length, msg);
|
setProgress((totalProgress / WIDGETS.length) * tpFactor, msg);
|
||||||
}, true);
|
}, true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -1808,8 +1825,10 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
showModeActive(UI.modeSlice);
|
showModeActive(UI.modeSlice);
|
||||||
break;
|
break;
|
||||||
case VIEWS.PREVIEW:
|
case VIEWS.PREVIEW:
|
||||||
|
// if (MODE !== MODES.SLA) {
|
||||||
showLayerView(true);
|
showLayerView(true);
|
||||||
showModeActive(UI.modePreview);
|
showModeActive(UI.modePreview);
|
||||||
|
// }
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBUG.log("invalid view mode: "+mode);
|
DBUG.log("invalid view mode: "+mode);
|
||||||
|
|
@ -1870,6 +1889,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
||||||
UI.modeCAM.setAttribute('class', MODE === MODES.CAM ? 'buton' : '');
|
UI.modeCAM.setAttribute('class', MODE === MODES.CAM ? 'buton' : '');
|
||||||
UI.modeLASER.setAttribute('class', MODE === MODES.LASER ? 'buton' : '');
|
UI.modeLASER.setAttribute('class', MODE === MODES.LASER ? 'buton' : '');
|
||||||
UI.mode.style.display = lock ? 'none' : '';
|
UI.mode.style.display = lock ? 'none' : '';
|
||||||
|
UI.modePreview.style.display = MODE === MODES.SLA ? 'none' : '';
|
||||||
UI.modeTable.style.display = lock ? 'none' : '';
|
UI.modeTable.style.display = lock ? 'none' : '';
|
||||||
if (camStock) {
|
if (camStock) {
|
||||||
camStock.material.visible = settings.mode === 'CAM';
|
camStock.material.visible = settings.mode === 'CAM';
|
||||||
|
|
|
||||||
|
|
@ -354,10 +354,6 @@ var gs_moto_ui = exports;
|
||||||
txt.setAttribute("cols", Math.max(30, cols + 1));
|
txt.setAttribute("cols", Math.max(30, cols + 1));
|
||||||
txt.setAttribute("rows", Math.max(10, rows.length + 1));
|
txt.setAttribute("rows", Math.max(10, rows.length + 1));
|
||||||
|
|
||||||
txt.onblur = () => {
|
|
||||||
console.log({text_lost_focus: txt});
|
|
||||||
};
|
|
||||||
|
|
||||||
let showing = pop === lastPop;
|
let showing = pop === lastPop;
|
||||||
hidePop();
|
hidePop();
|
||||||
if (!showing) {
|
if (!showing) {
|
||||||
|
|
|
||||||
|
|
@ -804,6 +804,7 @@ let ver = require('../js/license.js'),
|
||||||
"license",
|
"license",
|
||||||
"ext-tween",
|
"ext-tween",
|
||||||
"ext-fsave",
|
"ext-fsave",
|
||||||
|
"ext-earcut",
|
||||||
"add-array",
|
"add-array",
|
||||||
"add-three",
|
"add-three",
|
||||||
"geo",
|
"geo",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue