• weldPrimitive(a: Document | Primitive, b?: Primitive | WeldOptions, c?: Required<import("/Users/donmccurdy/Documents/Projects/glTF-Transform/packages/functions/src/weld").WeldOptions>): void
  • Index a Primitive and (optionally) weld similar vertices. When merged and indexed, data is shared more efficiently between vertices. File size can be reduced, and the GPU can sometimes use the vertex cache more efficiently.

    When welding, the 'tolerance' threshold determines which vertices qualify for welding based on distance between the vertices as a fraction of the primitive's bounding box (AABB). For example, tolerance=0.01 welds vertices within +/-1% of the AABB's longest dimension. Other vertex attributes are also compared during welding, with attribute-specific thresholds. For tolerance=0, geometry is indexed in place, without merging.


    import { weldPrimitive } from '@gltf-transform/functions';
    const mesh = document.getRoot().listMeshes()
        .find((mesh) => mesh.getName() === 'Gizmo');
    for (const prim of mesh.listPrimitives()) {
      weldPrimitive(prim, {tolerance: 0.0001});
Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy. Documentation built with greendoc and published under Creative Commons Attribution 3.0.