BabylonJS/Babylon.js · error

Triangle strip/fan fill mode is not implemented

Error message

Triangle strip/fan fill mode is not implemented

What it means

glTF only supports triangle lists (index order CCW). When a Babylon mesh uses TriangleStrip or TriangleFan fill mode with clockwise (back-facing) side orientation, the exporter would need to flip the triangle winding, but flipping strip/fan index sequences is not implemented, so it throws instead of producing wrong geometry.

Source

Thrown at packages/dev/serializers/src/glTF/2.0/glTFExporter.ts:1370

        indices: Nullable<IndicesArray>,
        is32Bits: boolean,
        start: number,
        count: number,
        offset: number,
        fillMode: number,
        sideOrientation: number,
        state: ExporterState,
        primitive: IMeshPrimitive
    ): void {
        let indicesToExport = null;

        primitive.mode = GetPrimitiveMode(fillMode);

        // Flip indices if triangle winding order is not CCW, as glTF is always CCW.
        const flip = sideOrientation !== Material.CounterClockWiseSideOrientation && IsTriangleFillMode(fillMode);
        if (flip) {
            if (fillMode === Material.TriangleStripDrawMode || fillMode === Material.TriangleFanDrawMode) {
                throw new Error("Triangle strip/fan fill mode is not implemented");
            }

            const newIndices = is32Bits ? new Uint32Array(count) : new Uint16Array(count);

            if (indices) {
                for (let i = 0; i + 2 < count; i += 3) {
                    newIndices[i] = indices[start + i] + offset;
                    newIndices[i + 1] = indices[start + i + 2] + offset;
                    newIndices[i + 2] = indices[start + i + 1] + offset;
                }
            } else {
                for (let i = 0; i + 2 < count; i += 3) {
                    newIndices[i] = i;
                    newIndices[i + 1] = i + 2;
                    newIndices[i + 2] = i + 1;
                }
            }

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Set the mesh's sideOrientation to Mesh.COUNTERCLOCKWISE_SIDE_ORIENTATION (or use Mesh.DEFAULTSIDE which is CCW) before exporting
  2. Convert the strip/fan geometry into a triangle list (expand indices via _ToTriangleList / CreateGreedyMesh-like conversion) so fillMode is the default TriangleFillMode
  3. Change material.fillMode to Material.TriangleFillMode before export and restore afterwards
  4. Catch the error and skip or pre-convert such meshes

Example fix

// before
mesh.material.fillMode = Material.TriangleStripDrawMode;
mesh.sideOrientation = Mesh.CLOCKWISE_SIDE_ORIENTATION;
await GLTF2Export.GLTFAsync(scene, "scene"); // throws
// after
mesh.material.fillMode = Material.TriangleFillMode;
mesh.sideOrientation = Mesh.COUNTERCLOCKWISE_SIDE_ORIENTATION;
await GLTF2Export.GLTFAsync(scene, "scene");
Defensive patterns

Strategy: validation

Validate before calling

function isExportableFillMode(mesh: Mesh): boolean {
    const fm = (mesh.material as Material)?.fillMode ?? Material.TriangleFillMode;
    const ccw = mesh.sideOrientation === Mesh.COUNTERCLOCKWISE_SIDE_ORIENTATION;
    return ccw || (fm !== Material.TriangleStripDrawMode && fm !== Material.TriangleFanDrawMode);
}

Try / catch

try {
    await GLTF2Export.GLTFAsync(scene, "scene");
} catch (e) {
    if (e instanceof Error && e.message === "Triangle strip/fan fill mode is not implemented") {
        // convert strip/fan geometry to triangle list or set CCW orientation, then retry
    } else { throw e; }
}

Prevention

When it happens

Trigger: Exporting a mesh whose material.fillMode is Material.TriangleStripDrawMode or Material.TriangleFanDrawMode AND whose sideOrientation is not Material.CounterClockWiseSideOrientation (e.g. Mesh.DEFAULTSIDE/sideOrientation set to ClockWiseSideOrientation or DOUBLESIDE handled via flip).

Common situations: Ribbon/strips or procedurally generated meshes built with triangle strips exported to glTF; meshes with sideOrientation explicitly set to clockwise for back-face rendering; converting scenes authored for Babylon's strip modes into glTF pipelines.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/8019d8e5c6880845. Report an issue: GitHub.