Skip to content

feat: introduce KEEP_CONNECTIONS and deprecate FLAT - #9271

Merged
davepagurek merged 4 commits into
processing:mainfrom
Srinidhi444:feat/keep-connections
Oct 13, 2026
Merged

davepagurek merged 4 commits into
processing:mainfrom
Srinidhi444:feat/keep-connections

Conversation

@Srinidhi444

Copy link
Copy Markdown
Contributor

Resolves #9270

Changes:

  • Introduced KEEP_CONNECTIONS as a new shading constant for computeNormals().
  • Deprecated FLAT while preserving its existing behavior for backward compatibility. It may be removed in p5.js 3.0.
  • Updated the default shading mode to KEEP_CONNECTIONS without changing the underlying normal calculation.
  • Updated the inline documentation and example to explain the new naming and clarify the difference between KEEP_CONNECTIONS and SMOOTH.
  • Added unit tests verifying that 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 SEGMENTED shading 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

@welcome

welcome Bot commented Oct 11, 2026

Copy link
Copy Markdown

🎉 Thanks for opening this pull request! For guidance on contributing, check out our contributor guidelines and other resources for contributors!
🤔 Please ensure that your PR links to an issue, which has been approved for work by a maintainer; otherwise, there might already be someone working on it, or still ongoing discussion about implementation. You are welcome to join the discussion in an Issue if you're not sure!
🌸 Once your PR is merged, be sure to add yourself to the list of contributors on the readme page !

Thank You!

@Srinidhi444

Copy link
Copy Markdown
Contributor Author

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!

@p5-bot

p5-bot Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Continuous Release

CDN link

Published Packages

Commit hash: fa23b18

Previous deployments

9bd9123


This is an automated message.

Comment thread src/core/constants.js Outdated
* @deprecated Use `KEEP_CONNECTIONS` instead. May be removed in p5.js 3.0.
*/

export const FLAT = 'flat';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @davepagurek applied the suggested changes let me know if any issues in this.

@davepagurek davepagurek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

@davepagurek
davepagurek merged commit 7a6d471 into processing:main Oct 13, 2026
4 checks passed
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.

Introduce KEEP_CONNECTIONS as a replacement for FLAT in computeNormals()

2 participants