ecs: std/transform 3D, Transform3, GlobalTransform3 and 3D propagation (step 3b of #89) #787

Closed
opened 2026-11-14 15:26:56 +00:00 by orion · 6 comments
Collaborator

Context

Step 3 of 3 of #89 (ECS slice 1), second sub-step. The specification is ECS.md section 7 ("Hierarchy"), section 11 (std/transform) and section 15 q7 (GlobalTransform3 is its own component). Step 3a (#779, PR #780) has landed: std/transform exists on main with Transform2, GlobalTransform2 and propagate (std/transform/src/transform2.trb, global.trb, propagate.trb); std/linear has Vector3, Quaternion, Matrix3, Matrix4. This issue is 3b, the 3D half, the same shape as 3a with Quaternion and Matrix4; follow 3a's decisions and the form it proved.

Goal

Add Transform3 and GlobalTransform3 as separate components to std/transform, with their arithmetic and the 3D propagation over depthOrder, generic over the stores it reads and writes, over Float and Fixed.

Depends on

#779 (merged), std/ecs (Column, Store, Parent, depthOrder), std/linear on main. No seed impact: no syntax, no native, no driver flag, no std name the compiler looks up by string (new items in an existing package).

Requirements

  • R1. std/transform shall provide public type Transform3<Scalar: Real = Float> with translation: Vector3<Scalar>, rotation: Quaternion<Scalar>, scale: Vector3<Scalar>, Equals, Show, and static identity.
  • R2. Transform3 shall provide composed(with: Self): Self, inverse(): Self? (None when a scale component is zero), interpolated(toward: Self, by: Scalar): Self (translation and scale linear, rotation by the shortest path of the quaternion, as Quaternion in std/linear offers it) and toMatrix4(): Matrix4<Scalar> (affine, composed from the rotation matrix, the scale and the translation). composed shall agree with toMatrix4 multiplication for uniform parent scale and is documented as exact only there, as in 3a.
  • R3. public type GlobalTransform3<Scalar: Real = Float> shall hold the world-space Matrix4<Scalar> (matrix), with Equals, Show, identity, transformedPoint(point) and transformedDirection(direction) delegating to the matrix.
  • R4. The package shall provide the 3D propagation as a function generic over the stores it reads and writes, in the style of 3a's propagate (the exact signature and name are the implementer's, consistent with 3a): each entity with a Transform3 in depthOrder gets the parent's global matrix times its own toMatrix4(); an entity without Parent, or whose parent has no global, uses its own matrix.
  • R5. The 3D items shall work over Float and Fixed, bounded by Real as std/linear is.
  • R6. Every public item carries a doc comment with an # Examples block; the package imports nothing but std/core, std/number, std/linear, std/ecs.

