add notes on how to improve path visuals and speed up compute time
This commit is contained in:
parent
89960ee784
commit
a15b47c05e
3 changed files with 16 additions and 2 deletions
|
|
@ -219,12 +219,13 @@ class Layers {
|
|||
const one = cur.paths[0];
|
||||
if (one) {
|
||||
// merge all contour geometry for massive speed gain
|
||||
// todo: recode to concat all geometries at once, and not incrementally
|
||||
const add = one.faces.length / 3;
|
||||
for (let i=0; i<index.length; i++) {
|
||||
index[i] += add;
|
||||
}
|
||||
const feces = new Float32Array(one.faces.length + faces.length);
|
||||
const indln = one.index.length;
|
||||
const indln = one.index.length || one.faces.length / 3;
|
||||
feces.set(one.faces);
|
||||
feces.set(faces, one.faces.length);
|
||||
one.faces = feces;
|
||||
|
|
@ -352,6 +353,18 @@ function ProfiledContourGeometry(profileShape, contour, contourClosed) {
|
|||
index.push(p8, p7, p5);
|
||||
}
|
||||
|
||||
// unrolled / non-indexed geometry provides a cleaner look because vertex
|
||||
// shading of indexed geometries looks wrong. this takes longer to re-compute
|
||||
// so it should be produced unrolled above.
|
||||
//
|
||||
// let nufaces = new Float32Array(index.length * 3), ii = 0;
|
||||
// for (let i of index) {
|
||||
// nufaces[ii++] = faces[i*3];
|
||||
// nufaces[ii++] = faces[i*3+1];
|
||||
// nufaces[ii++] = faces[i*3+2];
|
||||
// }
|
||||
// return { index:[], faces: nufaces };
|
||||
|
||||
return {index, faces};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -260,6 +260,7 @@ function path(levels, update, opts = {}) {
|
|||
|
||||
update(index / levels.length, output);
|
||||
});
|
||||
|
||||
// console.log({retractz});
|
||||
return layers;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class Stack {
|
|||
const { index, faces, z, colors } = path;
|
||||
const geo = new THREE.BufferGeometry();
|
||||
geo.setAttribute('position', new THREE.BufferAttribute(faces, 3));
|
||||
geo.setIndex(index);
|
||||
if (index.length) geo.setIndex(index);
|
||||
geo.computeVertexNormals();
|
||||
if (cpath) {
|
||||
cpath.forEach((c, i) => geo.addGroup(c.start, c.count, i));
|
||||
|
|
|
|||
Loading…
Reference in a new issue