@gltf-transform/extensions
Version:
Adds extension support to @gltf-transform/core
51 lines (50 loc) • 2.07 kB
TypeScript
import { Extension, PropertyType, type ReaderContext, type WriterContext } from '@gltf-transform/core';
import { KHR_MATERIALS_DISPERSION } from '../constants.js';
import { Dispersion } from './dispersion.js';
/**
* [KHR_materials_dispersion](https://github.com/KhronosGroup/gltf/blob/main/extensions/2.0/Khronos/KHR_materials_dispersion/)
* defines dispersion on a glTF PBR material.
*
* 
*
* > _**Figure:** Prisms demonstrating volumetric refraction and dispersion, for varying
* > values of dispersion and IOR. Source: Khronos Group, rendered in Adobe Stager._
*
* Dispersion enables configuring the strength of the angular separation of colors (chromatic
* aberration) transmitting through a relatively clear volume. It is an enhancement to the
* default `KHR_materials_volume` transmission model which assumes no dispersion.
*
* Properties:
* - {@link Dispersion}
*
* ### Example
*
* ```typescript
* import { KHRMaterialsDispersion, Dispersion } from '@gltf-transform/extensions';
*
* // Create an Extension attached to the Document.
* const dispersionExtension = document.createExtension(KHRMaterialsDispersion);
*
* // Create Dispersion property.
* const dispersion = dispersionExtension.createDispersion().setDispersion(1.0);
*
* // Assign to a Material.
* material.setExtension('KHR_materials_dispersion', dispersion);
* ```
*/
export declare class KHRMaterialsDispersion extends Extension {
static readonly EXTENSION_NAME: typeof KHR_MATERIALS_DISPERSION;
readonly extensionName: typeof KHR_MATERIALS_DISPERSION;
readonly prereadTypes: PropertyType[];
readonly prewriteTypes: PropertyType[];
/** Creates a new Dispersion property for use on a {@link Material}. */
createDispersion(): Dispersion;
/** @hidden */
read(_context: ReaderContext): this;
/** @hidden */
write(_context: WriterContext): this;
/** @hidden */
preread(context: ReaderContext): this;
/** @hidden */
prewrite(context: WriterContext): this;
}