• sortPrimitiveWeights(prim: Primitive | PrimitiveTarget, limit?: number): void
  • Sorts skinning weights from high to low, for each vertex of the input Primitive or PrimitiveTarget, and normalizes the weights. Optionally, uses the given 'limit' to remove least-significant joint influences such that no vertex has more than 'limit' influences.

    Most realtime engines support a limited number of joint influences per vertex, often 4 or 8. Sorting and removing the additional influences can reduce file size and improve compatibility.


    import { sortPrimitiveWeights } from '@gltf-transform/functions';
    const limit = 4;
    for (const mesh of document.getRoot().listMeshes()) {
        for (const prim of mesh.listPrimitives()) {
            sortPrimitiveWeights(prim, limit);
Function symbol, where the argument and output are a box labeled 'glTF'.

Made by Don McCurdy Documented with greendoc © 2023 MIT License