change default stock visualization in slice and preview modes
This commit is contained in:
parent
816810bbe9
commit
9522821232
3 changed files with 52 additions and 16 deletions
|
|
@ -5,17 +5,20 @@
|
|||
(function() {
|
||||
|
||||
let KIRI = self.kiri,
|
||||
BASE = self.base,
|
||||
CAM = KIRI.driver.CAM,
|
||||
PRO = CAM.process;
|
||||
PRO = CAM.process,
|
||||
newPolygon = BASE.newPolygon,
|
||||
newPoint = BASE.newPoint;
|
||||
|
||||
CAM.init = function(kiri, api) {
|
||||
api.event.on("mode.set", (mode) => {
|
||||
let isCAM = mode === 'CAM';
|
||||
const isCAM = mode === 'CAM';
|
||||
$('set-tools').style.display = isCAM ? '' : 'none';
|
||||
kiri.space.platform.setColor(isCAM ? 0xeeeeee : 0xcccccc);
|
||||
});
|
||||
api.event.on("settings.saved", (settings) => {
|
||||
let proc = settings.process;
|
||||
const proc = settings.process;
|
||||
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 =
|
||||
|
|
@ -24,6 +27,31 @@
|
|||
api.ui.camContour.marker.style.display =
|
||||
proc.camContourXOn || proc.camContourYOn ? 'flex' : 'none';
|
||||
});
|
||||
|
||||
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('stock', { face: 0xaaaaaa, line: 0xaaaaaa }, true);
|
||||
const stack = STACKS.create('stock', 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);
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -59,18 +59,21 @@
|
|||
camRoughDown = proc.camRoughDown,
|
||||
minStepDown = Math.min(1, roughDown, outlineDown),
|
||||
maxToolDiam = 0,
|
||||
thruHoles;
|
||||
thruHoles,
|
||||
stock = settings.stock || {};
|
||||
|
||||
if (settings.stock.x + 0.00001 < bounds.max.x - bounds.min.x) {
|
||||
return ondone('stock X too small for part. disable stock or use offset stock');
|
||||
}
|
||||
if (stock.x && stock.y && stock.z) {
|
||||
if (stock.x + 0.00001 < bounds.max.x - bounds.min.x) {
|
||||
return ondone('stock X too small for part. disable stock or use offset stock');
|
||||
}
|
||||
|
||||
if (settings.stock.y + 0.00001 < bounds.max.y - bounds.min.y) {
|
||||
return ondone('stock Y too small for part. disable stock or use offset stock');
|
||||
}
|
||||
if (stock.y + 0.00001 < bounds.max.y - bounds.min.y) {
|
||||
return ondone('stock Y too small for part. disable stock or use offset stock');
|
||||
}
|
||||
|
||||
if (settings.stock.z + 0.00001 < bounds.max.z - bounds.min.z) {
|
||||
return ondone('stock Z too small for part. disable stock or use offset stock');
|
||||
if (stock.z + 0.00001 < bounds.max.z - bounds.min.z) {
|
||||
return ondone('stock Z too small for part. disable stock or use offset stock');
|
||||
}
|
||||
}
|
||||
|
||||
if (sliceDepth <= 0.05) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue