Skip to content

docs: improve TriMesh documentation with examples#364

Open
kbo4sho wants to merge 1 commit intodimforge:masterfrom
kbo4sho:docs/trimesh-examples
Open

docs: improve TriMesh documentation with examples#364
kbo4sho wants to merge 1 commit intodimforge:masterfrom
kbo4sho:docs/trimesh-examples

Conversation

@kbo4sho
Copy link

@kbo4sho kbo4sho commented Feb 27, 2026

Summary

Improves the JSDoc documentation for ColliderDesc.trimesh() with:

  • Clear explanation of how the flat vertices array maps to vertex positions ([x1, y1, z1, x2, y2, z2, ...])
  • Explanation of how the indices array defines triangles by referencing vertex indices
  • Note about compatibility with Three.js BufferGeometry layout (same arrays can be shared)
  • Two practical @example blocks: single triangle floor and a quad with shared vertices
  • Documents the flags parameter

Motivation

As noted in #272, the current documentation for trimesh() is minimal and the vertex/index relationship is not intuitive — leading users to create incorrect index arrays (e.g. Uint32Array(9) filled with zeros instead of vertex references). The issue author figured out the correct usage and suggested adding examples to prevent others from hitting the same problem.

Closes #272

Add detailed JSDoc to ColliderDesc.trimesh() explaining:
- How the flat vertices array maps to vertex positions
- How the indices array defines triangles by referencing vertices
- Compatibility with Three.js BufferGeometry layout
- Two practical examples (single triangle and quad with shared vertices)

Closes dimforge#272
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.

TriMesh should have better documentation. Example included.

1 participant