LDrawLoader: Make normal smoothing condition more explicit #23093
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: Fixed #23085.
Description
Previously some primitives were getting smoothed multiple times due to the labeling of the file include hierarchy. This changes the condition for when the face normals are smoothed to be more explicit -- either when when a "Part" is being finalized or a set of faces (a "Primitive" type) is being added directly into a "Model" type.
Unfortunately the LDraw spec seems to be pretty vague when it comes to what "types" are valid (or the files are just a bit loose with them). In the case of the car model there was an extra type called "Configuration" that was triggering a extra "smooth normals" step with the previous condition which resulted in incorrect normals.
Here's the example page with the fix:
https://raw.githack.com/gkjohnson/three.js/ldraw-black-bit-fix/examples/webgl_loader_ldraw.html
Notice the black spots on the car model are fixed and the ribbed pipes and blue rubber band inside the model in the AT-ST file are smoothed correctly, as well (which was the original intent behind the condition).
Happy holidays!