Repository navigation
feat: introduce KEEP_CONNECTIONS and deprecate FLAT - #9271
Conversation
|
🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors! Thank You! |
|
Hey @davepagurek, I've introduced the new KEEP_CONNECTIONS constant and marked FLAT as deprecated for now, while keeping it functional for backward compatibility. When p5.js moves to 3.0, we can remove the deprecated FLAT constant and its related references. Currently, computeNormals() uses an if condition for SMOOTH, while everything else falls into the else block, so introducing KEEP_CONNECTIONS doesn't change the existing normal-calculation logic. In the future, we could make the conditions more explicit using else if branches for the supported shading modes, along with a fallback for unsupported values. This would also ensure that the old 'flat' value is no longer accepted once we remove it in 3.0. Let me know if that sounds reasonable! |
| * @deprecated Use `KEEP_CONNECTIONS` instead. May be removed in p5.js 3.0. | ||
| */ | ||
|
|
||
| export const FLAT = 'flat'; |
There was a problem hiding this comment.
If we change this to export const FLAT = KEEP_CONNECTIONS, then we could possibly also update the parameter docs for computeNormals to not have FLAT as a type at all (since it will typecheck the same as KEEP_CONNECTIONS.) That might be a little less confusing for readers, with less words spent on a thing they are encouraged not to use. What do you think?
There was a problem hiding this comment.
Ya actually makes sense to me we can rename it as you said and update the params which would be more cleaner and also it will not disrupt existing functionalities.
Thanks for the suggestion will apply the changes soon.
There was a problem hiding this comment.
Hey @davepagurek applied the suggested changes let me know if any issues in this.
davepagurek
left a comment
There was a problem hiding this comment.
Looks great, thanks!
Resolves #9270
Changes:
KEEP_CONNECTIONSas a new shading constant forcomputeNormals().FLATwhile preserving its existing behavior for backward compatibility. It may be removed in p5.js 3.0.KEEP_CONNECTIONSwithout changing the underlying normal calculation.KEEP_CONNECTIONSandSMOOTH.FLAT,KEEP_CONNECTIONS, and the default mode produce identical normals, while preserving vertex connections.This PR is a follow-up to #9205 and #9233. The proposed
SEGMENTEDshading mode will be handled in a separate issue and PR.Screenshots of the change:
Not applicable. This change introduces an API naming improvement and preserves the existing rendering behavior.
PR Checklist
npm run lintpasses