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

    Class SetComponent

    Represents a command to set a component by its data (ID, typeId). This action sends a message to the Metabox API to set a component using the provided data. To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event.

    Sets a component during initialization, which triggers the reconstruction of the component tree structure. Simulates clicking a component in the menu.

    Selects a component in the modular assembly. Takes componentId (UUID), typeId (category string). CRITICAL: Always set root component (isRoot:true) FIRST — nothing renders without it. Then add children (isRoot:false). Simulates clicking a component in the menu.

    ALWAYS set root first: new SetComponent('id', 'type', true). Then children: new SetComponent('childId', 'childType', false). Get valid IDs from configuratorDataUpdated event data — the configurator definition contains all available components and types. Wrong order = blank viewport. The typeId must match componentType values from the configurator.

    import { Communicator, ModularConfiguratorEnvelope, SetComponent } 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 component:', data);
    });

    api.sendCommandToMetabox(new SetComponent(
    'ffea6b5c-3a8a-4f56-9417-e605acb5cca3', 'typeId'
    ));
    };

    The component ID.

    The component type ID.

    Index

    Constructors

    Properties

    Constructors

    • Parameters

      • id: string
      • typeId: string

      Returns SetComponent

    Properties

    data: ToMetaBoxMessageEnvelope

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