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.
What does it unlock?
Sets a component during initialization, which triggers the reconstruction of the component tree structure.
Simulates clicking a component in the menu.
Practical Application
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.
AI Coding Best Practices
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.
//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); });
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.
What does it unlock?
Sets a component during initialization, which triggers the reconstruction of the component tree structure. Simulates clicking a component in the menu.
Practical Application
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.
AI Coding Best Practices
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.Example
Param: id
The component ID.
Param: typeId
The component type ID.