@gltf-transform/functions
Version:
Functions for common glTF modifications, written using the core API
33 lines (32 loc) • 1.03 kB
TypeScript
import { type Transform } from '@gltf-transform/core';
/** Options for the {@link sparse} function. */
export interface SparseOptions {
/**
* Threshold ratio used to determine when an accessor should be sparse.
* Default: 1 / 3.
*/
ratio: number;
}
/**
* Scans all {@link Accessor Accessors} in the Document, detecting whether each Accessor
* would benefit from sparse data storage. Currently, sparse data storage is used only
* when many values (>= ratio) are zeroes. Particularly for assets using morph target
* ("shape key") animation, sparse data storage may significantly reduce file sizes.
*
* Example:
*
* ```ts
* import { sparse } from '@gltf-transform/functions';
*
* accessor.getArray(); // → [ 0, 0, 0, 0, 0, 25.0, 0, 0, ... ]
* accessor.getSparse(); // → false
*
* await document.transform(sparse({ratio: 1 / 10}));
*
* accessor.getSparse(); // → true
* ```
*
* @experimental
* @category Transforms
*/
export declare function sparse(_options?: SparseOptions): Transform;