Skip to content

Commit

Permalink
fix: Add checks for missing UVs. (#34)
Browse files Browse the repository at this point in the history
Co-authored-by: Sam Alexander <samalexander@users.noreply.github.com>
  • Loading branch information
manthrax and samalexander authored Jul 12, 2021
1 parent dd9658a commit 026d5b6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/CSG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ export class CSG {
normals.write(pvs[0].normal);
normals.write(pvs[j - 2].normal);
normals.write(pvs[j - 1].normal);
uvs.write(pvs[0].uv);
uvs.write(pvs[j - 2].uv);
uvs.write(pvs[j - 1].uv);
if (uvs) {
uvs.write(pvs[0].uv);
uvs.write(pvs[j - 2].uv);
uvs.write(pvs[j - 1].uv);
}

if (colors) {
colors.write(pvs[0].color);
colors.write(pvs[j - 2].color);
Expand All @@ -131,7 +134,7 @@ export class CSG {
}
geom.setAttribute('position', new BufferAttribute(vertices.array, 3));
geom.setAttribute('normal', new BufferAttribute(normals.array, 3));
geom.setAttribute('uv', new BufferAttribute(uvs.array, 2));
uvs && geom.setAttribute('uv', new BufferAttribute(uvs.array, 2));
colors && geom.setAttribute('color', new BufferAttribute(colors.array, 3));
for (let gi = 0; gi < grps.length; gi++) {
if (grps[gi] === undefined) {
Expand Down

0 comments on commit 026d5b6

Please sign in to comment.