Skip to content
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

OBJLoader: Better handle inconsistent face definitions. #19338

Merged
merged 3 commits into from May 11, 2020

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented May 11, 2020

Fixed #16211.

  • If a face definition does not define normal indices, a face normal is computed.
  • If a face definition does not define uv indices, (0,0) is set.
  • Only adds normal or uv attribute if faces have respective (potentially inconsistent) definitions.

@Mugen87
Copy link
Collaborator Author

Mugen87 commented May 11, 2020

@gkjohnson Did you have something like that in mind?

@@ -305,26 +346,45 @@ var OBJLoader = ( function () {
this.addVertex( ia, ib, ic );
this.addColor( ia, ib, ic );

// normals

if ( na !== undefined && na !== '' ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's probably not worth worrying about until there's a model that demonstrates the issue but I wonder if it's possible for just one of the vertices in a face to specify a normal while the other two do not.

@gkjohnson
Copy link
Collaborator

This looks good to me, thank you!

@mrdoob mrdoob added this to the r117 milestone May 11, 2020
@mrdoob mrdoob merged commit 5db1eb3 into mrdoob:dev May 11, 2020
@mrdoob
Copy link
Owner

mrdoob commented May 11, 2020

Thanks!

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.

OBJLoader: Loader does not return valid geometry with inconsistent face definitions
3 participants