Interface MaterialExtension

Material extension interface This is used to extend a three.js material satisfying the IMaterial interface, with extra uniforms, defines, shader code, etc.

interface MaterialExtension {
    __setDirty?: (() => void);
    computeCacheKey?: string | ((material) => string);
    extraDefines?: Record<string, ValOrFunc<undefined | string | number | boolean>>;
    extraUniforms?: {
        [uniform: string]: ValOrFunc<IUniform>;
    };
    getUiConfig?: ((material, refreshUi?) => undefined | UiObjectConfig<any, string, any>);
    isCompatible: ((material) => boolean);
    onAfterRender?: ((object, material, renderer) => void);
    onObjectRender?: ((object, material, renderer) => void);
    parsFragmentSnippet?: string | ((renderer?, material?) => string);
    parsVertexSnippet?: string | ((renderer?, material?) => string);
    priority?: number;
    setDirty?: (() => void);
    shaderExtender?: ((shader, material, renderer) => void);
    updateVersion?: number;
    updaters?: IShaderPropertiesUpdater[] | (() => IShaderPropertiesUpdater[]);
    uuid?: string;
}

Implemented by

Properties

__setDirty?: (() => void)

Type declaration

    • (): void
    • Returns void

computeCacheKey?: string | ((material) => string)

Custom cache key to use for this material extension. A different cache key will cause the shader to be recompiled. Check three.js docs for more info. Value can be a string or a function that returns a string This will only be checked if material.needsUpdate is true, not on every render. Note: extension might never be registered if an empty string is returned.

Type declaration

extraDefines?: Record<string, ValOrFunc<undefined | string | number | boolean>>

Extra defines to copy to material Note: boolean are converted to 0 and 1

extraUniforms?: {
    [uniform: string]: ValOrFunc<IUniform>;
}

Extra uniforms to copy to material

Type declaration

getUiConfig?: ((material, refreshUi?) => undefined | UiObjectConfig<any, string, any>)

Function to return the UI config for this material extension. This is called once when the material extension is registered.

Type declaration

    • (material, refreshUi?): undefined | UiObjectConfig<any, string, any>
    • Function to return the UI config for this material extension. This is called once when the material extension is registered.

      Parameters

      Returns undefined | UiObjectConfig<any, string, any>

Param: material

isCompatible: ((material) => boolean)

Function to check if this material extension is compatible with the given material. If not compatible, the material extension will not be applied. This is only checked when the extension is registered.

Type declaration

    • (material): boolean
    • Function to check if this material extension is compatible with the given material. If not compatible, the material extension will not be applied. This is only checked when the extension is registered.

      Returns boolean

Param: material

onAfterRender?: ((object, material, renderer) => void)

Custom callback to run code after the material is rendered Executes from material.onAfterRender for each material for each object it's rendered on.

Type declaration

Param: object

Param: material

Param: renderer

onObjectRender?: ((object, material, renderer) => void)

Custom callback to run code before the material is rendered Executes from material.onBeforeRender for each material for each object it's rendered on.

Type declaration

Param: object

Param: material

Param: renderer

parsFragmentSnippet?: string | ((renderer?, material?) => string)

Extra code to add to the top of the fragment shader Value can be a string or a function that returns a string

Type declaration

parsVertexSnippet?: string | ((renderer?, material?) => string)

Extra code to add to the top of the vertex shader Value can be a string or a function that returns a string

Type declaration

priority?: number

Higher priority extensions are applied first.

setDirty?: (() => void)

Type declaration

    • (): void
    • Returns void

shaderExtender?: ((shader, material, renderer) => void)

Custom callback to extend/modify/replace shader code and other shader properties

Type declaration

Param: shader

Param: material

Param: renderer

updateVersion?: number

List of shader properties updaters to run on the material.

Type declaration

uuid?: string

Generated using TypeDoc