threepipe
Version:
A 3D viewer framework built on top of three.js in TypeScript with a focus on quality rendering, modularity and extensibility.
82 lines • 3.53 kB
TypeScript
import { AViewerPluginSync, ThreeViewer } from '../../viewer';
import { UiObjectConfig } from 'uiconfig.js';
import { IMaterial, PhysicalMaterial } from '../../core';
import { MaterialPreviewGenerator } from '../../three';
/**
* 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<''> {
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;
/**
* Reapply all selected variations again.
* Useful when the scene is loaded or changed and the variations are not applied.
*/
reapplyAll(): void;
fromJSON(data: any, meta?: any): this | Promise<this | null> | null;
onRemove(viewer: ThreeViewer): void;
findVariation(uuid?: string): MaterialVariations | undefined;
getSelectedVariation(): MaterialVariations | undefined;
/**
* Apply a material variation based on index or uuid.
* @param variations
* @param matUuidOrIndex
*/
applyVariation(variations: MaterialVariations, matUuidOrIndex: string | number): boolean;
/**
* 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>;
variations: MaterialVariations[];
private _selectedMaterial;
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;
}[];
selectedIndex?: number;
}
//# sourceMappingURL=MaterialConfiguratorBasePlugin.d.ts.map