Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commite8beb5604c

README.md

geometry.triangulate

Cut every polygon into triangles: a primitive of n vertices becomes the n - 2 triangles of a fan about its first vertex, and a triangle stays as it is. Points, vertex attributes and primitive attributes carry to the result; a primitive's attributes repeat on each triangle it became, and a primitive of fewer than three vertices makes none. The result is allocated for as many triangles as the vertices can make and carries the number of them as its live counts on the device, which nothing reads back; a CPU reader drains it (Geometry.drain).

Inputs

  • geometry (Geometry). What is triangulated. Positions, attributes and material all reach the result.
  • diagonal (String, default "first", one of "first", "second"). Which diagonal cuts a quad. "first" runs from its first corner to its third, the fan about the first vertex: (0, 1, 2) and (0, 2, 3). "second" runs from its second corner to its fourth: (0, 1, 3) and (1, 2, 3), the cut of a band of quads stitched ring to ring. A polygon of any other size is a fan about its first vertex either way.

Outputs

  • geometry (Geometry). The triangles.
local tris = g.geometry.triangulate({ geometry = g.mesh.grid({ size = { x = 2, z = 2 }, cells = { x = 2, z = 2 } }) })