@3dsource/metabox-front-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 scene updates in one pass rather than slot by slot.

    Takes an array of SetProductMaterial and SetEnvironmentMaterial instances and sends them as one batch, preserving order. Use it to apply presets or themed bundles, 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 — product.slots and environment.slots, each slot's enabledMaterials. Pattern: new SetMaterials([new SetProductMaterial('body', 'uuid'), new SetEnvironmentMaterial('floor', 'uuid')]). Nothing is validated client-side: entries are sent exactly as given, in order, and the referenced product must already be set. Keep using SetProductMaterial on its own for a single swatch click.

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

    api.sendCommandToMetabox(new SetMaterials([
    new SetProductMaterial('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.