weld

  • Index Primitives and (optionally) merge 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.

    To preserve visual appearance consistently, use low toleranceNormal thresholds around 0.1 (±3º). To pre-processing a scene before simplification or LOD creation, use higher thresholds around 0.5 (±30º).

    Example:

    import { weld } from '@gltf-transform/functions';
    
    await document.transform(
        weld({ tolerance: 0.001, toleranceNormal: 0.5 })
    );
    
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.