Repository navigation
Remove dead normals check in loadModel() and document computeNormals() for OBJ files without normals - #9407
Open
Prbhtsgh wants to merge 1 commit into
Open
Remove dead normals check in loadModel() and document computeNormals() for OBJ files without normals#9407Prbhtsgh wants to merge 1 commit into
Prbhtsgh wants to merge 1 commit into
Conversation
…uteNormals() parseObj pushes a (0, 0, 0) normal for every vertex without one, so the vertexNormals.length === 0 check never ran. Remove it, fix the comment and test names that said normals get computed, and add a note to the loadModel() reference about calling computeNormals() when a file has no vn lines.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Resolves #9404
Changes:
As discussed in #9404,
loadModel()doesn't compute normals automatically for OBJ files withoutvnlines (that's expected, since it's expensive and not always needed). But the code and tests still said it did, which was confusing. This PR makes them match the actual behaviour:src/webgl/loading.js: removed theif (model.vertexNormals.length === 0) model.computeNormals();check.parseObjpushes a(0, 0, 0)normal for every vertex that has none, so this check could never be true. Also updated the comment below it that said "normals are ready above".src/webgl/loading.js: added a note to theloadModel()reference: if a.objfile has no vertex normals, the model won't react to lights, so callmodel.computeNormals()after it loads.test/unit/io/loadModel.js: renamed two tests and updated a comment that said normals are "computed" when the OBJ has none. The assertions are unchanged (they check one normal per vertex, which is still true).Behaviour is unchanged. As mentioned in the issue,
computeNormals()on a multi-material model doesn't updatemodel.partsyet; that's left for #9321.Screenshots of the change:
Not applicable (docs, comments and test names only).
PR Checklist
npm run lintpasses