glTF TRIANGLE_FAN: Preserve the Shared First Index When Reviewing a Drone Model
Expand a constructed decoded glTF triangle fan using the normative ordered triples, retain repeated-index findings, and keep topology assembly separate from surface validation.

Identify the topology mode before grouping a model index list
An index sequence does not explain its triangle assembly rule by itself. A glTF primitive may use independent triangles, a strip, or a fan, and those modes connect the same positions differently. In a drone-model handoff, a diagnostic that groups every three indices independently can therefore produce an incorrect face summary before it examines any geometry. Preserve the received asset and identify the selected primitive mode, decoded index sequence, component type, and position count before interpreting an unexpected topology report.
This tutorial expands five invented decoded indices under TRIANGLE_FAN. It does not open a glTF file, decode an accessor, alter a mesh, measure a surveyed surface, or establish that NiVO software exports this format. The catalogue photograph provides separate product context. The function reports ordered topology triples and repeated-index findings while preserving the input sequence. Its output is an assembly trace, not proof that the resulting surface has correct coordinates, orientation after transforms, complete coverage, or acceptable geometry for a project.
Follow the fan equation and the explicit mode value
The glTF specification assigns mode six to TRIANGLE_FAN. Its fan equation assembles each triangle from the next outer pair and the first supplied vertex: positions i plus one, i plus two, and zero. This tutorial follows that documented order directly. The specification also requires at least three indices for a fan. An omitted mode does not mean fan; the default mode is independent triangles. The function therefore requires an explicit mode-six argument instead of guessing the topology from the number of indices.
For the constructed sequence zero, one, two, three, four, the ordered triples are one-two-zero, two-three-zero, and three-four-zero. Each triangle includes the original first index, while the outer pair advances. Five supplied indices consequently produce three triples. This differs from independent groups of three and from a strip that advances an overlapping window with its own ordering rule. A count alone cannot expose all such mistakes, so retain the actual ordered triples beside the reported number of assembled triangles.

Product context only; this photograph does not depict the constructed examples in this article.
Expand a bounded decoded fan without editing its sequence
Run the following Python function locally with an already decoded list or tuple, a supplied vertex count, an explicit mode, and the index accessor component type. The function accepts three through sixty-four indices and limits the vertex count for the exercise. Those upper limits are teaching choices. It checks the supported unsigned component types, excludes their forbidden maximum values, and requires every index to be below the supplied vertex count. Booleans and non-integer inputs are rejected rather than silently converted.
The result preserves the raw sequence, lists the assembled triples, and identifies triples that reuse an index within themselves. Those repeated references are retained for review rather than deleted from the input. Removing an element can change the assembly of subsequent fan triangles. The specification recommends avoiding degenerate geometry, but this function does not repair it or declare an asset valid. It lacks vertex positions, so it cannot detect every zero-area triangle or determine whether distinct indices refer to coincident points.
def expand_triangle_fan(indices, vertex_count, mode, component_type):
if type(mode) is not int or mode != 6:
raise ValueError("This reader requires explicit TRIANGLE_FAN mode 6")
if type(vertex_count) is not int or not 1 <= vertex_count <= 1000000:
raise ValueError("Expected a positive teaching vertex count")
maxima = {5121: 255, 5123: 65535, 5125: 4294967295}
if type(component_type) is not int or component_type not in maxima:
raise ValueError("Expected an unsigned glTF index component type")
if not isinstance(indices, (list, tuple)) or not 3 <= len(indices) <= 64:
raise ValueError("Expected 3 through 64 decoded indices")
maximum = maxima[component_type]
if any(type(x) is not int or not 0 <= x < maximum or x >= vertex_count
for x in indices):
raise ValueError("Index outside vertex bounds or component profile")
raw = tuple(indices)
triangles = [(raw[i + 1], raw[i + 2], raw[0]) for i in range(len(raw) - 2)]
repeated = [i for i, tri in enumerate(triangles) if len(set(tri)) < 3]
return {"raw_indices": raw, "triangles": triangles,
"repeated_index_triangles": repeated}
# Constructed decoded indices; no actual model is opened or repaired.
print(expand_triangle_fan([0, 1, 2, 3, 4], 5, 6, 5121))Test the anchor, outer-pair order, and input boundaries
Test the minimum three-index fan and the displayed five-index example. Then use a nonzero first index with distinct remaining values to confirm that the anchor is the first supplied value rather than the numeric value zero. Every output triple should retain that anchor in the documented position, and the outer pair should follow adjacent input positions. Check the expected number of triples for several lengths, but compare their full ordered contents as well. A wrong assembly can have the correct count.
Test repeated references near the beginning and farther along the sequence. Preserve each resulting triple and its finding position so a reviewer can see where the repeated index enters the assembly. Include an index equal to the vertex count, a negative value, an unsupported component type, and a maximum component value. The latter is not an ordinary permitted index in glTF. Test a larger component type separately: a number forbidden as the maximum of one storage type can have a different status under another type and vertex bound.
Keep topology findings separate from coordinates and rendering
These triples identify references, not measured vertices or complete faces in world space. The receiving workflow still needs correct accessor decoding, attribute counts, positions, transforms, and any relevant extensions. This function takes those decoded references as input and does not verify their origin. A correctly assembled fan can still refer to unsuitable coordinates or an incomplete delivery. Conversely, a rendering discrepancy can arise after topology assembly rather than indicating that the source index sequence changed.
Winding and visibility require their own context. The order of a triangle is meaningful, but node transforms and material behavior can affect the displayed result. This tutorial neither applies transforms nor evaluates culling, normals, or materials. It also does not infer a surveyed area from the number of triples. Use a complete glTF-aware inspection alongside the narrow assembly trace and preserve the receiving tool version, selected node and primitive, and relevant processing assumptions before deciding whether a model needs an authorized change.
Keep the original primitive boundary intact when reviewing several sequences. The first index is shared only within the particular fan being assembled; concatenating separate primitives and using one anchor would create different topology. Likewise, a non-indexed primitive needs an appropriate implicit sequence before a decoded-index helper can be applied. The example does not discover those sequences or merge draw calls. Record each primitive independently so that a summary does not quietly introduce connections between unrelated parts of a model.
Deliver the ordered assembly trace with unresolved geometry checks
For an actual handoff, retain the unchanged asset identity, mesh and primitive location, explicit or default mode interpretation, index accessor metadata, decoded sequence, vertex count, reader version, ordered triples, and repeated-reference findings. Include one independently checked nonzero-anchor example. Keep any full geometry validation, coordinate or transform checks, and rendering observations as separately identified evidence. If repair is required, preserve the original and document the authorized operation instead of treating index expansion as a safe automatic cleanup procedure.
In a NiVO-related model review, this method explains how five supplied references produce three fan triangles that all retain the first reference. It makes no claim about actual customer meshes, mapped surfaces, surveyed area, product export capability, or project acceptance. The useful result is a reproducible topology interpretation with the original sequence and unresolved geometry questions still available. Continue the independent checks required by the real task before using a triangle summary to justify a delivery or a change to it.



