Skip to content

Mesh Draw Range

App: apps/mesh_draw_range/

Uses setDrawRange and clearDrawRange to reveal a grid of triangles over time: a sine wave drives how many vertices are “visible,” so triangles appear progressively (then hide and repeat).

Terminal window
% ./plume3d mesh_draw_range

or

Terminal window
% ./../plume3d .
  • Builds a 5×5 grid of small triangles (each cell = 3 vertices), draw mode "triangles".
  • In update: ratio = (Math.sin(_time) + 1) / 2, then visibleCount = floor(ratio * totalVertices) aligned to a multiple of 3.
  • If visibleCount > 0: _mesh.setDrawRange(0, visibleCount); else _mesh.clearDrawRange().
  • GraphicsloadShader, newMesh, drawMesh.
  • MeshgetVertexCount, setDrawRange, clearDrawRange.
  • Mathsin, floor.