UNPKG

threepipe

Version:

A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.

103 lines 4.65 kB
import { EventDispatcher, Material } from 'three'; import { AnimateTimeMaterial, IMaterial, IMaterialParameters } from '../core'; import { MaterialExtension } from '../materials'; /** * Material Manager * Utility class to manage materials. * Maintains a library of materials and material templates that can be used to manage or create new materials. * Used in {@link AssetManager} to manage materials. * @category Asset Manager */ export declare class MaterialManager<TEventMap extends object = object> extends EventDispatcher<TEventMap> { private _materials; constructor(); /** * @deprecated * @param info - uuid or material type * @param params */ findOrCreate(info: string, params?: IMaterialParameters | Material): IMaterial | undefined; /** * Create a material from the material type * @param type * @param register * @param params */ create<TM extends IMaterial>(type: string, params?: IMaterialParameters, register?: boolean, uuid?: string): TM | undefined; protected _create<TM extends IMaterial>(template: IMaterial['constructor'], oldMaterial?: IMaterialParameters | Partial<TM>): TM | undefined; protected _disposeMaterial: (e: { target?: IMaterial; }) => void; protected _registerMaterial: (e: { target?: IMaterial; }) => void; registerMaterial(material: IMaterial): void; registerMaterials(materials: IMaterial[]): void; unregisterExtensionsOnRemove: boolean; /** * This is done automatically on material dispose. * @param material */ unregisterMaterial(material: IMaterial): void; clearMaterials(): void; dispose(disposeRuntimeMaterials?: boolean): void; findMaterial(uuid: string): IMaterial | undefined; findMaterialsByName(name: string | RegExp, regex?: boolean): IMaterial[]; getMaterialsOfType<TM extends IMaterial = IMaterial>(typeSlug: string | undefined): TM[]; getAllMaterials(): IMaterial[]; /** * Creates a new material if a compatible template is found or apply minimal upgrades and returns the original material. * Also checks from the registered materials, if one with the same uuid is found, it is returned instead with the new parameters. * Also caches the response. * Returns the same material if its already upgraded. * @param material - the material to upgrade/check * @param useSourceMaterial - if false, will not use the source material parameters in the new material. default = true * @param materialTemplate - any specific material template to use instead of detecting from the material type. * @param createFromTemplate - if false, will not create a new material from the template, but will apply minimal upgrades to the material instead. default = true */ convertToIMaterial(material: Material & { assetType?: 'material'; iMaterial?: IMaterial; }, { useSourceMaterial, materialTemplate, createFromTemplate }?: { useSourceMaterial?: boolean; materialTemplate?: string; createFromTemplate?: boolean; }): IMaterial | undefined; protected _materialExtensions: MaterialExtension[]; registerMaterialExtension(extension: MaterialExtension): void; unregisterMaterialExtension(extension: MaterialExtension): void; clearExtensions(): void; exportMaterial(material: IMaterial, filename?: string, minify?: boolean, download?: boolean): File; applyMaterial(material: IMaterial, nameRegexOrUuid: string, regex?: boolean, time?: AnimateTimeMaterial): boolean; /** * copyProps from material to c * @param c * @param material * @param time */ copyMaterialProps(c: IMaterial, material: IMaterial, time?: AnimateTimeMaterial): boolean; /** * @deprecated use {@link ThreeSerialization.SerializableMaterials} directly * @param template */ registerMaterialTemplate(template: IMaterial['constructor']): void; /** * @deprecated use {@link ThreeSerialization.SerializableMaterials} directly * @param template */ unregisterMaterialTemplate(template: IMaterial['constructor']): void; /** * @deprecated use {@link ThreeSerialization.SerializableMaterials} directly * @param type */ findTemplate(type: string): { new (...args: any[]): IMaterial; TYPE: string; TypeSlug: string; TypeAlias?: string[]; MaterialProperties?: Record<string, any>; MapProperties?: string[]; InterpolateProperties?: string[]; } | undefined; } //# sourceMappingURL=../src/assetmanager/MaterialManager.d.ts.map