ThreePipe
    Preparing search index...

    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: IMaterial) => string);
        extraDefines?: Record<
            string,
            ValOrFunc<undefined | string | number | boolean>,
        >;
        extraUniforms?: { [uniform: string]: ValOrFunc<IUniform<any>> };
        getUiConfig?: (
            material: IMaterial,
            refreshUi?: (
                deep?: boolean,
                mode?: TUiRefreshModes | "immediate",
                delay?: number,
            ) => void,
        ) => undefined | UiObjectConfig<any, string, any>;
        isCompatible?: (material: IMaterial) => undefined | boolean;
        onAddToMesh?: (mesh: Object3D, material: IMaterial) => void;
        onAfterRender?: (
            object: Object3D,
            material: IMaterial,
            renderer: IWebGLRenderer,
        ) => void;
        onMaterialUpdate?: (material: IMaterial) => void;
        onObjectRender?: (
            object: Object3D,
            material: IMaterial,
            renderer: IWebGLRenderer,
        ) => void;
        onRegister?: (material: IMaterial) => void;
        onRemoveFromMesh?: (mesh: Object3D, material: IMaterial) => void;
        onUnregister?: (material: IMaterial) => void;
        parsFragmentSnippet?:
            | string
            | (
                (
                    renderer?: WebGLRenderer,
                    material?: IMaterial<IMaterialEventMap>,
                ) => string
            );
        parsVertexSnippet?:
            | string
            | (
                (
                    renderer?: WebGLRenderer,
                    material?: IMaterial<IMaterialEventMap>,
                ) => string
            );
        priority?: number;
        setDirty?: () => void;
        shaderExtender?: (
            shader: WebGLProgramParametersWithUniforms,
            material: IMaterial,
            renderer: WebGLRenderer,
        ) => void;
        updaters?: IShaderPropertiesUpdater[] | (() => IShaderPropertiesUpdater[]);
        updateVersion?: number;
        uuid?: string;
    }

    Implemented by

    Index

    Properties

    __setDirty?: () => void
    computeCacheKey?: string | ((material: IMaterial) => 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.

    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<any>> }

    Extra uniforms to copy to material

    getUiConfig?: (
        material: IMaterial,
        refreshUi?: (
            deep?: boolean,
            mode?: TUiRefreshModes | "immediate",
            delay?: number,
        ) => void,
    ) => 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.

    isCompatible?: (material: IMaterial) => undefined | boolean

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

    The extension is assumed to be compatible if this function is not defined

    onAddToMesh?: (mesh: Object3D, material: IMaterial) => void

    Custom callback to run code when the material is added/applied to a mesh or any Object3D.

    Type declaration

    onAfterRender?: (
        object: Object3D,
        material: IMaterial,
        renderer: IWebGLRenderer,
    ) => 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.

    onMaterialUpdate?: (material: IMaterial) => void

    Custom callback to run code when the material is updated. (when materialUpdate event is dispatched on the material)

    Type declaration

      • (material: IMaterial): void
      • Parameters

        • material: IMaterial

          material that was updated

        Returns void

    onObjectRender?: (
        object: Object3D,
        material: IMaterial,
        renderer: IWebGLRenderer,
    ) => 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.

    onRegister?: (material: IMaterial) => void

    Custom callback to run code when this material extension is registered to a material.

    onRemoveFromMesh?: (mesh: Object3D, material: IMaterial) => void

    Custom callback to run code when the material is removed from a mesh or any Object3D.

    onUnregister?: (material: IMaterial) => void

    Custom callback to run code when this material extension is unregistered from a material.

    parsFragmentSnippet?:
        | string
        | (
            (
                renderer?: WebGLRenderer,
                material?: IMaterial<IMaterialEventMap>,
            ) => string
        )

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

    parsVertexSnippet?:
        | string
        | (
            (
                renderer?: WebGLRenderer,
                material?: IMaterial<IMaterialEventMap>,
            ) => string
        )

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

    priority?: number

    Higher priority extensions are applied first. (or as they are added, depends on the type of extension)

    setDirty?: () => void
    shaderExtender?: (
        shader: WebGLProgramParametersWithUniforms,
        material: IMaterial,
        renderer: WebGLRenderer,
    ) => void

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

    List of shader properties updaters to run on the material.

    updateVersion?: number
    uuid?: string