@3dsource/metabox-front-api
Version:
API for Metabox BASIC configurator
1,032 lines (995 loc) • 36.2 kB
TypeScript
import { Observable } from 'rxjs';
type ApplicationDeviceTypes = 'deviceTypeAuto' | 'deviceTypeMobile' | 'deviceTypeDesktop';
declare const Metabox = "metabox_v3";
declare const MetaboxHost = "metaboxHost_v3";
declare const MetaboxData = "metaboxData_v3";
declare const AppLoaded = "appLoaded_v3";
declare const MetaboxDomain = "metabox.3dsource.com";
declare const BasicRouteUrl = "metabox-configurator/basic";
declare const VERSION = "3.0.5";
type FromMetaboxApiAction = 'bridge' | typeof AppLoaded;
interface IntegrateMetaboxConfig {
standalone?: boolean;
loadingImage?: string;
introVideo?: string;
introImage?: string;
state?: string;
domain?: string;
}
interface MetaboxCommandConfig {
standalone?: boolean;
hostUrl: string;
apiVersion: string;
}
declare const MetaboxBasicConfiguratorActions: {
readonly metaboxConfig: "metaboxConfig";
readonly setEnvironment: "setEnvironment";
readonly setEnvironmentMaterialById: "setEnvironmentMaterialById";
readonly setProduct: "setProduct";
readonly setProductMaterialById: "setProductMaterialById";
readonly getPdf: "getPdf";
readonly getCallToActionInformation: "getCallToActionInformation";
readonly getScreenshot: "getScreenshot";
readonly showEmbeddedMenu: "showEmbeddedMenu";
readonly forceSetDeviceType: "forceSetDeviceType";
readonly showOverlayInterface: "showOverlayInterface";
readonly resetCamera: "resetCamera";
readonly applyZoom: "applyZoom";
readonly initShowcase: "initShowcase";
readonly playShowcase: "playShowcase";
readonly pauseShowcase: "pauseShowcase";
readonly stopShowcase: "stopShowcase";
readonly sendCommandToUnreal: "sendCommandToUnreal";
readonly watchCallbacks: "watchCallbacks";
};
type ToMetaBoxActions = (typeof MetaboxBasicConfiguratorActions)[keyof typeof MetaboxBasicConfiguratorActions];
/**
* @internal
* @hidden
*/
type ToMetaboxMessagePayload = ToMetaboxMessagePayloads[keyof ToMetaboxMessagePayloads];
/**
* Interface for messages sent from the application to the Basic Metabox API.
*/
interface ToMetaboxMessagePayloads {
[MetaboxBasicConfiguratorActions.metaboxConfig]: {
appId: string;
config: MetaboxCommandConfig;
};
[MetaboxBasicConfiguratorActions.setProduct]: {
productId: string;
};
[MetaboxBasicConfiguratorActions.setEnvironment]: {
id: string;
};
[MetaboxBasicConfiguratorActions.getPdf]: void;
[MetaboxBasicConfiguratorActions.getCallToActionInformation]: void;
[MetaboxBasicConfiguratorActions.watchCallbacks]: void;
[MetaboxBasicConfiguratorActions.getScreenshot]: {
format: MimeType;
size?: {
x: number;
y: number;
};
};
[MetaboxBasicConfiguratorActions.setProductMaterialById]: {
slotId: string;
materialId: string;
};
[MetaboxBasicConfiguratorActions.setEnvironmentMaterialById]: {
slotId: string;
materialId: string;
};
[MetaboxBasicConfiguratorActions.showEmbeddedMenu]: {
visible: boolean;
};
[MetaboxBasicConfiguratorActions.showOverlayInterface]: {
visible: boolean;
};
[MetaboxBasicConfiguratorActions.forceSetDeviceType]: {
deviceType: ApplicationDeviceTypes;
};
[MetaboxBasicConfiguratorActions.resetCamera]: void;
[MetaboxBasicConfiguratorActions.applyZoom]: {
zoom: number;
};
[MetaboxBasicConfiguratorActions.initShowcase]: void;
[MetaboxBasicConfiguratorActions.playShowcase]: void;
[MetaboxBasicConfiguratorActions.pauseShowcase]: void;
[MetaboxBasicConfiguratorActions.stopShowcase]: void;
[MetaboxBasicConfiguratorActions.sendCommandToUnreal]: object;
}
interface ToMetaBoxMessageEnvelope {
action: ToMetaBoxActions;
payload?: ToMetaboxMessagePayload | never;
}
interface ToMetaBoxMessage {
host: typeof MetaboxHost;
payload: ToMetaBoxMessageEnvelope;
}
/** Represents an ecom configurator object with all necessary information about cta */
interface EcomConfigurator {
/** The unique ecom configurator identifier. */
id: string;
/** The created data of ecom configurator. */
createdAt: string;
/** A reference to the Call To Action Information. */
cta?: Cta;
/** GraphQL typename for the ecom configurator. */
__typename: 'Configurator';
}
/**
* Represents the call-to-action information for an ecom configurator.
*/
interface Cta {
/** The indicator of whether the call-to-action is enabled or not. */
enabled: boolean;
/** Label of button for call-to-action. */
label: string;
/** Callback URL using for sent configurator selected information to this url and redirected to the url after get response. */
callbackUrl: string;
/** GraphQL typename for the CTA object. */
__typename: 'Cta';
}
/**
* Represents a basic configurator object with its configuration, selected materials,
* product identifier, and associated environment with its materials.
*/
interface ConfiguratorEnvelope {
/**
* A reference to the universal configurator.
*/
configurator: UniversalConfigurator;
/**
* The unique product identifier.
*/
productId: string;
/**
* A record mapping product material selections.
*/
productMaterialsIds: SelectedIds;
/**
* The unique environment identifier.
*/
environmentId: string;
/**
* A record mapping environment material selections.
*/
environmentMaterialsIds: SelectedIds;
}
/**
* Represents the universal configurator with its basic properties and components.
*/
interface UniversalConfigurator {
/** Unique identifier for the configurator. */
id: string;
/** Client information associated with the configurator. */
/** The name of the configurator. */
name: string;
/** Label for the product collection. */
productCollectionLabel: string;
/** A list of products for the configurator. */
products: UniversalConfiguratorProduct[];
/** A list of available environments. */
environments: UniversalConfiguratorEnvironment[];
/** Indicates if the configurator is active. */
isActive: boolean;
/** Indicates if the cta in ecom configurator is enabled or not. */
ctaEnabled: boolean;
/** GraphQL typename for the configurator. */
__typename: 'UniversalConfigurator';
}
/**
* Represents a product within the universal configurator.
*/
interface UniversalConfiguratorProduct {
/** The product's unique identifier. */
productId: string;
/** Position index of the product. */
position: number;
/** Display label for the product. */
label: string;
/** The detailed product information. */
product: Product;
/** GraphQL typename for the product. */
__typename: 'UniversalConfiguratorProduct';
}
/**
* Represents product details including visual assets and configuration.
*/
interface Product {
/** The title of the product. */
title: string;
/** List of thumbnails for the product. */
thumbnailList: Thumbnail[];
/** Available slots for the product. */
slots: Slot[];
/** List of metaProperties for the product (optional). */
metaProperties: MetaProperty[];
/** The model information associated with the product. */
/** Unique identifier for the product. */
id: string;
/** Unique external id for the product. */
externalId: string;
/** Showcase details for the product. */
showcase?: Showcase;
/** GraphQL typename for the product. */
__typename: 'Product';
}
/**
* Represents a thumbnail image entity with dimensions and URL path.
*/
interface Thumbnail {
/** Width of the thumbnail. */
width: number;
/** Height of the thumbnail. */
height: number;
/** URL path to the thumbnail image. */
urlPath: string;
/** GraphQL typename (as a string, flexible type). */
__typename: 'Thumbnail';
}
/**
* Represents a slot within a product that may allow material customization.
*/
interface Slot {
/** Unique identifier for the slot. */
id: string;
/** Display a label for the slot. */
label: string;
/** A list of enabled materials for the slot. */
enabledMaterials: Material[];
/** GraphQL typename for the slot. */
__typename: 'Slot';
}
/**
* Represents a metaProperty within a product that may allow business logic customization.
*/
interface MetaProperty {
/** Unique identifier for the metaProperty. */
id: string;
/** Display the name for the metaProperty. */
name: string;
/** Value for the metaProperty. */
value: string;
/** Type for the metaProperty. */
type: string;
/** GraphQL typename for the metaProperty. */
__typename: 'MetaProperty';
}
/**
* Represents a material that can be applied to a product slot.
*/
interface Material {
/** Unique identifier for the material. */
id: string;
/** Title or name of the material. */
title: string;
/** Unique external id for the material. */
externalId: string;
/** List of thumbnails for the material. */
thumbnailList: Thumbnail[];
/** The model information associated with the material. */
/** GraphQL typename for the material. */
__typename: 'Material';
}
/**
* Details showcase the presentation of a product.
*/
interface Showcase {
/** A list of low-bandwidth versions for the showcase (optional). */
lowBandwidth?: (Timecode | null)[] | null;
/** Duration for the showcase (optional). */
duration?: number;
/** GraphQL typename for the showcase. */
__typename: 'Showcase';
}
/**
* Represents a low-bandwidth entity used in showcases in LBM mode.
*/
interface Timecode {
/** Time marker for the entity. */
time: number;
/** Duration of the entity display. */
duration: number;
/** GraphQL typename (as a string, flexible type). */
__typename: 'Timecode';
}
/**
* Represents the environment settings for a universal configurator.
*/
interface UniversalConfiguratorEnvironment {
/** Unique identifier for the environment. */
environmentId: string;
/** Position index of the environment. */
position: number;
/** Display label for the environment. */
label: string;
/** Detailed environment configuration. */
environment: Environment;
/** GraphQL typename for the environment. */
__typename: 'UniversalConfiguratorEnvironment';
}
/**
* Represents an environment with associated media and configuration.
*/
interface Environment {
/** Unique identifier for the environment. */
id: string;
/** Title or name of the environment. */
title: string;
/** Flag indicating if UDS is enabled. */
udsEnabled: boolean;
/** The north yaw of the sun in the environment. */
sunNorthYaw: number;
/** The UDS hour setting for the environment. */
udsHour: number;
/** GraphQL typename for the environment. */
__typename: 'Environment';
/** List of thumbnails for the environment (optional). */
thumbnailList: Thumbnail[];
/** List of slots for the environment (optional). */
slots: Slot[];
}
/**
* Defines the structure for a mapping of selected materials.
*/
type SelectedIds = Record<string, Record<string, string>>;
/**
* Defines the structure for an available showcase status for the current product on a scene.
*/
type ShowCaseStatus = 'init' | 'play' | 'pause' | 'stop';
/**
* Defines the structure for a video resolution.
*/
interface VideoResolution {
width: number | null;
height: number | null;
}
interface FromMetaboxMessagePayloads {
/**
* Dispatches every time the configurator data is updated.
* I.e., when the user changes the configuration. (Material, Product, Environment)
*/
configuratorDataUpdated: ConfiguratorEnvelope;
/**
* Dispatches every time the ecom configurator data is updated (label, endpointUrl).
*/
ecomConfiguratorDataUpdated: EcomConfigurator;
/**
* Dispatches every time when the configurator connected/disconnected with Unreal Engine.
*/
dataChannelConnected: boolean;
/**
* Dispatches every time when the Unreal Viewport is visible/hidden.
*/
viewportReady: boolean;
/**
* Dispatches every time when while the configurator loads. Shows showcase status information on a scene.
*/
showcaseStatusChanged: ShowCaseStatus;
/**
* Dispatches at the moment while the configurator loads. Shows status information.
*/
statusMessageChanged: string | null;
/**
* Dispatches every time when Unreal is sending ordered render with new GetScreenshot() command.
*/
screenshotReady: string | null;
/**
* Dispatches every time when Unreal is changing its video stream size.
*/
videoResolutionChanged: VideoResolution;
}
/**
* @hidden
*/
type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads;
/**
* @internal
* This creates all event envelopes defined in MetaBoxAPIPayloads.
*/
interface MetaBoxApiEnvelope<T extends FromMetaBoxApiEvents> {
action: 'bridge';
eventType: T;
payload: FromMetaboxMessagePayloads[T];
}
type MetaboxEnvironment = 'metabox' | 'host';
/**
* @hidden
* @internal
* Used for signaling that the app is loaded and ready to open api.
*/
interface MCAppLoaded {
action: typeof AppLoaded;
eventType?: unknown;
payload: {
appId: string;
version?: string;
};
}
/**
* @internal
* @hidden
* This creates a union of all event envelopes defined in MetaBoxAPIPayloads.
*/
type FromMetaBoxAPIEnvelope = {
[K in keyof FromMetaboxMessagePayloads]: MetaBoxApiEnvelope<K>;
}[keyof FromMetaboxMessagePayloads] | MCAppLoaded;
interface FromMetaBoxMessage {
host: typeof Metabox;
envelope: FromMetaBoxAPIEnvelope;
}
/**
* Base class for commands sent to the Metabox API.
*/
declare class CommandBase {
data: ToMetaBoxMessageEnvelope;
}
/**
* Represents a callback listener for specific message types.
* Used internally by EventDispatcher to store event listeners.
*
* @public
*/
interface Listener {
/** The message type this listener is registered for */
messageType: string;
/** The callback function to execute when a message of the specified type is received */
callback: (data: unknown) => void;
}
/**
* EventDispatcher is a class that manages event listeners and dispatches events to them.
*/
declare class EventDispatcher {
/**
* Storage for callback listeners by message type.
*/
listeners: Listener[];
destroy(key: string): void;
/**
* Adds an event listener for receiving specific types of messages.
*
* @param messageType - The message type to listen for.
* @param callback - The callback function to execute when a message is received.
*/
addEventListener(messageType: string, callback: (data: unknown) => void): this;
/**
* Dispatches an event to all listeners of a specific message type.
*
* @param messageType - The message type.
* @param data - The data associated with the event.
*/
dispatchEvent(messageType: string, data: unknown): this;
/**
* Removes an event listener for a specific type of message.
*
* @param messageType - The message type.
* @param callback - The callback function to remove.
*/
removeEventListener(messageType: string, callback: (data: unknown) => void): this;
}
/**
* Handles messaging between the host page and embedded Metabox content.
* @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate.
*/
declare class Communicator extends EventDispatcher {
/**
* Bound handler for incoming postMessage events.
*/
private binder;
/**
* Constructs a Communicator, replacing any existing instance, and begins listening for messages.
* @internal
*/
constructor(data: MCAppLoaded['payload'], environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>);
/**
* Listens for Metabox to signal readiness, then initializes communicator.
* @param apiReadyCallback - Called with the new Communicator once to the Metabox is loaded.
* @param {MetaboxEnvironment} environment - The environment in which the Communicator is running.
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
*/
static createInstance(apiReadyCallback: (api: Communicator) => void, environment: MetaboxEnvironment, config?: Partial<MetaboxCommandConfig>): void;
/**
* Cleans up resources and stops listening for messages.
*/
destroy(key: string): void;
static clearAll(): void;
static getCommunicator(key: string): {
instance: Communicator;
} | undefined;
/**
* Posts a command to the Metabox iframe.
* @param command - An action command containing data to send.
*/
sendCommandToMetabox<T extends CommandBase>(command: T): void;
/**
* Registers an event listener for messages dispatched by to the Metabox.
* @override
*/
addEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
/**
* Dispatches a typed event to all registered listeners.
* @override
*/
dispatchEvent<T extends FromMetaBoxApiEvents>(messageType: T, data: FromMetaboxMessagePayloads[T]): this;
/**
* Removes a previously registered event listener.
* @override
*/
removeEventListener<T extends FromMetaBoxApiEvents>(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this;
/**
* Filters and dispatches incoming messages from to the Metabox.
* @param {FromMetaBoxApiEvents | 'metaboxData' } messageType - Expected message type for filtering ('metaboxData').
* @param {MessageEvent} event - The postMessage event received on a window.
*/
private handleMessageReceived;
}
/**
* Integrates the Metabox Basic Configurator into the page by injecting an iframe and
* initializing a Communicator instance for host-to-iframe messaging.
*
* @remarks
* - Builds a secure iframe URL using the provided configuratorId and config options.
* - Ensures the resulting URL uses HTTPS and that the target container exists.
* - Removes any previously embedded iframe with id "embeddedContent" before inserting a new one.
*
* @param {string} configuratorId - The Basic Configurator ID (not a full URL). It is appended to
* `https://{domain}/metabox-configurator/basic/{configuratorId}` to form the iframe src.
*
* @param {string} [containerId='embed3DSource'] - The id of the container element where the iframe will be injected.
*
* @param {(api: Communicator) => void} apiReadyCallback - Called when the Communicator instance is created on the host side.
*
* @param {IntegrateMetaboxConfig} config - Optional configuration used to build the iframe URL and initialize the communicator.
* Supported fields:
* - standalone?: boolean — if true, disables Metabox custom template and related logic.
* - introImage?: string — URL to an image shown on the intro screen (added as ?introImage=...).
* - introVideo?: string — URL to a video shown on the intro screen (added as ?introVideo=...).
* - loadingImage?: string — URL to an image displayed while loading (added as ?loadingImage=...).
* - state?: string — Predefined state for configurator for initial loading (added as ?state=...).
* - domain?: string — custom domain for testing (defaults to metabox.3dsource.com). HTTPS is enforced.
*
* @throws Error If configuratorId or containerId are empty strings.
* @throws Error If the computed iframe URL is invalid or does not use HTTPS.
* @throws Error If the container element with the provided id cannot be found.
*
* @example
* import { integrateMetabox } from '@3dsource/metabox-front-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',
* },
* );
*/
declare function integrateMetabox(configuratorId: string, containerId: string | undefined, apiReadyCallback: (api: Communicator) => void, config?: IntegrateMetaboxConfig): void;
/**
* Saves an image by triggering a download.
*
* @remarks
* This function creates an anchor element, sets its `href` attribute to the provided image URL,
* and triggers a click event to initiate a download with the specified filename.
*
* @param {string} imageUrl - The URL of the image to save.
* @param {string} filename - The name of the file to save.
*/
declare function saveImage(imageUrl: string, filename: string): void;
/**
* Sets the URL parameters based on the provided state.
*
* @remarks
* This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object.
*
* @param {Record<string, string>} state - An object containing key-value pairs to set as URL parameters.
*/
declare function setUrlParams(state: Record<string, string>): void;
/**
* Retrieves the URL parameters as an object.
*
* @remarks
* This function parses the current URL's search parameters and returns them as a key-value object.
*
* @returns An object containing the URL parameters.
*/
declare function getUrlParams(): Record<string, string>;
declare const prepareIframeSrc: (configuratorId: string, config?: IntegrateMetaboxConfig) => string;
/**
* Wrapper helper function to use it with rxJs the same as `fromEvent` to listen to events from the Communicator.
* @param {Communicator} target
* @param eventName
*/
declare function fromCommunicatorEvent<T extends FromMetaBoxApiEvents>(target: Communicator, eventName: T): Observable<FromMetaboxMessagePayloads[T]>;
/**
* Represents a command to send Metabox Config to Metabox Basic Configurator.
* @remarks
* Automatically sent when the Communicator instance is ready.
*/
declare class MetaboxConfig extends CommandBase {
/**
* Creates an instance of MetaboxConfig.
* @param {string} appId - The unique identifier for the Communicator Instance
* @param {MetaboxCommandConfig} config - optional initial config: standalone - if true - disable metabox custom template and all logic
*/
constructor(appId: string, config: MetaboxCommandConfig);
}
/**
* Represents a command to get a PDF from Metabox Basic Configurator.
* @remarks
* This class sends a message to the Metabox API to generate a PDF based on the current configuration.
* This action does not require any parameters.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { GetPdf, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new GetPdf());
* };
*/
declare class GetPdf extends CommandBase {
/**
* Creates an instance of GetPdf.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* Represents a command to get a Call To Action Information from Metabox Basic Configurator.
* @remarks
* This class sends a message to the Metabox API to generate Call To Action information based on the current configuration and sends it to the endpoint url from the cta information.
* This action does not require any parameters.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { GetCallToActionInformation, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new GetCallToActionInformation());
* };
*/
declare class GetCallToActionInformation extends CommandBase {
/**
* Creates an instance of GetCallToActionInformation.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* Represents a command to send to unreal and reset camera to initial.
* @remarks
* This class sends a message to the Metabox API to reset the camera on a scene.
* This action does not require any parameters.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { ResetCamera, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new ResetCamera());
* };
*/
declare class ResetCamera extends CommandBase {
/**
* Creates an instance of ResetCamera.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* Represents a command to ApplyZoom and change zoom camera on a scene.
* @remarks
* This class sends a command to the Metabox API to change zoom on a scene.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new ApplyZoom(10));
* api.sendCommandToMetabox(new ApplyZoom(-10));
* };
*/
declare class ApplyZoom extends CommandBase {
/**
* Creates an instance of ApplyZoom.
*
* @param {...number} zoom
*/
constructor(zoom: number);
}
/**
* Represents a command to Init Showcase for a product a scene and start a sequence for the product.
* @remarks
* This class sends a command to the Metabox API to init showcase if the product has a sequence.
* For check this needs to find a showcase property in the current product.
* If this property exists, you can send init showcase command.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* ```typescript
* import { InitShowcase, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new InitShowcase());
* };
*/
declare class InitShowcase extends CommandBase {
/**
* Creates an instance of InitShowcase.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* Represents a command to Play Showcase for a product when it already init, and you call pause, for example, before it.
* @remarks
* This class sends a command to the Metabox API to play showcase for a product if it is already initialized and pause.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { PlayShowcase, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new PlayShowcase());
* };
*/
declare class PlayShowcase extends CommandBase {
/**
* Creates an instance of PlayShowcase.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* @internal
* @hidden
* Represents a command to send Unreal command.
*/
declare class UnrealCommand extends CommandBase {
constructor(payload: object);
}
/**
* Represents a command to Pause Showcase for a product when it already init and play, and you call pause.
* @remarks
* This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and play.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { PauseShowcase, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new PauseShowcase());
* };
*/
declare class PauseShowcase extends CommandBase {
/**
* Creates an instance of PauseShowcase.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* Represents a command to Stop Showcase for a product when it already init, and you want to destroy it.
* @remarks
* This class sends a command to the Metabox API to Stop showcase for a product if it is already initialized.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { StopShowcase, Communicator } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new StopShowcase());
* };
*/
declare class StopShowcase extends CommandBase {
/**
* Creates an instance of StopShowcase.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
/**
* Image format.
* @remarks
* This type represents the allowed image formats.
*/
type MimeType = 'image/png' | 'image/jpeg' | 'image/webp';
/**
* Represents a command to get a screenshot.
*
* **Important**: Invoking this command will buffer it until the viewport is ready. Only then will the request be processed.
*
* @example
* import { GetScreenshot, Communicator, saveImage } from '@3dsource/metabox-front-api';
* window.env3DSource.apiReady = (api: Communicator) => {
* // Listen for events from to the Metabox API
* api.addEventListener('screenshot', (data) => {
* // Process the get screenshot response
* saveImage(data, 'Render.png');
* });
* api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 }));
* };
*/
declare class GetScreenshot extends CommandBase {
/**
* Constructs an instance of GetScreenshot.
* @param {MimeType} mimeType - The output format.
* @param {{ x: number; y: number }} [size] - Optional size in pixels.
*/
constructor(mimeType: MimeType, size?: {
x: number;
y: number;
});
}
/**
* Represents a command to set a product by its ID.
*
* @remarks
* This action sends a message to the Metabox API to set a product using the provided product ID.
*
* @example
* import { SetProduct, Communicator } from '@3dsource/metabox-front-api';
*
* //...Assume that the integration is already implemented
* window.env3DSource.apiReady = (api: Communicator) => {
* api.setCommandToMetaBox(new SetProduct(
* 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3'
* ));
* };
*/
declare class SetProduct extends CommandBase {
/**
* Creates an instance of SetProduct.
*
* @param {string} productId - The product ID.
*/
constructor(productId: string);
}
/**
* Represents a command to set a material by its slot ID and Material ID.
*
* @example
* import { SetProductMaterial, Communicator } from '@3dsource/metabox-front-api';
*
* //...Assume that the integration is already implemented
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new SetProductMaterial(
* 'carpaint',
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
* ));
* };
*/
declare class SetProductMaterial extends CommandBase {
/**
* Creates an instance of SetProductMaterial.
*
* @param {string} slotId - The slot ID.
* @param {string} materialId - The material ID.
*/
constructor(slotId: string, materialId: string);
}
/**
* Represents a command to set the environment by its ID.
*
* @example
* import { SetEnvironment, Communicator } from '@3dsource/metabox-front-api';
*
* //...Assume that the integration is already implemented
* window.env3DSource.apiReady = (api: Communicator) => {
* // Change the environment to '55555555-1234-1234-1234-01234567890'
* api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890'));
* };
*/
declare class SetEnvironment extends CommandBase {
/**
* Creates an instance of SetEnvironment.
*
* @param {string} environmentId - The environment ID.
*/
constructor(environmentId: string);
}
/**
* Represents a command to set an environment material by its slot ID and Material ID.
*
* @example
* import { SetEnvironmentMaterial, Communicator } from '@3dsource/metabox-front-api';
*
* //...Assume that the integration is already implemented
* window.env3DSource.apiReady = (api: Communicator) => {
* api.sendCommandToMetabox(new SetEnvironmentMaterial(
* 'carpaint',
* 'dd829d6e-9200-47a7-8d5b-af5df89b7e91',
* ));
* };
*/
declare class SetEnvironmentMaterial extends CommandBase {
/**
* Creates an instance of SetEnvironmentMaterial.
*
* @param {string} slotId - The slot ID.
* @param {string} materialId - The material ID.
*/
constructor(slotId: string, materialId: string);
}
/**
* Represents a command to toggle the Embedded to the Metabox Menu.
*
* @example
* import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api';
*
* //...Assume that the integration is already implemented
* window.env3DSource.apiReady = (api: Communicator) => {
* api.setCommandToMetaBox(new ShowEmbeddedMenu(true));
* };
*/
declare class ShowEmbeddedMenu extends CommandBase {
/**
* Creates an instance of ShowEmbeddedMenu.
*
* @param {boolean} visible - A flag indicating whether the embedded menu should be visible.
*/
constructor(visible: boolean);
}
/**
* Represents a command to toggle the Unreal Overlay Interface Menu.
*
* @remarks
* This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI.
*
* @example
* import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api';
*
* //...Assume that the integration is already implemented
* window.env3DSource.apiReady = (api: Communicator) => {
* api.setCommandToMetaBox(new ShowOverlayInterface(true));
* };
*/
declare class ShowOverlayInterface extends CommandBase {
/**
* Creates an instance of ShowOverlayInterface.
*
* @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible.
*/
constructor(visible: boolean);
}
/**
* @experimental
* @internal
* @hidden
* @remarks
* Represents a command to watch Unreal callbacks from Unreal engine.
* Can be useful for custom solutions.
*/
declare class WatchCallbacks extends CommandBase {
/**
* Creates an instance of WatchCallbacks.
*
* @remarks
* This constructor does not require any parameters.
*/
constructor();
}
export { AppLoaded, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetPdf, GetScreenshot, InitShowcase, Metabox, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxData, MetaboxDomain, MetaboxHost, PauseShowcase, PlayShowcase, ResetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, WatchCallbacks, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams };
export type { ApplicationDeviceTypes, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxApiAction, FromMetaboxMessagePayloads, IntegrateMetaboxConfig, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };