UNPKG

@gltf-transform/extensions

Version:

Adds extension support to @gltf-transform/core

48 lines (47 loc) 1.85 kB
import { Extension, type ReaderContext, type WriterContext } from '@gltf-transform/core'; import { KHR_TEXTURE_TRANSFORM } from '../constants.js'; import { Transform } from './transform.js'; /** * [`KHR_texture_transform`](https://github.com/KhronosGroup/gltf/blob/main/extensions/2.0/Khronos/KHR_texture_transform/) * adds offset, rotation, and scale to {@link TextureInfo} properties. * * Affine UV transforms are useful for reducing the number of textures the GPU must load, improving * performance when used in techniques like texture atlases. UV transforms cannot be animated at * this time. * * Properties: * - {@link Transform} * * ### Example * * The `KHRTextureTransform` class provides a single {@link ExtensionProperty} type, `Transform`, which * may be attached to any {@link TextureInfo} instance. For example: * * ```typescript * import { KHRTextureTransform } from '@gltf-transform/extensions'; * * // Create an Extension attached to the Document. * const transformExtension = document.createExtension(KHRTextureTransform) * .setRequired(true); * * // Create a reusable Transform. * const transform = transformExtension.createTransform() * .setScale([100, 100]); * * // Apply the Transform to a Material's baseColorTexture. * document.createMaterial() * .setBaseColorTexture(myTexture) * .getBaseColorTextureInfo() * .setExtension('KHR_texture_transform', transform); * ``` */ export declare class KHRTextureTransform extends Extension { readonly extensionName: typeof KHR_TEXTURE_TRANSFORM; static readonly EXTENSION_NAME: typeof KHR_TEXTURE_TRANSFORM; /** Creates a new Transform property for use on a {@link TextureInfo}. */ createTransform(): Transform; /** @hidden */ read(context: ReaderContext): this; /** @hidden */ write(context: WriterContext): this; }