User Rating 0.0 ā˜…ā˜…ā˜…ā˜…ā˜…
Total Usage 0 times
Is this tool helpful?

Your feedback helps us improve.

ā˜… ā˜… ā˜… ā˜… ā˜…

About

Raw geometry data from GPU buffers, OBJ parsers, or procedural generators often arrives as a flat array of floating-point numbers. Each consecutive triplet represents one vertex component (x, y, z), and each consecutive group of three vertices defines one triangle face. This flat layout duplicates shared vertices at every face boundary, inflating memory and preventing adjacency queries. The reindex operation reconstructs an indexed mesh: a deduplicated positions array and a cells array of index triples. Without deduplication, the cell count equals N9 where N is the flat array length, and every vertex gets a unique index.

This tool parses your flat vertex data, validates divisibility constraints, and outputs a simplicial-complex-style indexed mesh compatible with modules like simplicial-complex and unindex-mesh. Enable vertex deduplication to merge coincident points within a configurable epsilon tolerance (default 1eāˆ’6). The tool approximates deduplication using spatial hashing. Note: deduplication forces hard edges to become smooth. If you need hard edges, leave deduplication off and use the raw indexed output with unindex-mesh downstream.

mesh reindex flat array to mesh simplicial complex indexed mesh vertex array 3D mesh converter webgl mesh triangle mesh

Formulas

The reindex algorithm operates in two phases. Phase 1 groups the flat array into positions and cells without deduplication. Phase 2 (optional) merges coincident vertices.

Given flat array A of length N, with stride s = 3 and face size f = 3:

Vertex count: V = Ns

Face count: F = Vf

Constraint: N mod (s Ɨ f) = 0

Position i: Pi = [A[i ā‹… s], A[i ā‹… s + 1], A[i ā‹… s + 2]]

Cell j: Cj = [j ā‹… f, j ā‹… f + 1, j ā‹… f + 2]

Deduplication: Two vertices Pa and Pb are merged when:

√(xa āˆ’ xb)2 + (ya āˆ’ yb)2 + (za āˆ’ zb)2 < ε

Where A is the input flat array, N is its length, s is the component stride (2 for 2D, 3 for 3D), f is the face size (3 for triangles), Pi is the i-th position vector, Cj is the j-th cell (triangle), and ε is the merge tolerance.

Reference Data

TermDefinitionTypical Value / Format
Flat Vertex ArraySequential x, y, z floats for every vertex of every face[xā‚€,yā‚€,zā‚€, x₁,y₁,z₁, …]
StrideNumber of components per vertex3 (XYZ) or 2 (XY)
Face SizeVertices per face (triangles)3
Positions ArrayDeduplicated or raw list of [x, y, z] arrays[[0,0,0],[1,0,0],…]
Cells ArrayIndex triples referencing positions[[0,1,2],[3,4,5],…]
Simplicial ComplexTopological mesh representation: vertices + index arraysUsed by simplicial-complex npm module
Epsilon (ε)Distance threshold for merging coincident vertices1eāˆ’6
Winding OrderVertex ordering defining face normal directionCCW (counter-clockwise) is standard
Vertex Count (flat)N3 where N = array lengthMust be integer
Face CountN9 for 3D trianglesMust be integer
Index BufferGPU-side representation of cellsUint16 or Uint32
Hard EdgeEdge where adjacent faces do NOT share vertex indicesPreserved without dedup
Smooth EdgeEdge where adjacent faces share vertex indicesCreated by dedup
Spatial HashGrid-based lookup for nearby verticesCell size = ε
Memory SavingRatio of deduplicated vs flat vertex countCube: 8 vs 36 vertices (78% reduction)
OBJ FormatText-based 3D format using indexed facesv 0 0 0 + f 1 2 3
STL FormatFlat triangle format (no indexing)Typical input source for this tool
glTF AccessorTyped array view into binary bufferUses indexed meshes natively

Frequently Asked Questions

For 3D triangulated meshes, the array length must satisfy N mod (s Ɨ f) &equals; 0. With stride 3 and face size 3, that means divisible by 9. If you switch to 2D mode (stride 2), divisibility by 6 is required. The tool will reject invalid input and report the remainder so you can identify truncated or corrupted data.
Without deduplication, every triangle owns its own vertices, producing hard edges everywhere (flat shading). Enabling deduplication merges coincident vertices so adjacent triangles share indices. Downstream renderers interpolate normals across shared vertices, producing smooth shading. If you need a mix of hard and smooth edges, you must selectively split vertices at crease angles. This tool does not perform crease-angle analysis. It is all-or-nothing.
The default ε &equals; 1eāˆ’6 works for meshes authored in meters or normalized coordinates. If your geometry uses millimeter units with values in the thousands, floating-point noise may exceed 1eāˆ’6. Try 1eāˆ’4 or 1eāˆ’3. Setting epsilon too high will collapse distinct vertices and destroy geometry. Always inspect the 3D preview after deduplication.
The tool supports 2D mode (stride 2), which reads pairs of floats as x, y coordinates. Quad faces are not supported. Tessellate quads into triangles before input. For a quad with vertices A, B, C, D, input them as two triangles: A, B, C, A, C, D.
The tool processes arrays up to approximately 1,000,000 floats (roughly 37,000 triangles) without noticeable lag. Beyond that, parsing and deduplication may take several seconds. The 3D preview uses Canvas 2D wireframe rendering, which slows down above 50,000 edges. For very large meshes, disable the preview and use the JSON or OBJ export directly.
The tool outputs JSON with positions and cells arrays (simplicial-complex format). It also provides an OBJ export with v lines for positions and f lines for faces (1-indexed). Both can be copied to clipboard or downloaded as files.