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.

116 lines 5 kB
import { AViewerPluginEventMap, AViewerPluginSync, ThreeViewer } from '../../viewer'; import { UiObjectConfig } from 'uiconfig.js'; import { IMaterial, PhysicalMaterial } from '../../core'; import { MaterialPreviewGenerator } from '../../three'; import { AnimationResult } from '../animation/PopmotionPlugin'; import { AnimateTime } from '../../utils'; /** * Material Configurator Plugin (Base) * * This plugin allows you to create variations of materials mapped to material names or uuids in the scene. * These variations can be applied to the materials in the scene. (This copies the properties to the same material instances instead of assigning new materials) * The plugin interfaces with the picking plugin and also provides uiConfig to show and edit the variations. * * See `MaterialConfiguratorPlugin` in [plugin-configurator](https://threepipe.org/plugins/configurator/docs/index.html) for example on inheriting with a custom UI renderer. * * @category Plugins */ export declare class MaterialConfiguratorBasePlugin extends AViewerPluginSync<{ 'refreshUi': object; } & AViewerPluginEventMap> { enabled: boolean; static PluginType: string; private _picking; protected _previewGenerator: MaterialPreviewGenerator | undefined; private _uiNeedRefresh; constructor(); onAdded(viewer: ThreeViewer): void; /** * Apply all variations(by selected index or first item) when a config is loaded */ applyOnLoad: boolean; applyOnLoadForce: boolean; /** * Reapply all selected variations again. * Useful when a model or config is loaded or changed and the variations are not applied in the model. * It is automatically called when the config is loaded if `applyOnLoad` is true. */ reapplyAll(): void; fromJSON(data: any, meta?: any): this | Promise<this | null> | null; onRemove(viewer: ThreeViewer): void; findVariation(mapping?: string): MaterialVariations | undefined; getSelectedVariation(): MaterialVariations | undefined; /** * Apply a material variation based on index or uuid. * @param variations * @param matUuidOrIndex * @param setSelectedIndex - default true, to be used with animation * @param time - optional data to animate(lerp) from current value to the target material. */ applyVariation(variations: MaterialVariations, matUuidOrIndex: string | number, setSelectedIndex?: boolean, time?: AnimateTime & { from?: string | number; }): boolean; findMaterialVariation(matUuidOrIndex: string | number, variations: MaterialVariations): IMaterial<import('../../core').IMaterialEventMap> | undefined; applyVariationAnimate(variations: MaterialVariations, matUuidOrIndex: string | number, duration?: number): Promise<void>; /** * Get the preview for a material variation * Should be called from preFrame ideally. (or preRender but set viewerSetDirty = false) * @param preview - Type of preview. Could be generate:sphere, generate:cube, color, map, emissive, etc. * @param material - Material or index of the material in the variation. * @param viewerSetDirty - call viewer.setDirty() after setting the preview. So that the preview is cleared from the canvas. */ getPreview(material: IMaterial, preview: string, viewerSetDirty?: boolean): string; /** * Refreshes the UI in the next frame */ refreshUi(): void; private _refreshUiConfig; protected _refreshUi(): Promise<boolean>; protected _preFrame(): boolean; variations: MaterialVariations[]; private _selectedMaterial; protected _uicShowAllVariations: boolean; createVariationsUiConfig(v?: MaterialVariations): { type: string; label: string; uuid: string; children: {}[]; } | undefined; uiConfig: UiObjectConfig; removeVariationForMaterial(material: IMaterial): void; removeVariation(variation: MaterialVariations): void; addVariation(material?: IMaterial, variationKey?: string, cloneMaterial?: boolean): void; createVariation(material: IMaterial, variationKey?: string): MaterialVariations; } export interface MaterialVariations { /** * The name or the uuid of the material in the scene */ uuid: string; /** * Title to show in the UI */ title: string; preview: keyof PhysicalMaterial | 'generate:sphere' | 'generate:cube' | 'generate:cylinder'; materials: IMaterial[]; data?: { icon?: string; [key: string]: any; }[]; /** * Whether to use regex to match the material name. * @default true */ regex?: boolean; selectedIndex?: number | string; /** * Keyframes for the viewer timeline animation */ timeline?: { time: number; index: number | string; duration?: number; }[]; _animation?: AnimationResult; } //# sourceMappingURL=../../src/plugins/configurator/MaterialConfiguratorBasePlugin.d.ts.map