patchup for line basic material bug with two materials?
This commit is contained in:
parent
fee3e075f8
commit
7cbc694c93
1 changed files with 8 additions and 6 deletions
|
|
@ -115,8 +115,8 @@
|
||||||
const mat = []; // materials
|
const mat = []; // materials
|
||||||
const grp = []; // material groups
|
const grp = []; // material groups
|
||||||
const geo = new THREE.BufferGeometry();
|
const geo = new THREE.BufferGeometry();
|
||||||
// map all the poly and line colors
|
// map all the poly and line colors for re-use
|
||||||
const cmap = {}
|
// const cmap = {}
|
||||||
let cidx = 0;
|
let cidx = 0;
|
||||||
let last = undefined;
|
let last = undefined;
|
||||||
for (let i=0, il=polys.length; i<il; i++) {
|
for (let i=0, il=polys.length; i<il; i++) {
|
||||||
|
|
@ -125,12 +125,14 @@
|
||||||
addPoly(vert, poly);
|
addPoly(vert, poly);
|
||||||
const pc = poly.color !== undefined ? { line: poly.color, opacity: data.color.opacity } : data.color;
|
const pc = poly.color !== undefined ? { line: poly.color, opacity: data.color.opacity } : data.color;
|
||||||
const pk = pc.line;
|
const pk = pc.line;
|
||||||
const cc = cmap[pk] = cmap[pk] || { idx: cidx++, mat: createLineMaterial(pc, mat) };
|
// const cc = cmap[pk] = cmap[pk] || { idx: cidx++, mat: createLineMaterial(pc, mat) };
|
||||||
if (last !== pk) {
|
const cc = { idx: cidx++, mat: createLineMaterial(pc, mat) };
|
||||||
|
// does not appear you can re-use material indices out of order
|
||||||
|
if (true || last !== pk) {
|
||||||
if (grp.length) {
|
if (grp.length) {
|
||||||
// rewrite counts for last group
|
// rewrite counts for last group
|
||||||
const prev = grp[grp.length - 1]
|
const prev = grp[grp.length - 1]
|
||||||
prev[1] = prev[1] - vl;
|
prev[1] = vl;
|
||||||
}
|
}
|
||||||
grp.push([vl, Infinity, cc.idx]);
|
grp.push([vl, Infinity, cc.idx]);
|
||||||
last = pk;
|
last = pk;
|
||||||
|
|
@ -151,8 +153,8 @@
|
||||||
const g = grp[i];
|
const g = grp[i];
|
||||||
geo.addGroup(g[0], g[1], g[2]);
|
geo.addGroup(g[0], g[1], g[2]);
|
||||||
}
|
}
|
||||||
group.add(new THREE.LineSegments(geo, mat));
|
|
||||||
geo.setFromPoints(vert);
|
geo.setFromPoints(vert);
|
||||||
|
group.add(new THREE.LineSegments(geo, mat));
|
||||||
ctrl.group.appendAll(mat);
|
ctrl.group.appendAll(mat);
|
||||||
}
|
}
|
||||||
if (faces.length) {
|
if (faces.length) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue