@3dsource/metabox-front-api
    Preparing search index...

    Class SetProductMaterial

    Represents a command to set a 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 product slot. Simulates selecting a different material/finish from the menu for a specific customizable surface on the product.

    Applies a material to a specific slot on the active product. Takes 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 product's slot definitions in the configuratorDataUpdated envelope — check product.slots and each slot's enabledMaterials list. Pattern: new SetProductMaterial('slot-name', 'material-uuid'). The referenced product must already be set.

    import { Communicator,ConfiguratorEnvelope,SetProductMaterial } from '@3dsource/metabox-front-api';
    window.env3DSource.apiReady = (api: Communicator) => {

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

    api.sendCommandToMetabox(new SetProductMaterial(
    'carpaint',
    'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
    ));
    };

    The slot ID.

    The material ID.

    Index

    Constructors

    Properties

    Constructors

    Properties

    data: ToMetaBoxMessageEnvelope

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