codec and color cleanup
This commit is contained in:
parent
3aa07314c2
commit
1d573b1605
8 changed files with 29 additions and 43 deletions
3
notes.md
3
notes.md
|
|
@ -3,7 +3,6 @@
|
||||||
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
|
## `C` cosmetic, `F` functional, `P` performance, `B` bug fix
|
||||||
|
|
||||||
* `F` detect and report slow framerates
|
* `F` detect and report slow framerates
|
||||||
* `F` gcode generation progress bar
|
|
||||||
* `F` implement an in-app bug reporting system. add workspace to export option.
|
* `F` implement an in-app bug reporting system. add workspace to export option.
|
||||||
* `F` extend mesh object to store raw + annotations (rot,scale,pos)
|
* `F` extend mesh object to store raw + annotations (rot,scale,pos)
|
||||||
* share raw data w/ dups, encode/decode
|
* share raw data w/ dups, encode/decode
|
||||||
|
|
@ -12,6 +11,8 @@
|
||||||
* `F` 2D image import
|
* `F` 2D image import
|
||||||
* `P` improve decimation speed by avoiding in/out of Point?
|
* `P` improve decimation speed by avoiding in/out of Point?
|
||||||
* `P` duplicate objects should share same slice data unless rotated or scaled
|
* `P` duplicate objects should share same slice data unless rotated or scaled
|
||||||
|
* `P` worker state cache cleanup and organization
|
||||||
|
* `P` client/worker interface normalization and cleanup
|
||||||
|
|
||||||
# FDM
|
# FDM
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@
|
||||||
for (let i=0; i<v.layers.length; i++) {
|
for (let i=0; i<v.layers.length; i++) {
|
||||||
render.layers[v.layers[i]] = {
|
render.layers[v.layers[i]] = {
|
||||||
polys: decode(v.data[i].polys, state),
|
polys: decode(v.data[i].polys, state),
|
||||||
|
cpoly: v.data[i].cpoly,
|
||||||
lines: decodePointArray(v.data[i].lines),
|
lines: decodePointArray(v.data[i].lines),
|
||||||
faces: v.data[i].faces,
|
faces: v.data[i].faces,
|
||||||
color: v.data[i].color,
|
color: v.data[i].color,
|
||||||
|
|
@ -142,27 +143,11 @@
|
||||||
return {
|
return {
|
||||||
type: 'top',
|
type: 'top',
|
||||||
poly: encode(this.poly, state),
|
poly: encode(this.poly, state),
|
||||||
// traces: encode(this.traces, state),
|
|
||||||
// inner: encode(this.inner, state),
|
|
||||||
// // thinner: encode(this.thinner, state),
|
|
||||||
// solids: encode(this.solids, state),
|
|
||||||
// thin_fill: encodePointArray(this.thin_fill, state),
|
|
||||||
// fill_lines: encodePointArray(this.fill_lines, state),
|
|
||||||
// fill_sparse: encode(this.fill_sparse, state),
|
|
||||||
// polish: encode(this.polish, state)
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
registerDecoder('top', function(v, state) {
|
registerDecoder('top', function(v, state) {
|
||||||
let top = KIRI.newTop(decode(v.poly, state));
|
let top = KIRI.newTop(decode(v.poly, state));
|
||||||
// top.traces = decode(v.traces, state);
|
|
||||||
// top.inner = decode(v.inner, state);
|
|
||||||
// // top.thinner = decode(v.thinner, state);
|
|
||||||
// top.solids = decode(v.solids, state);
|
|
||||||
// top.thin_fill = decodePointArray(v.thin_fill, state);
|
|
||||||
// top.fill_lines = decodePointArray(v.fill_lines, state);
|
|
||||||
// top.fill_sparse = decode(v.fill_sparse, state);
|
|
||||||
// top.polish = decode(v.polish, state);
|
|
||||||
return top;
|
return top;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -215,10 +200,7 @@
|
||||||
let cached = state.poly[this.id];
|
let cached = state.poly[this.id];
|
||||||
|
|
||||||
if (cached) {
|
if (cached) {
|
||||||
return {
|
return { type: 'poly', ref: this.id };
|
||||||
type: 'poly',
|
|
||||||
ref: this.id
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state.poly[this.id] = this;
|
state.poly[this.id] = this;
|
||||||
|
|
@ -230,8 +212,9 @@
|
||||||
open: this.isOpen(),
|
open: this.isOpen(),
|
||||||
inner: encode(this.inner, state),
|
inner: encode(this.inner, state),
|
||||||
parent: encode(this.parent, state),
|
parent: encode(this.parent, state),
|
||||||
fills: encodePointArray(this.fills, state),
|
// fills: encodePointArray(this.fills, state),
|
||||||
depth: this.depth
|
depth: this.depth,
|
||||||
|
color: this.color
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -255,8 +238,9 @@
|
||||||
|
|
||||||
poly.inner = decode(v.inner, state);
|
poly.inner = decode(v.inner, state);
|
||||||
poly.parent = decode(v.parent, state);
|
poly.parent = decode(v.parent, state);
|
||||||
poly.fills = decodePointArray(v.fills);
|
// poly.fills = decodePointArray(v.fills);
|
||||||
poly.depth = v.depth;
|
poly.depth = v.depth;
|
||||||
|
poly.color = v.color;
|
||||||
|
|
||||||
return poly;
|
return poly;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,7 @@
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// z planar closed polygonal areas
|
||||||
addAreas(polys, options) {
|
addAreas(polys, options) {
|
||||||
const faces = this.current.faces;
|
const faces = this.current.faces;
|
||||||
polys = Array.isArray(polys) ? polys : [ polys ];
|
polys = Array.isArray(polys) ? polys : [ polys ];
|
||||||
|
|
@ -102,6 +103,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// misleading name. these are flat offset paths (old style rendering)
|
||||||
addFlats(polys, options) {
|
addFlats(polys, options) {
|
||||||
const opts = options || {};
|
const opts = options || {};
|
||||||
const offset = opts.offset || 1;
|
const offset = opts.offset || 1;
|
||||||
|
|
@ -121,7 +123,7 @@
|
||||||
if (open) {
|
if (open) {
|
||||||
exp.appendAll(POLY.expand_lines(poly, offset * 0.9, z));
|
exp.appendAll(POLY.expand_lines(poly, offset * 0.9, z));
|
||||||
this.stats.flat_line = 0;
|
this.stats.flat_line = 0;
|
||||||
} else {
|
} else if (offset) {
|
||||||
POLY.offset([poly], offset * 0.9, off_opt);
|
POLY.offset([poly], offset * 0.9, off_opt);
|
||||||
POLY.offset([poly], -offset * 0.9, off_opt);
|
POLY.offset([poly], -offset * 0.9, off_opt);
|
||||||
this.stats.flat_poly = 0;
|
this.stats.flat_poly = 0;
|
||||||
|
|
|
||||||
|
|
@ -109,11 +109,11 @@
|
||||||
|
|
||||||
ctrl.toggle.checked = defstate;
|
ctrl.toggle.checked = defstate;
|
||||||
|
|
||||||
const { polys, lines, faces, paths, cpath } = data;
|
const { polys, cpoly, lines, faces, paths, cpath } = data;
|
||||||
if (polys.length || lines.length) {
|
if (polys.length || lines.length) {
|
||||||
const mat = [];
|
const mat = [];
|
||||||
if (cpath) {
|
if (cpoly) {
|
||||||
cpath.forEach(c => { mat.push(createLineMaterial({ color: c })) });
|
cpoly.forEach(c => { mat.push(createLineMaterial({ color: c })) });
|
||||||
} else {
|
} else {
|
||||||
mat.push(createLineMaterial(data));
|
mat.push(createLineMaterial(data));
|
||||||
}
|
}
|
||||||
|
|
@ -128,8 +128,8 @@
|
||||||
vert.push(new THREE.Vector3(p.x, p.y, p.z));
|
vert.push(new THREE.Vector3(p.x, p.y, p.z));
|
||||||
}
|
}
|
||||||
if (vert.length) {
|
if (vert.length) {
|
||||||
if (cpath) {
|
if (cpoly) {
|
||||||
cpath.forEach((c, i) => geo.addGroup(c.start, c.count, i));
|
cpoly.forEach((c, i) => geo.addGroup(c.start, c.count, i));
|
||||||
} else {
|
} else {
|
||||||
geo.addGroup(0, Infinity, 0);
|
geo.addGroup(0, Infinity, 0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -172,7 +172,7 @@ KIRI.worker = {
|
||||||
}, done => {
|
}, done => {
|
||||||
const layers = KIRI.driver.FDM.prepareRender(done.output, progress => {
|
const layers = KIRI.driver.FDM.prepareRender(done.output, progress => {
|
||||||
send.data({ progress: 0.5 + progress * 0.5 });
|
send.data({ progress: 0.5 + progress * 0.5 });
|
||||||
}, { thin, tools });
|
}, { thin, tools, xspeed: mode === 'FDM' });
|
||||||
send.done({parsed: KIRI.codec.encode(layers)});
|
send.done({parsed: KIRI.codec.encode(layers)});
|
||||||
}, { fdm : mode === 'FDM' });
|
}, { fdm : mode === 'FDM' });
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -415,6 +415,10 @@
|
||||||
const cn_len = new Counter();
|
const cn_len = new Counter();
|
||||||
const cn_col = new Counter();
|
const cn_col = new Counter();
|
||||||
|
|
||||||
|
function color(point) {
|
||||||
|
return hsv2rgb({h:point.speed / maxspd, s:1, v:0.75}, true);
|
||||||
|
}
|
||||||
|
|
||||||
levels.forEach((level, index) => {
|
levels.forEach((level, index) => {
|
||||||
const prints = {};
|
const prints = {};
|
||||||
const moves = [];
|
const moves = [];
|
||||||
|
|
@ -444,7 +448,7 @@
|
||||||
if (!lastOut.emit || (ckspeed && out.speed !== lastOut.speed)) {
|
if (!lastOut.emit || (ckspeed && out.speed !== lastOut.speed)) {
|
||||||
current = newPolygon().setOpen();
|
current = newPolygon().setOpen();
|
||||||
current.push(lastOut.point);
|
current.push(lastOut.point);
|
||||||
current.color = hsv2rgb({h:out.speed/maxspd, s:1, v:0.75}, true);
|
current.color = color(out);
|
||||||
pushPrint(out.tool, current);
|
pushPrint(out.tool, current);
|
||||||
}
|
}
|
||||||
current.push(out.point);
|
current.push(out.point);
|
||||||
|
|
@ -460,7 +464,7 @@
|
||||||
current = newPolygon().setOpen();
|
current = newPolygon().setOpen();
|
||||||
current.push(out.point);
|
current.push(out.point);
|
||||||
if (out.emit) {
|
if (out.emit) {
|
||||||
current.color = hsv2rgb({h:out.speed/maxspd, s:1, v:1}, true);
|
current.color = color(out);
|
||||||
pushPrint(out.tool, current);
|
pushPrint(out.tool, current);
|
||||||
} else {
|
} else {
|
||||||
moves.push(current);
|
moves.push(current);
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
FILL = KIRI.fill,
|
FILL = KIRI.fill,
|
||||||
FILLFIXED = KIRI.fill_fixed,
|
FILLFIXED = KIRI.fill_fixed,
|
||||||
COLOR = {
|
COLOR = {
|
||||||
shell: { face: 0x003399, line: 0x003399, opacity: 1 },
|
shell: { face: 0x0077bb, line: 0x0077bb, opacity: 1 },
|
||||||
fill: { face: 0x003399, line: 0x003399, opacity: 1 },
|
fill: { face: 0x0077bb, line: 0x0077bb, opacity: 1 },
|
||||||
infill: { face: 0x003399, line: 0x003399, opacity: 1 },
|
infill: { face: 0x0077bb, line: 0x0077bb, opacity: 1 },
|
||||||
support: { face: 0x006699, line: 0x006699, opacity: 1 }
|
support: { face: 0x006699, line: 0x006699, opacity: 1 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@
|
||||||
slice,
|
slice,
|
||||||
prepare,
|
prepare,
|
||||||
export: exportLaser,
|
export: exportLaser,
|
||||||
printRender,
|
|
||||||
exportGCode,
|
exportGCode,
|
||||||
exportSVG,
|
exportSVG,
|
||||||
exportDXF
|
exportDXF
|
||||||
|
|
@ -256,8 +255,8 @@
|
||||||
min.y = 0;
|
min.y = 0;
|
||||||
} else {
|
} else {
|
||||||
// normalize against center of build area
|
// normalize against center of build area
|
||||||
let w = print.settings.device.bedWidth;
|
let w = settings.device.bedWidth;
|
||||||
let h = print.settings.device.bedDepth;
|
let h = settings.device.bedDepth;
|
||||||
output.forEach(function(layer) {
|
output.forEach(function(layer) {
|
||||||
layer.forEach(function(out) {
|
layer.forEach(function(out) {
|
||||||
point = out.point;
|
point = out.point;
|
||||||
|
|
@ -495,8 +494,4 @@
|
||||||
return lines.join('\n');
|
return lines.join('\n');
|
||||||
};
|
};
|
||||||
|
|
||||||
function printRender(print) {
|
|
||||||
return KIRI.driver.FDM.printRender(print, {aslines: true, nomoves: true, flat: true});
|
|
||||||
}
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue