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

Fixed bug with vertex positions #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tengotengo
Copy link

Vertices marked with v has 2 spaces after values, so yeah

@mikolalysenko
Copy link
Owner

Can you post a test case which was failing earlier?

@tengotengo
Copy link
Author

I'm sorry, obj files that were exported from 3dsMax have 2 spaces after each "v", which is weird.

here's a screenshot http://ii.pe/Tengiz_1439592782.jpg

@mikolalysenko
Copy link
Owner

Ok. Maybe a better way to fix this is to modify the tokenizer to be whitespace insensitive. Perhaps you could modify the line which splits on ' ' to split on `/\w+/'?

@mikolalysenko
Copy link
Owner

Err that should be \s or whatever the regex pattern is for whitespace.

@tengotengo
Copy link
Author

yes sir, great solution!
But perhaps simply checking if (toks[1] === '') { toks.shift() } would be faster?
Your choice

@tengotengo
Copy link
Author

of in line 25, instead of this:
v.push([+toks[1], +toks[2], +toks[3]])
do like this:
v.push([+toks[toks.length-3], +toks[toks.length-2], +toks[toks.length-1]])

@mikolalysenko
Copy link
Owner

What if some other code generated an example where the components of the vector 3 were spaced differently, for example:

v  1    3                    5

@tengotengo
Copy link
Author

excellent question.
I just found an obj file where double spacing occurs not just after "v" but also after "vt" and "vn"
I guess the right thing to do would be to split that string using white-space regex, like you suggested at the very beginning

@tengotengo
Copy link
Author

I don't see why would anyone generate it using multiple spaces between values, but I could definitely get it if someone used, for example, \t character as a separator. Hence /\s+/ would be ideal

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.

2 participants