Repository navigation
Conversation
|
pkg.pr.new packages benchmark commit |
Bundle size comparison (
|
| 🟢 Decreased | ➖ Unchanged | 🔴 Increased | ❔ Unknown |
|---|---|---|---|
| 0 | 360 | 0 | 0 |
No notable changes.
If you wish to run a comparison for other, slower bundlers, run the 'Tree-shake test' from the GitHub Actions menu.
Resolution Time Benchmark---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Random Branching (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.70, 1.47, 3.46, 5.01, 6.27, 10.31, 21.13, 25.52]
line [0.70, 1.52, 3.20, 5.43, 6.57, 11.41, 22.52, 23.21]
line [0.78, 1.63, 3.36, 6.10, 6.73, 10.39, 21.18, 24.19]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Linear Recursion (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.23, 0.37, 0.51, 0.61, 0.84, 0.89, 1.08, 1.16]
line [0.21, 0.45, 0.55, 0.61, 0.84, 0.86, 1.15, 1.14]
line [0.23, 0.42, 0.49, 0.61, 0.87, 0.89, 1.06, 1.17]
---
config:
themeVariables:
xyChart:
plotColorPalette: "#E63946, #3B82F6, #059669"
---
xychart
title "Full Tree (🔴 PR | 🔵 main | 🟢 release)"
x-axis "max depth" [1, 2, 3, 4, 5, 6, 7, 8]
y-axis "time (ms)"
line [0.87, 2.02, 3.59, 6.03, 12.95, 25.12, 51.34, 105.83]
line [0.82, 2.19, 3.62, 5.87, 11.68, 26.08, 51.23, 107.84]
line [0.94, 1.66, 3.02, 5.63, 10.89, 22.32, 46.48, 99.75]
|
4513b17 to
177de99
Compare
177de99 to
73218eb
Compare
4e3132a to
36cdb51
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Rounded-box radius handling can invert faces for thin dimensions, while fully rounded boxes retain unnecessary collapsed geometry.
2 open issues
What changed in this PR
Adds triangular patch surfaces to the meshes API, separating surface sampling from subdivision. This supports both indexed geometry and direct vertex-shader evaluation.
Changes:
- Adds icosphere, capsule, and rounded-box patches with tessellated convenience constructors.
- Introduces triangle subdivision utilities, reusable index prefixes, and spherical interpolation helpers.
- Adds an interactive example and tests for topology, surface sampling, and shader resolution.
| File | Description |
|---|---|
packages/typegpu-geometry/tests/patches.test.ts |
Tests subdivision, watertightness, and interpolation specialization. |
packages/typegpu-geometry/tests/mesh.test.ts |
Extends primitive and degenerate-triangle checks. |
packages/typegpu-geometry/src/mesh/triangles.ts |
Defines patch surfaces and subdivision utilities. |
packages/typegpu-geometry/src/mesh/patchPrimitives.ts |
Adds tessellated primitive constructors. |
packages/typegpu-geometry/src/mesh/patches/spherical.ts |
Implements spherical interpolation helpers. |
packages/typegpu-geometry/src/mesh/patches/rounded.ts |
Implements capsule and rounded-box patches. |
packages/typegpu-geometry/src/mesh/patches/index.ts |
Exports patch constructors and interpolation helpers. |
packages/typegpu-geometry/src/mesh/patches/icosphere.ts |
Implements icosphere patches. |
packages/typegpu-geometry/src/mesh/index.ts |
Exposes the new mesh APIs. |
apps/typegpu-docs/tests/individual-example-tests/mesh-patches.test.ts |
Checks example pipeline shader resolution. |
apps/typegpu-docs/src/examples/rendering/mesh-patches/meta.json |
Registers the example metadata. |
apps/typegpu-docs/src/examples/rendering/mesh-patches/index.ts |
Demonstrates adjustable subdivision with shared indices. |
apps/typegpu-docs/src/examples/rendering/mesh-patches/index.html |
Provides the example canvas. |
Review effort: Balanced
There was a problem hiding this comment.
Important
roundedBox silently produces inside-out geometry when radius exceeds half the smallest box dimension, and a majority-degenerate, non-manifold mesh at exactly half. inset = halfSize - radius is never clamped or validated.
( ◦°^°◦) 🏴☠️
Ahoy! I plundered the diff o' PR #3014, ran the geometry tests, typecheck and linters, and keelhauled one leaky roundedBox radius that flips the hull inside-out when it be past half the smallest beam. One warnin' be posted below, savvy?
Reviewed changes
- Patch surfaces — adds
icosphere,capsuleandroundedBoxas shader-evaluatedPatchSurfaceobjects undersrc/mesh/patches/, with spherical interpolation helpers (linear,uniformArea,arc,warp). - Triangle tessellation —
triangles.tsadds the CPU helperstriangleVertexCount/triangleIndexCount/triangleIndicesand the GPU helperstriangleBarycentrics/triangleIndexAt, plustessellatemapping a linear vertex index onto a triangular grid. - Shared index buffer —
triangleIndexAtis segment-independent, so one max-segment index buffer works as a prefix at every lower subdivision; the new docs example drives detail from a single buffer while the vertex shader recomputes barycentrics. - Patch primitives + example —
patchPrimitives.tstessellates the three shapes with asegmentsoption, plus a newmesh-patchesdocs example and jsdom example test.
I verified the geometry tests (44 passing), typecheck, lint and formatting locally, and independently checked that the index-prefix property holds for every segment value in [1..32] and that capsule/icosphere stay watertight and correctly wound across the probed parameter ranges. The only issue found is the unclamped radius below.
There was a problem hiding this comment.
✅ No new issues found.
( ◦°^°◦) 🏴☠️
Ahoy! I boarded the new commit on PR #3014 and found the leak I'd flagged last voyage already plugged — the roundedBox radius be clamped to half the smallest beam, so no more inside-out hulls. Batten down the tests and let her sail.
Reviewed changes
- Clamped the rounded-box radius —
roundedBoxnow resolvesradiusasMath.min(maxRadius, halfSize.x, halfSize.y, halfSize.z)(patches/rounded.ts:92) and documents it as "Clamped to half of the smallest dimension". This removes the negativeinsetthat previously mirrored face/edge patches and wound ~55% of triangles inside-out onceradiusexceeded half the smallest dimension. - Added a thin-box winding case —
mesh.test.tsgains['thin rounded box', meshes.roundedBox({ height: 0.05 })], exercising the newly clamped path whereinsetreaches zero on the smallest axis.
I re-ran the geometry suite (45 passing) and package typecheck, and independently probed five configurations (radius well above min/2, exactly min/2, thin boxes, and a normal case): none produce inside-out triangles anymore. The residual trade-off — collapsing to exactly min/2 leaves zero-area face/edge patches on the smallest axis (e.g. radius: 0.5 on a unit cube yields 576/704 degenerate triangles) — is wasted geometry rather than a rendering defect, and matches the clamp semantics the author chose. Prior review's inline thread is resolved on GitHub.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
b83da47 to
7c7b644
Compare
13fb69d to
e9de4bc
Compare
104e9bf to
3f883fc
Compare
3f883fc to
7a2cd21
Compare
7a2cd21 to
a457593
Compare
There was a problem hiding this comment.
✅ No new issues found.
( ◦°^°◦) 🏴☠️
Ahoy! I re-scanned the fresh commits on PR #3014, saw the example hand its resizin' duties to the shared auto-resizer, and found nary a leak to swab — she sails clean.
Reviewed changes
- Ported the docs example to
common.attachAutoResizer—mesh-patchesnow creates the shared auto-resizer with anonResizecallback that rebuilds the depth texture and requests a frame, andonCleanupdetaches it, replacing the hand-rolledResizeObserver. - Switched the canvas to utility-class sizing —
index.htmlnow usesclass="w-full h-full"instead of the unuseddata-fit-to-containerattribute, matching the other rendering examples.
I re-ran the geometry suite (5 files / 50 tests) and the mesh-patches example test (1 passed) at a457593a; both pass. The only authored delta since the prior review is these two example files — the rest of the range-diff is base-branch rebase noise.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
a457593 to
f14bae5
Compare
There was a problem hiding this comment.
✅ No new issues found.
( ◦°^°◦) 🏴☠️
Ahoy! I checked the fresh head o' PR #3014 and found it a bare rebase — nary a line o' the PR's own cargo shifted, so I let her sail on with a clean bill.
Reviewed changes
- Rebased onto an updated
feat/geometry-meshesbase — no PR-owned file changed between the prior reviewed heada457593aandf14bae57;git diff-tree -rover all 13 PR paths is empty, and every difference between the two heads belongs to the base branch. The previously reviewedroundedBoxradius clamp and theattachAutoResizerexample port are unchanged.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
f14bae5 to
061fffe
Compare
aleksanderkatan
left a comment
There was a problem hiding this comment.
Looks clean!
I didn't understand everyting (like warp function) but I trust
| const start = std.intdiv(row * (row + 1), 2); | ||
| const corner = index % 3; | ||
| if (col <= row) { | ||
| if (corner === 0) return start + col; |
There was a problem hiding this comment.
Agreed
| if (corner === 0) return start + col; | |
| if (corner === 0) { | |
| return start + col; | |
| } |
| ); | ||
|
|
||
| const signatures = shaderCodes.match(/^fn .*(?= \{$)/gm); | ||
| expect([...new Set(signatures)].join('\n')).toMatchInlineSnapshot(` |
There was a problem hiding this comment.
Nice for human readability!
Could you add a full snapshot in as well? I think of them as a low maintenance canary for wgsl generation changes
061fffe to
75e94c7
Compare
|
Could you add a thumbnail for the Mesh Patches example? |
| const start = std.intdiv(row * (row + 1), 2); | ||
| const corner = index % 3; | ||
| if (col <= row) { | ||
| if (corner === 0) return start + col; |
There was a problem hiding this comment.
Agreed
| if (corner === 0) return start + col; | |
| if (corner === 0) { | |
| return start + col; | |
| } |
| if (row * row > triangle) row -= 1; | ||
| else if ((row + 1) * (row + 1) <= triangle) row += 1; |
There was a problem hiding this comment.
| if (row * row > triangle) row -= 1; | |
| else if ((row + 1) * (row + 1) <= triangle) row += 1; | |
| if (row * row > triangle) { | |
| row -= 1; | |
| } else if ((row + 1) * (row + 1) <= triangle) { | |
| row += 1; | |
| } |
| if (corner === 0) return vertex; | ||
| if (corner === 1) return vertex + row + 2; | ||
| return vertex + 1; |
There was a problem hiding this comment.
I think this reads very nice, maybe let's keep it without the brackets
There was a problem hiding this comment.
braced it to match the if above and the rest of the file
| if (std.intdiv(row * (row + 1), 2) > vertex) row -= 1; | ||
| else if (std.intdiv((row + 1) * (row + 2), 2) <= vertex) row += 1; |
There was a problem hiding this comment.
| if (std.intdiv(row * (row + 1), 2) > vertex) row -= 1; | |
| else if (std.intdiv((row + 1) * (row + 2), 2) <= vertex) row += 1; | |
| if (std.intdiv(row * (row + 1), 2) > vertex) { | |
| row -= 1; | |
| } else if (std.intdiv((row + 1) * (row + 2), 2) <= vertex) { | |
| row += 1; | |
| } |
| export * from './patchPrimitives.ts'; | ||
| export * from './triangles.ts'; |
There was a problem hiding this comment.
Like in the PR under this one, I'd prefer if we listed what gets exported here. Doing a * export from index.ts files is fine imo, as it is below.
| radius?: number; | ||
| interpolate?: (a: d.v3f, b: d.v3f, c: d.v3f, weights: d.v3f) => d.v3f; |
There was a problem hiding this comment.
| radius?: number; | |
| interpolate?: (a: d.v3f, b: d.v3f, c: d.v3f, weights: d.v3f) => d.v3f; | |
| radius?: number | undefined; | |
| interpolate?: ((a: d.v3f, b: d.v3f, c: d.v3f, weights: d.v3f) => d.v3f) | undefined; |
| export * from './icosphere.ts'; | ||
| export * from './rounded.ts'; |
There was a problem hiding this comment.
Would appreciate listing out the exports here 🫡
There was a problem hiding this comment.
I think these functions deserve a JS doc describing what their purpose and/or different names, right now they're available as meshes.patches.linear and meshes.patches.uniformArea.
Maybe meshes.patches.linearWeightDistribution and meshes.patches.uniformAreaWeightDistribution?
Adapt triangle tessellation and spherical interpolation from https://github.com/deluksic/TypeGPU/tree/647e8f5dc8e5a708420ac83fbf51503e37828049 Co-authored-by: David Emanuel Luksic <deluksic@gmail.com>
75e94c7 to
cc314f0
Compare



Adds triangular patch surfaces to
meshes, with subdivision separate from surface samplingTessellation and spherical interpolation ideas yoinked from @deluksic’s de/geometry-spheres branch, shared in the original PR comment
Stacks on #2997