-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
Fix OBJ loader with empty uvs or normals #13400
Conversation
Looking at the origin of the "problem" we see that the faces on the So when we split that line, we get And then we add the face with that array of parameters: So basically we could do the check directly on the @mrdoob up to you! ;) |
That's for investigating further. But then this only affects uvs, right? The normals check shouldn't be needed? |
@@ -286,19 +286,17 @@ THREE.OBJLoader = ( function () { | |||
|
|||
this.addVertex( ia, ib, ic ); | |||
|
|||
if ( ua !== undefined ) { | |||
if ( ua !== undefined && ua !== '' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or test ua.length
? Do we know it is a string at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WestLangley yeah, it's a string, I could change it for if ( ua !== undefined && ua.length)
I don't have an strong opinion here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder why this loader passes strings around, instead of converting to numbers right away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WestLangley that a good point, I could give it a try to refactor it, something like adding a:
var vertexParts = vertex.split( '/' ).map(function(value) {return parseInt(value, 10); });
before passing the data around: https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/OBJLoader.js#L503
So we could get rid of the conversions inside the methods that use these values: https://github.com/mrdoob/three.js/blob/dev/examples/js/loaders/OBJLoader.js#L189
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll still need to do the check ua !== undefined && !isNaN(ua)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a refactor in that regard would be beneficial.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WestLangley Agreed. I'll create an issue about it.
@mrdoob not in this model, but I believe we could find some models using the following syntax and they'll still be valid obj models:
In fact if using our OBJExporter we'll get that that style syntax if no normal found: https://github.com/mrdoob/three.js/blob/dev/examples/js/exporters/OBJExporter.js#L144 |
I don't think that's correct. These are the possible options:
The obj format is crazy but not THAT crazy 😁
We should fix that 😕 |
@mrdoob not sure... http://paulbourke.net/dataformats/obj/
From that text I wouldn't say |
Thanks! |
UVs idx or normals could be
!== undefined
but they could still be empty, as happens with the WaltzHead.obj re: #13397