UNPKG

@gltf-transform/functions

Version:

Functions for common glTF modifications, written using the core API

59 lines (58 loc) 2.34 kB
import { Primitive, Transform } from '@gltf-transform/core'; /** Options for the {@link weld} function. */ export interface WeldOptions { /** Whether to overwrite existing indices. */ overwrite?: boolean; /** * 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; } export declare const WELD_DEFAULTS: Required<WeldOptions>; /** * Welds {@link Primitive Primitives}, merging bitwise identical vertices. When * merged and indexed, data is shared more efficiently between vertices. File size * can be reduced, and the GPU uses the vertex cache more efficiently. * * Example: * * ```javascript * import { weld, getSceneVertexCount, VertexCountMethod } from '@gltf-transform/functions'; * * const scene = document.getDefaultScene(); * const srcVertexCount = getSceneVertexCount(scene, VertexCountMethod.UPLOAD); * await document.transform(weld()); * const dstVertexCount = getSceneVertexCount(scene, VertexCountMethod.UPLOAD); * ``` * * @category Transforms */ export declare function weld(_options?: WeldOptions): Transform; /** * Welds a {@link Primitive}, merging bitwise identical vertices. When merged * and indexed, data is shared more efficiently between vertices. File size can * be reduced, and the GPU uses the vertex cache more efficiently. * * Example: * * ```javascript * import { weldPrimitive, getMeshVertexCount, VertexCountMethod } from '@gltf-transform/functions'; * * const mesh = document.getRoot().listMeshes() * .find((mesh) => mesh.getName() === 'Gizmo'); * * const srcVertexCount = getMeshVertexCount(mesh, VertexCountMethod.UPLOAD); * * for (const prim of mesh.listPrimitives()) { * weldPrimitive(prim); * } * * const dstVertexCount = getMeshVertexCount(mesh, VertexCountMethod.UPLOAD); * ``` */ export declare function weldPrimitive(prim: Primitive, _options?: WeldOptions): void;