Repository navigation
Conversation
e69e63f to
bdc9342
Compare
|
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.54, 1.05, 2.28, 3.07, 3.89, 7.04, 12.63, 16.46]
line [0.42, 0.86, 1.95, 3.21, 3.97, 6.37, 13.93, 15.11]
line [0.41, 0.85, 1.86, 3.42, 3.53, 6.33, 12.21, 12.93]
---
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.13, 0.23, 0.38, 0.43, 0.61, 0.61, 0.75, 0.82]
line [0.12, 0.22, 0.30, 0.36, 0.51, 0.50, 0.65, 0.72]
line [0.09, 0.21, 0.26, 0.35, 0.50, 0.53, 0.61, 0.69]
---
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.67, 1.36, 2.03, 3.61, 6.98, 15.09, 30.69, 66.59]
line [0.63, 1.41, 1.92, 3.59, 7.03, 15.35, 30.64, 63.00]
line [0.61, 1.12, 2.00, 3.65, 6.04, 13.35, 29.89, 57.89]
|
bdc9342 to
931f6a3
Compare
931f6a3 to
24626f1
Compare
211795a to
86df052
Compare
86df052 to
9922b8c
Compare
9922b8c to
03f7d84
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run reviewed the full @typegpu/geometry docs PR against its stacked base feat/geometry-patches, including the interactive preview runtime and its regression test.
- Docs guide (
typegpu-geometry.mdx) — 558-line guide covering primitives, parametric surfaces, triangular patches, custom geometry, combinators, baking/updating and lines/joins/caps; prose claims spot-checked againstpackages/typegpu-geometry/src. - Preview viewer (
viewer.ts,renderer.ts,shaders.ts,demos.ts) — shared-root WebGPU viewer with visibility/pause gating, per-schema pipeline caching, deferred resource cleanup and five demo scenes. - React shell (
MeshPreview.tsx) — param/shading/pause controls plus loading and error states. - Docs nav (
astro.config.mjs) —DEV-gated@typegpu/geometrysidebar entry with adevbadge. - Regression test (
mesh-preview.test.ts) — pins that a bake in flight at disposal submits before its uniforms are destroyed.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
🟡 Changes recommended
The line-rendering example leaves its control points uninitialized, so it renders no visible line.
1 open issue
What changed in this PR
Adds an @typegpu/geometry guide with interactive mesh previews, extending the documentation to cover the triangular patches introduced in #3014.
Changes:
- Documents primitives, composition, custom attributes, mesh evaluation and updates, and line rendering.
- Adds configurable previews with smooth, flat, and wireframe shading.
- Adds a disposal regression test and development-only sidebar navigation.
| File | Description |
|---|---|
apps/typegpu-docs/tests/individual-example-tests/mesh-preview.test.ts |
Tests disposal while asynchronous baking is pending. |
apps/typegpu-docs/src/content/docs/ecosystem/typegpu-geometry.mdx |
Adds the geometry guide and embedded previews. |
apps/typegpu-docs/src/components/geometry/viewer.ts |
Manages preview state, animation, baking, and cleanup. |
apps/typegpu-docs/src/components/geometry/shaders.ts |
Defines lighting and shading modes. |
apps/typegpu-docs/src/components/geometry/renderer.ts |
Handles render pipelines, camera updates, and depth textures. |
apps/typegpu-docs/src/components/geometry/MeshPreview.tsx |
Adds preview controls and visibility handling. |
apps/typegpu-docs/src/components/geometry/demos.ts |
Defines configurable geometry demonstrations. |
apps/typegpu-docs/astro.config.mjs |
Adds the development-only geometry sidebar entry. |
Review effort: Balanced
03f7d84 to
9b0a57e
Compare
286afb9 to
ffef34c
Compare
db47c86 to
876be9b
Compare
aleksanderkatan
left a comment
There was a problem hiding this comment.
Nice and extensive docs with really cool visuals! I like the wireframe view
I leave some small suggestions, and potential tweaks to the geomery API.
I only skimmed the geometry component files.
|
|
||
| ## Available utilities | ||
|
|
||
| Line utilities are exported from the package root: | ||
|
|
||
| | Group | Exports | | ||
| | --- | --- | | ||
| | Drawing | `polylineVariableWidth`, `lineVariableWidth`, `LineControlPoint`, `LineSegmentOutput` | | ||
| | Indices | `lineSegmentIndices`, `lineSegmentWireframeIndices`, `lineSegmentLeftIndices` | | ||
| | Joins and caps | `joins`, `caps`, `joinSlot`, `startCapSlot`, `endCapSlot`, `miterJoinLimitSlot`, `arrowCapParamsSlot`, `JoinInput` | | ||
|
|
||
| Mesh utilities live under the `meshes` namespace: | ||
|
|
||
| | Group | Exports | | ||
| | --- | --- | | ||
| | Primitives | `sphere`, `plane`, `box`, `cylinder`, `torus`, `icosphere`, `capsule`, `roundedBox` | | ||
| | Surfaces | `parametric`, `surfaces`, `patches.icosphere`, `patches.capsule`, `patches.roundedBox` | | ||
| | Tessellation | `tessellate`, `triangleBarycentrics`, `triangleIndexAt`, `triangleIndices`, `triangleVertexCount`, `triangleIndexCount` | | ||
| | Spherical interpolation | `patches.linear`, `patches.uniformArea` | | ||
| | Combinators | `transform`, `map`, `attach`, `concat`, `unindexed` | | ||
| | Buffers | `bake`, `bakeAsync`, `bakeIndices`, `bakeIndicesAsync`, `UpdateOptions`, `RecordOptions` | | ||
| | Schema and type guard | `Surface`, `isIndexed` | |
There was a problem hiding this comment.
nit: I don't think this table is too useful, and I think it will become outdated quickly.
I may be good to include this in a geometry skill if we ever make one
| ## Available utilities | |
| Line utilities are exported from the package root: | |
| | Group | Exports | | |
| | --- | --- | | |
| | Drawing | `polylineVariableWidth`, `lineVariableWidth`, `LineControlPoint`, `LineSegmentOutput` | | |
| | Indices | `lineSegmentIndices`, `lineSegmentWireframeIndices`, `lineSegmentLeftIndices` | | |
| | Joins and caps | `joins`, `caps`, `joinSlot`, `startCapSlot`, `endCapSlot`, `miterJoinLimitSlot`, `arrowCapParamsSlot`, `JoinInput` | | |
| Mesh utilities live under the `meshes` namespace: | |
| | Group | Exports | | |
| | --- | --- | | |
| | Primitives | `sphere`, `plane`, `box`, `cylinder`, `torus`, `icosphere`, `capsule`, `roundedBox` | | |
| | Surfaces | `parametric`, `surfaces`, `patches.icosphere`, `patches.capsule`, `patches.roundedBox` | | |
| | Tessellation | `tessellate`, `triangleBarycentrics`, `triangleIndexAt`, `triangleIndices`, `triangleVertexCount`, `triangleIndexCount` | | |
| | Spherical interpolation | `patches.linear`, `patches.uniformArea` | | |
| | Combinators | `transform`, `map`, `attach`, `concat`, `unindexed` | | |
| | Buffers | `bake`, `bakeAsync`, `bakeIndices`, `bakeIndicesAsync`, `UpdateOptions`, `RecordOptions` | | |
| | Schema and type guard | `Surface`, `isIndexed` | |
|
|
||
| Every option has a default, so `meshes.box()` is a unit cube and `meshes.torus()` a ring that fits the same space. | ||
| Options ending in `Segments` count the subdivisions along one direction: `radialSegments` around the vertical axis of a sphere or cylinder, `heightSegments` from top to bottom. The `segments` option of `icosphere`, `capsule` and `roundedBox` subdivides each edge of their [triangular patches](#triangular-patches). | ||
| Switch the previews to **Wireframe** to inspect their triangles. **Pause animation** freezes both rotation and deformation. |
There was a problem hiding this comment.
nit: I don't see any deformation in this preview, can we move this note to previews below?
| <MeshPreview client:visible demo="primitives" /> | ||
|
|
||
| Primitives use the `Surface` schema: `position: d.vec3f`, `normal: d.vec3f` and `uv: d.vec2f`. Normals point outwards. UVs follow each surface's parametrization. | ||
| `capsule.height` is the length of its straight section, excluding the caps. |
There was a problem hiding this comment.
nit: This sentence seems misplaced to me
I think it belongs in JSDoc
| `capsule.height` is the length of its straight section, excluding the caps. |
|
|
||
| <MeshPreview client:visible demo="primitives" /> | ||
|
|
||
| Primitives use the `Surface` schema: `position: d.vec3f`, `normal: d.vec3f` and `uv: d.vec2f`. Normals point outwards. UVs follow each surface's parametrization. |
There was a problem hiding this comment.
good idea, leaving it for a follow-up
| const ball = meshes.sphere(); | ||
| const pole = ball.vertexAt(0); | ||
|
|
||
| console.log(pole.position, pole.normal, pole.uv); |
There was a problem hiding this comment.
| console.log(pole.position, pole.normal, pole.uv); | |
| console.log(`${pole.position} ${pole.normal} ${pole.uv}`); | |
| // vec3f(0, 0.5, 0) vec3f(0, 1, 0) vec2f(0, 0) |
| Vertex updates leave indices unchanged. They reuse the pipeline and bindings prepared by `bake`, including on the first update. | ||
| Counts and schemas are fixed at bake time. To change the number of subdivisions, create and bake a new geometry. | ||
|
|
||
| Without options, an update submits its own compute work. Use `{ encoder }` to record it as one compute pass alongside draws before submitting, or `{ pass }` for an open compute pass. Pass one or the other, not both. Updates leave the encoder or pass open. `bake` and `bakeIndices` accept these options for the initial fill too, as `@typegpu/sort` does for its `run()`. |
There was a problem hiding this comment.
sort is not yet published, we should make sure to wait with this doc until it is published, or publish sort soon after
| Vertex updates leave indices unchanged. They reuse the pipeline and bindings prepared by `bake`, including on the first update. | ||
| Counts and schemas are fixed at bake time. To change the number of subdivisions, create and bake a new geometry. | ||
|
|
||
| Without options, an update submits its own compute work. Use `{ encoder }` to record it as one compute pass alongside draws before submitting, or `{ pass }` for an open compute pass. Pass one or the other, not both. Updates leave the encoder or pass open. `bake` and `bakeIndices` accept these options for the initial fill too, as `@typegpu/sort` does for its `run()`. |
There was a problem hiding this comment.
nit: types already forbid that
| Without options, an update submits its own compute work. Use `{ encoder }` to record it as one compute pass alongside draws before submitting, or `{ pass }` for an open compute pass. Pass one or the other, not both. Updates leave the encoder or pass open. `bake` and `bakeIndices` accept these options for the initial fill too, as `@typegpu/sort` does for its `run()`. | |
| Without options, an update submits its own compute work. Use `{ encoder }` to record it as one compute pass alongside draws before submitting, or `{ pass }` for an open compute pass. Updates leave the encoder or pass open. `bake` and `bakeIndices` accept these options for the initial fill too, as `@typegpu/sort` does for its `run()`. |
|
|
||
| If the source accesses resources through a [bind group layout](/TypeGPU/apis/bind-groups/), pass the bind groups to `bake` through `{ bindGroups }`. | ||
| Updates keep using them, and `{ bindGroups }` on an update swaps them for that one call. | ||
| For [slots](/TypeGPU/apis/slots/) and [accessors](/TypeGPU/apis/accessors/), pass a configured pipeline builder, for example `{ with: root.with(heightAccess, heightUniform) }`. |
There was a problem hiding this comment.
Maybe we could use config?: (cfg: Configurable) => Configurable instead of with in this API?
| setPaused(window.matchMedia('(prefers-reduced-motion: reduce)').matches); | ||
|
|
||
| createMeshViewer(canvas, (value) => { | ||
| if (!disposed) setState(value); |
There was a problem hiding this comment.
I keep seeing braceless ifs across different PRs, do we really want to keep the convention of no braceless ifs?
If so, we can enforce it easily via one line in oxlint config. We'll also be able to add missing blocks to all ifs via nr fix.
Otherwise, I think that we could clean up a lot of existing code.
There was a problem hiding this comment.
yes, braced these, a repo-wide curly rule fits better in its own PR
| A miter longer than `miterJoinLimitSlot` times the radius, 2 by default, bends back towards a bevel. `arrowCapParamsSlot` sets the arrow's length, width and slant, relative to the radius. | ||
| A custom join or cap is a `'use gpu'` function with the same signature, `(join: JoinInput, joinVertexIndex: number, maxJoinCount: number) => d.v2f`. For index 0 it returns the segment's own corner, `join.v`. Indices 1 to `maxJoinCount` fan out from that corner around the control point `join.C`. | ||
|
|
||
| The [Lines Combinations](/TypeGPU/examples#example=geometry--lines-combinations) example shows every join and cap. |
There was a problem hiding this comment.
Can we link to a dev example in docs?
876be9b to
e56a228
Compare
e56a228 to
22b4ea4
Compare
There was a problem hiding this comment.
✅ No new issues found.
Approach: sound — the new commits are review-driven docs and preview polish, and the only behavior change is an integer twist step that removes the UV seam.
Reviewed changes
This run re-reviewed the delta since the prior pullfrog review: the author's response to the human review, synced with the base package's uvSphere rename and new config bake option.
uvSphererename — the guide and previews now callmeshes.uvSphere, matching the base package;meshes.surfaces.sphereis still a valid export and remains correctly referenced.configbake option — the slot/accessor guidance now uses{ config: (cfg) => cfg.with(...) }, whichBakeOptionsprovides in the base package.- Seam-safe twist slider — the stripes preview steps twist by whole turns, so the torus UV seam stays continuous.
- Review-driven prose cleanup — the utilities tables, the
@typegpu/sortcomparison, the "pass one or the other" note and the lines-combinations link are gone; the pause note now sits under the deformation preview; patch primitives are described as examples rather than an exhaustive list. - Brace cleanup — every single-statement
ifin the preview components is braced;oxlint --type-awareandoxfmt --checkpass on the changed files.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏



Adds a guide for
@typegpu/geometry, covering mesh creation, composition and the different ways to evaluate and update geometryStacks on #3014