The Modular Configurator ID (not a full URL). It is appended to
https://{domain}/metabox-configurator/modular/{configuratorId} to form the iframe src.
The id of the container element where the iframe will be injected.
Called when the Communicator instance is created on the host side.
Optionalconfig: IntegrateMetaboxConfig
Optional configuration used to build the iframe URL and initialize the communicator. Supported fields:
A cancel function that stops waiting for the Metabox to load.
Calling it is optional — a later integrateMetabox call automatically
supersedes a still-pending handshake — but it lets you remove the handshake
listener immediately on teardown (e.g. SPA route change before
apiReadyCallback fires). Idempotent.
import { integrateMetabox } from '@3dsource/metabox-modular-configurator-api';
integrateMetabox('configurator-id',
'embed3DSource',
(api) => {
// Communicator is ready to use
},
{
standalone: false,
introImage: 'https://example.com/intro.png',
loadingImage: 'https://example.com/loading.png',
showLoadingProgress: true,
showResumeStreamPopup: true,
showUserInactivityTimer: true,
userInactivityTimeout: 20,
},
);
Integrates the Metabox Modular Configurator into the page by injecting an iframe and initializing a Communicator instance for host-to-iframe messaging.
What does it unlock?
Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle, and sets up all configurations.
Practical Application
is THE entry point function. Creates the configurator iframe, establishes postMessage communication, and returns the Communicator api handle via callback. Call ONCE per configurator. Params: configuratorId (modular UUID), containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig).
AI Coding Best Practices
Pattern:
integrateMetabox('uuid', 'div-id', (api) => { set up listeners, then set a root component, then environment, then children }, { standalone: true }). Ensure a container div exists in DOM with non-zero dimensions. HTTPS required. Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetComponent root, 3) SetEnvironment, 4) SetComponent children, 5) SetComponentMaterial.