update preview point rotation. fix state sensitive visuals
This commit is contained in:
parent
430f85120a
commit
f53b9825cb
7 changed files with 44 additions and 10 deletions
1
notes.md
1
notes.md
|
|
@ -75,6 +75,7 @@
|
||||||
* `B` need to force cut line at synthetic z bottom (midlines, etc)
|
* `B` need to force cut line at synthetic z bottom (midlines, etc)
|
||||||
* `B` contour does not honor clip to stock
|
* `B` contour does not honor clip to stock
|
||||||
|
|
||||||
|
* `F` import and follow 2D paths (conformed like pocket contours)
|
||||||
* `F` add user-defined origin (issue #28)
|
* `F` add user-defined origin (issue #28)
|
||||||
* `F` add custom gcode operation for things like injecting pauses
|
* `F` add custom gcode operation for things like injecting pauses
|
||||||
* `F` all ops should allow limit and milling direction / ease down overrides
|
* `F` all ops should allow limit and milling direction / ease down overrides
|
||||||
|
|
|
||||||
|
|
@ -104,8 +104,8 @@ kiri.load(() => {
|
||||||
geo.setIndex(new THREE.BufferAttribute(ia, 1));
|
geo.setIndex(new THREE.BufferAttribute(ia, 1));
|
||||||
const mat = new THREE.MeshMatcapMaterial({
|
const mat = new THREE.MeshMatcapMaterial({
|
||||||
flatShading: true,
|
flatShading: true,
|
||||||
transparent: true,
|
transparent: false,
|
||||||
opacity: 0.1,
|
opacity: 1,
|
||||||
color: 0x888888,
|
color: 0x888888,
|
||||||
side: THREE.DoubleSide
|
side: THREE.DoubleSide
|
||||||
});
|
});
|
||||||
|
|
@ -366,6 +366,7 @@ kiri.load(() => {
|
||||||
const { process } = settings;
|
const { process } = settings;
|
||||||
const print = worker.print;
|
const print = worker.print;
|
||||||
const density = parseInt(settings.controller.animesh) * 1000;
|
const density = parseInt(settings.controller.animesh) * 1000;
|
||||||
|
const isIndexed = process.camStockOn && process.camStockIndexed;
|
||||||
|
|
||||||
pathIndex = 0;
|
pathIndex = 0;
|
||||||
path = print.output.flat();
|
path = print.output.flat();
|
||||||
|
|
@ -381,11 +382,11 @@ kiri.load(() => {
|
||||||
indexCount = 0;
|
indexCount = 0;
|
||||||
startTime = 0;
|
startTime = 0;
|
||||||
updates = 0;
|
updates = 0;
|
||||||
stockZ = stock.z;
|
stockZ = isIndexed ? 0 : stock.z;
|
||||||
|
|
||||||
stockSlices = [];
|
stockSlices = [];
|
||||||
const { x, y, z } = stock;
|
const { x, y, z } = stock;
|
||||||
const sliceCount = 1;
|
const sliceCount = 10;
|
||||||
const sliceWidth = stock.x / sliceCount;
|
const sliceWidth = stock.x / sliceCount;
|
||||||
for (let i=0; i<sliceCount; i++) {
|
for (let i=0; i<sliceCount; i++) {
|
||||||
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth / 2;
|
let xmin = -(x/2) + (i * sliceWidth) + sliceWidth / 2;
|
||||||
|
|
@ -452,6 +453,7 @@ kiri.load(() => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pathIndex++;
|
pathIndex++;
|
||||||
|
// console.log(next.point.z);
|
||||||
|
|
||||||
if (next.tool >= 0 && (!tool || tool.getNumber() !== next.tool)) {
|
if (next.tool >= 0 && (!tool || tool.getNumber() !== next.tool)) {
|
||||||
// on real tool change, go to safe Z first
|
// on real tool change, go to safe Z first
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const { CAM } = driver;
|
||||||
|
|
||||||
let isAnimate,
|
let isAnimate,
|
||||||
isArrange,
|
isArrange,
|
||||||
|
isPreview,
|
||||||
isCamMode,
|
isCamMode,
|
||||||
isIndexed,
|
isIndexed,
|
||||||
isParsed,
|
isParsed,
|
||||||
|
|
@ -153,10 +154,17 @@ CAM.init = function(kiri, api) {
|
||||||
|
|
||||||
api.event.on("view.set", (mode) => {
|
api.event.on("view.set", (mode) => {
|
||||||
isArrange = (mode === VIEWS.ARRANGE);
|
isArrange = (mode === VIEWS.ARRANGE);
|
||||||
|
isPreview = (mode === VIEWS.PREVIEW);
|
||||||
isAnimate = false;
|
isAnimate = false;
|
||||||
animFn().animate_clear(api);
|
animFn().animate_clear(api);
|
||||||
func.clearPops();
|
func.clearPops();
|
||||||
$('camops').style.display = isCamMode && isArrange ? 'flex' : '';
|
$('camops').style.display = isCamMode && isArrange ? 'flex' : '';
|
||||||
|
if (isCamMode && isPreview) {
|
||||||
|
for (let widget of API.widgets.all()) {
|
||||||
|
widget.setAxisIndex(0);
|
||||||
|
}
|
||||||
|
updateStock();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
api.event.on("settings.saved", (settings) => {
|
api.event.on("settings.saved", (settings) => {
|
||||||
|
|
@ -596,11 +604,10 @@ CAM.init = function(kiri, api) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update widget rotations from timeline marker
|
// update widget rotations from timeline marker
|
||||||
if (isIndexed)
|
|
||||||
for (let widget of API.widgets.all()) {
|
for (let widget of API.widgets.all()) {
|
||||||
widget.setAxisIndex(-index);
|
widget.setAxisIndex(isPreview || !isIndexed ? 0 : -index);
|
||||||
}
|
}
|
||||||
currentIndex = isIndexed ? index * (Math.PI / 180) : 0;
|
currentIndex = isIndexed && !isPreview ? index * (Math.PI / 180) : 0;
|
||||||
updateStock();
|
updateStock();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -481,7 +481,6 @@ class OpOutline extends CamOp {
|
||||||
max: op.top ? zMax + ztOff : undefined
|
max: op.top ? zMax + ztOff : undefined
|
||||||
};
|
};
|
||||||
let indices = slicer.interval(op.down, intopt);
|
let indices = slicer.interval(op.down, intopt);
|
||||||
console.log({slicer, indices, zBottom});
|
|
||||||
let trueShadow = process.camTrueShadow === true;
|
let trueShadow = process.camTrueShadow === true;
|
||||||
// shift out first (top-most) slice
|
// shift out first (top-most) slice
|
||||||
indices.shift();
|
indices.shift();
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
outerz = outer.max.z,
|
outerz = outer.max.z,
|
||||||
slices = widget.slices,
|
slices = widget.slices,
|
||||||
hasStock = stock.x && stock.y && stock.z && process.camStockOn,
|
hasStock = stock.x && stock.y && stock.z && process.camStockOn,
|
||||||
|
isIndexed = hasStock && process.camStockIndexed,
|
||||||
startCenter = process.outputOriginCenter,
|
startCenter = process.outputOriginCenter,
|
||||||
alignTop = settings.controller.alignTop,
|
alignTop = settings.controller.alignTop,
|
||||||
zclear = (process.camZClearance || 1),
|
zclear = (process.camZClearance || 1),
|
||||||
|
|
@ -78,7 +79,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
ztOff = hasStock ? stock.z - wztop : 0,
|
ztOff = hasStock ? stock.z - wztop : 0,
|
||||||
bounds = widget.getBoundingBox(),
|
bounds = widget.getBoundingBox(),
|
||||||
boundsz = bounds.max.z + ztOff,
|
boundsz = bounds.max.z + ztOff,
|
||||||
zadd = hasStock ? stock.z - boundsz : alignTop ? outerz - boundsz : 0,
|
zadd = hasStock && !isIndexed ? stock.z - boundsz : alignTop ? outerz - boundsz : 0,
|
||||||
zmax = outerz + zclear,
|
zmax = outerz + zclear,
|
||||||
wmpos = widget.track.pos,
|
wmpos = widget.track.pos,
|
||||||
wmx = wmpos.x,
|
wmx = wmpos.x,
|
||||||
|
|
@ -296,6 +297,7 @@ function prepEach(widget, settings, print, firstPoint, update) {
|
||||||
point.y += wmy;
|
point.y += wmy;
|
||||||
point.z += zadd;
|
point.z += zadd;
|
||||||
|
|
||||||
|
// console.log(point.z);
|
||||||
if (nextIsMove) {
|
if (nextIsMove) {
|
||||||
cut = 0;
|
cut = 0;
|
||||||
nextIsMove = false;
|
nextIsMove = false;
|
||||||
|
|
|
||||||
|
|
@ -157,7 +157,7 @@ CAM.slice = function(settings, widget, onupdate, ondone) {
|
||||||
slices = [ slices ];
|
slices = [ slices ];
|
||||||
}
|
}
|
||||||
sliceAll.appendAll(slices);
|
sliceAll.appendAll(slices);
|
||||||
if (axisIndex !== undefined) {
|
if (isIndexed && axisIndex !== undefined) {
|
||||||
// update slice cam lines to add axis indexing
|
// update slice cam lines to add axis indexing
|
||||||
for (let slice of slices.filter(s => s.camLines)) {
|
for (let slice of slices.filter(s => s.camLines)) {
|
||||||
for (let poly of slice.camLines) {
|
for (let poly of slice.camLines) {
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,8 @@ gapp.register("kiri.render", [], (root, exports) => {
|
||||||
const { base, kiri } = root;
|
const { base, kiri } = root;
|
||||||
const { config, util, newPolygon } = base;
|
const { config, util, newPolygon } = base;
|
||||||
const hsV = 0.9;
|
const hsV = 0.9;
|
||||||
|
const XAXIS = new THREE.Vector3(1,0,0);
|
||||||
|
const DEG2RAD = Math.PI / 180;
|
||||||
|
|
||||||
exports({
|
exports({
|
||||||
path,
|
path,
|
||||||
|
|
@ -126,6 +128,7 @@ async function path(levels, update, opts = {}) {
|
||||||
const retracts = [];
|
const retracts = [];
|
||||||
const engages = [];
|
const engages = [];
|
||||||
const lasers = [];
|
const lasers = [];
|
||||||
|
const sparks = [];
|
||||||
const output = new kiri.Layers();
|
const output = new kiri.Layers();
|
||||||
layers.push(output);
|
layers.push(output);
|
||||||
|
|
||||||
|
|
@ -165,6 +168,19 @@ async function path(levels, update, opts = {}) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rotate 4th axis indexed points
|
||||||
|
// todo -- add spark lines
|
||||||
|
if (out.point.a) {
|
||||||
|
let { point } = out;
|
||||||
|
let p2 = new THREE.Vector3(point.x, point.y, point.z)
|
||||||
|
.applyAxisAngle(XAXIS, point.a * DEG2RAD);
|
||||||
|
out.point.x = p2.x;
|
||||||
|
out.point.y = p2.y;
|
||||||
|
out.point.z = p2.z;
|
||||||
|
// let sp = base.newPoint(out.point.x * 1.1, out.point.y * 1.1, out.point.z * 1.1);
|
||||||
|
// sparks.push(out.point, sp);
|
||||||
|
}
|
||||||
|
|
||||||
if (lastOut) {
|
if (lastOut) {
|
||||||
if (arrowAll || lastOut.emit !== out.emit) {
|
if (arrowAll || lastOut.emit !== out.emit) {
|
||||||
heads.push({p1: lastOut.point, p2: out.point});
|
heads.push({p1: lastOut.point, p2: out.point});
|
||||||
|
|
@ -261,6 +277,13 @@ async function path(levels, update, opts = {}) {
|
||||||
}), { outline: true });
|
}), { outline: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (thin && sparks.length) {
|
||||||
|
let line = dark ? 0xffffff : 0x112233;
|
||||||
|
output
|
||||||
|
.setLayer('sparks', { face: headColor, line, opacity: 0.75 }, true)
|
||||||
|
.addLines(sparks, { thin: true });
|
||||||
|
}
|
||||||
|
|
||||||
if (thin && heads.length) {
|
if (thin && heads.length) {
|
||||||
let line = dark ? 0xffffff : 0x112233;
|
let line = dark ? 0xffffff : 0x112233;
|
||||||
output
|
output
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue