@gltf-transform/functions
Version:
Functions for common glTF modifications, written using the core API
42 lines (41 loc) • 1.57 kB
TypeScript
import { Transform } from '@gltf-transform/core';
/** Options for the {@link reorder} function. */
export interface ReorderOptions {
/** MeshoptEncoder instance. */
encoder: unknown;
/**
* Whether the order should be optimal for transmission size (recommended for Web)
* or for GPU rendering performance. Default is 'size'.
*/
target?: 'size' | 'performance';
/**
* Whether to perform cleanup steps after completing the operation. Recommended, and enabled by
* default. Cleanup removes temporary resources created during the operation, but may also remove
* pre-existing unused or duplicate resources in the {@link Document}. Applications that require
* keeping these resources may need to disable cleanup, instead calling {@link dedup} and
* {@link prune} manually (with customized options) later in the processing pipeline.
* @experimental
*/
cleanup?: boolean;
}
/**
* Optimizes {@link Mesh} {@link Primitive Primitives} for locality of reference. Choose whether
* the order should be optimal for transmission size (recommended for Web) or for GPU rendering
* performance. Requires a MeshoptEncoder instance from the Meshoptimizer library.
*
* Example:
*
* ```ts
* import { MeshoptEncoder } from 'meshoptimizer';
* import { reorder } from '@gltf-transform/functions';
*
* await MeshoptEncoder.ready;
*
* await document.transform(
* reorder({encoder: MeshoptEncoder})
* );
* ```
*
* @category Transforms
*/
export declare function reorder(_options: ReorderOptions): Transform;