SimplifyModifier: Add check if face are not undefined. #24169
Merged
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.
add check if face are not undefined
check with u.faces[i]
Description
add condition for undefined for loop
Now I’m making code for web 3d world viewer. I want to make lod system for my world and for that, I have to use simplify modifier for this.
Anyway, when I use simplify modifier to simplify gltf model it shows error with this
I spend lot of time to search about it, but I can’t find the hint
So I console log it to find out what happen to simplify modifier and I think this might be reason.
I console log this loop
I found that when removeFace function run, it sometimes remove two faces at one loop. As you can see in picture above, first length of u.faces.length = 8, and value i = 7, at second loop u.faces.length = 6, and value i = 6 this cause error.
Is it okay with just add
if (!u.faces[i]) continue;
in for loop?it seems running but I think it work not propery.
This contribution is funded by forum