Skip to content

ColorConverter: Fix HSV conversion at black and white boundaries. - #34806

Merged
Mugen87 merged 3 commits into
mrdoob:devfrom
dhairyajangir:fix/color-converter-boundaries
Oct 5, 2026
Merged

Mugen87 merged 3 commits into
mrdoob:devfrom
dhairyajangir:fix/color-converter-boundaries

Conversation

@dhairyajangir

Copy link
Copy Markdown

Description

ColorConverter.setHSV() produces NaN RGB channels for normalized black (v=0) and white (s=0, v=1) inputs. getHSV() likewise produces NaN saturation for black. Input clamping can reach these same boundaries.

Guard the zero denominators while preserving hue wrapping, saturation/value clamping, the existing nonboundary arithmetic, and working-color-space behavior. Add six registered addon tests for achromatic colors, primaries, clamping, hue wrapping, round trips, and the linear working color space.

Validation on Node 24.19.0:

  • New tests with original production code: three boundary groups fail; 430 addon tests pass.
  • npm test: core lint passes, 1,524 core tests pass with one existing TODO, and all 433 addon tests pass.
  • Changed-file ESLint and test-e2e-cov example inventory check pass. GPU backends were unavailable, so GPU-dependent assertions were skipped; rendered-example E2E was not run.

Independent review checked 24,505 HSV inputs and 1,331 RGB inputs against separate conversion oracles; all previously finite sampled results remain unchanged. Implementation and independent review were AI-assisted.

@Mugen87 Mugen87 added this to the r187 milestone Oct 5, 2026
@Mugen87
Mugen87 merged commit 1e721b1 into mrdoob:dev Oct 5, 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.

2 participants