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;
|
||||
polys.forEach(poly => {
|
||||
layer.poly(poly, 0x888888, true, false);
|
||||
layer.poly(poly, 0x222222, true);
|
||||
layer.solid(poly, 0x00bbee);
|
||||
count++;
|
||||
});
|
||||
});
|
||||
layer.renderSolid();
|
||||
layer.render();
|
||||
|
||||
if (count === 0) {
|
||||
|
|
|
|||
|
|
@ -313,7 +313,9 @@ var gs_kiri_init = exports;
|
|||
API.function.slice();
|
||||
break;
|
||||
case cca('p'): // prepare print
|
||||
API.function.print();
|
||||
if (API.mode.get() !== 'SLA') {
|
||||
API.function.print();
|
||||
}
|
||||
break;
|
||||
case cca('P'): // position widget
|
||||
positionSelection();
|
||||
|
|
@ -653,7 +655,6 @@ var gs_kiri_init = exports;
|
|||
}
|
||||
|
||||
function updateDeviceName() {
|
||||
console.log('update device name');
|
||||
let newname = UI.deviceName.value,
|
||||
selected = API.device.get(),
|
||||
devs = settings().devices;
|
||||
|
|
|
|||
|
|
@ -16,10 +16,17 @@ let gs_kiri_layer = exports;
|
|||
KIRI.Layer = Layer;
|
||||
KIRI.newLayer = function(view) { return new Layer(view) };
|
||||
|
||||
function materialFor(color) {
|
||||
function materialFor(color, mesh, linewidth) {
|
||||
let m = mcache[color];
|
||||
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,
|
||||
color: color,
|
||||
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
|
||||
*/
|
||||
function Layer(view) {
|
||||
this.changed = false;
|
||||
this.group = null;
|
||||
this.solids = null;
|
||||
this.view = view;
|
||||
this.bycolor = {};
|
||||
};
|
||||
|
||||
LP.setVisible = function(vis) {
|
||||
if (this.group) this.group.visible = vis;
|
||||
if (this.solids) this.solids.visible = vis;
|
||||
};
|
||||
|
||||
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) {
|
||||
let layer = this,
|
||||
sz = size/2;
|
||||
|
|
@ -130,6 +153,32 @@ let gs_kiri_layer = exports;
|
|||
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() {
|
||||
if (!(this.view && this.changed)) return;
|
||||
if (this.group) this.view.remove(this.group);
|
||||
|
|
|
|||
52
js/kiri.js
52
js/kiri.js
|
|
@ -638,6 +638,10 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
}
|
||||
|
||||
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
|
||||
for (let i=0; i < WIDGETS.length; i++) {
|
||||
if (!WIDGETS[i].slices || WIDGETS[i].isModified()) {
|
||||
|
|
@ -661,16 +665,21 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
forAllWidgets(function(widget) {
|
||||
widget.setColor(color.cam_preview);
|
||||
});
|
||||
} else {
|
||||
} else if (!isSLA) {
|
||||
setOpacity(color.preview_opacity);
|
||||
}
|
||||
|
||||
currentPrint = kiri.newPrint(settings, WIDGETS);
|
||||
currentPrint.setup(true, function(update, status) {
|
||||
// on update
|
||||
setProgress(update, status);
|
||||
setProgress(tpBase + update * tpFactor, status);
|
||||
}, function() {
|
||||
setProgress(0);
|
||||
|
||||
if (isSLA) {
|
||||
setOpacity(0);
|
||||
}
|
||||
|
||||
currentPrint.render();
|
||||
|
||||
// on done
|
||||
|
|
@ -729,6 +738,8 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
countdown = WIDGETS.length,
|
||||
preserveMax = API.var.layer_max,
|
||||
preserveLayer = API.var.layer_at,
|
||||
isSLA = MODE === MODES.SLA,
|
||||
tpFactor = isSLA ? 0.5 : 1,
|
||||
totalProgress,
|
||||
track = {};
|
||||
|
||||
|
|
@ -749,12 +760,14 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
widget.setColor(color.slicing);
|
||||
widget.slice(settings, function(sliced, error) {
|
||||
let mark = UTIL.time();
|
||||
// on done
|
||||
widget.render(renderMode, MODE === MODES.CAM);
|
||||
// clear wireframe
|
||||
widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
|
||||
widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
||||
widget.setColor(color.deselected);
|
||||
if (!isSLA) {
|
||||
// on done
|
||||
widget.render(renderMode, MODE === MODES.CAM);
|
||||
// clear wireframe
|
||||
widget.setWireframe(false, color.wireframe, color.wireframe_opacity);
|
||||
widget.setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
||||
widget.setColor(color.deselected);
|
||||
}
|
||||
// update UI info
|
||||
if (sliced) {
|
||||
// update segment time
|
||||
|
|
@ -769,11 +782,15 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
}
|
||||
// on the last exit, update ui and call the callback
|
||||
if (--countdown === 0 || error || errored) {
|
||||
setProgress(0);
|
||||
showSlices(preserveLayer);
|
||||
setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
if (isSLA) {
|
||||
preparePrint(callback);
|
||||
} else {
|
||||
setProgress(0);
|
||||
showSlices(preserveLayer);
|
||||
setOpacity(settings.mode === 'CAM' ? color.cam_sliced_opacity : color.sliced_opacity);
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
// update slider window
|
||||
|
|
@ -800,7 +817,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
forAllWidgets(function(w) {
|
||||
totalProgress += (track[w.id] || 0);
|
||||
});
|
||||
setProgress(totalProgress / WIDGETS.length, msg);
|
||||
setProgress((totalProgress / WIDGETS.length) * tpFactor, msg);
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
|
|
@ -1808,8 +1825,10 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
showModeActive(UI.modeSlice);
|
||||
break;
|
||||
case VIEWS.PREVIEW:
|
||||
showLayerView(true);
|
||||
showModeActive(UI.modePreview);
|
||||
// if (MODE !== MODES.SLA) {
|
||||
showLayerView(true);
|
||||
showModeActive(UI.modePreview);
|
||||
// }
|
||||
break;
|
||||
default:
|
||||
DBUG.log("invalid view mode: "+mode);
|
||||
|
|
@ -1870,6 +1889,7 @@ self.kiri.copyright = exports.COPYRIGHT;
|
|||
UI.modeCAM.setAttribute('class', MODE === MODES.CAM ? 'buton' : '');
|
||||
UI.modeLASER.setAttribute('class', MODE === MODES.LASER ? 'buton' : '');
|
||||
UI.mode.style.display = lock ? 'none' : '';
|
||||
UI.modePreview.style.display = MODE === MODES.SLA ? 'none' : '';
|
||||
UI.modeTable.style.display = lock ? 'none' : '';
|
||||
if (camStock) {
|
||||
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("rows", Math.max(10, rows.length + 1));
|
||||
|
||||
txt.onblur = () => {
|
||||
console.log({text_lost_focus: txt});
|
||||
};
|
||||
|
||||
let showing = pop === lastPop;
|
||||
hidePop();
|
||||
if (!showing) {
|
||||
|
|
|
|||
|
|
@ -804,6 +804,7 @@ let ver = require('../js/license.js'),
|
|||
"license",
|
||||
"ext-tween",
|
||||
"ext-fsave",
|
||||
"ext-earcut",
|
||||
"add-array",
|
||||
"add-three",
|
||||
"geo",
|
||||
|
|
|
|||
Loading…
Reference in a new issue