Skip to content

ExtrudeGeometry: Fix regression introduced by #30750. #30822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 31, 2025

Conversation

mlasala45
Copy link
Contributor

@mlasala45 mlasala45 commented Mar 29, 2025

Fixed #30819

Description

Changes introduced by #30750 resulted in the inputs to ShapeUtils.triangulateGeometry not being initialized when bevelSegments == 0 (which happens when bevelEnabled == false), causing triangulation to fail. This PR adds code to manually populate those lists if they are empty before triangulation, fixing the issue. See related issue for examples.

Copy link

github-actions bot commented Mar 29, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 336.08
78.29
336.08
78.29
+0 B
+0 B
WebGPU 532.74
148.03
532.74
148.03
+0 B
+0 B
WebGPU Nodes 532.21
147.93
532.21
147.93
+0 B
+0 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 465.09
112.16
465.09
112.16
+0 B
+0 B
WebGPU 604.38
164
604.38
164
+0 B
+0 B
WebGPU Nodes 559.37
153.45
559.37
153.45
+0 B
+0 B

@mlasala45
Copy link
Contributor Author

mlasala45 commented Mar 29, 2025

Maybe it would be worth having a test screenshot for bevelEnabled == false? I'm not familiar with the process for setting those up.

@WestLangley
Copy link
Collaborator

These new changes appear to be causing additional regressions. Also check the console errors.

Screenshot 2025-03-29 at 7 25 29 PM

https://threejs.org/examples/webgl_geometry_text.html // tested after merging this PR

I would be inclined to revert #30750 at this point and allow time for proper testing.

@mlasala45
Copy link
Contributor Author

@WestLangley not seeing console errors, but I see the geometry bug (oddly, it's different on my end). I'll investigate.

The variable "vertices" could probably use renaming for clarity.
@mlasala45
Copy link
Contributor Author

Fixed. The change was using the wrong variable to populate contractedContourVertices, which would cause an error for shapes with holes when bevelEnabled == false. My bad, I should have tested the PR more thoroughly.

@WestLangley
Copy link
Collaborator

@WestLangley not seeing console errors, ...

The console errors occurred when the font was changed.

Unrelated to this PR, but FYI, file 8.svg from the webgl_loader_svg.html example does not extrude properly. It is just a rectangle with a single hole.

@mlasala45
Copy link
Contributor Author

mlasala45 commented Mar 30, 2025

The console errors occurred when the font was changed.

Ah, yeah I did see those later. They're gone now that the variable is fixed.

Unrelated to this PR, but FYI, file 8.svg from the webgl_loader_svg.html example does not extrude properly. It is just a rectangle with a single hole.

@WestLangley It appears that the outside boundary is being classified as a hole, while the inside boundary is being classified as a contour. This is happening before it's passed to ExtrudeGeometry, so it's probably a defect with the SVG file itself, the SVGLoader, or path.toShapes(). The issue seems to predate #30750 though.

@WestLangley
Copy link
Collaborator

@gkjohnson I have done the best I can to identify the failure points. Someone other than myself will have to approve the code changes. 🙏

@gkjohnson
Copy link
Collaborator

I have done the best I can to identify the failure points. Someone other than myself will have to approve the code changes. 🙏

Sorry I missed that there were already other reviews on this PR somehow. I'm not an expert in this file but as this PR is addressing it looks like the tringulated arrays were not being populated if there were no bevel points. Using the "contour" and "holes" arrays should revert the behavior back to what it was before #30750 when bevels were disabled. This change also seems to work.

let faces;
if ( contractedContourVertices.length === 0 ) {

	faces = ShapeUtils.triangulateShape( contour, holes );

} else {

	faces = ShapeUtils.triangulateShape( contractedContourVertices, expandedHoleVertices );

}

@mlasala45
Copy link
Contributor Author

Using the "contour" and "holes" arrays should revert the behavior back to what it was before #30750 when bevels were disabled.

@gkjohnson Good call. I've restructured this fix to check bevelSegments early, and avoid calculating contractedContourVertices and expandedHoleVertices when not necessary. The diffs show up poorly due to indentation changes, but the structure is now:

let faces;
if ( bevelSegments == 0 ) {

	faces = ShapeUtils.triangulateShape( contour, holes );

} else {
	// Calculate contractedContourVertices and expandedHoleVertices
	// ...

	faces = ShapeUtils.triangulateShape( contractedContourVertices, expandedHoleVertices );
}

Now branches based on bevelSegments ?= 0, bypassing contractedContourVertices/expandedHoleVertices  generation when there is no bevel.
@mlasala45 mlasala45 force-pushed the fix/30819-regression-caused-by-30750 branch from e6484d2 to 9091141 Compare March 30, 2025 04:39
Copy link
Collaborator

@gkjohnson gkjohnson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good and ready to merge.

@Mugen87 Mugen87 changed the title Fix regression introduced by #30750 ExtrudeGeometry: Fix regression introduced by #30750. Mar 31, 2025
@Mugen87 Mugen87 added this to the r176 milestone Mar 31, 2025
@Mugen87 Mugen87 merged commit 05e77b0 into mrdoob:dev Mar 31, 2025
12 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.

ExtrudeGeometry: Extruded faces are missing
4 participants