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

    Class SetMaterials

    Represents a command to apply several materials at once. To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.

    Applies a whole material set in a single message instead of one command per slot. Simulates picking every swatch of a preset at once, so the assembly updates in one pass rather than slot by slot.

    Takes an array of SetComponentMaterial and SetEnvironmentMaterial instances and sends them as one batch, preserving order. Use it to apply presets or themed bundles across several components, to restore a saved configuration, or to sync a full material set from an external PIM/ERP system — instead of firing (and debouncing) N separate commands.

    Build the entries from the configuratorDataUpdated envelope — walk configurationTree, take each active component's product.slots and each slot's enabledMaterials. Pattern: new SetMaterials([new SetComponentMaterial('component-uuid', 'body', 'uuid'), new SetEnvironmentMaterial('floor', 'uuid')]). Nothing is validated client-side: entries are sent exactly as given, in order, and every referenced component must already be set in the tree. Keep using SetComponentMaterial on its own for a single swatch click.

    import { Communicator,ModularConfiguratorEnvelope,SetComponentMaterial,SetEnvironmentMaterial,SetMaterials } 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 materials:', data);
    });

    api.sendCommandToMetabox(new SetMaterials([
    new SetComponentMaterial('ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'carpaint', 'dd829d6e-9200-47a7-8d5b-af5df89b7e91'),
    new SetEnvironmentMaterial('floor', '7c1f4b2a-58e3-4a19-9d6c-2b0f83e5a114'),
    ]));
    };

    The material commands to apply, in order.

    Index
    data: ToMetaBoxMessageEnvelope

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