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];
|
const one = cur.paths[0];
|
||||||
if (one) {
|
if (one) {
|
||||||
// merge all contour geometry for massive speed gain
|
// 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;
|
const add = one.faces.length / 3;
|
||||||
for (let i=0; i<index.length; i++) {
|
for (let i=0; i<index.length; i++) {
|
||||||
index[i] += add;
|
index[i] += add;
|
||||||
}
|
}
|
||||||
const feces = new Float32Array(one.faces.length + faces.length);
|
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(one.faces);
|
||||||
feces.set(faces, one.faces.length);
|
feces.set(faces, one.faces.length);
|
||||||
one.faces = feces;
|
one.faces = feces;
|
||||||
|
|
@ -352,6 +353,18 @@ function ProfiledContourGeometry(profileShape, contour, contourClosed) {
|
||||||
index.push(p8, p7, p5);
|
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};
|
return {index, faces};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -260,6 +260,7 @@ function path(levels, update, opts = {}) {
|
||||||
|
|
||||||
update(index / levels.length, output);
|
update(index / levels.length, output);
|
||||||
});
|
});
|
||||||
|
|
||||||
// console.log({retractz});
|
// console.log({retractz});
|
||||||
return layers;
|
return layers;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -191,7 +191,7 @@ class Stack {
|
||||||
const { index, faces, z, colors } = path;
|
const { index, faces, z, colors } = path;
|
||||||
const geo = new THREE.BufferGeometry();
|
const geo = new THREE.BufferGeometry();
|
||||||
geo.setAttribute('position', new THREE.BufferAttribute(faces, 3));
|
geo.setAttribute('position', new THREE.BufferAttribute(faces, 3));
|
||||||
geo.setIndex(index);
|
if (index.length) geo.setIndex(index);
|
||||||
geo.computeVertexNormals();
|
geo.computeVertexNormals();
|
||||||
if (cpath) {
|
if (cpath) {
|
||||||
cpath.forEach((c, i) => geo.addGroup(c.start, c.count, i));
|
cpath.forEach((c, i) => geo.addGroup(c.start, c.count, i));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue