Skip to main content

Class: MaterialConfiguratorBasePlugin

Plugins.MaterialConfiguratorBasePlugin

Hierarchy​

Properties​

PluginType​

▪ Static PluginType: string = 'MaterialConfiguratorPlugin'


enabled​

• enabled: boolean = true

Overrides​

AViewerPlugin.enabled


applyOnLoad​

• applyOnLoad: boolean = true

Apply all variations(by selected index or first item) when a config is loaded


dependencies​

• dependencies: typeof AssetManagerPlugin[]


variations​

• variations: MaterialVariations[] = []


uiConfig​

• uiConfig: UiObjectConfig<any, string>


_dirty​

• Protected _dirty: boolean = false

Inherited from​

AViewerPlugin._dirty


_viewer​

• Protected Optional _viewer: ViewerApp

Inherited from​

AViewerPlugin._viewer


_previewGenerator​

• Protected _previewGenerator: undefined | MaterialPreviewGenerator

Accessors​

dirty​

• get dirty(): boolean

Returns​

boolean

Inherited from​

AViewerPlugin.dirty

• set dirty(value): void

Parameters​

NameType
valueboolean

Returns​

void

Inherited from​

AViewerPlugin.dirty


viewer​

• get viewer(): undefined | ViewerApp

Returns​

undefined | ViewerApp

Inherited from​

AViewerPlugin.viewer

Methods​

onDispose​

▸ onDispose(viewer): Promise<void>

Parameters​

NameType
viewerViewerApp

Returns​

Promise<void>

Inherited from​

AViewerPlugin.onDispose


toJSON​

▸ toJSON(meta?): any

Parameters​

NameType
meta?any

Returns​

any

Inherited from​

AViewerPlugin.toJSON


exportState​

▸ exportState(): any

Returns​

any

Inherited from​

AViewerPlugin.exportState


importState​

▸ importState(state): Promise<void>

Parameters​

NameType
stateany

Returns​

Promise<void>

Inherited from​

AViewerPlugin.importState


storeState​

▸ storeState(prefix?, storage?, data?): void

Parameters​

NameType
prefix?string
storage?Storage
data?any

Returns​

void

Inherited from​

AViewerPlugin.storeState


loadState​

▸ loadState(prefix?, storage?): Promise<void>

Parameters​

NameType
prefix?string
storage?Storage

Returns​

Promise<void>

Inherited from​

AViewerPlugin.loadState


onAdded​

▸ onAdded(viewer): Promise<void>

Parameters​

NameType
viewerViewerApp

Returns​

Promise<void>

Overrides​

AViewerPlugin.onAdded


reapplyAll​

▸ reapplyAll(): void

Reapply all selected variations again. Useful when the scene is loaded or changed and the variations are not applied.

Returns​

void


fromJSON​

▸ fromJSON(data, meta?): null | MaterialConfiguratorBasePlugin | Promise<null | MaterialConfiguratorBasePlugin>

Parameters​

NameType
dataany
meta?any

Returns​

null | MaterialConfiguratorBasePlugin | Promise<null | MaterialConfiguratorBasePlugin>

Overrides​

AViewerPlugin.fromJSON


onRemove​

▸ onRemove(viewer): Promise<void>

Parameters​

NameType
viewerViewerApp

Returns​

Promise<void>

Overrides​

AViewerPlugin.onRemove


findVariation​

▸ findVariation(uuid?): undefined | MaterialVariations

Parameters​

NameType
uuid?string

Returns​

undefined | MaterialVariations


getSelectedVariation​

▸ getSelectedVariation(): undefined | MaterialVariations

Returns​

undefined | MaterialVariations


applyVariation​

▸ applyVariation(variations, matUuidOrIndex): boolean

Apply a material variation based on index or uuid.

Parameters​

NameType
variationsMaterialVariations
matUuidOrIndexstring | number

Returns​

boolean


getPreview​

▸ getPreview(material, preview, viewerSetDirty?): string

Get the preview for a material variation Should be called from preFrame ideally. (or preRender but set viewerSetDirty = false)

Parameters​

NameTypeDefault valueDescription
materialIMaterial<any, IMaterialEventMap>undefinedMaterial or index of the material in the variation.
previewstringundefinedType of preview. Could be generate:sphere, generate:cube, color, map, emissive, etc.
viewerSetDirtybooleantruecall viewer.setDirty() after setting the preview. So that the preview is cleared from the canvas.

Returns​

string


refreshUi​

▸ refreshUi(): void

Refreshes the UI in the next frame

Returns​

void


removeVariationForMaterial​

▸ removeVariationForMaterial(material): void

Parameters​

NameType
materialIMaterial<any, IMaterialEventMap>

Returns​

void


removeVariation​

▸ removeVariation(variation): void

Parameters​

NameType
variationMaterialVariations

Returns​

void


addVariation​

▸ addVariation(material?, variationKey?, cloneMaterial?): void

Parameters​

NameTypeDefault value
material?IMaterial<any, IMaterialEventMap>undefined
variationKey?stringundefined
cloneMaterialbooleantrue

Returns​

void


createVariation​

▸ createVariation(material, variationKey?): MaterialVariations

Parameters​

NameType
materialIMaterial<any, IMaterialEventMap>
variationKey?string

Returns​

MaterialVariations


_storeKey​

▸ Protected _storeKey(prefix?): string

Parameters​

NameType
prefix?string

Returns​

string

Inherited from​

AViewerPlugin._storeKey


_refreshUi​

▸ Protected _refreshUi(): Promise<boolean>

Returns​

Promise<boolean>

Constructors​

constructor​

• new MaterialConfiguratorBasePlugin()

Overrides​

AViewerPlugin.constructor