Decisions (by the loop)

  • GlobalTransform3 holds a Matrix4, not a decomposed transform, for the same shear reason as in 3a (see the decisions of #779); Transform3 stays decomposed for authoring and interpolation.
  • No change to the 2D items of 3a, no new package, no compiler change.

Acceptance criteria

  • Transform3, GlobalTransform3 and the 3D propagation exist as above; torb check std/transform and torb format --check are clean; tools/check-commits.sh clean.
  • Arithmetic tests in std/transform/tests/: identity neutral for composed on both sides; inverse composed with the transform gives identity within a tolerance, None for a zero scale; interpolated at 0, 1 and 0.5 (rotation takes the short way); toMatrix4 of translation-only, rotation-only and scale-only equals the expected matrix.
  • Propagation tests on a program-declared group: a three-level chain given in reverse order yields the expected globals in one pass; a non-uniform-scale root with a rotated child gives the matrix product; an entity without Parent has global equal to its own matrix; the same chain over Fixed equals the hand-computed values.
  • A conformance program tests/conformance/transform-propagate-3d.trb (as transform-propagate for 2D) steps a small 3D hierarchy through a Schedule for several frames, tier B runs it in the VM and natively with .expected byte for byte; the .allocations budget is taken from the first forge CI run; a leak run is clean.
  • docs/standard-library/transform.md gains the 3D part, skills/ regenerated (--check is a tier A gate); ECS.md notes std/transform 3D landed with #89 and this issue.
  • Tier A and B green in forge CI.

Seed impact

None.

Size and model

One PR, two Conventional Commits (no style type): feat(std/transform): Transform3, GlobalTransform3 and 3D propagation and docs(std/transform): the 3D part of the standard library page, skills and the design record. Implementer: sonnet, medium (std/ package, no compiler change).

Part of #89 (Refs #89, not Closes).

## Context Step 3 of 3 of #89 (ECS slice 1), second sub-step. The specification is [ECS.md section 7](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/ECS.md) ("Hierarchy"), [section 11](https://git.torb.dev/torbscript/language/src/branch/main/docs/design/ECS.md) (`std/transform`) and section 15 q7 (`GlobalTransform3` is its own component). Step 3a (#779, PR #780) has landed: `std/transform` exists on `main` with `Transform2`, `GlobalTransform2` and `propagate` (`std/transform/src/transform2.trb`, `global.trb`, `propagate.trb`); `std/linear` has `Vector3`, `Quaternion`, `Matrix3`, `Matrix4`. This issue is **3b, the 3D half**, the same shape as 3a with `Quaternion` and `Matrix4`; follow 3a's decisions and the form it proved. ## Goal Add `Transform3` and `GlobalTransform3` as separate components to `std/transform`, with their arithmetic and the 3D propagation over `depthOrder`, generic over the stores it reads and writes, over `Float` and `Fixed`. ## Depends on #779 (merged), `std/ecs` (`Column`, `Store`, `Parent`, `depthOrder`), `std/linear` on `main`. **No seed impact**: no syntax, no native, no driver flag, no std name the compiler looks up by string (new items in an existing package). ## Requirements - R1. `std/transform` shall provide `public type Transform3<Scalar: Real = Float>` with `translation: Vector3<Scalar>`, `rotation: Quaternion<Scalar>`, `scale: Vector3<Scalar>`, `Equals, Show`, and `static identity`. - R2. `Transform3` shall provide `composed(with: Self): Self`, `inverse(): Self?` (`None` when a scale component is zero), `interpolated(toward: Self, by: Scalar): Self` (translation and scale linear, rotation by the shortest path of the quaternion, as `Quaternion` in `std/linear` offers it) and `toMatrix4(): Matrix4<Scalar>` (affine, composed from the rotation matrix, the scale and the translation). `composed` shall agree with `toMatrix4` multiplication for uniform parent scale and is documented as exact only there, as in 3a. - R3. `public type GlobalTransform3<Scalar: Real = Float>` shall hold the world-space `Matrix4<Scalar>` (`matrix`), with `Equals, Show`, `identity`, `transformedPoint(point)` and `transformedDirection(direction)` delegating to the matrix. - R4. The package shall provide the 3D propagation as a function generic over the stores it reads and writes, in the style of 3a's `propagate` (the exact signature and name are the implementer's, consistent with 3a): each entity with a `Transform3` in `depthOrder` gets the parent's global matrix times its own `toMatrix4()`; an entity without `Parent`, or whose parent has no global, uses its own matrix. - R5. The 3D items shall work over `Float` and `Fixed`, bounded by `Real` as `std/linear` is. - R6. Every public item carries a doc comment with an `# Examples` block; the package imports nothing but `std/core`, `std/number`, `std/linear`, `std/ecs`. ## Decisions (by the loop) - `GlobalTransform3` holds a `Matrix4`, not a decomposed transform, for the same shear reason as in 3a (see the decisions of #779); `Transform3` stays decomposed for authoring and interpolation. - No change to the 2D items of 3a, no new package, no compiler change. ## Acceptance criteria - [ ] `Transform3`, `GlobalTransform3` and the 3D propagation exist as above; `torb check std/transform` and `torb format --check` are clean; `tools/check-commits.sh` clean. - [ ] Arithmetic tests in `std/transform/tests/`: identity neutral for `composed` on both sides; `inverse` composed with the transform gives identity within a tolerance, `None` for a zero scale; `interpolated` at 0, 1 and 0.5 (rotation takes the short way); `toMatrix4` of translation-only, rotation-only and scale-only equals the expected matrix. - [ ] Propagation tests on a program-declared group: a three-level chain given in reverse order yields the expected globals in one pass; a non-uniform-scale root with a rotated child gives the matrix product; an entity without `Parent` has global equal to its own matrix; the same chain over `Fixed` equals the hand-computed values. - [ ] A conformance program `tests/conformance/transform-propagate-3d.trb` (as `transform-propagate` for 2D) steps a small 3D hierarchy through a `Schedule` for several frames, tier B runs it in the VM and natively with `.expected` byte for byte; the `.allocations` budget is taken from the first forge CI run; a leak run is clean. - [ ] `docs/standard-library/transform.md` gains the 3D part, `skills/` regenerated (`--check` is a tier A gate); ECS.md notes `std/transform` 3D landed with #89 and this issue. - [ ] Tier A and B green in forge CI. ## Seed impact None. ## Size and model One PR, two Conventional Commits (no `style` type): `feat(std/transform): Transform3, GlobalTransform3 and 3D propagation` and `docs(std/transform): the 3D part of the standard library page, skills and the design record`. Implementer: sonnet, medium (`std/` package, no compiler change). Part of #89 (`Refs #89`, not `Closes`).
Author
Collaborator

[loop:torbscript] refine: filed just in time as step 3b of #89 after 3a (#779, PR #780) landed; requirements R1-R6 and criteria follow the 2D form that landed, decided by the loop (GlobalTransform3 holds a Matrix4, same shear reason as 3a), no seed impact, no owner question. Label ready. next: implement

[loop:torbscript] refine: filed just in time as step 3b of #89 after 3a (#779, PR #780) landed; requirements R1-R6 and criteria follow the 2D form that landed, decided by the loop (GlobalTransform3 holds a Matrix4, same shear reason as 3a), no seed impact, no owner question. Label ready. next: implement
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1626 until 2026-11-14T21:26:00Z

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1626 until 2026-11-14T21:26:00Z
Author
Collaborator

[loop:torbscript] implement: opened #788 (2 commits: feat Transform3/GlobalTransform3/propagate3 with tests and conformance program, docs for page, skills and ECS.md). Verified: commit format only. Unverified until CI: all tests, format, doc checks, hand-computed .expected golden, native leg, skills copy (hand-edited, no torb binary), .allocations omitted as in 2D (budget from first CI run). next: waiting (CI on the PR, then review)

[loop:torbscript] release implement by session:loop-torbscript-20261114-1626

[loop:torbscript] implement: opened https://git.torb.dev/torbscript/language/pulls/788 (2 commits: feat Transform3/GlobalTransform3/propagate3 with tests and conformance program, docs for page, skills and ECS.md). Verified: commit format only. Unverified until CI: all tests, format, doc checks, hand-computed .expected golden, native leg, skills copy (hand-edited, no torb binary), .allocations omitted as in 2D (budget from first CI run). next: waiting (CI on the PR, then review) [loop:torbscript] release implement by session:loop-torbscript-20261114-1626
Author
Collaborator

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1832 until 2026-11-14T21:32:00Z

[loop:torbscript] claim implement by session:loop-torbscript-20261114-1832 until 2026-11-14T21:32:00Z
Author
Collaborator

[loop:torbscript] implement: fixed CI of PR #788 (tier A failed two gates: format --check on 3 files, the Transform3 command calls not in the command-call canon, and docs check, the std/transform summary at 286 of at most 240 characters; changed: calls rewritten to the canon in transform3.trb, transform3.test.trb and transform-propagate-3d.trb, summary shortened in docs/standard-library/transform.md and in its 5 generated copies in the index pages and skills; a pushed style fix commit was replaced by fix/docs commits because check-commits.sh refuses style, branch force-pushed with lease), new head e4718c95; CI re-runs.

next: waiting (CI on PR #788, then argus review)

[loop:torbscript] implement: fixed CI of PR #788 (tier A failed two gates: `format --check` on 3 files, the Transform3 command calls not in the command-call canon, and `docs check`, the std/transform summary at 286 of at most 240 characters; changed: calls rewritten to the canon in transform3.trb, transform3.test.trb and transform-propagate-3d.trb, summary shortened in docs/standard-library/transform.md and in its 5 generated copies in the index pages and skills; a pushed `style` fix commit was replaced by `fix`/`docs` commits because check-commits.sh refuses `style`, branch force-pushed with lease), new head e4718c95; CI re-runs. next: waiting (CI on PR #788, then argus review)
Author
Collaborator

[loop:torbscript] release implement by session:loop-torbscript-20261114-1832

[loop:torbscript] release implement by session:loop-torbscript-20261114-1832
argus closed this issue 2026-11-14 21:18:24 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
torbscript/language#787
No description provided.