-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add custom face color calculation function #3
Add custom face color calculation function #3
Conversation
…ons with a customizeable pipeline. Use library math functions instead of hand-crafted implementations.
lib/object_3d.dart
Outdated
face = faceColorFunc == null | ||
? _defaultFaceColor(face) | ||
: faceColorFunc!(face); |
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.
Could also do something like this: face = faceColorFunc?.call(face) ?? _defaultFaceColor(face);
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.
Didn't know about this! Will do.
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.
done
lib/object_3d.dart
Outdated
Face face = Face(verticesToDraw[faceIdx[0] - 1], | ||
verticesToDraw[faceIdx[1] - 1], verticesToDraw[faceIdx[2] - 1]); |
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 it would be a bit nicer to extract these function parameters above this call so its a bit more readable
Face face = Face(verticesToDraw[faceIdx[0] - 1], | |
verticesToDraw[faceIdx[1] - 1], verticesToDraw[faceIdx[2] - 1]); | |
final v1 = verticesToDraw[faceIdx[0] - 1]; | |
final v2 = verticesToDraw[faceIdx[1] - 1]; | |
final v3 = verticesToDraw[faceIdx[2] - 1]; | |
Face face = Face(v1, v2, v3); |
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.
done
I've also added a workflow to lint and analyze the code base. You should probably first merge that into your own branch so the workflow can run on this pull request as well. This is also necessary to resolve the merge conflicts. |
2e39884
to
7e75dc9
Compare
The only linter not addressed was the request to change explicit types to |
The two list initializations can be written like this final List<Offset> offsets = [];
final List<Color> colors = []; If you use a constructor, it is redundant to also provide a type for the variable, so Face face = Face(...) can be written like var face = Face(...) But as I was writing this, I read the style guide for the Flutter repo and this recommends to always explicitly type variables (as you were doing). If you can find the right combination of rules to enforce this style, go ahead and change them. I do honestly not really care for which code style is used, as long as it is consistent and a common set up in other Flutter projects |
…uite. Replaced vector_math with vector_math_64. google/vector_math.dart#210
Face
class to hold face data and calculate a unit normal (cached).New: