Skip to content

feat: accept readonly inputs across the package - #53

Draft
RodrigoHamuy wants to merge 31 commits into
pmndrs:mainfrom
RodrigoHamuy:feat/readonly-types-all
Draft

feat: accept readonly inputs across the package#53
RodrigoHamuy wants to merge 31 commits into
pmndrs:mainfrom
RodrigoHamuy:feat/readonly-types-all

Conversation

@RodrigoHamuy

@RodrigoHamuy RodrigoHamuy commented Sep 10, 2026

Copy link
Copy Markdown

Continuation of:

Types added

RVec2 RVec3 RVec4 RQuat RQuat2 RMat2 RMat2d RMat3 RMat4 REuler RSpherical RPolar RColor RHSL RBox2 RBox3 RSphere RCircle RPlane3 ROBB3 RFrustum RFrustumCorners

RodrigoHamuy and others added 30 commits September 9, 2026 11:01
Add RVec2, a readonly Vec2, and use it for every vec2 parameter that is
only read from. Output parameters stay mutable Vec2 so the receiving
vector can still be written to.

Mutable vectors remain assignable to RVec2, so existing callers are
unaffected. Callers holding a readonly vector can now pass it directly
instead of copying or casting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RVec3, a readonly Vec3, and use it for every vec3 parameter that is
only read from. Output parameters stay mutable Vec3 so the receiving
vector can still be written to.

Mutable vectors remain assignable to RVec3, so existing callers are
unaffected. Callers holding a readonly vector can now pass it directly
instead of copying or casting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RVec4, a readonly Vec4, and use it for every vec4 parameter that is
only read from. Output parameters stay mutable Vec4 so the receiving
vector can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RQuat, a readonly Quat, and use it for every quaternion parameter
that is only read from. Read-only vec3 parameters take RVec3 as well.
Output parameters stay mutable so the receiving value can still be
written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RQuat2, a readonly Quat2, and use it for every dual quaternion
parameter that is only read from. Read-only quat and vec3 parameters
take RQuat and RVec3 as well. Output parameters stay mutable so the
receiving value can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat2, a readonly Mat2, and use it for every matrix parameter that
is only read from. Read-only vec2 parameters take RVec2 as well. Output
parameters stay mutable so the receiving matrix can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat2d, a readonly Mat2d, and use it for every matrix parameter that
is only read from. Read-only vec2 parameters take RVec2 as well. Output
parameters stay mutable so the receiving matrix can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat3, a readonly Mat3, and use it for every matrix parameter that
is only read from. Read-only mat2d, quat and vec2 parameters take their
readonly aliases as well. Output parameters stay mutable so the
receiving matrix can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RMat4, a readonly Mat4, and use it for every matrix parameter that
is only read from. Read-only quat, quat2 and vec3 parameters take their
readonly aliases as well. Output parameters stay mutable so the
receiving value can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add REuler, a readonly Euler, and use it for every euler parameter that
is only read from, in euler and in quat.fromEuler. Read-only mat4 and
quat parameters take their readonly aliases as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RSpherical, a readonly Spherical, and use it for every spherical
parameter that is only read from. Read-only vec2 and vec3 parameters
take their readonly aliases as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RPolar, a readonly Polar, and use it for every polar parameter that
is only read from. Read-only vec2 parameters take RVec2 as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RColor, a readonly Color, and use it for every color parameter that
is only read from, in color, colorspace and hsl. Read-only sRGB triples
become readonly tuples too. Output parameters stay mutable so the
receiving color can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RHSL, a readonly HSL, and use it for every hsl parameter that is
only read from. Output parameters stay mutable so the receiving color
can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RBox2, a readonly Box2, and use it for every box parameter that is
only read from. Read-only vec2 parameters take RVec2 as well. Output
parameters stay mutable so the receiving box can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RBox3, a readonly Box3, and use it for every box parameter that is
only read from. Read-only vec3 and mat4 parameters take their readonly
aliases as well. Output parameters stay mutable so the receiving box can
still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RSphere, a sphere whose center and radius are both readonly, and use
it for every sphere parameter that is only read from. Readonly<Sphere>
alone would still allow writes through the center vector, so the fields
are spelled out.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RCircle, a circle whose center and radius are both readonly, and use
it for the read-only circle parameter of box2.intersectsCircle. The
fields are spelled out because Readonly<Circle> would still allow writes
through the center vector.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RPlane3, a plane whose normal and constant are both readonly, and
use it for every plane parameter that is only read from. Read-only vec3,
mat4 and sphere parameters take their readonly aliases as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add ROBB3, an oriented box whose center, half extents and rotation are
all readonly, and use it for every obb parameter that is only read from.
Read-only vec3, mat3, mat4, quat and box3 parameters take their readonly
aliases as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Add RFrustum and RFrustumCorners, whose planes and vectors are readonly
all the way down, and use RFrustum for every frustum parameter that is
only read from. Read-only mat4, sphere, box3 and vec3 parameters take
their readonly aliases as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec2 for every vector parameter that is only read from. Output
parameters stay mutable Vec2 so the receiving vector can still be
written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec2 for every vertex and point parameter that is only read from.
Output parameters stay mutable so the receiving vector or box can still
be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec3 for every vertex parameter that is only read from. Output
parameters stay mutable so the receiving vector or box can still be
written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Use RVec3 for the ray and triangle parameters and RBox3 for the tested
box. IntersectsTriangleResult is written to, so it stays mutable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Vertex buffers that are only read from become readonly number[], and
read-only point and segment parameters take RVec2. The reverse output
buffer and the out vector and box parameters stay mutable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Vertex and point buffers that are only read from become readonly
number[], and circumcircle takes RVec2 points. Accumulators and out
parameters stay mutable so results can still be written to.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Spring targets and the initial value passed to create are only read
from, so they take RVec2, RVec3 and RVec4. The spring state itself is
mutated each frame and stays mutable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Targets, base locations, bone endpoints, directions and constraint axes
are only read from, so they take RVec2 and RVec3. The chain, bone and
joint structures are solved in place and stay mutable.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
choice only reads the array it picks from, so it takes readonly T[].

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The modules converted before their dependencies had readonly aliases
still took mutable ones. Transform functions now take RMat2, RMat2d,
RMat3, RMat4 and RQuat, mat3 and quat2 take RMat4, and box3 takes
RSphere and RPlane3.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Sep 10, 2026

Copy link
Copy Markdown

鈿狅笍 No Changeset found

Latest commit: 49c2457

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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