Skip to content

Conversation

@nakednous
Copy link
Contributor

@nakednous nakednous commented Nov 25, 2025

This PR fixes issue #7837.

In p5.js v2, Matrix.mat4 is exposed via a getter that returns an internal Float32Array.
Camera.slerp() (and potentially other code) assigns to uPMatrix.mat4 which throws:

TypeError: setting getter-only property "mat4"

This change adds a set mat4(values) on Matrix that:

  • only applies to 4×4 matrices,
  • expects an array-like of length 16, and
  • copies values into the existing Float32Array instead of reassigning it.
  • Adds a symmetric set mat3(values) for 3×3 matrices.

This fixes the intended writable behavior (used by Camera.slerp()), while preserving the internal buffer identity required by WebGL bindings and other code that holds references to the matrix storage.

@welcome
Copy link

welcome bot commented Nov 25, 2025

🎉 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!

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.

1 participant