Skip to content

Conversation

@mrdoob
Copy link
Owner

@mrdoob mrdoob commented Nov 7, 2025

Related issue: #32111

Description

Implements proper near/far plane clipping for triangles in the SVGRenderer using the Sutherland-Hodgman clipping algorithm in homogeneous clip space.

Changes

  • Projector.js: Added triangle clipping against near and far planes

    • Implements Sutherland-Hodgman algorithm in homogeneous clip space (before perspective divide)
    • Uses object pools to prevent garbage collection
    • Fast path for unclipped triangles (no clipping overhead when triangle is fully inside frustum)
    • Early rejection for completely clipped triangles
  • SVGRenderer.js: Removed Z-coordinate checks for triangle vertices

    • Removed the three if ( _v1/v2/v3.positionScreen.z < -1 || > 1 ) checks
    • Clipping is now handled properly by the Projector before vertices reach the renderer

@mrdoob mrdoob added this to the r182 milestone Nov 7, 2025
@mrdoob mrdoob merged commit b03e036 into dev Nov 7, 2025
9 checks passed
@mrdoob mrdoob deleted the svg-clipping branch November 7, 2025 09:24
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