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.88, 1.76, 4.06, 6.37, 6.59, 11.99, 23.38, 26.50]
line [0.82, 1.67, 3.92, 5.88, 6.65, 10.51, 23.49, 25.71]
line [0.78, 1.54, 3.47, 6.14, 7.55, 10.60, 20.35, 23.69]
---
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.41, 0.54, 0.69, 0.94, 0.99, 1.16, 1.38]
line [0.23, 0.44, 0.59, 0.69, 0.93, 0.97, 1.17, 1.27]
line [0.20, 0.36, 0.54, 0.69, 1.11, 0.97, 1.13, 1.28]
---
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.88, 2.08, 4.30, 6.82, 14.76, 27.13, 55.08, 113.06]
line [0.89, 2.24, 3.77, 7.07, 14.21, 27.39, 54.69, 114.21]
line [0.74, 1.93, 3.28, 8.40, 12.16, 23.32, 48.27, 100.33]
|
4af9244 to
b452155
Compare
|
Please take a look at my (almost finished) branch, if you would like to incorporate any of it, or steal techniques https://github.com/deluksic/TypeGPU/tree/de/geometry-spheres (it is more than spheres) |
b452155 to
434811e
Compare
1e09d9b to
6246334
Compare
58c4fcb to
043c0ab
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Baked-index consistency and primitive boundaries during concatenation need correction before approval.
2 open issues
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Adds a composable meshes API to @typegpu/geometry, supporting procedural 3D geometry, shader evaluation, and GPU buffer baking.
Changes:
- Introduces primitives, parametric surfaces, and geometry transformations and composition.
- Adds full and index-only baking, asynchronous preparation, and compute-driven vertex updates.
- Adds tests and an animated mesh gallery with shadows.
| File | Description |
|---|---|
pnpm-lock.yaml |
Records geometry testing dependencies. |
packages/typegpu-geometry/vitest.config.mts |
Configures shader-aware unit tests. |
packages/typegpu-geometry/tsconfig.test.json |
Enables test type checking. |
packages/typegpu-geometry/tests/updates.test.ts |
Tests baking updates, bindings, and dispatch. |
packages/typegpu-geometry/tests/mesh.test.ts |
Tests primitives and geometry composition. |
packages/typegpu-geometry/tests/fixtures.ts |
Adds shared geometry and shader fixtures. |
packages/typegpu-geometry/tests/bake.test.ts |
Tests baking, buffer ownership, and pipeline injection. |
packages/typegpu-geometry/src/mesh/primitives.ts |
Implements five primitives and surface evaluators. |
packages/typegpu-geometry/src/mesh/parametric.ts |
Implements grid sampling and estimated normals. |
packages/typegpu-geometry/src/mesh/math.ts |
Adds coordinate-frame helpers. |
packages/typegpu-geometry/src/mesh/index.ts |
Exports the mesh API. |
packages/typegpu-geometry/src/mesh/geometry.ts |
Defines geometry contracts and vertex layouts. |
packages/typegpu-geometry/src/mesh/fill.ts |
Implements compute-based buffer filling. |
packages/typegpu-geometry/src/mesh/combinators.ts |
Implements transforms, mapping, attachment, and concatenation. |
packages/typegpu-geometry/src/mesh/bake.ts |
Implements baking and baked-mesh operations. |
packages/typegpu-geometry/src/index.ts |
Exposes the meshes namespace. |
packages/typegpu-geometry/package.json |
Adds test scripts and dependencies. |
apps/typegpu-docs/tests/individual-example-tests/mesh-primitives.test.ts |
Tests example shader resolution. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/spring.ts |
Defines an animated procedural spring. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/shading.ts |
Implements lighting and shadow sampling. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/meta.json |
Registers the example metadata. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/index.ts |
Sets up rendering, animation, and cleanup. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/index.html |
Provides the example canvas. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/geometry.ts |
Adds placement and color helpers. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/gallery.ts |
Arranges the primitive gallery. |
apps/typegpu-docs/src/examples/rendering/mesh-primitives/blob.ts |
Defines an animated parametric blob. |
Review effort: Balanced
There was a problem hiding this comment.
ℹ️ No critical issues — two consistency/robustness points inline.
Reviewed changes
Reviewed the full meshes namespace in @typegpu/geometry and the new mesh-primitives example at 043c0ab.
meshesgeometry model —Geometry/IndexedGeometry(schema +vertexAt/indexAt),Surfacedefault schema,isIndexed, WeakMap-cached vertex layouts.- Primitives & parametric —
plane/box/sphere/cylinder/torus, thesurfaceshelpers, and grid sampling with finite-difference normals. - Combinators —
transform(inverse-transpose normal matrix + winding reversal on reflection),map,attach,unindexed,concat. - Baking —
bake/bakeAsyncandbakeIndices/bakeIndicesAsync, compute-driven fills, buffer ownership anddestroysemantics. - Example & tests — animated shadowed gallery example; CPU geometry/winding tests, bake and update tests, and the example WGSL snapshot.
Verification: packages/typegpu-geometry tests (26 passed), the mesh-primitives example snapshot (1 passed), test:types, oxfmt --check, and oxlint --max-warnings=0 all pass locally.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the latest commits — one earlier thread (the
concatboundary) still stands; the rest of this delta is clean.
Reviewed changes
Reviewed the 7 commits pushed since the prior pullfrog review at 043c0ab (350d0ca6..0b0b53a).
- Build migrated to
tsdown— replacedunbuildwith atsdown.config.tsand updatedpackage.jsonexports/dependencies to match the sibling packages. beveljoin added — newlines/joins/bevel.ts, registered injoins, andmiterJoinLimitSlotis now exported.- Normal matrix hardened —
transformnow uses a sign-corrected cofactor matrix instead of the inverse transpose, so flattening transforms keep valid normals and collapsed normals stay zero. - Fill recording unified —
fill.tsgainedrecordFills, sobake/updateVerticesrecord vertex and index fills into a single compute pass and honour a caller-supplied encoder/pass without submitting. - Buffer offsets added —
bake/bakeIndicesacceptbaseVertex/firstIndexto pack several meshes into shared buffers; the bakedindexAtnow reads the baked index buffer (resolves the earlier stale-indexAtthread). sphereoptions renamed —segments/rings→radialSegments/heightSegments, matchingcylinder; callers and tests updated.- Tests — new
lines.test.ts, offset-baking cases inbake.test.ts, and a flattening-normals case inmesh.test.ts.
Verification at 0b0b53a: @typegpu/geometry tests (31 passed), the mesh-primitives example snapshot (1 passed), test:types, and the tsdown build all pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the re-reviewed commits — the earlier
concatboundary thread remains open, so this is not an approval.
Reviewed changes
Re-reviewed the 7 commits pushed after 043c0ab0 (through 0b0b53a1) that make up this synchronize event's delta.
- Build migrated to
tsdown—unbuildandbuild.config.tswere replaced by atsdown.config.tsusingunplugin-typegpu/rolldownandunbundle: true, matching@typegpu/sdfand@typegpu/sort, with the dependentpackage.jsonexports/mainand the lockfile updated. beveljoin added —lines/joins/bevel.tswas added and registered injoins, andmiterJoinLimitSlotis now re-exported.- Normal matrix hardened —
transformnow uses a sign-corrected cofactor matrix, so flattening transforms keep valid normals and reflected normals stay outward. - Fill recording unified —
fill.tsgainedRecordOptionsandrecordFills, sobakeandupdateVerticesrecord vertex and index fills into a single compute pass and honour a caller-supplied encoder or pass without submitting. - Buffer offsets added —
bake/bakeIndicesacceptbaseVertex/firstIndex, and the bakedindexAtreads the baked index buffer. sphereoptions renamed —segments/ringswere renamed toradialSegments/heightSegments, matchingcylinder.- Tests — added
lines.test.ts, plus offset-baking and flattening-normals cases.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the commits reviewed since the last pullfrog review — the earlier
concatboundary thread remains open, so this is not an approval.
Reviewed changes
Re-reviewed the 7 commits pushed after 043c0ab (through 0b0b53a1): the tsdown build migration, the bevel join, the hardened normal matrix, unified fill recording, buffer-offset baking, and the sphere option rename.
- Build migrated to
tsdown—build.config.tswas replaced bytsdown.config.ts(unplugin-typegpu/rolldown,unbundle: true, ESM), with the dependentpackage.jsonpublish exports/mainand dev dependencies updated to match@typegpu/sdf/@typegpu/sort. beveljoin added —lines/joins/bevel.tscuts the outside of a turn with a straight edge, andmiterJoinLimitSlotis now re-exported from the joins barrel.- Normal matrix hardened —
transformnow builds a sign-corrected cofactor matrix instead of the inverse transpose, so transforms that flatten or reflect a shape keep valid outward normals rather than collapsing or flipping them. - Fill recording unified —
fill.tsgainedRecordOptions/recordFills, sobakeandupdateVerticesrecord vertex and index fills into a single compute pass and honour a caller-supplied encoder or pass without submitting. - Buffer offsets added —
bake/bakeIndicesacceptbaseVertex/firstIndexso several meshes can pack into shared buffers, and the bakedindexAtnow reads the baked index buffer. sphereoptions renamed —segments/ringsbecameradialSegments/heightSegments, matchingcylinder; callers and tests were updated.- Tests — added
lines.test.ts(bevel geometry and slot configuration) plus offset-baking, single-pass recording, and flattening-normals cases.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No new issues in the follow-up commit — the earlier
concatboundary thread remains open, so this is not an approval.
Reviewed changes
Reviewed the single commit pushed after the prior pullfrog review (0b0b53a → 95e1ad5b).
- Example helpers widened —
paint/placein themesh-primitivesexample now taked.InferInput<d.Vec3f>(arrays, tuples, or vectors) and normalise tod.vec3finternally, so callers pass plain arrays andgallery.tsno longer importsd.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
aleksanderkatan
left a comment
There was a problem hiding this comment.
Enormous PR!
I leave mostly nits and questions
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the delta since the prior pullfrog review at 95e1ad5b — the single "address review" commit 4330f17.
- Mesh generics tightened —
ConstructibleSchema(Extract<d.AnyWgslData, () => unknown>) moved intogeometry.ts, exported, and applied in place ofd.AnyWgslDataacrossGeometry,IndexedGeometry,isIndexed,layoutOf,map,unindexed,concat, and thebake/bakeIndicesfamily. - Primitives reuse surface helpers —
cylinder's side andtorusnow callsurfaces.cylinder/surfaces.torus; verified algebraically identical to the inline math they replace, including thesurfaces.torus(u, v, 0, 1)unit normal.spherenow documents why it skips the pole triangles. - Brace convention restored — single-statement
if/awaitbodies infill.ts,bake.ts,primitives.ts, andcombinators.tsnow use block braces. - Tests added —
bakeIndicesanalogues (proceduralvertexAt, index-only injection, offset baking, encoder recording), anattachfield-collision test, and a topology guard inwindingAgreesWithNormals.
Verification at 4330f17: @typegpu/geometry tests (36 passed), the mesh-primitives example snapshot (1 passed), and pnpm --filter @typegpu/geometry test:types (both tsconfigs) all pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
4330f17 to
95f344f
Compare
|
|
||
| export interface Parametric { | ||
| at(this: void, u: number, v: number): d.v3f; | ||
| normalAt?(this: void, u: number, v: number): d.v3f; |
There was a problem hiding this comment.
It would be nice to have a JS Doc here explaining how the normals are inferred from the vertex positions if omitted.
| heightSegments?: number; | ||
| } | ||
|
|
||
| export function sphere({ |
There was a problem hiding this comment.
Do we want to be fully correct and name the full uvsphere topology, in case we'd like to add icospheres and the sort?
2f1e0be to
e692408
Compare
iwoplaza
left a comment
There was a problem hiding this comment.
Very pleasant to review! Left a few nits
| @@ -0,0 +1,8 @@ | |||
| export * from './bake.ts'; | |||
There was a problem hiding this comment.
I think I'd prefer to list out each export, so we can better control the public API surface, and not accidentally expose something that we want to share between files that wasn't meant to be shared.
| export type { ConstructibleSchema, Geometry, IndexedGeometry, Topology } from './geometry.ts'; | ||
| export { parametric } from './parametric.ts'; | ||
| export type { Parametric, ParametricOptions } from './parametric.ts'; | ||
| export * from './primitives.ts'; |
|
|
||
| export type UpdateOptions = RecordOptions & { | ||
| /** Bind groups for this call, applied over the ones given when baking */ | ||
| bindGroups?: readonly TgpuBindGroup[]; |
There was a problem hiding this comment.
| bindGroups?: readonly TgpuBindGroup[]; | |
| bindGroups?: readonly TgpuBindGroup[] | undefined; |
There was a problem hiding this comment.
Can you give an example where this matters? It adds some noise to our types, and we probably are really inconsistent with this
There was a problem hiding this comment.
exactOptionalPropertyTypes is on in tsconfig.base and the CLI templates, so without it uvSphere({ radius: opts.radius }) fails when opts.radius is number | undefined. typegpu core spells it the same way
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | ||
| vertices?: VertexBuffer<V>; | ||
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | ||
| indices?: IndexBuffer; | ||
| /** Writes the first vertex at this index of `vertices`. Indices stay relative to it. Default 0 */ | ||
| baseVertex?: number; | ||
| /** Writes the first index at this index of `indices`. Default 0 */ | ||
| firstIndex?: number; | ||
| /** Creates the fill pipelines from this configured root, for slots and accessors */ | ||
| with?: WithBinding; |
There was a problem hiding this comment.
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | |
| vertices?: VertexBuffer<V>; | |
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | |
| indices?: IndexBuffer; | |
| /** Writes the first vertex at this index of `vertices`. Indices stay relative to it. Default 0 */ | |
| baseVertex?: number; | |
| /** Writes the first index at this index of `indices`. Default 0 */ | |
| firstIndex?: number; | |
| /** Creates the fill pipelines from this configured root, for slots and accessors */ | |
| with?: WithBinding; | |
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | |
| vertices?: VertexBuffer<V> | undefined; | |
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | |
| indices?: IndexBuffer | undefined; | |
| /** Writes the first vertex at this index of `vertices`. Indices stay relative to it. Default 0 */ | |
| baseVertex?: number | undefined; | |
| /** Writes the first index at this index of `indices`. Default 0 */ | |
| firstIndex?: number | undefined; | |
| /** Creates the fill pipelines from this configured root, for slots and accessors */ | |
| with?: WithBinding | undefined; |
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | ||
| indices?: IndexBuffer; | ||
| /** Writes the first index at this index of `indices`. Default 0 */ | ||
| firstIndex?: number; | ||
| /** Creates the fill pipeline from this configured root, for slots and accessors */ | ||
| with?: WithBinding; |
There was a problem hiding this comment.
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | |
| indices?: IndexBuffer; | |
| /** Writes the first index at this index of `indices`. Default 0 */ | |
| firstIndex?: number; | |
| /** Creates the fill pipeline from this configured root, for slots and accessors */ | |
| with?: WithBinding; | |
| /** Writes into this buffer instead of creating one. `destroy()` leaves it alive */ | |
| indices?: IndexBuffer | undefined; | |
| /** Writes the first index at this index of `indices`. Default 0 */ | |
| firstIndex?: number | undefined; | |
| /** Creates the fill pipeline from this configured root, for slots and accessors */ | |
| with?: WithBinding | undefined; |
| export interface SphereOptions { | ||
| radius?: number; | ||
| /** Segments around the vertical axis, as in `cylinder` */ | ||
| radialSegments?: number; | ||
| /** Segments from pole to pole, at least 2 */ | ||
| heightSegments?: number; | ||
| } |
There was a problem hiding this comment.
| export interface SphereOptions { | |
| radius?: number; | |
| /** Segments around the vertical axis, as in `cylinder` */ | |
| radialSegments?: number; | |
| /** Segments from pole to pole, at least 2 */ | |
| heightSegments?: number; | |
| } | |
| export interface SphereOptions { | |
| radius?: number | undefined; | |
| /** Segments around the vertical axis, as in `cylinder` */ | |
| radialSegments?: number | undefined; | |
| /** Segments from pole to pole, at least 2 */ | |
| heightSegments?: number | undefined; | |
| } |
| width?: number; | ||
| depth?: number; | ||
| widthSegments?: number; | ||
| depthSegments?: number; |
There was a problem hiding this comment.
| width?: number; | |
| depth?: number; | |
| widthSegments?: number; | |
| depthSegments?: number; | |
| width?: number | undefined; | |
| depth?: number | undefined; | |
| widthSegments?: number | undefined; | |
| depthSegments?: number | undefined; |
| width?: number; | ||
| height?: number; | ||
| depth?: number; | ||
| widthSegments?: number; | ||
| heightSegments?: number; | ||
| depthSegments?: number; |
There was a problem hiding this comment.
| width?: number; | |
| height?: number; | |
| depth?: number; | |
| widthSegments?: number; | |
| heightSegments?: number; | |
| depthSegments?: number; | |
| width?: number | undefined; | |
| height?: number | undefined; | |
| depth?: number | undefined; | |
| widthSegments?: number | undefined; | |
| heightSegments?: number | undefined; | |
| depthSegments?: number | undefined; |
| radius?: number; | ||
| height?: number; | ||
| radialSegments?: number; | ||
| heightSegments?: number; | ||
| caps?: boolean; |
There was a problem hiding this comment.
| radius?: number; | |
| height?: number; | |
| radialSegments?: number; | |
| heightSegments?: number; | |
| caps?: boolean; | |
| radius?: number | undefined; | |
| height?: number | undefined; | |
| radialSegments?: number | undefined; | |
| heightSegments?: number | undefined; | |
| caps?: boolean | undefined; |
| radius?: number; | ||
| tube?: number; | ||
| ringSegments?: number; | ||
| tubeSegments?: number; |
There was a problem hiding this comment.
| radius?: number; | |
| tube?: number; | |
| ringSegments?: number; | |
| tubeSegments?: number; | |
| radius?: number | undefined; | |
| tube?: number | undefined; | |
| ringSegments?: number | undefined; | |
| tubeSegments?: number | undefined; |
e692408 to
c467d71
Compare
There was a problem hiding this comment.
✅ No new issues found.
( ◦°^°◦) ✅
Approach: sound — fill pipelines are configured per bake through root.pipe, matching the core pipeline configuration API.
Reviewed changes
Reviewed the five commits pushed since the last reviewed tip (e692408).
sphererenamed touvSphere—SphereOptionsbecameUvSphereOptions, and the example and tests follow, leaving room for anicospherelater.- Fill pipelines configured by function —
bake/bakeIndicesnow takeconfig?: (cfg: Configurable) => Configurableand apply it withroot.pipe, replacing the earlierwith?: WithBinding; the slot/accessor test was updated. - Explicit mesh exports —
mesh/index.tslists each public export instead ofexport *, keeping internal helpers private. exactOptionalPropertyTypesspelling — optional properties now include| undefined, andRecordOptionsusesundefinedrather thanneverfor its mutually exclusive fields.- Parametric normal docs —
Parametric.normalAtdocuments the finite-difference fallback and its boundary handling.
Verification at c467d71: @typegpu/geometry tests (36 passed), the mesh-primitives example snapshot (1 passed), and test:types both pass.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏


Adds
meshesto@typegpu/geometry. Geometry is a vertex schema +vertexAt(and optionallyindexAt), so primitives and transformations compose before anything needs a bufferInteractive cloth example and docs will follow in separate PRs