import { Observable } from 'rxjs'; /** * @internal * @hidden * Core constants used for host-to-iframe communication and URL construction. */ /** * Storage key for the Metabox Communicator instance registry. * * ### What does it unlock? * Constant string identifier for MetaBox version. Used internally to reference the MetaBox system and versioning. * * ### Practical Application * Internal system reference for versioning. * Not needed in front-end application code. * * ### AI Coding Best Practices * Skip in application code. This constant is for internal MetaBox system identification only. * * @internal */ declare const Metabox = "metabox"; /** * Identifier used as the `host` field in postMessage envelopes sent to the iframe. * * ### What does it unlock? * Constant for the MetaBox host connection point. Specifies endpoint for MetaBox connections. * * ### Practical Application * MetaBox endpoint constant. The host the configurator iframe connects to for Unreal Engine pixel streaming. * Not needed in front-end application code. * * ### AI Coding Best Practices * Skip in application code. This constant is for internal MetaBox system identification only. * * @internal */ declare const MetaboxHost = "metaboxHost"; /** * Action string dispatched by the iframe when the configurator app has loaded. * * ### What does it unlock? * Indicates when the application has completed initialization. * * ### Practical Application * App initialization flag variable. Signals when MetaBox has completed loading. Use the viewportReady event * (more reliable) to gate your UI rendering — don't show controls until MetaBox confirms it's ready. * * ### AI Coding Best Practices * Prefer the viewportReady event over this variable: * `api.addEventListener('viewportReady', (ready) => { if(ready) enableUI(); })`. * viewportReady with true value is the reliable signal that MetaBox PixelStreaming is become visible. * * @internal */ declare const AppLoaded = "appLoaded"; /** * Default production domain for the Metabox Basic Configurator. * * ### What does it unlock? * Constant for the standard default MetaBox domain. Used as the primary domain for connecting to MetaBox server. * * ### Practical Application * The base domain used when no override is specified. Override only via IntegrateMetaboxConfig.domain * if connecting to a custom or self-hosted MetaBox instance. * * ### AI Coding Best Practices * Let integrateMetabox() use the default. Override only if needed: * `integrateMetabox(id, container, callback, { domain: 'https://custom.domain.com' })`. * HTTPS is mandatory — HTTP will be rejected. */ /** * @deprecated */ declare const Metabox_V3 = "metabox_v3"; /** * @deprecated */ declare const MetaboxHost_V3 = "metaboxHost_v3"; /** * @deprecated */ declare const AppLoaded_V3 = "appLoaded_v3"; declare const MetaboxDomain = "metabox.3dsource.com"; /** * Base route path appended to the domain when building the configurator iframe URL. * * ### What does it unlock? * Base route URL constant used for loading the configurator. Standard path endpoint for accessing the configurator. * * ### Practical Application * The configurator URL format is: `https://{domain}/metabox-configurator/basic/{configuratorId}`. * Automatically constructed by integrateMetabox(). * * ### AI Coding Best Practices * Let integrateMetabox() handle URL construction. Only reference if building URLs manually * (e.g., QR codes, email links, server-side rendering). */ declare const BasicRouteUrl = "metabox-configurator/basic"; declare const VERSION = "3.0.17"; /** * Configuration options for integrating the Metabox Basic Configurator iframe into a host page. * Passed as the `config` parameter to {@link integrateMetabox}. * * ### What does it unlock? * Configuration interface for initializing the configurator. Passed to integrateMetabox function with settings * like domain, host, and standalone mode. * * ### Practical Application * Config interface for integrateMetabox() initialization. Supports: standalone (boolean — disables all built-in UI), * introImage/introVideo (URLs), loadingImage (URL), state (initial state), domain (HTTPS override). * * ### AI Coding Best Practices * Pass as 4th parameter to integrateMetabox(). Key: `standalone:true` for custom UI builds. loadingImage for branded * loading. domain only if overriding the default MetaBox server. All URLs must be HTTPS. The state field lets you * restore a previously saved configuration. */ interface IntegrateMetaboxConfig { /** If true, disables Metabox custom template and all related logic. */ standalone?: boolean; /** URL to an image displayed while the configurator is loading (added as `?loadingImage=...`). */ loadingImage?: string; /** URL to a video shown on the intro screen (added as `?introVideo=...`). */ introVideo?: string; /** URL to an image shown on the intro screen (added as `?introImage=...`). */ introImage?: string; /** Predefined state for the configurator on initial loading in rison format (see * https://github.com/Nanonid/rison) (added as `?state=...`). */ state?: string; /** Custom domain for testing purposes. Defaults to `metabox.3dsource.com`. HTTPS is enforced. */ domain?: string; } /** * Internal configuration sent to the Metabox Basic Configurator via postMessage. * Used by {@link Communicator} when establishing host-to-iframe communication. * * ### What does it unlock? * Configuration object for MetaBox commands. Contains parameters for command execution and behavior settings. * * ### Practical Application * Configuration object for MetaBox command execution. Contains parameters controlling command behavior and settings. * Used internally by the command dispatch system. * * ### AI Coding Best Practices * Read-only reference — commands use this internally. When building dynamic command systems, refer to individual * command class constructors for their specific parameter requirements rather than this config. */ interface MetaboxCommandConfig { /** If true, disables Metabox custom template and all related logic. */ standalone?: boolean; /** The URL of the host page embedding the configurator. */ hostUrl: string; /** The API version string sent to the configurator for compatibility. */ apiVersion: string; } /** * Registry of all action identifiers that can be sent from the host application to the Metabox Basic Configurator. * Each key maps to a string used as the `action` field in the postMessage envelope. * * ### What does it unlock? * Variable containing all available action names. Interface listing all actions that the configurator supports. * * ### Practical Application * Master action registry object — all supported configurator action names. Invaluable reference for building * admin dashboards, permission systems, or feature-availability displays. * * ### AI Coding Best Practices * Iterate this object to dynamically build action dropdowns, command palettes, or feature checklists in admin tools. * Each key is an action name, value is its description. Excellent reference for AI coding agents to understand * the full command vocabulary available. */ declare const MetaboxBasicConfiguratorActions: { readonly metaboxConfig: "metaboxConfig"; readonly resumeStream: "resumeStream"; 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 showOverlayInterface: "showOverlayInterface"; readonly getCamera: "getCamera"; readonly setCamera: "setCamera"; readonly resetCamera: "resetCamera"; readonly applyZoom: "applyZoom"; readonly initShowcase: "initShowcase"; readonly playShowcase: "playShowcase"; readonly pauseShowcase: "pauseShowcase"; readonly stopShowcase: "stopShowcase"; readonly sendCommandToUnreal: "sendCommandToUnreal"; readonly showMeasurement: "showMeasurement"; readonly hideMeasurement: "hideMeasurement"; }; /** * Union of all action string literals from {@link MetaboxBasicConfiguratorActions}. * * ### What does it unlock? * Type alias for all actions that can be sent to MetaBox. Defines the complete set of command types available. * * ### Practical Application * Type alias enumerating all available outgoing command types. Master list of everything your app can tell MetaBox to do. * Use as a checklist when planning which features to implement. * * ### AI Coding Best Practices * Reference for building command dispatchers or admin tools. Full command set includes all values of * MetaboxBasicConfiguratorActions like: "metaboxConfig" | "setEnvironment" | "setEnvironmentMaterialById" | ... */ 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. * * ### What does it unlock? * Defines payload structures for different types of outgoing messages to MetaBox. Contains data models for various command parameters. * * ### Practical Application * Payload type definitions for all outgoing command types. Defines required and optional fields per command. * Essential TypeScript reference for type-safe command construction. * * ### AI Coding Best Practices * Use as TypeScript type reference for proper typing when building dynamic command dispatchers. * Each key corresponds to a command name and its value defines the expected payload structure. */ interface ToMetaboxMessagePayloads { [MetaboxBasicConfiguratorActions.metaboxConfig]: { appId: string; config: MetaboxCommandConfig; }; [MetaboxBasicConfiguratorActions.setProduct]: { productId: string; }; [MetaboxBasicConfiguratorActions.setEnvironment]: { id: string; }; [MetaboxBasicConfiguratorActions.getPdf]: void; [MetaboxBasicConfiguratorActions.getCallToActionInformation]: 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.getCamera]: void; [MetaboxBasicConfiguratorActions.setCamera]: { camera: CameraCommandPayload; }; [MetaboxBasicConfiguratorActions.resetCamera]: void; [MetaboxBasicConfiguratorActions.applyZoom]: { zoom: number; }; [MetaboxBasicConfiguratorActions.initShowcase]: void; [MetaboxBasicConfiguratorActions.playShowcase]: void; [MetaboxBasicConfiguratorActions.pauseShowcase]: void; [MetaboxBasicConfiguratorActions.stopShowcase]: void; [MetaboxBasicConfiguratorActions.sendCommandToUnreal]: object; } /** * Payload for the {@link SetCamera} command describing the desired camera state in the Unreal scene. * All fields are optional — only the provided values will be applied. * * ### What does it unlock? * Defines the payload structure for camera commands. Contains camera-related parameters passed to SetCamera command. * * ### Practical Application * Read-only interface defining camera parameters: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}), * rotation ({horizontal: yaw, vertical: pitch}), and restrictions (distance/FOV/rotation limits). * Both returned by getCameraResult event and accepted by SetCamera. * * ### AI Coding Best Practices * This interface is bidirectional — returned from GetCamera and accepted by SetCamera. * Capture a camera state via getCameraResult and replay it with SetCamera(payload). * Only include restriction fields you want to enforce; omitted values keep current settings. * In orbit mode, distance limits are relative to the orbit pivot. */ interface CameraCommandPayload { /** Field of a view angle in degrees. */ fov?: number; /** Camera control mode: `'fps'` for first-person or `'orbit'` for orbital rotation around pivot. */ mode?: 'fps' | 'orbit'; /** Camera position in 3D world space. */ position?: { x: number; y: number; z: number; }; /** Camera rotation angles in degrees. */ rotation?: { horizontal: number; vertical: number; }; /** Min/max constraints applied to camera movement, zoom, and rotation. */ restrictions?: { maxDistanceToPivot?: number; maxFov?: number; maxHorizontalRotation?: number; maxVerticalRotation?: number; minDistanceToPivot?: number; minFov?: number; minHorizontalRotation?: number; minVerticalRotation?: number; }; } /** * @internal * @hidden * Envelope wrapping an action and its payload for host-to-Metabox postMessage communication. * * ### What does it unlock? * Envelope structure for outgoing MetaBox messages. Encapsulates messages with protocol headers for transmission. * * ### Practical Application * Protocol envelope for outgoing messages — adds headers for transmission to MetaBox iframe. * Internal to the communication layer, handled automatically by the Communicator. * * ### AI Coding Best Practices * Do not construct manually. The Communicator handles all message wrapping. Only reference this interface * if debugging raw postMessage traffic in browser devtools to diagnose why commands aren't being received. */ interface ToMetaBoxMessageEnvelope { action: ToMetaBoxActions; payload?: ToMetaboxMessagePayload | never; } /** * @internal * @hidden */ type ToMetaboxTarget = 'metabox' | 'child'; /** * @internal * @hidden * Top-level postMessage structure sent from the host to the Metabox iframe. * * ### What does it unlock? * Message interface for sending data to MetaBox. Wraps outgoing commands with necessary protocol information. * * ### Practical Application * Outgoing message format for commands to MetaBox. Wraps commands with protocol information for postMessage delivery. * Handled automatically by Communicator.sendCommandToMetabox() — never construct manually. * * ### AI Coding Best Practices * Do not construct ToMetaBoxMessage objects. Always use `api.sendCommandToMetabox(new CommandName(...))`. * The Communicator wraps your command in the correct message format automatically. */ interface ToMetaBoxMessage { host: typeof MetaboxHost; envelope: ToMetaBoxMessageEnvelope; /** * @deprecated, use envelope instead of payload */ payload: ToMetaBoxMessageEnvelope; target: ToMetaboxTarget; apiVersion: string; } /** * Represents an ecom configurator object with all necessary information about cta. * * ### What does it unlock? * Configuration interface for the embedded MetaBox menu. Specifies settings and behavior for the menu system. * * ### Practical Application * Configuration interface for the e-commerce/CTA system. Received via ecomConfiguratorDataUpdated event. * Defines CTA button settings (label, callback URL) for the built-in or custom purchase workflow. * * ### AI Coding Best Practices * Read-only data — subscribe to ecomConfiguratorDataUpdated to receive. If building custom UI, extract * the CTA label and display it on your own button. The callback URL is where MetaBox POSTs the * configuration data when CTA is triggered. */ 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; /** Represents object typename for the ecom configurator. */ __typename: 'Configurator'; } /** * Represents the call-to-action information for an ecom configurator. * * ### What does it unlock? * Call-to-Action interface. Defines interactive elements and buttons for user actions within the configurator. * * ### Practical Application * Read-only CTA definition containing the label text and action URL configured in MetaBox admin. Received via * ecomConfiguratorDataUpdated event. Use to render custom CTA buttons matching admin-configured actions * (e.g., 'Request Quote', 'Add to Cart'). * * ### AI Coding Best Practices * Subscribe to ecomConfiguratorDataUpdated to receive CTA config. Use the label for button text. * The actual CTA trigger is `api.sendCommandToMetabox(new GetCallToActionInformation())` — which POSTs * the config JSON to the callback URL. The backend returns `{ redirectUrl }`. */ 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; /** Represents object 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. * * ### What does it unlock? * Main data envelope received from MetaBox on every state change. Contains the full configurator * definition, currently selected product, environment, and all material selections. * * ### Practical Application * Delivered as the payload of the `configuratorDataUpdated` event. Use it to build and update custom UI: * read `configurator` for available options, `productId`/`environmentId` for current selections, * and `productMaterialsIds`/`environmentMaterialsIds` for active materials. * * ### AI Coding Best Practices * Subscribe to `configuratorDataUpdated` to receive this on every state change. * Key fields: `configurator` (full definition — parse once for menu building), `productId` (active product), * `productMaterialsIds` (active materials), `environmentId` (active scene), `environmentMaterialsIds` * (scene materials). Rebuild affected UI sections on each update. */ 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. * * ### What does it unlock? * Full configurator definition containing all available products, environments, and metadata. * This is the catalog of everything the configurator supports. * * ### Practical Application * Accessed via `ConfiguratorEnvelope.configurator` from the `configuratorDataUpdated` event. * Use `products` to build product selectors, `environments` to build scene pickers, * and `ctaEnabled` to conditionally show call-to-action buttons. * * ### AI Coding Best Practices * Parse once on first `configuratorDataUpdated` to build menus. The configurator definition * rarely changes — only current selections change between updates. Use `products` array for * product listing, each product's `slots` for material options, and `environments` for scene switching. */ 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; /** Represents object typename for the configurator. */ __typename: 'UniversalConfigurator'; } /** * Represents a product within the universal configurator. * * ### What does it unlock? * Wrapper linking a product to its position and label inside the configurator's product list. * Each entry in `UniversalConfigurator.products` is of this type. * * ### Practical Application * Iterate `UniversalConfigurator.products` to build a product selector. Use `label` for display text, * `productId` to switch products via {@link SetProduct}, and `product` for thumbnails and slot details. * * ### AI Coding Best Practices * Use `productId` (not `product.id`) when calling `new SetProduct(productId)`. * Sort by `position` if rendering a product list to match the order configured in MetaBox admin. */ 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; /** Represents object typename for the product. */ __typename: 'UniversalConfiguratorProduct'; } /** * Represents product details including visual assets and configuration. * * ### What does it unlock? * Interface representing a product in the configurator system. Contains product metadata, components, and configuration options. * * ### Practical Application * Product data model: the base 3D digital twin. Contains product metadata and externalId (SKU) for e-commerce/ERP mapping. * * ### AI Coding Best Practices * Access via configurator data. Use product.externalId to look up pricing, inventory, and specs in external systems * (ERP, PIM, Shopify, etc.). The product represents the underlying 3D asset rendered in the Unreal viewport. */ 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; /** Represents object typename for the product. */ __typename: 'Product'; } /** * Represents a thumbnail image entity with dimensions and URL path. * * ### What does it unlock? * Thumbnail interface representing preview images. Contains image data and metadata for visual representation. * * ### Practical Application * Preview image data: contains URLs and metadata for thumbnails used in product selectors, material swatch pickers, * and environment preview cards. Essential for building visual option pickers. * * ### AI Coding Best Practices * Access thumbnailList arrays from materials, environments, and products. Use URLs directly in img tags. * Implement lazy loading for grids with many options. Consider preloading thumbnails for the currently visible category. */ interface Thumbnail { /** Width of the thumbnail. */ width: number; /** Height of the thumbnail. */ height: number; /** URL path to the thumbnail image. */ urlPath: string; /** Represents object typename (as a string, flexible type). */ __typename: 'Thumbnail'; } /** * Represents a slot within a product that may allow material customization. * * ### What does it unlock? * Represents a material slot. Defines customizable surfaces within a product or environment. * * ### Practical Application * Material slot on a product or environment — represents a customizable surface. Each slot has an id * (used in SetProductMaterial/SetEnvironmentMaterial) and a list of available materials. * Use to build per-surface material pickers. * * ### AI Coding Best Practices * Access slot definitions from product or environment data in the envelope. Each slot's id is the slotId parameter * for SetProductMaterial or SetEnvironmentMaterial. Iterate slot.enabledMaterials to build the swatch picker * for that specific surface. */ 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[]; /** Represents object typename for the slot. */ __typename: 'Slot'; } /** * Represents a metaProperty within a product that may allow business logic customization. * * ### What does it unlock? * Represents metadata properties. May contain custom key-value data set in MetaBox admin. * * ### Practical Application * Represents metadata with properties and hierarchy info. May contain custom key-value data * (pricing hints, availability flags, descriptions) set in MetaBox admin. * * ### AI Coding Best Practices * Check for MetaProperty data in product definitions from the configurator data. Custom metadata can be used for * display purposes — tooltips, pricing, lead times, availability badges. These are set by content teams in MetaBox admin. */ 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; /** Represents object typename for the metaProperty. */ __typename: 'MetaProperty'; } /** * Represents a material that can be applied to a product slot. * * ### What does it unlock? * Describes material characteristics. Contains properties like name, textures, and appearance attributes. * * ### Practical Application * Material data model: id (UUID), title (display name), externalId (SKU for ERP mapping), and thumbnailList * (swatch preview images). Use to build material/finish pickers with visual swatches and to map selections * to external product systems. * * ### AI Coding Best Practices * Access material data from product slot definitions in configuratorDataUpdated. Use title for labels, * thumbnailList for swatch images, externalId to map to your PIM/ERP for pricing and inventory. * Pass material.id to SetProductMaterial or SetEnvironmentMaterial. */ 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. */ /** Represents object typename for the material. */ __typename: 'Material'; } /** * Details showcase the presentation of a product. * * ### What does it unlock? * Interface for showcase/demo mode features. Defines properties for timeline-based presentation of the configurator state. * * ### Practical Application * Showcase/demo animation data. Defines camera animation sequences for auto-playing product presentations — * timeline-based with camera movements, transitions, and durations. * * ### AI Coding Best Practices * Check if products have associated showcase data before enabling demo playback buttons. Use showcase metadata * (duration, slot count) to build custom timeline controls. Playback sequence: InitShowcase → PlayShowcase → monitor * via showcaseStatusChanged. */ interface Showcase { /** A list of low-bandwidth versions for the showcase (optional). */ lowBandwidth?: (Timecode | null)[] | null; /** Duration for the showcase (optional). */ duration?: number; /** Represents object typename for the showcase. */ __typename: 'Showcase'; } /** * Represents a low-bandwidth entity used in showcases in LBM mode. * * ### What does it unlock? * Timecode interface for showcase timeline management. Tracks timing and playback position information. * * ### Practical Application * Playback position tracking for showcase animations. Contains current timestamp within the animation timeline. * Use for building progress bars, time displays, or syncing external content to showcase playback. * * ### AI Coding Best Practices * Access timecode data from showcase status events during playback. Use to update progress indicators in custom playback UIs. * Combine with showcaseStatusChanged to build full media player controls for product demo presentations. */ interface Timecode { /** Time marker for the entity. */ time: number; /** Duration of the entity display. */ duration: number; /** Represents object 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; /** Represents object typename for the environment. */ __typename: 'UniversalConfiguratorEnvironment'; } /** * Represents an environment with associated media and configuration. * * ### What does it unlock? * Internal interface for environment data model used by MetaBox. * * ### Practical Application * Environment data model: id, title, udsEnabled (dynamic sky toggle), sunNorthYaw, udsHour (time of day for dynamic sky), * thumbnailList (preview images), and slots (configurable material slots). Use to build environment/scene picker UIs. * * ### AI Coding Best Practices * Access environment definitions from the configuratorDataUpdated envelope. Use thumbnailList for preview cards. * Check udsEnabled to know if time-of-day controls are available. Iterate slots array to build environment material pickers. */ 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; /** Represents object 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. * * ### What does it unlock? * Type alias representing selected item IDs. Used to track which entities are currently selected in the configurator UI. * * ### Practical Application * Record type (key-value map) tracking currently selected IDs. Found in the configurator envelope. * Maps slot or type keys to selected material/product UUIDs. * * ### AI Coding Best Practices * Access from configuratorDataUpdated envelope. Use to mark 'active/selected' state on material swatches in your UI. * Updates on every state change. */ type SelectedIds = Record>; /** * Defines the structure for an available showcase status for the current product on a scene. * * ### What does it unlock? * Type alias for showcase status states. Defines possible states of showcase/timeline playback. * * ### Practical Application * Type alias: 'init' | 'play' | 'pause' | 'stop'. Received via showcaseStatusChanged event. * Use to conditionally render playback controls and toggle configurator interactivity during demos. * * ### AI Coding Best Practices * Subscribe to showcaseStatusChanged and switch UI state: 'play' → show pause button, disable config controls; * 'pause' → show play/stop buttons; 'stop' → show play button, re-enable all config controls. */ type ShowCaseStatus = 'init' | 'play' | 'pause' | 'stop'; /** * Defines the structure for a video resolution. * * ### What does it unlock? * Defines video resolution settings for the configurator display. Specifies viewport dimensions and rendering parameters. * * ### Practical Application * Video resolution interface: {width: number|null, height: number|null}. Received via videoResolutionChanged event * when the pixel stream resolution changes. Use for responsive layout adjustments or displaying stream quality info. * * ### AI Coding Best Practices * Subscribe to videoResolutionChanged to monitor stream resolution. Use to dynamically adjust UI overlay positioning, * inform users about stream quality, or scale screenshot size requests proportionally. */ interface VideoResolution { width: number | null; height: number | null; } /** * Maps event names received from the Metabox iframe to their typed payloads. * Used by {@link Communicator.addEventListener} to provide type-safe event subscriptions. * * ### What does it unlock? * Message format for MetaBox communication protocol. Wraps data for transmission between API and MetaBox. * * ### Practical Application * Payload type map for all incoming event types. Defines the data shape for each event name * (configuratorDataUpdated, screenshotReady, viewportReady, etc.). Essential TypeScript reference for properly typing event handlers. * * ### AI Coding Best Practices * Use as TypeScript type reference: `api.addEventListener('configuratorDataUpdated', (data: FromMetaboxMessagePayloads['configuratorDataUpdated']) => {...})`. * Key events and their types: configuratorDataUpdated→ConfiguratorEnvelope, screenshotReady→string|null, * viewportReady→boolean, showcaseStatusChanged→ShowCaseStatus. */ 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 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 an ordered render with a new GetScreenshot() command. */ screenshotReady: string | null; /** * Dispatches every time when Unreal is changing its video stream size. */ videoResolutionChanged: VideoResolution; /** * Dispatches every time when the User sends get camera command new GetCamera() command. */ getCameraResult: CameraCommandPayload; /** * @deprecated * Dispatches every time when the configurator connected/disconnected with Unreal Engine. */ dataChannelConnected: boolean; } /** * Union of all event names received from MetaBox. * * ### What does it unlock? * Type alias for MetaBox API actions coming from the server. Defines all possible action types. * * ### Practical Application * Type alias enumerating all possible incoming action/event types from MetaBox. Reference as a complete * checklist of subscribable events for building comprehensive event handling. * * ### AI Coding Best Practices * Use as a reference for all valid event names in api.addEventListener(). Key events: * configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged, getCameraResult, * statusMessageChanged, ecomConfiguratorDataUpdated, videoResolutionChanged. * * @hidden */ type FromMetaBoxApiEvents = keyof FromMetaboxMessagePayloads; /** * @internal * This creates all event envelopes defined in MetaBoxAPIPayloads. * * ### What does it unlock? * Envelope structure for wrapping MetaBox API messages. Encapsulates commands and data for transmission. * * ### Practical Application * Protocol envelope structure wrapping all MetaBox API messages. Internal to the communication layer — adds * routing and protocol headers. The Communicator handles this automatically. * * ### AI Coding Best Practices * For debugging: inspect postMessage events in browser devtools and match * against this structure to diagnose malformed messages. The Communicator handles all wrapping/unwrapping. */ interface MetaBoxApiEnvelope { action: 'bridge'; eventType: T; payload: FromMetaboxMessagePayloads[T]; } /** * Identifies which side of the iframe boundary the Communicator is running on. * * ### What does it unlock? * Distinguishes which side of the postMessage channel the Communicator is operating on — * `'host'` for the embedding page and `'metabox'` for the iframe. * * ### Practical Application * Used internally by the Communicator to tag outgoing messages so the receiving side can verify their origin. * You never need to set or check this value in application code. * * ### AI Coding Best Practices * Skip in application code. The Communicator sets this automatically based on the `createInstance()` call. * Only relevant if debugging raw postMessage traffic between your page and the MetaBox iframe. */ 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; }[keyof FromMetaboxMessagePayloads] | MCAppLoaded; /** * @internal * @hidden */ type FromMetaboxTarget = 'parent' | 'communicator'; /** * @internal * @hidden * Top-level postMessage structure received from the Metabox iframe. * * ### What does it unlock? * Represents the Top-level postMessage structure received from the Metabox iframe. Contains read-only data. * * ### Practical Application * Incoming message wrapper from MetaBox. Defines how MetaBox wraps response data for postMessage delivery. * Internal to communication layer — the Communicator parses these automatically. * * ### AI Coding Best Practices * Do not parse these manually. The Communicator handles unwrapping and delivers typed payloads to your event listeners. * Only reference if debugging raw postMessage traffic in browser devtools. */ interface FromMetaBoxMessage { host: typeof Metabox; envelope: FromMetaBoxAPIEnvelope; target: FromMetaboxTarget; } /** * Base class for commands sent to the Metabox API. * * ### What does it unlock? * Base class that all other commands inherit from in a class hierarchy. Provides common properties * and methods that are automatically available to all command subclasses. * * ### Practical Application * Base class all commands inherit from. Never instantiate directly — use specific subclasses like * SetProduct, SetCamera, etc. All commands are sent via `api.sendCommandToMetabox(new CommandName(...))`. * * ### AI Coding Best Practices * Never construct a generic CommandBase. Always use the specific typed command class. When generating * dynamic command dispatch, use a switch/map pattern matching command names to their constructors. * * @internal * @hidden */ declare class CommandBase { /** The message envelope populated by subclass constructors and sent via {@link Communicator.sendCommandToMetabox}. */ data: ToMetaBoxMessageEnvelope; } /** * Represents a callback listener for specific message types. * Used internally by EventDispatcher to store event listeners. * * ### What does it unlock? * Event listener interface. Allows subscription to specific events from the configurator to receive real-time data updates. * * ### Practical Application * Event listener interface. addEventListener() and removeEventListener() on Communicator. Subscribe to real-time * configurator events: state changes, viewport readiness, screenshots, showcase status, camera results, resolution changes. * * ### AI Coding Best Practices * Set up listeners BEFORE sending commands that trigger them. Always clean up with removeEventListener on component unmount. * Key events: configuratorDataUpdated (every state change), viewportReady (init complete), screenshotReady (captures), * getCameraResult (camera queries), showcaseStatusChanged (demo playback). * * @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. * * ### What does it unlock? * Parent class of Communicator that dispatches commands. Acts as an event dispatcher that routes command messages internally. * * ### Practical Application * Internal event routing layer — parent class of Communicator. Routes postMessage commands between your app * and the Unreal Engine pixel stream. Not used directly but understanding it helps debug message delivery issues. * * ### AI Coding Best Practices * Do not reference or extend EventDispatcher in application code. Use only the Communicator interface methods. * If debugging communication failures, check browser console for postMessage errors related to this layer. */ declare class EventDispatcher { /** * Storage for callback listeners by message type. */ listeners: Listener[]; /** * Removes all registered listeners. Subclasses override this to perform additional cleanup. * @param key - Instance key (used by subclass overrides for registry cleanup). */ destroy(key: string): void; /** * Adds an event listener for receiving specific types of messages. * * @param {string} 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 {string} 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 {string} 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. * * ### What does it unlock? * Internal class that creates a proxy/communication layer between the API and MetaBox. * Handles reading and sending commands through the established connection. * * ### Practical Application * The API handle returned in the integrateMetabox callback. Provides sendCommandToMetabox() to send commands, * and addEventListener()/removeEventListener() for event subscriptions. This is your entire interface to * the MetaBox Unreal Engine stream. * * ### AI Coding Best Practices * Store the Communicator reference from the apiReadyCallback in a module-scoped variable or state store. * NEVER send commands before this callback fires. All commands and event listeners go through this single * api object. Clean up listeners with removeEventListener on component unmount. * * @internal Use {@link Communicator.createInstance} or the {@link integrateMetabox} helper to instantiate. */ declare class Communicator extends EventDispatcher { /** * Singleton reference to the current communicator instance. */ static instance: Communicator | null; /** * 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); /** * Listens for Metabox to signal readiness, then initializes communicator. * @param apiReadyCallback - Called with the new Communicator once 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): void; /** * Cleans up resources and stops listening for messages. */ destroy(key: string): void; /** Destroys all active Communicator instances and clears the internal registry. */ static clearAll(): void; /** * Retrieves a registered Communicator instance by its key. * @param key - The composite key (`version_environment_appId`) identifying the instance. */ static getCommunicator(key: string): { instance: Communicator; } | undefined; /** * Posts a command to the Metabox iframe. * @param command - An action command containing data to send. */ sendCommandToMetabox(command: T): void; /** * Registers an event listener for messages dispatched by the Metabox. * @param messageType - The event name to listen for (e.g. `'configuratorDataUpdated'`). * @param callback - Handler invoked with the typed payload when the event fires. * @override */ addEventListener(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this; /** * Dispatches a typed event to all registered listeners. * @param messageType - The event name to dispatch. * @param data - The payload to pass to each listener. * @override */ dispatchEvent(messageType: T, data: FromMetaboxMessagePayloads[T]): this; /** * Removes a previously registered event listener. * @param messageType - The event name the listener was registered for. * @param callback - The same function reference that was passed to {@link addEventListener}. * @override */ removeEventListener(messageType: T, callback: (data: FromMetaboxMessagePayloads[T]) => void): this; /** * Filters and dispatches incoming messages from the Metabox. * @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. * * - 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. * * ### What does it unlock? * Main initialization function for MetaBox integration. Initializes the configurator, receives an API handle, * and sets up all configurations. * * ### Practical Application * 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 (UUID), * containerId (DOM element ID, default 'embed3DSource'), apiReadyCallback, config (IntegrateMetaboxConfig). * * ### AI Coding Best Practices * Pattern: `integrateMetabox('uuid', 'div-id', (api) => { * setup listeners, then set product, then environment * }, { standalone: true })`. * Ensure container div exists in DOM with non-zero dimensions. HTTPS required. * Inside callback: 1) addEventListener for configuratorDataUpdated, 2) SetProduct, 3) SetEnvironment. * * @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 - 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, apiReadyCallback: (api: Communicator) => void, config?: IntegrateMetaboxConfig): void; /** * Saves an image by triggering a download. * * 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. * * ### What does it unlock? * Main exported function to save images from the configurator. Converts base64 image data to actual image * files and saves them to the local filesystem. * * ### Practical Application * Exported utility function that converts base64 screenshot data (from screenshotReady event) to a downloadable * image file. Handles the base64 → blob → browser download flow. Import directly from the API package. * * ### AI Coding Best Practices * Pattern: `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'config-screenshot.png'); })`. * Filename extension should match the MimeType passed to GetScreenshot. * Import: `import { saveImage } from '@3dsource/metabox-front-api'`. * * @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. * * @internal * @hidden * This function updates the current URL by replacing its search parameters with the key-value pairs from the provided state object. * * @param {Record} state - An object containing key-value pairs to set as URL parameters. */ declare function setUrlParams(state: Record): void; /** * Retrieves the URL parameters as an object. * * @remarks * @internal * @hidden * 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; /** * Constructs the iframe source URL for the Metabox Basic Configurator. * * ### What does it unlock? * Utility function that prepares the iframe source URL. Constructs the proper URL with parameters * for loading the MetaBox configurator. * * ### Practical Application * Utility function that constructs the iframe source URL with proper parameters. * URL format: `https://{domain}/metabox-configurator/basic/{configuratorId}`. * Called internally by integrateMetabox() — use directly only for manual URL construction. * * ### AI Coding Best Practices * Usually called internally. Use directly only for pre-constructing embed URLs (QR codes, email links, * preview URLs). Verify output is HTTPS. Remember basic configurators use `/basic/` path. * * @internal * @hidden * * @param {string} configuratorId - An string identifier for the configurator. * @param {IntegrateMetaboxConfig} config - An object containing the configuration options. */ declare const prepareIframeSrc: (configuratorId: string, config?: IntegrateMetaboxConfig) => string; /** * Wrapper helper function to use with RxJS the same way as `fromEvent`, to listen to events from the Communicator. * * ### What does it unlock? * Function that creates an event listener subscription. Allows developers to subscribe to specific events from the Communicator. * * ### Practical Application * Function that creates event listener subscriptions. Alternative to api.addEventListener() — both subscribe * to configurator events. Use to react to state changes, screenshot readiness, viewport loading, showcase status, etc. * * ### AI Coding Best Practices * Prefer api.addEventListener() directly from the Communicator object. If using fromCommunicatorEvent, pass the * event name and handler. Key events: configuratorDataUpdated, viewportReady, screenshotReady, showcaseStatusChanged, * getCameraResult. Always subscribe BEFORE sending commands that trigger responses. * * @param {Communicator} target - The Communicator instance to listen on. * @param {T} eventName - The event name from {@link FromMetaBoxApiEvents} to subscribe to. * @returns An Observable that emits the typed payload each time the event fires. * @internal */ declare function fromCommunicatorEvent(target: Communicator, eventName: T): Observable; /** * Represents a command to send Metabox Config to Metabox Basic Configurator. * * ### What does it unlock? * Configuration object passed to MetaBox during initialization. Specifies domain, host, standalone mode, * and other parameters that control how the configurator behaves. * * ### Practical Application * Internal configuration object auto-sent during initialization. Contains appId and config. * DO NOT call directly — integrateMetabox() handles this automatically as part of its setup sequence. * * ### AI Coding Best Practices * NEVER instantiate or send MetaboxConfig manually. It is auto-sent by integrateMetabox(). * Use the IntegrateMetaboxConfig parameter of integrateMetabox() instead for setting domain, standalone, * loadingImage, introImage, state, etc. * * @internal * Automatically sent when the Communicator instance is ready. * * @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 */ declare class MetaboxConfig extends CommandBase { constructor(appId: string, config: MetaboxCommandConfig); } /** * Represents a command to get a PDF from Metabox Basic Configurator. * This class sends a message to the Metabox API to generate a PDF based on the current configuration. * **Important**: No need to listen to any events to see changes. Pdf will be downloaded automatically once it's ready. * * ### What does it unlock? * Generates a native MetaBox PDF document. No subscription required — it executes independently. * * ### Practical Application * Generates a branded PDF from the current configurator state server-side. No event subscription needed. * Use for B2B quote workflows, downloadable spec sheets, or emailing configured product summaries to prospects. * * ### AI Coding Best Practices * Simply call `api.sendCommandToMetabox(new GetPdf())`. No parameters or event subscription required. * The PDF generates inside MetaBox application. * * @example * import { GetPdf, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * * api.sendCommandToMetabox(new GetPdf()); * }; */ declare class GetPdf extends CommandBase { constructor(); } /** * Represents a command to get a Call To Action Information from Metabox Basic Configurator. * 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. * * To listen for changes after sending this command, listen to the 'ecomConfiguratorDataUpdated' event. * * ### What does it unlock? * Retrieves information about call-to-action that were added to the configurator. Requires subscription to receive data. * * ### Practical Application * Triggers the CTA (Call-to-Action) workflow configured in MetaBox admin. The CTA label and callback URL are set in admin. * When invoked, MetaBox POSTs the full configuration JSON (including BOM) to your callback URL endpoint, which returns a { redirectUrl }. * * ### AI Coding Best Practices * Call only after user completes configuration. Subscribe to ecomConfiguratorDataUpdated to get CTA label/URL for building * custom CTA buttons in your UI. The POST payload includes the full bill of materials — your backend endpoint processes it * and returns a redirect URL. * * @example * import { Communicator, EcomConfigurator,GetCallToActionInformation } 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('ecomConfiguratorDataUpdated', (data:EcomConfigurator) => { * console.log('Ecom configurator params:', data); * }); * * Send the command to get Call To Action information from Metabox Basic Configurator * api.sendCommandToMetabox(new GetCallToActionInformation()); * }; */ declare class GetCallToActionInformation extends CommandBase { constructor(); } /** * Represents a command to get the camera configuration from Unreal. * This class sends a message to the Metabox API to get the camera from a scene. * To listen for changes after sending this command, listen to the 'getCameraResult' event. * * ### What does it unlock? * Retrieves camera presets for the configurator; allowing extraction and application of saved camera positions. * * ### Practical Application * Requests current camera state — returns asynchronously via the getCameraResult event. Returns a CameraCommandPayload * with fov, mode, position, rotation, and restrictions. Use to save camera positions, create shareable view links, * or build 'save this angle' features. * * ### AI Coding Best Practices * ALWAYS subscribe to getCameraResult BEFORE calling GetCamera(). Pattern: `api.addEventListener('getCameraResult', handler);` * then `api.sendCommandToMetabox(new GetCamera())`. The returned CameraCommandPayload can be fed directly back into * SetCamera to restore the view. * * @example * import { Communicator, CameraCommandPayload,GetCamera } 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('getCameraResult', (data:CameraCommandPayload) => { * console.log('Camera params after get camera command:', data); * }); * * api.sendCommandToMetabox(new GetCamera()); * }; */ declare class GetCamera extends CommandBase { constructor(); } /** * Represents a command to set the camera configuration. * This class sends a message to the Metabox API to set the camera on a scene. * **Important**: No need to listen to any events to see changes. * * ### What does it unlock? * Sets camera presets with restriction parameters (FOV, rotation, position). * * ### Practical Application * Sets camera with precise control: fov (degrees), mode ('orbit'|'fps'), position ({x,y,z}), * rotation ({horizontal,vertical}), and restrictions (min/max distance, FOV, rotation bounds). * Use for guided tours, preset view buttons, or restricting camera to prevent users seeing behind the product. * * ### AI Coding Best Practices * Only include fields you want to change — omitted values keep current settings. Use orbit mode for typical product viewing, * fps for walkthrough/room scenes. Apply restrictions to prevent bad angles. Full interface: * `{fov?, mode?, position?, rotation?, restrictions?}`. * * @example * import { SetCamera, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new SetCamera({ * fov: 45, * mode: 'orbit', * position: { x: 100, y: 100, z: 100 }, * rotation: { horizontal: 0, vertical: 0 }, * restrictions: { * maxDistanceToPivot: 0, * maxFov: 0, * maxHorizontalRotation: 0, * maxVerticalRotation: 0, * minDistanceToPivot: 0, * minFov: 0, * minHorizontalRotation: 0, * minVerticalRotation: 0, * }, * })); * }; * * @param {CameraCommandPayload} camera - The camera configuration. */ declare class SetCamera extends CommandBase { constructor(camera: CameraCommandPayload); } /** * Represents a command to reset the camera to its initial position. * This class sends a message to the Metabox API to reset the camera on a scene. * * ### What does it unlock? * Resets the camera to its default state and position. Used to return camera to initial configuration after user manipulation. * * ### Practical Application * Resets camera to the default position defined in the product/environment template. Essential for 'Reset View' buttons. * Also, useful after programmatic camera moves to return to a known starting state. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new ResetCamera())`. No parameters. Restores template defaults — not the last user position. * Good practice to call after SetProduct changes that may shift the focal point. * * @example * import { ResetCamera, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new ResetCamera()); * }; */ declare class ResetCamera extends CommandBase { constructor(); } /** * Represents a command to apply zoom and change the camera zoom on a scene. * This class sends a command to the Metabox API to change zoom on a scene. * * ### What does it unlock? * Controls zoom functionality for the configurator; allowing users to adjust the zoom level of 3D objects and camera presets. * * ### Practical Application * Implements programmatic zoom on the pixel-streamed viewport. Use to build zoom slider controls, pinch-to-zoom on mobile, * or 'zoom to detail' buttons. Takes a numeric delta: positive zooms in, negative zooms out * (e.g., ApplyZoom(50) zooms in, ApplyZoom(-50) zooms out). * * ### AI Coding Best Practices * Always use numeric delta values, not absolute zoom levels. Pair with a UI slider that sends incremental values. * Debounce zoom input to ~100ms intervals to prevent overwhelming the Unreal stream. * Pattern: `api.sendCommandToMetabox(new ApplyZoom(50))`. * * @example * import { ApplyZoom, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new ApplyZoom(50)); * }; * * @param {number} zoom - The zoom value to apply. */ declare class ApplyZoom extends CommandBase { constructor(zoom: number); } /** * @remarks * Represents a command to initialize Showcase for a product scene and start a sequence for the product. * This class sends a command to the Metabox API to initialize showcase if the product has a sequence. * To check this, find the showcase property in the current product and listen to the 'configuratorDataUpdated' event. * If this property exists, you can send the init showcase command. * * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event. * * ### What does it unlock? * Initializes and displays the showcase/demo view for the configurator. Used when transitioning into presentation or demo mode. * * ### Practical Application * Loads the showcase/animation sequence attached to the current product. Must be called BEFORE PlayShowcase. * Use to initialize auto-playing product demos, trade show presentations, or hero section animations on landing pages. * * ### AI Coding Best Practices * ALWAYS call InitShowcase() before PlayShowcase(). Required sequence: InitShowcase → PlayShowcase → PauseShowcase/StopShowcase. * Subscribe to showcaseStatusChanged to track playback state ('playing'/'paused'/'stopped'). * * @example * import { Communicator,ShowCaseStatus,InitShowcase } 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('showcaseStatusChanged', (data:ShowCaseStatus) => { * console.log('Showcase status value after changed:', data); * }); * * api.sendCommandToMetabox(new InitShowcase()); * }; */ declare class InitShowcase extends CommandBase { constructor(); } /** * Represents a command to play Showcase for a product when it is already initialized and paused. * This class sends a command to the Metabox API to play showcase for a product if it is already initialized and paused. * * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event. * * ### What does it unlock? * Starts or resumes the showcase/timeline playback. Executes the internal MetaBox play command internally. * * ### Practical Application * Starts or resumes showcase playback. Use for 'Play Demo' buttons on landing pages, auto-play on page load, * or resuming demos after inactivity timeout on kiosk displays. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new PlayShowcase())`. Must call InitShowcase() first or it won't play. * Subscribe to showcaseStatusChanged to track state. Auto-play pattern: wait for viewportReady → InitShowcase → * PlayShowcase. * * @example * import { Communicator,PlayShowcase } 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('showcaseStatusChanged', (data) => { * console.log('Showcase status value after changed:', data); * }); * * api.sendCommandToMetabox(new PlayShowcase()); * }; */ declare class PlayShowcase extends CommandBase { constructor(); } /** * @internal * @hidden * Represents a command to send Unreal command. * * @param {Object} payload - An raw command that will be sent into MetaBox Unreal Application. */ declare class UnrealCommand extends CommandBase { constructor(payload: object); } /** * Represents a command to pause Showcase for a product when it is already initialized and playing. * This class sends a command to the Metabox API to pause showcase for a product if it is already initialized and playing. * * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event. * * ### What does it unlock? * Pauses the showcase/timeline playback. Can be called independently without requiring any flag parameters. * * ### Practical Application * Pauses showcase animation playback. The showcase remains initialized and can be resumed with * PlayShowcase. Use when you need to temporarily freeze the animation (e.g., on a "Pause" button click). * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new PauseShowcase())`. No parameters. Subscribe to showcaseStatusChanged * to confirm 'pause' state. Use PlayShowcase to resume or StopShowcase to reset. * * @example * import { Communicator,ShowCaseStatus,PauseShowcase } 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('showcaseStatusChanged', (data:ShowCaseStatus) => { * console.log('Showcase status value after changed:', data); * }); * * api.sendCommandToMetabox(new PauseShowcase()); * }; */ declare class PauseShowcase extends CommandBase { constructor(); } /** * Represents a command to stop Showcase for a product when it is already initialized, and you want to destroy it. * This class sends a command to the Metabox API to stop showcase for a product if it is already initialized. * * To listen for changes after sending this command, listen to the 'showcaseStatusChanged' event. * * ### What does it unlock? * Stops the showcase/timeline playback and closes the showcase mode. Returns to normal configurator view. * * ### Practical Application * Stops showcase playback and exits showcase mode entirely. Returns to normal interactive configurator view. * Use for 'Exit Demo' buttons or auto-trigger when the user starts actively configuring the product. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new StopShowcase())`. Fully resets the showcase state. Subscribe to * showcaseStatusChanged to confirm 'stopped' status. After stopping, the configurator returns to full * interactive mode — re-enable configuration controls. * * @example * import { Communicator,ShowCaseStatus } 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('showcaseStatusChanged', (data:ShowCaseStatus) => { * console.log('Showcase status value after changed:', data); * }); * * api.sendCommandToMetabox(new StopShowcase()); * }; */ declare class StopShowcase extends CommandBase { constructor(); } /** * Image format. * This type represents the allowed image formats. * * ### What does it unlock? * Type alias for MIME types used in file/media handling. Defines supported file formats and media types. * * ### Practical Application * Type alias: 'image/png' | 'image/jpeg' | 'image/webp'. Used as the format parameter in GetScreenshot. * PNG for quality/transparency, JPEG for smaller files, WebP for modern browser optimization. * * ### AI Coding Best Practices * Pass as first param to GetScreenshot: `new GetScreenshot('image/png', {x:2048, y:2048})`. * Use PNG for highest quality and transparency. JPEG for smaller file size. WebP for modern browser optimization. * Match the saveImage filename extension to the format. */ type MimeType = 'image/png' | 'image/jpeg' | 'image/webp'; /** * Represents a command to get a screenshot. * * To listen for changes after sending this command, listen to the 'screenshot' event before command is sent. * * ### What does it unlock? * Takes a screenshot on the server side (Unreal Engine) of the 3D scene. Returns high-quality image. * Requires subscription to the screenshotReady event to receive the rendered image. * * ### Practical Application * Renders a high-res screenshot on the Unreal Engine server. Takes format ('image/png'|'image/jpeg'|'image/webp') * and optional size ({x, y}). Returns base64 data via screenshotReady event. Use for thumbnails, social sharing, * saving config snapshots, or attaching images to quotes. * * ### AI Coding Best Practices * Subscribe to screenshotReady BEFORE sending GetScreenshot. Pattern: * `api.addEventListener('screenshotReady', (data) => { if(data) saveImage(data, 'name.png'); })`. * Specify size for consistent outputs: `new GetScreenshot('image/png', {x:2048, y:2048})`. * Use saveImage() helper to convert base64 to downloadable file. * * @example * import { Communicator,saveImage,GetScreenshot } 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('screenshot', (data:string) => { * // The data is a base64 string of the image. You can use it to display the image or save it as a file. * console.log('Get screenshot here:', data); * saveImage(data, 'Render.png'); * }); * * api.sendCommandToMetabox(new GetScreenshot('image/png', { x: 1024, y: 1024 })); * }; * * @param {MimeType} mimeType - The output format. * @param {{ x: number; y: number }} [size] - Optional size in pixels. */ declare class GetScreenshot extends CommandBase { constructor(mimeType: MimeType, size?: { x: number; y: number; }); } /** * Represents a command to set a product by its ID. * This action sends a message to the Metabox API to set a product using the provided product ID. * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event. * * ### What does it unlock? * Sets the active product in the Basic Configurator by its UUID. Triggers a full state update including * available materials, slots, showcase data, and environment compatibility. * * ### Practical Application * Selects which product to display in the 3D viewport. Takes a productId (UUID). Use to build product picker UIs, * deep-link to specific products, or switch products programmatically based on external catalog selections. * The configurator responds with a full ConfiguratorEnvelope via configuratorDataUpdated. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new SetProduct('product-uuid'))`. Get valid product IDs from * `configurator.products` in the configuratorDataUpdated envelope. Subscribe to configuratorDataUpdated * BEFORE sending the command. After switching products, material and environment selections may reset — * re-apply them if needed. * * @example * import { Communicator,ConfiguratorEnvelope } 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 product:', data); * }); * * api.sendCommandToMetabox(new SetProduct( * 'ffea6b5c-3a8a-4f56-9417-e605acb5cca3' * )); * }; * * @param {string} productId - The product ID. */ declare class SetProduct extends CommandBase { constructor(productId: string); } /** * Represents a command to set a material by its slot ID and Material ID. * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event. * * ### What does it unlock? * Sets a material variant for a product slot. Simulates selecting a different material/finish from the menu * for a specific customizable surface on the product. * * ### Practical Application * Applies a material to a specific slot on the active product. Takes slotId (string) and materialId (UUID). * Use to build swatch pickers, apply preset themes/bundles, or sync material selections from an external * PIM/ERP system via externalId mapping. * * ### AI Coding Best Practices * Get valid slotId and materialId values from the product's slot definitions in the configuratorDataUpdated envelope — * check `product.slots` and each slot's `enabledMaterials` list. Pattern: * `new SetProductMaterial('slot-name', 'material-uuid')`. The referenced product must already be set. * * @example * import { Communicator,ConfiguratorEnvelope,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 material:', data); * }); * * api.sendCommandToMetabox(new SetProductMaterial( * 'carpaint', * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91', * )); * }; * * @param {string} slotId - The slot ID. * @param {string} materialId - The material ID. */ declare class SetProductMaterial extends CommandBase { constructor(slotId: string, materialId: string); } /** * Represents a command to set the environment by its ID. * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event. * * ### What does it unlock? * Sets environmental/lighting settings for the scene. Controls factors like lighting conditions and environmental appearance. * * ### Practical Application * Changes the 3D scene/environment (studio, showroom, outdoor, etc.). Takes an environmentId UUID. * Environments include lighting, backdrop, and optionally dynamic sky (udsEnabled) with time-of-day (udsHour) control. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new SetEnvironment('env-uuid'))`. Get valid environment IDs from the configurator * definition in configuratorDataUpdated. Set environment after product during initialization. Each environment has * its own material slots, thumbnails, and lighting properties. * * @example * import { Communicator,ConfiguratorEnvelope } 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 environment:', data); * }); * * api.sendCommandToMetabox(new SetEnvironment('55555555-1234-1234-1234-01234567890')) * }; * * @param {string} environmentId - The environment ID. */ declare class SetEnvironment extends CommandBase { constructor(environmentId: string); } /** * Represents a command to set an environment material by its slot ID and Material ID. * To listen for changes after sending this command, listen to the 'configuratorDataUpdated' event. * * ### What does it unlock? * Sets environmental material properties such as textures and appearance attributes for the scene environment. * * ### Practical Application * Applies materials to environment slots (floor, walls, backdrop textures). Takes slotId and materialId. * Use for scene-based configurators where the environment is also customizable — kitchen visualizers, * room planners, trade show booth designers. * * ### AI Coding Best Practices * Pattern: `new SetEnvironmentMaterial('floor-slot-id', 'material-uuid')`. Get valid slot and material IDs from * the environment definition's slots array in configuratorDataUpdated. Only useful when the active environment * has configurable material slots. * * @example * import { Communicator,ConfiguratorEnvelope } 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 environment material:', data); * }); * * api.sendCommandToMetabox(new SetEnvironmentMaterial( * 'carpaint', * 'dd829d6e-9200-47a7-8d5b-af5df89b7e91', * )); * }; * * @param {string} slotId - The slot ID. * @param {string} materialId - The material ID. */ declare class SetEnvironmentMaterial extends CommandBase { constructor(slotId: string, materialId: string); } /** * Represents a command to toggle the embedded Metabox menu. * This command can only be used when using the metabox menu. * * ### What does it unlock? * Shows the embedded menu interface. Only works when using the MetaBox native menu (not in standalone/custom menu * mode). * * ### Practical Application * Toggles the native MetaBox right sidebar menu. Takes a boolean parameter. Pass false to hide when building custom UI. * In standalone mode, the menu is already hidden — this is only relevant in default (non-standalone) mode. * * ### AI Coding Best Practices * In standalone mode (`{standalone:true}`), this is unnecessary (menu already hidden). In default mode, * call `new ShowEmbeddedMenu(false)` early in initialization to hide built-in UI before rendering custom controls. * Pattern for custom UI: `ShowEmbeddedMenu(false)` + `ShowOverlayInterface(false)`. * * @example * import { ShowEmbeddedMenu, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new ShowEmbeddedMenu(true)); * }; * * @param {boolean} visible - A flag indicating whether the embedded menu should be visible. */ declare class ShowEmbeddedMenu extends CommandBase { constructor(visible: boolean); } /** * Represents a command to toggle the Unreal Overlay Interface Menu. * This action sends a message to the Metabox API to toggle the visibility of the Unreal overlay UI. * * ### What does it unlock? * Shows the overlay interface elements. Displays UI controls and buttons overlaid on the 3D scene. * * ### Practical Application * Toggles viewport overlay controls (buttons overlaid on the 3D scene). Takes a boolean. * Use `ShowOverlayInterface(false)` alongside `ShowEmbeddedMenu(false)` when building fully custom UI * that replaces all native MetaBox controls. * * ### AI Coding Best Practices * In standalone mode, overlays are already hidden. In default mode, call `new ShowOverlayInterface(false)` * early in initialization to prevent flash of native UI. Always pair with `ShowEmbeddedMenu(false)` for clean custom UI. * Pass true to restore if entering a mode that uses native controls. * * @example * import { ShowOverlayInterface, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new ShowOverlayInterface(true)); * }; * * @param {boolean} visible - A flag indicating whether the Unreal overlay UI should be visible. */ declare class ShowOverlayInterface extends CommandBase { constructor(visible: boolean); } /** * Represents a command to show measurement for a product when it is already loaded. * This class sends a command to the Metabox API to show measurement for a product if it is already initialized. * * ### What does it unlock? * Shows the measurement overlay. Works as a toggle with HideMeasurement to control visibility. * * ### Practical Application * Shows the measurement/dimension overlay tools on the 3D viewport. Use for B2B or technical applications * where buyers need to verify product dimensions, check fit specifications, or confirm measurements during procurement. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new ShowMeasurement())`. No parameters. Pair with HideMeasurement for toggle behavior. * Track visibility state in your app to keep toggle buttons in sync. * * @example * import { ShowMeasurement, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new ShowMeasurement()); * }; */ declare class ShowMeasurement extends CommandBase { constructor(); } /** * Represents a command to hide measurement for a product when it is already loaded. * This class sends a command to the Metabox API to hide measurement for a product if it is already initialized. * * ### What does it unlock? * Hides the measurement overlay. Executes unconditionally to hide the UI controls. * * ### Practical Application * Hides the measurement/dimension overlay. Use when transitioning from a technical spec view back to a clean * product presentation, or to keep consumer-facing configurators visually clean. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new HideMeasurement())`. No parameters. Pair with ShowMeasurement as a toggle. * Track visibility state in your app state to keep toggle buttons in sync. * * @example * import { HideMeasurement, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new HideMeasurement()); * }; */ declare class HideMeasurement extends CommandBase { constructor(); } /** * Represents a command to resume the pixel streaming session. * This class sends a message to the Metabox API to resume a paused or disconnected stream. * * ### What does it unlock? * Resumes the Unreal Engine pixel streaming connection after it has been paused, disconnected, or stopped due to inactivity (AFK timeout). * * ### Practical Application * Used to reconnect the 3D streaming session without a full page reload. Essential for 'Reconnect' or 'Resume' buttons * shown when the stream is interrupted, e.g., after an idle timeout or network disruption. * * ### AI Coding Best Practices * Call `api.sendCommandToMetabox(new ResumeStream())`. No parameters. Resumes the existing streaming session — * does not reinitialize the configurator or reset product/environment state. * * @example * import { ResumeStream, Communicator } from '@3dsource/metabox-front-api'; * window.env3DSource.apiReady = (api: Communicator) => { * api.sendCommandToMetabox(new ResumeStream()); * }; */ declare class ResumeStream extends CommandBase { constructor(); } export { AppLoaded, AppLoaded_V3, ApplyZoom, BasicRouteUrl, CommandBase, Communicator, EventDispatcher, GetCallToActionInformation, GetCamera, GetPdf, GetScreenshot, HideMeasurement, InitShowcase, Metabox, MetaboxBasicConfiguratorActions, MetaboxConfig, MetaboxDomain, MetaboxHost, MetaboxHost_V3, Metabox_V3, PauseShowcase, PlayShowcase, ResetCamera, ResumeStream, SetCamera, SetEnvironment, SetEnvironmentMaterial, SetProduct, SetProductMaterial, ShowEmbeddedMenu, ShowMeasurement, ShowOverlayInterface, StopShowcase, UnrealCommand, VERSION, fromCommunicatorEvent, getUrlParams, integrateMetabox, prepareIframeSrc, saveImage, setUrlParams }; export type { CameraCommandPayload, ConfiguratorEnvelope, Cta, EcomConfigurator, Environment, FromMetaBoxAPIEnvelope, FromMetaBoxApiEvents, FromMetaBoxMessage, FromMetaboxMessagePayloads, FromMetaboxTarget, IntegrateMetaboxConfig, Listener, MCAppLoaded, Material, MetaBoxApiEnvelope, MetaProperty, MetaboxCommandConfig, MetaboxEnvironment, MimeType, Product, SelectedIds, ShowCaseStatus, Showcase, Slot, Thumbnail, Timecode, ToMetaBoxActions, ToMetaBoxMessage, ToMetaBoxMessageEnvelope, ToMetaboxMessagePayload, ToMetaboxMessagePayloads, ToMetaboxTarget, UniversalConfigurator, UniversalConfiguratorEnvironment, UniversalConfiguratorProduct, VideoResolution };