Skip to content

bug(three): createGradient divides by zero when size <= 1 #1251

Description

@YayoRazo

Description

TextureUtils.createGradient() accepts a size parameter (default 256). When size <= 1, the denominators in the gradient calculation become zero, producing Infinity values that propagate through the color lerp and result in NaN pixel values.

  • Horizontal/vertical: t = x / (size - 1)0 / 0 = NaN
  • Radial: t = Math.sqrt(...) / (size / 2)0 / 0 = NaN

Steps to reproduce

TextureUtils.createGradient(1) // or size 0
// Result: texture filled with NaN pixels

Expected behavior

Textures with size <= 1 should produce at least a 2x2 gradient, or at minimum not crash with NaN.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions