refactor cam stock visualization
This commit is contained in:
parent
ba13531297
commit
8a1118d6c1
12 changed files with 253 additions and 189 deletions
4
notes.md
4
notes.md
|
|
@ -1,12 +1,14 @@
|
|||
# Kiri:Moto todo
|
||||
|
||||
## 2.3 remaining
|
||||
* stock to outline for slice mode
|
||||
* adaptive shadow-line generation for small parts collision detection
|
||||
* test path clearance for every move > % of tool diam and ...
|
||||
* contour tabs support
|
||||
* path arrows, retracts, and engages
|
||||
* cap path ends
|
||||
* help dialog
|
||||
* full bug reports
|
||||
* onshape mouse mapping option
|
||||
|
||||
## 2.4
|
||||
* cnc: tracing, visualization, manual tabs
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "grid-apps",
|
||||
"version": "2.3.8D",
|
||||
"version": "2.3.9D",
|
||||
"description": "grid.space 3d slice & modeling tools",
|
||||
"author": "Stewart Allen <sa@grid.space>",
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -453,6 +453,7 @@
|
|||
camStockY: 0,
|
||||
camStockZ: 0,
|
||||
camStockOffset: true,
|
||||
camStockOn: false,
|
||||
camConventional: false, // outputClockwise
|
||||
outputOriginCenter: false,
|
||||
outputInvertX: false,
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@
|
|||
control.decimate = UI.decimate.checked;
|
||||
SPACE.view.setZoom(control.reverseZoom, control.zoomSpeed);
|
||||
platform.layout();
|
||||
platform.update_stock();
|
||||
// platform.update_stock();
|
||||
API.conf.save();
|
||||
API.mode.set_expert(control.expert);
|
||||
API.platform.update_size();
|
||||
|
|
@ -145,6 +145,7 @@
|
|||
});
|
||||
UC.setHoverPop(control.hoverPop);
|
||||
updateFPS();
|
||||
API.event.emit('boolean.update');
|
||||
}
|
||||
|
||||
function updateFPS() {
|
||||
|
|
@ -170,6 +171,7 @@
|
|||
}
|
||||
API.conf.update();
|
||||
DOC.activeElement.blur();
|
||||
// API.event.emit("boolean.click");
|
||||
}
|
||||
|
||||
function inputHasFocus() {
|
||||
|
|
@ -1483,6 +1485,7 @@
|
|||
camContourOver: UC.newInput(LANG.cc_sovr_s, {title:LANG.cc_sovr_l, convert:UC.toFloat, bound:UC.bound(0.05,1.0), modes:CAM}),
|
||||
camContourSpeed: UC.newInput(LANG.cc_feed_s, {title:LANG.cc_feed_l, convert:UC.toInt, modes:CAM, units:true}),
|
||||
camContourAngle: UC.newInput(LANG.cf_angl_s, {title:LANG.cf_angl_l, convert:UC.toFloat, bound:UC.bound(45,90), modes:CAM}),
|
||||
camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM, units:true}),
|
||||
camContourCurves: UC.newBoolean(LANG.cf_curv_s, onBooleanClick, {title:LANG.cf_curv_l, modes:CAM}),
|
||||
camContourIn: UC.newBoolean(LANG.cf_olin_s, onBooleanClick, {title:LANG.cf_olin_l, modes:CAM}),
|
||||
camContourSep: UC.newBlank({class:"pop-sep"}),
|
||||
|
|
@ -1518,6 +1521,8 @@
|
|||
camStockY: UC.newInput(LANG.cs_dpth_s, {title:LANG.cs_dpth_l, convert:UC.toFloat, bound:UC.bound(0,9999), modes:CAM, units:true}),
|
||||
camStockZ: UC.newInput(LANG.cs_hght_s, {title:LANG.cs_hght_l, convert:UC.toFloat, bound:UC.bound(0,9999), modes:CAM, units:true}),
|
||||
camStockOffset: UC.newBoolean(LANG.cs_offs_s, onBooleanClick, {title:LANG.cs_offs_l, modes:CAM}),
|
||||
camStockSep: UC.newBlank({class:"pop-sep"}),
|
||||
camStockOn: UC.newBoolean(LANG.cs_offe_s, onBooleanClick, {title:LANG.cs_offe_l, modes:CAM}),
|
||||
|
||||
camCommon: UC.newGroup(LANG.cc_menu, null, {modes:CAM}),
|
||||
camZTopOffset: UC.newInput(LANG.ou_ztof_s, {title:LANG.ou_ztof_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
|
|
@ -1526,7 +1531,6 @@
|
|||
camZThru: UC.newInput(LANG.ou_ztru_s, {title:LANG.ou_ztru_l, convert:UC.toFloat, bound:UC.bound(0.0,100), modes:CAM, units:true, show:() => { return UI.camZBottom.value == 0 }}),
|
||||
camFastFeedZ: UC.newInput(LANG.cc_rzpd_s, {title:LANG.cc_rzpd_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
camFastFeed: UC.newInput(LANG.cc_rapd_s, {title:LANG.cc_rapd_l, convert:UC.toFloat, modes:CAM, units:true}),
|
||||
camTolerance: UC.newInput(LANG.ou_toll_s, {title:LANG.ou_toll_l, convert:UC.toFloat, bound:UC.bound(0.001,1.0), modes:CAM, units:true}),
|
||||
|
||||
laserLayout: UC.newGroup(LANG.lo_menu, null, {modes:LASER, group:"lz-lo"}),
|
||||
outputTileSpacing: UC.newInput(LANG.ou_spac_s, {title:LANG.ou_spac_l, convert:UC.toInt, modes:LASER}),
|
||||
|
|
@ -1900,7 +1904,8 @@
|
|||
widget.move(delta.x, delta.y, 0);
|
||||
API.event.emit('widget.move', {widget, delta});
|
||||
});
|
||||
platform.update_stock();
|
||||
// platform.update_stock();
|
||||
API.event.emit('selection.drag', delta);
|
||||
} else {
|
||||
return API.selection.meshes().length > 0;
|
||||
}
|
||||
|
|
|
|||
194
src/kiri/main.js
194
src/kiri/main.js
|
|
@ -50,8 +50,7 @@
|
|||
viewMode = VIEWS.ARRANGE,
|
||||
layoutOnAdd = true,
|
||||
local = SETUP.local,
|
||||
camStock = null,
|
||||
camTopZ = 0,
|
||||
topZD = 0,
|
||||
topZ = 0,
|
||||
busy = 0,
|
||||
showFavorites = SDB.getItem('dev-favorites') === 'true',
|
||||
|
|
@ -98,7 +97,7 @@
|
|||
compute_max_z: platformComputeMaxZ,
|
||||
update_origin: platformUpdateOrigin,
|
||||
update_bounds: platformUpdateBounds,
|
||||
update_stock: platformUpdateStock,
|
||||
// update_stock: platformUpdateStock,
|
||||
update_size: platformUpdateSize,
|
||||
update_top_z: platformUpdateTopZ,
|
||||
update_selected: platformUpdateSelected,
|
||||
|
|
@ -108,7 +107,8 @@
|
|||
group_done: platformGroupDone,
|
||||
set_font: SPACE.platform.setFont,
|
||||
set_axes: SPACE.platform.setAxes,
|
||||
set_volume: SPACE.platform.setVolume
|
||||
set_volume: SPACE.platform.setVolume,
|
||||
top_z: () => { return topZ }
|
||||
};
|
||||
|
||||
const color = {
|
||||
|
|
@ -296,7 +296,8 @@
|
|||
update_slider: updateSlider,
|
||||
update_fields: updateFields,
|
||||
wireframe: setWireframe,
|
||||
snapshot: null
|
||||
snapshot: null,
|
||||
unit_scale: unitScale
|
||||
},
|
||||
widgets: {
|
||||
new: newWidget,
|
||||
|
|
@ -437,12 +438,17 @@
|
|||
}
|
||||
|
||||
function sendOnEvent(name, data) {
|
||||
if (name && onEvent[name]) onEvent[name].forEach(function(fn) {
|
||||
fn(data);
|
||||
});
|
||||
if (name && onEvent[name]) {
|
||||
onEvent[name].forEach(function(fn) {
|
||||
fn(data, name);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function addOnEvent(name, handler) {
|
||||
if (Array.isArray(name)) {
|
||||
return name.forEach(n => addOnEvent(n, handler));
|
||||
}
|
||||
if (name && typeof(name) === 'string' && typeof(handler) === 'function') {
|
||||
onEvent[name] = onEvent[name] || [];
|
||||
onEvent[name].push(handler);
|
||||
|
|
@ -786,20 +792,6 @@
|
|||
|
||||
hideSlider(true);
|
||||
|
||||
// kick off slicing it hasn't been done already
|
||||
for (let i=0; i < WIDGETS.length; i++) {
|
||||
if (!WIDGETS[i].slices || WIDGETS[i].isModified()) {
|
||||
prepareSlices(function() {
|
||||
if (!WIDGETS[i].slices || WIDGETS[i].isModified()) {
|
||||
alert2("nothing to print");
|
||||
} else {
|
||||
preparePreview(callback);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let isCam = MODE === MODES.CAM, pMode = getMode();
|
||||
|
||||
if (feature.preview) {
|
||||
|
|
@ -901,13 +893,15 @@
|
|||
|
||||
function setOpacity(value) {
|
||||
forAllWidgets(function (w) { w.setOpacity(value) });
|
||||
// UI.modelOpacity.value = value * 100;
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
function moveSelection(x, y, z, abs) {
|
||||
forSelectedGroups(function (w) { w.move(x, y, z, abs) });
|
||||
platform.update_stock();
|
||||
forSelectedGroups(function (w) {
|
||||
w.move(x, y, z, abs);
|
||||
});
|
||||
API.event.emit('selection.move', {x, y, z, abs});
|
||||
// platform.update_stock();
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
|
|
@ -916,13 +910,14 @@
|
|||
forSelectedGroups(function (w) {
|
||||
w.scale(...args);
|
||||
});
|
||||
platform.compute_max_z();
|
||||
API.event.emit('selection.scale', [...arguments]);
|
||||
// skip update if last argument is strictly 'false'
|
||||
if ([...arguments].pop() === false) {
|
||||
return;
|
||||
}
|
||||
updateSelectedInfo();
|
||||
platform.compute_max_z();
|
||||
platform.update_stock(true);
|
||||
// platform.update_stock(true);
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
|
|
@ -930,9 +925,10 @@
|
|||
forSelectedGroups(function (w) {
|
||||
w.rotate(x, y, z);
|
||||
});
|
||||
updateSelectedInfo();
|
||||
platform.compute_max_z();
|
||||
platform.update_stock(true);
|
||||
API.event.emit('selection.rotate', {x, y, z});
|
||||
updateSelectedInfo();
|
||||
// platform.update_stock(true);
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
|
|
@ -942,9 +938,14 @@
|
|||
|
||||
function platformUpdateOrigin() {
|
||||
platform.update_bounds();
|
||||
// return;
|
||||
|
||||
let dev = settings.device;
|
||||
let proc = settings.process;
|
||||
let ruler = settings.controller.showRulers;
|
||||
let stock = settings.stock;
|
||||
let stockCenter = stock.center || {};
|
||||
let hasStock = stock.x && stock.y && stock.z;
|
||||
let center = MODE === MODES.FDM ? dev.originCenter :
|
||||
MODE === MODES.SLA ? false :
|
||||
MODE === MODES.CAM ? proc.outputOriginCenter :
|
||||
|
|
@ -953,15 +954,15 @@
|
|||
let y = 0;
|
||||
let z = 0;
|
||||
if (MODE === MODES.CAM && proc.camOriginTop) {
|
||||
z = camTopZ + 0.01;
|
||||
if (!camStock) {
|
||||
z += proc.camZTopOffset * unitScale();
|
||||
}
|
||||
z = (topZ + topZD) + 0.01;
|
||||
// if (!hasStock) {
|
||||
// z += proc.camZTopOffset * unitScale();
|
||||
// }
|
||||
}
|
||||
if (!center) {
|
||||
if (camStock) {
|
||||
x = (-camStock.scale.x / 2) + camStock.position.x;
|
||||
y = (camStock.scale.y / 2) - camStock.position.y;
|
||||
if (hasStock) {
|
||||
x = (-stock.x / 2) + stockCenter.x;
|
||||
y = (stock.y / 2) - stockCenter.y;
|
||||
} else {
|
||||
if (MODE === MODES.LASER && proc.outputOriginBounds) {
|
||||
let b = settings.bounds;
|
||||
|
|
@ -972,9 +973,9 @@
|
|||
y = dev.bedDepth / 2;
|
||||
}
|
||||
}
|
||||
} else if (camStock) {
|
||||
x = camStock.position.x;
|
||||
y = -camStock.position.y;
|
||||
} else if (hasStock) {
|
||||
x = stockCenter.x;
|
||||
y = -stockCenter.y;
|
||||
}
|
||||
settings.origin = {x, y, z};
|
||||
SPACE.platform.setRulers(ruler, ruler, center);
|
||||
|
|
@ -985,10 +986,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
function platformUpdateTopZ() {
|
||||
function platformUpdateTopZ(zdelta) {
|
||||
topZD = zdelta !== undefined ? zdelta : topZD;
|
||||
let stock = settings.stock;
|
||||
let hasStock = stock.x && stock.y && stock.z;
|
||||
let alignTopOk = WIDGETS.length > 1 && settings.controller.alignTop;
|
||||
let camz = (MODE === MODES.CAM) && (settings.stock.z || alignTopOk);
|
||||
let ztop = camz ? camTopZ - settings.process.camZTopOffset * unitScale() : 0;
|
||||
let camz = (MODE === MODES.CAM) && (hasStock || alignTopOk);
|
||||
let czto = hasStock ? settings.process.camZTopOffset * unitScale() : 0;
|
||||
let ztop = camz ? (topZ + topZD) - czto : 0;
|
||||
forAllWidgets(function(widget) {
|
||||
widget.setTopZ(ztop);
|
||||
});
|
||||
|
|
@ -1040,6 +1045,7 @@
|
|||
wb.max.y += wp.y;
|
||||
bounds.union(wb);
|
||||
});
|
||||
// console.log(JSON.stringify(bounds))
|
||||
return settings.bounds = bounds;
|
||||
}
|
||||
|
||||
|
|
@ -1203,7 +1209,9 @@
|
|||
selectedMeshes.remove(widget.mesh);
|
||||
updateSliderMax();
|
||||
platform.compute_max_z();
|
||||
if (MODE !== MODES.FDM) platform.layout();
|
||||
if (MODE !== MODES.FDM) {
|
||||
platform.layout();
|
||||
}
|
||||
SPACE.update();
|
||||
platformUpdateSelected();
|
||||
if (layoutOnAdd) platform.layout();
|
||||
|
|
@ -1218,8 +1226,7 @@
|
|||
let auto = UI.autoLayout.checked,
|
||||
proc = settings.process,
|
||||
oldmode = viewMode,
|
||||
layout = (viewMode === VIEWS.ARRANGE && auto),
|
||||
topZ = MODE === MODES.CAM ? camTopZ - proc.camZTopOffset * unitScale() : 0;
|
||||
layout = (viewMode === VIEWS.ARRANGE && auto);
|
||||
|
||||
switch (MODE) {
|
||||
case MODES.SLA:
|
||||
|
|
@ -1239,11 +1246,13 @@
|
|||
|
||||
// only auto-layout when in arrange mode
|
||||
if (oldmode !== VIEWS.ARRANGE) {
|
||||
API.event.emit('platform.layout');
|
||||
return SPACE.update();
|
||||
}
|
||||
|
||||
// do not layout when switching back from slice view
|
||||
if (!auto || (!space && !layout)) {
|
||||
API.event.emit('platform.layout');
|
||||
return SPACE.update();
|
||||
}
|
||||
|
||||
|
|
@ -1277,92 +1286,9 @@
|
|||
// m.material.visible = true;
|
||||
}
|
||||
|
||||
if (MODE === MODES.CAM) {
|
||||
platform.update_stock(true);
|
||||
}
|
||||
platform.update_origin();
|
||||
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
function updateStockVisibility() {
|
||||
if (camStock) {
|
||||
camStock.material.visible = settings.mode === 'CAM';// && viewMode === VIEWS.ARRANGE;
|
||||
}
|
||||
}
|
||||
|
||||
function platformUpdateStock(refresh) {
|
||||
let sd = settings.process;
|
||||
let offset = UI.camStockOffset.checked;
|
||||
let stockSet = offset || (sd.camStockX && sd.camStockY && sd.camStockZ > 0);
|
||||
let scale = unitScale();
|
||||
settings.stock = { };
|
||||
camTopZ = topZ;
|
||||
// create/inject cam stock if stock size other than default
|
||||
if (MODE === MODES.CAM && stockSet && WIDGETS.length) {
|
||||
// UI.stock.style.display = offset ? 'inline-block' : 'none';
|
||||
let csx = sd.camStockX * scale;
|
||||
let csy = sd.camStockY * scale;
|
||||
let csz = sd.camStockZ * scale;
|
||||
let csox = 0;
|
||||
let csoy = 0;
|
||||
if (offset) {
|
||||
let min = { x: Infinity, y: Infinity, z: 0 };
|
||||
let max = { x: -Infinity, y: -Infinity, z: -Infinity };
|
||||
forAllWidgets(function(widget) {
|
||||
let wbnd = widget.getBoundingBox(refresh);
|
||||
let wpos = widget.track.pos;
|
||||
min = {
|
||||
x: Math.min(min.x, wpos.x + wbnd.min.x),
|
||||
y: Math.min(min.y, wpos.y + wbnd.min.y),
|
||||
z: 0
|
||||
};
|
||||
max = {
|
||||
x: Math.max(max.x, wpos.x + wbnd.max.x),
|
||||
y: Math.max(max.y, wpos.y + wbnd.max.y),
|
||||
z: Math.max(max.z, wbnd.max.z)
|
||||
};
|
||||
});
|
||||
csx += max.x - min.x;
|
||||
csy += max.y - min.y;
|
||||
csz += max.z - min.z;
|
||||
csox = min.x + ((max.x - min.x) / 2);
|
||||
csoy = min.y + ((max.y - min.y) / 2);
|
||||
}
|
||||
if (!camStock) {
|
||||
let geo = new THREE.BoxGeometry(1, 1, 1);
|
||||
let mat = new THREE.MeshBasicMaterial({
|
||||
color: 0x777777,
|
||||
opacity: 0.2,
|
||||
transparent: true,
|
||||
side:THREE.DoubleSide
|
||||
});
|
||||
let cube = new THREE.Mesh(geo, mat);
|
||||
SPACE.platform.add(cube);
|
||||
camStock = cube;
|
||||
cube.renderOrder = 2;
|
||||
}
|
||||
settings.stock = {
|
||||
x: csx,
|
||||
y: csy,
|
||||
z: csz
|
||||
};
|
||||
camStock.scale.x = csx;
|
||||
camStock.scale.y = csy;
|
||||
camStock.scale.z = csz;
|
||||
camStock.position.x = csox;
|
||||
camStock.position.y = csoy;
|
||||
camStock.position.z = csz / 2;
|
||||
updateStockVisibility();
|
||||
camTopZ = csz;
|
||||
} else if (camStock) {
|
||||
// UI.stock.style.display = 'none';
|
||||
SPACE.platform.remove(camStock);
|
||||
camStock = null;
|
||||
camTopZ = topZ;
|
||||
}
|
||||
platform.update_top_z();
|
||||
platform.update_origin();
|
||||
API.event.emit('platform.layout');
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
|
|
@ -1513,7 +1439,7 @@
|
|||
updateSettingsFromFields(device.extruders[device.internal]);
|
||||
}
|
||||
API.conf.save();
|
||||
platform.update_stock();
|
||||
// platform.update_stock();
|
||||
$('mode-device').innerText = settings.device.deviceName;
|
||||
$('mode-profile').innerText = settings.process.processName;
|
||||
}
|
||||
|
|
@ -1694,7 +1620,7 @@
|
|||
|
||||
updateFields();
|
||||
platform.update_size();
|
||||
platform.update_stock();
|
||||
// platform.update_stock();
|
||||
|
||||
let fz = SPACE.scene.freeze(true);
|
||||
SPACE.view.reset();
|
||||
|
|
@ -1969,7 +1895,7 @@
|
|||
viewMode = mode;
|
||||
platform.deselect();
|
||||
updateSelectedInfo();
|
||||
updateStockVisibility();
|
||||
// updateStockVisibility();
|
||||
switch (mode) {
|
||||
case VIEWS.ARRANGE:
|
||||
UI.back.style.display = '';
|
||||
|
|
@ -1999,7 +1925,7 @@
|
|||
DBUG.log("invalid view mode: "+mode);
|
||||
return;
|
||||
}
|
||||
API.event.emit('view.mode', mode);
|
||||
API.event.emit('view.set', mode);
|
||||
DOC.activeElement.blur();
|
||||
}
|
||||
|
||||
|
|
@ -2045,7 +1971,7 @@
|
|||
API.event.emit('device.set', currentDeviceName());
|
||||
}
|
||||
// really belongs in CAM driver (lots of work / abstraction needed)
|
||||
updateStockVisibility();
|
||||
// updateStockVisibility();
|
||||
// updates right-hand menu by enabling/disabling fields
|
||||
setViewMode(VIEWS.ARRANGE);
|
||||
UC.setMode(MODE);
|
||||
|
|
|
|||
|
|
@ -618,12 +618,6 @@
|
|||
}
|
||||
};
|
||||
|
||||
PRO.getCamBounds = function(settings) {
|
||||
let bounds = this.getBoundingBox().clone();
|
||||
bounds.max.z += settings.process.camZTopOffset;
|
||||
return bounds;
|
||||
};
|
||||
|
||||
/**
|
||||
* render to provided stack
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
let terms = {
|
||||
COPYRIGHT: "Copyright (C) Stewart Allen <sa@grid.space> - All Rights Reserved",
|
||||
LICENSE: "See the license.md file included with the source distribution",
|
||||
VERSION: "2.3.D8"
|
||||
VERSION: "2.3.D9"
|
||||
};
|
||||
|
||||
if (typeof(module) === 'object') {
|
||||
|
|
|
|||
|
|
@ -9,16 +9,35 @@
|
|||
CAM = KIRI.driver.CAM,
|
||||
PRO = CAM.process,
|
||||
newPolygon = BASE.newPolygon,
|
||||
newPoint = BASE.newPoint;
|
||||
newPoint = BASE.newPoint,
|
||||
isArrange,
|
||||
isCamMode,
|
||||
camStock,
|
||||
API, SPACE, MODES, VIEWS, UI, UC;
|
||||
|
||||
CAM.init = function(kiri, api) {
|
||||
// console.log({kiri,api})
|
||||
SPACE = api.const.SPACE;
|
||||
MODES = api.const.MODES;
|
||||
VIEWS = api.const.VIEWS;
|
||||
UI = api.ui;
|
||||
UC = api.uc;
|
||||
API = api;
|
||||
|
||||
api.event.on("mode.set", (mode) => {
|
||||
const isCAM = mode === 'CAM';
|
||||
$('set-tools').style.display = isCAM ? '' : 'none';
|
||||
kiri.space.platform.setColor(isCAM ? 0xeeeeee : 0xcccccc);
|
||||
isCamMode = mode === 'CAM';
|
||||
$('set-tools').style.display = isCamMode ? '' : 'none';
|
||||
kiri.space.platform.setColor(isCamMode ? 0xeeeeee : 0xcccccc);
|
||||
updateStock(undefined, 'internal');
|
||||
});
|
||||
|
||||
api.event.on("view.set", (mode) => {
|
||||
isArrange = (mode === VIEWS.ARRANGE);
|
||||
});
|
||||
|
||||
api.event.on("settings.saved", (settings) => {
|
||||
const proc = settings.process;
|
||||
// show/hide dots in enabled process pop buttons
|
||||
api.ui.camTabs.marker.style.display = proc.camTabsOn ? 'flex' : 'none';
|
||||
api.ui.camRough.marker.style.display = proc.camRoughOn ? 'flex' : 'none';
|
||||
api.ui.camDrill.marker.style.display =
|
||||
|
|
@ -26,32 +45,142 @@
|
|||
api.ui.camOutline.marker.style.display = proc.camOutlineOn ? 'flex' : 'none';
|
||||
api.ui.camContour.marker.style.display =
|
||||
proc.camContourXOn || proc.camContourYOn ? 'flex' : 'none';
|
||||
updateStock(settings, 'settings.saved.internal');
|
||||
});
|
||||
|
||||
function updateStock() {
|
||||
const STACKS = api.const.STACKS;
|
||||
const SPACE = api.const.SPACE;
|
||||
const stock = api.conf.get().stock;
|
||||
const {x, y, z} = stock;
|
||||
if (x && y && z) {
|
||||
const render = new KIRI.Render().setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa }, true);
|
||||
const stack = STACKS.create('bounds', SPACE.platform.world);
|
||||
stack.add(render.addPolys([
|
||||
newPolygon().centerRectangle({x:0, y:0, z:0}, x, y),
|
||||
newPolygon().centerRectangle({x:0, y:0, z}, x, y)
|
||||
], { thin: true } ));
|
||||
const hx = x/2, hy = y/2;
|
||||
stack.add(render.addLines([
|
||||
newPoint( hx, -hy, 0), newPoint( hx, -hy, stock.z),
|
||||
newPoint( hx, hy, 0), newPoint( hx, hy, stock.z),
|
||||
newPoint(-hx, -hy, 0), newPoint(-hx, -hy, stock.z),
|
||||
newPoint(-hx, hy, 0), newPoint(-hx, hy, stock.z),
|
||||
], { thin: true }));
|
||||
}
|
||||
}
|
||||
|
||||
api.event.on("slice.end", updateStock);
|
||||
api.event.on("preview.end", updateStock);
|
||||
api.event.on([
|
||||
"init-done",
|
||||
// update stock when modes change?
|
||||
"slice.end",
|
||||
"preview.end",
|
||||
// update stock when preferences change
|
||||
// "boolean.click",
|
||||
"boolean.update",
|
||||
// update stock when objects move
|
||||
"platform.layout",
|
||||
"selection.drag",
|
||||
"selection.move",
|
||||
// force bounds update, too
|
||||
"selection.scale",
|
||||
"selection.rotate"
|
||||
], updateStock);
|
||||
};
|
||||
|
||||
function updateStock(args, event) {
|
||||
const SPACE = API.const.SPACE;
|
||||
|
||||
if (!isCamMode) {
|
||||
if (camStock) {
|
||||
SPACE.platform.remove(camStock);
|
||||
camStock = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
const STACKS = API.const.STACKS;
|
||||
const refresh = (event === "selection.scale" || event === 'selection.rotate');
|
||||
|
||||
let settings = API.conf.get();
|
||||
let widgets = API.widgets.all();
|
||||
let proc = settings.process;
|
||||
let enabled = UI.camStockOn.checked;
|
||||
let offset = UI.camStockOffset.checked;
|
||||
let stockSet = offset || (proc.camStockX && proc.camStockY && proc.camStockZ > 0);
|
||||
let scale = API.view.unit_scale();
|
||||
let topZ = API.platform.top_z();
|
||||
let delta = 0;
|
||||
let csox = 0;
|
||||
let csoy = 0;
|
||||
let stock = settings.stock = { };
|
||||
|
||||
// create/inject cam stock if stock size other than default
|
||||
if (enabled && stockSet && widgets.length) {
|
||||
// UI.stock.style.display = offset ? 'inline-block' : 'none';
|
||||
let csx = proc.camStockX * scale;
|
||||
let csy = proc.camStockY * scale;
|
||||
let csz = proc.camStockZ * scale;
|
||||
if (offset) {
|
||||
let min = { x: Infinity, y: Infinity, z: 0 };
|
||||
let max = { x: -Infinity, y: -Infinity, z: -Infinity };
|
||||
widgets.forEach(function(widget) {
|
||||
let wbnd = widget.getBoundingBox(refresh);
|
||||
let wpos = widget.track.pos;
|
||||
min = {
|
||||
x: Math.min(min.x, wpos.x + wbnd.min.x),
|
||||
y: Math.min(min.y, wpos.y + wbnd.min.y),
|
||||
z: 0
|
||||
};
|
||||
max = {
|
||||
x: Math.max(max.x, wpos.x + wbnd.max.x),
|
||||
y: Math.max(max.y, wpos.y + wbnd.max.y),
|
||||
z: Math.max(max.z, wbnd.max.z)
|
||||
};
|
||||
});
|
||||
csx += max.x - min.x;
|
||||
csy += max.y - min.y;
|
||||
csz += max.z - min.z;
|
||||
csox = min.x + ((max.x - min.x) / 2);
|
||||
csoy = min.y + ((max.y - min.y) / 2);
|
||||
}
|
||||
if (!camStock) {
|
||||
let geo = new THREE.BoxGeometry(1, 1, 1);
|
||||
let mat = new THREE.MeshBasicMaterial({
|
||||
color: 0x777777,
|
||||
opacity: 0.2,
|
||||
transparent: true,
|
||||
side:THREE.DoubleSide
|
||||
});
|
||||
camStock = new THREE.Mesh(geo, mat);
|
||||
camStock.renderOrder = 2;
|
||||
SPACE.platform.add(camStock);
|
||||
}
|
||||
stock = settings.stock = {
|
||||
x: csx,
|
||||
y: csy,
|
||||
z: csz,
|
||||
center: {
|
||||
x: csox,
|
||||
y: csoy,
|
||||
z: csz / 2
|
||||
}
|
||||
};
|
||||
camStock.scale.x = csx + 0.005;
|
||||
camStock.scale.y = csy + 0.005;
|
||||
camStock.scale.z = csz + 0.005;
|
||||
camStock.position.x = csox;
|
||||
camStock.position.y = csoy;
|
||||
camStock.position.z = csz / 2;
|
||||
delta = csz - topZ;
|
||||
} else if (camStock) {
|
||||
SPACE.platform.remove(camStock);
|
||||
camStock = null;
|
||||
delta = 0;
|
||||
}
|
||||
|
||||
if (isArrange) {
|
||||
STACKS.clear();
|
||||
}
|
||||
|
||||
const {x, y, z} = stock;
|
||||
if (x && y && z) {
|
||||
const render = new KIRI.Render().setLayer('bounds', { face: 0xaaaaaa, line: 0xaaaaaa });
|
||||
const stack = STACKS.create('bounds', SPACE.platform.world);
|
||||
stack.add(render.addPolys([
|
||||
newPolygon().centerRectangle({x:csox, y:csoy, z:0}, x, y),
|
||||
newPolygon().centerRectangle({x:csox, y:csoy, z}, x, y)
|
||||
], { thin: true } ));
|
||||
const hx = x/2, hy = y/2;
|
||||
stack.add(render.addLines([
|
||||
newPoint(csox + hx, csoy - hy, 0), newPoint(csox + hx, csoy - hy, stock.z),
|
||||
newPoint(csox + hx, csoy + hy, 0), newPoint(csox + hx, csoy + hy, stock.z),
|
||||
newPoint(csox - hx, csoy - hy, 0), newPoint(csox - hx, csoy - hy, stock.z),
|
||||
newPoint(csox - hx, csoy + hy, 0), newPoint(csox - hx, csoy + hy, stock.z),
|
||||
], { thin: true }));
|
||||
}
|
||||
|
||||
API.platform.update_top_z(delta);
|
||||
API.platform.update_origin();
|
||||
SPACE.update();
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -55,14 +55,14 @@
|
|||
outer = settings.bounds,
|
||||
outerz = outer.max.z,
|
||||
slices = widget.slices,
|
||||
bounds = widget.getCamBounds(settings),
|
||||
boundsz = bounds.max.z,
|
||||
hasStock = process.camStockOffset || (process.camStockZ && process.camStockX && process.camStockY),
|
||||
hasStock = stock.x && stock.y && stock.z && process.camStockOn,
|
||||
startCenter = process.outputOriginCenter,
|
||||
alignTop = settings.controller.alignTop,
|
||||
zclear = (process.camZClearance || 1),
|
||||
zmax_outer = hasStock ? stock.z + zclear : outerz + zclear,
|
||||
ztOff = process.camZTopOffset,
|
||||
ztOff = hasStock ? process.camZTopOffset : 0,
|
||||
bounds = widget.getBoundingBox(),
|
||||
boundsz = bounds.max.z + ztOff,
|
||||
zadd = hasStock ? stock.z - boundsz : alignTop ? outerz - boundsz : 0,
|
||||
zmax = outerz + zclear,
|
||||
wmpos = widget.mesh.position,
|
||||
|
|
@ -247,8 +247,8 @@
|
|||
deltaXY = 0;
|
||||
}
|
||||
} //else (TODO verify no else here b/c above could change isMove)
|
||||
// move over things
|
||||
if ((deltaXY > toolDiam || (deltaZ > toolDiam && deltaXY > tolerance)) && (isMove || absDeltaZ >= tolerance)) {
|
||||
// move over things ... try checking path clearance tests for *every* move
|
||||
if ((deltaXY > toolDiam || (deltaZ > tolerance && deltaXY > tolerance)) && (isMove || absDeltaZ >= tolerance)) {
|
||||
let maxz = getZClearPath(
|
||||
terrain,
|
||||
lastPoint.x,// - wmx,
|
||||
|
|
|
|||
|
|
@ -24,13 +24,15 @@
|
|||
CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||
let conf = settings,
|
||||
proc = conf.process,
|
||||
stock = settings.stock || {},
|
||||
hasStock = stock.x && stock.y && stock.z && proc.camStockOn,
|
||||
sliceAll = widget.slices = [],
|
||||
unitsName = settings.controller.units,
|
||||
roughTool = new CAM.Tool(conf, proc.camRoughTool),
|
||||
roughToolDiam = roughTool.fluteDiameter(),
|
||||
drillTool = new CAM.Tool(conf, proc.camDrillTool),
|
||||
drillToolDiam = drillTool.fluteDiameter(),
|
||||
procFacing = proc.camRoughOn && proc.camZTopOffset,
|
||||
procFacing = proc.camRoughOn && proc.camZTopOffset && hasStock,
|
||||
procRough = proc.camRoughOn && proc.camRoughDown,
|
||||
procOutlineIn = proc.camOutlineIn,
|
||||
procOutlineOn = proc.camOutlineOn,
|
||||
|
|
@ -54,13 +56,12 @@
|
|||
zMin = Math.max(bounds.min.z, zBottom),
|
||||
zMax = bounds.max.z,
|
||||
zThru = zBottom === 0 ? (proc.camZThru || 0) : 0,
|
||||
ztOff = proc.camZTopOffset,
|
||||
ztOff = hasStock ? proc.camZTopOffset : 0,
|
||||
camRoughStock = proc.camRoughStock,
|
||||
camRoughDown = proc.camRoughDown,
|
||||
minStepDown = Math.min(1, roughDown, outlineDown),
|
||||
maxToolDiam = 0,
|
||||
thruHoles,
|
||||
stock = settings.stock || {};
|
||||
thruHoles;
|
||||
|
||||
if (stock.x && stock.y && stock.z) {
|
||||
if (stock.x + 0.00001 < bounds.max.x - bounds.min.x) {
|
||||
|
|
|
|||
|
|
@ -84,12 +84,12 @@
|
|||
freeze = false,
|
||||
isRound = false,
|
||||
platformMaterial = new THREE.MeshPhongMaterial({
|
||||
color: 0xcccccc,
|
||||
specular: 0xcccccc,
|
||||
shininess: 5,
|
||||
color: 0xeeeeee,
|
||||
specular: 0xeeeeee,
|
||||
shininess: 0,
|
||||
transparent: true,
|
||||
opacity: 0.6,
|
||||
// side: THREE.DoubleSide
|
||||
side: THREE.DoubleSide
|
||||
}),
|
||||
hiddenKey,
|
||||
vizChange,
|
||||
|
|
@ -496,15 +496,16 @@
|
|||
));
|
||||
pi4.position.x = 0.25;
|
||||
pi4.position.y = -0.25;
|
||||
group.add(new THREE.Mesh(
|
||||
let aa, bb, cc;
|
||||
group.add(aa = new THREE.Mesh(
|
||||
new THREE.RingGeometry(5, 5.5, 50),
|
||||
rmat
|
||||
));
|
||||
group.add(new THREE.Mesh(
|
||||
group.add(bb = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(0.5, 10),
|
||||
rmat
|
||||
));
|
||||
group.add(new THREE.Mesh(
|
||||
group.add(cc = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(10, 0.5),
|
||||
rmat
|
||||
));
|
||||
|
|
@ -512,6 +513,9 @@
|
|||
group.position.x = x;
|
||||
group.position.y = z;
|
||||
group.position.z = y;
|
||||
[bb,cc].forEach(m => {
|
||||
m.renderOrder = 3;
|
||||
});
|
||||
Space.scene.add(group);
|
||||
Space.update();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -410,6 +410,8 @@ kiri.lang['en-us'] = {
|
|||
cs_hght_l: "height (z) in workspace units\n0 defaults to part size",
|
||||
cs_offs_s: "offset",
|
||||
cs_offs_l: "use width, depth, height\nas offsets from max\npart size on platform",
|
||||
cs_offe_s: "enable",
|
||||
cs_offe_l: "enable milling stock",
|
||||
|
||||
// ORIGIN (CAM & LASER)
|
||||
or_bnds_s: "origin bounds",
|
||||
|
|
|
|||
Loading…
Reference in a new issue