Scans all 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:
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
Made by Don McCurdy • Documented with greendoc • © 2023 MIT License
sparse