@3dsource/metabox-modular-configurator-api
    Preparing search index...

    Class SetComponentMaterial

    Represents a command to set component material by its slot ID and Material ID. To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.

    Sets a material variant for a component. Simulates selecting a different material from the menu for a specific component.

    Applies a material to a specific slot on a component. Takes componentId (UUID), slotId (string), and materialId (UUID). Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external PIM/ERP system via externalId mapping.

    Get valid slotId and materialId values from the configuratorDataUpdated envelope — check component slot definitions and material lists. Pattern: new SetComponentMaterial('component-uuid', 'slot-name', 'material-uuid'). The referenced component must already be set in the tree.

    import { Communicator, ModularConfiguratorEnvelope, SetComponentMaterial } from '@3dsource/metabox-modular-configurator-api';
    window.env3DSource.apiReady = (api: Communicator) => {

    //Subscribe to the event before sending the command to ensure you capture the response
    api.addEventListener('configuratorDataUpdated', (data:ModularConfiguratorEnvelope) => {
    console.log('State updated after applied new material:', data);
    });

    api.sendCommandToMetabox(new SetComponentMaterial(
    'ffea6b5c-3a8a-4f56-9417-e605acb5cca3',
    'carpaint',
    'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
    ));
    };

    The component ID.

    The slot ID.

    The material ID.

    Index

    Constructors

    Properties

    Constructors

    • Parameters

      • componentId: string
      • slotId: string
      • materialId: string

      Returns SetComponentMaterial

    Properties

    data: ToMetaBoxMessageEnvelope

    The message envelope populated by subclass constructors and sent via Communicator.sendCommandToMetabox.