BufferGeometryUtils: avoid vertex hash overflow at zero tolerance by hamedrabah · Pull Request #34390 · mrdoob/three.js · GitHub
Skip to content

BufferGeometryUtils: avoid vertex hash overflow at zero tolerance - #34390

Merged
Mugen87 merged 3 commits into
mrdoob:devfrom
hamedrabah:fix/merge-vertices-zero-tolerance
Aug 29, 2026
Merged

BufferGeometryUtils: avoid vertex hash overflow at zero tolerance#34390
Mugen87 merged 3 commits into
mrdoob:devfrom
hamedrabah:fix/merge-vertices-zero-tolerance

Conversation

@hamedrabah

@hamedrabah hamedrabah commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Fixed #31550

Description

mergeVertices() used bitwise coercion to truncate each quantized attribute value. Bitwise operations first wrap Numbers to signed 32-bit integers, so a zero or very small tolerance can make distinct vertices collide in the hash.

This replaces the coercion with Math.trunc(), which preserves the full Number range, and adds a regression with positions [0, 8, 0] at zero tolerance. The repeated origin is merged while the vertex at x=8 remains distinct.

Validation:

  • Focused runtime check returned two positions and index [0, 1, 0].
  • git diff --check passed.
  • The full QUnit suite was not available because the local dependency cache was incomplete and the configured package registry was unreachable.

Comment thread examples/jsm/utils/BufferGeometryUtils.js
Comment thread test/unit/addons/utils/BufferGeometryUtils.tests.js
@Mugen87 Mugen87 added this to the r186 milestone Aug 28, 2026
@Mugen87
Mugen87 merged commit af4ff3e into mrdoob:dev Aug 29, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BufferGeometryUtils.mergeVertices example has a hashing bug with minimal tolerance value

2 participants