@gltf-transform/functions
Version:
Functions for common glTF modifications, written using the core API
29 lines (28 loc) • 1.1 kB
TypeScript
import { Primitive, PrimitiveTarget } from '@gltf-transform/core';
/**
* Sorts skinning weights from high to low, for each vertex of the input
* {@link Primitive} or {@link 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.
*
* Example:
*
* ```javascript
* 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);
* }
* }
* ```
*
* @param prim Input, to be modified in place.
* @param limit Maximum number of joint influences per vertex. Must be a multiple of four.
*/
export declare function sortPrimitiveWeights(prim: Primitive | PrimitiveTarget, limit?: number): void;