Skip to content

Commit

Permalink
Merge pull request #6591 from davepagurek/fix/smooth-normals-seams
Browse files Browse the repository at this point in the history
Fix rounding of values close to 0 when computing smooth normals
  • Loading branch information
davepagurek authored Nov 26, 2023
2 parents 773eb0d + 7c91654 commit 7587e0a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/webgl/p5.Geometry.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,10 @@ p5.Geometry = class Geometry {
const vertexIndices = {};
const uniqueVertices = [];

const power = Math.pow(10, roundToPrecision);
const rounded = val => Math.round(val * power) / power;
const getKey = vert =>
`${vert.x.toFixed(roundToPrecision)},${vert.y.toFixed(roundToPrecision)},${vert.z.toFixed(roundToPrecision)}`;
`${rounded(vert.x)},${rounded(vert.y)},${rounded(vert.z)}`;

// loop through each vertex and add uniqueVertices
for (let i = 0; i < vertices.length; i++) {
Expand Down

0 comments on commit 7587e0a

Please sign in to comment.