Configurator Core Events
Why Type-Safe Events?
Standard JavaScript event subscriptions use string names. A misspelled event name won't produce any error -- the browser simply never fires a callback for a name that doesn't exist, and there is no way to know.
The Epigraph Configurator solves this by storing all event names in an EVENTS object on the Core API. If you try to access an event that doesn't exist, you get a TypeError immediately instead of a silent failure.
// Fragile -- a typo here fails silently
configurator.addEventListener("contxtMenu:show", callback);
// Type-safe -- a typo here throws a TypeError
configurator.addEventListener(coreApi.EVENTS.UI.ContxtMenu_Show, callback);
// → TypeError: Cannot read properties of undefinedAccessing Events
All events are accessed via coreApi.EVENTS.<category>.<eventName>:
const configurator = document.getElementById("wcEpigraphConfigurator");
configurator.addEventListener("coreApi:ready", () => {
const coreApi = configurator.api.core;
configurator.addEventListener(
coreApi.EVENTS.SCENE.Item_Added,
() => {
console.log("An item was added to the scene");
}
);
});Note: The
coreApi:readyandcoreApi:failedlifecycle events are not part of theEVENTSobject. These two events must always be subscribed to using string names, since the Core API (and therefore theEVENTSobject) is not yet available when you need to listen for them.
Lifecycle Events
These events are subscribed to directly with string names on the web component element:
| Event | Description |
|---|---|
coreApi:ready | The Core API has initialized and is ready for use |
coreApi:failed | The Core API failed to initialize (network error, invalid key, unsupported hardware) |
configurator.addEventListener("coreApi:ready", () => {
// Core API is available at configurator.api.core
});
configurator.addEventListener("coreApi:failed", (event) => {
// Show error UI to the user
});UI Events
Events related to the configurator's user interface elements. Access via coreApi.EVENTS.UI.*.
| Accessor | Internal Value | Description |
|---|---|---|
PreloadScreen_Show | preload:show | The loading screen should be shown |
PreloadScreen_Hide | preload:hide | The loading screen should be hidden |
ContextMenu_Show | contextMenu:show | An item was clicked in the scene; show the context menu |
ContextMenu_Hide | contextMenu:hide | The context menu should be dismissed |
ContextMenu_InfoBtnClicked | infoButtonClicked_ContextMenu | The info button inside the context menu was clicked |
UtilityMenu_Show | utilityMenu:show | The utility menu should be shown |
UtilityMenu_Hide | utilityMenu:hide | The utility menu should be hidden |
ShareButton_Show | shareButton:show | The share button should be shown |
ShareButton_Hide | shareButton:hide | The share button should be hidden |
ViewInYourSpaceButton_Show | viewInYourSpace:show | The AR / View In Your Space button should be shown |
ViewInYourSpaceButton_Hide | viewInYourSpace:hide | The AR button should be hidden |
ResetButton_Show | resetBtn:show | The reset button should be shown |
ResetButton_Hide | resetBtn:hide | The reset button should be hidden |
DimensionsButton_Show | dimensionsBtn:show | The dimensions button should be shown |
DimensionsButton_Hide | dimensionsBtn:hide | The dimensions button should be hidden |
Instructions_Show | instructions:show | The instructions modal should be shown |
ReviewCart_Shown | review-cart-shown | The review cart panel was shown |
ReviewCart_Hidden | review-cart-hidden | The review cart panel was hidden |
Example: Custom Context Menu
configurator.addEventListener(
coreApi.EVENTS.UI.ContextMenu_Show,
(event) => {
const item = event.data.primary;
console.log(`Clicked: ${item.name} (${item.guid})`);
console.log("Available looks:", item.data.itemData.looks);
// Show your custom context menu
}
);
configurator.addEventListener(
coreApi.EVENTS.UI.ContextMenu_Hide,
() => {
// Hide your custom context menu
}
);Scene Events
Events related to changes in the 3D scene. Access via coreApi.EVENTS.SCENE.*.
| Accessor | Internal Value | Description |
|---|---|---|
Item_Added | item:added | An item was added to the scene |
Item_Removed | item:removed | An item was removed from the scene |
Items_Updated | items:updated | Item data was updated (e.g. position, attachments) |
FittingSkuIds_Updated | fittingSkuIds:updated | The list of compatible SKU IDs was recalculated |
CartItems_Updated | cartItems:updated | Cart contents changed |
Hotspot_Enter | hotspot:enter | The user entered/activated a hotspot |
Hotspot_Exit | hotspot:exit | The user exited a hotspot |
SavedConfiguration_Loaded | loaded-saved-configuration | A saved configuration was loaded into the scene |
MaterialOverrides_Exists | materialOverrideExists | A material override was applied to an item |
Cart_Checkout | cart:checkout | Checkout was initiated |
Cart_OutOfStock | cart:outOfStock | Checkout was blocked due to out-of-stock items |
Cart_StatusUpdated | cart:statusUpdated | Cart status was updated |
ReplaceableCategory_Updated | replaceableCategory:updated | A replaceable item category was changed |
GlobalVariant_Updated | globalVariant:updated | A global material variant was switched |
CategoryData_Updated | categoryData:updated | Category data was updated |
GlobalGeometryVariant_Updated | globalGeometryVariant:updated | A global geometry variant was switched |
Ghost_Loaded | ghost:loaded | Ghost previews finished loading |
Model_Loaded | model:loaded | A 3D model finished loading |
Model_Removed | model:removed | A 3D model was removed |
Scene_Cleared | scene:cleared | The scene was cleared |
Inventory_Updated | inventory:updated | Inventory data was updated |
DraggingOnDrop_CollisionDetected | draggingOnDrop:collisionDetected | A collision was detected during drag-and-drop |
ItemRemoveModalTriggered | itemRemoveModal:triggered | Item removal confirmation was requested |
ActionButton_Clicked | actionButton:clicked | An action button was clicked |
CartMessage_Update | cartMessage:updated | Cart message was updated |
Example: Reacting to Scene Changes
configurator.addEventListener(
coreApi.EVENTS.SCENE.Item_Added,
() => {
console.log("Item count:", coreApi.getSceneItemCount());
}
);
configurator.addEventListener(
coreApi.EVENTS.SCENE.CartItems_Updated,
async () => {
const cartItems = await coreApi.getCartItemsAsync();
// Update your cart UI
}
);
configurator.addEventListener(
coreApi.EVENTS.SCENE.SavedConfiguration_Loaded,
() => {
console.log("Configuration loaded successfully");
}
);Configuration Events
Events related to item interaction and camera state. Access via coreApi.EVENTS.CONFIGURATION.*.
| Accessor | Internal Value | Description |
|---|---|---|
OnClickItem | onClickItem | An item was clicked in the scene |
CameraDetails_Update | cameraDetails:Update | Camera details were updated |
Quick Reference
All events at a glance:
EVENTS
├── UI
│ ├── PreloadScreen_Show
│ ├── PreloadScreen_Hide
│ ├── ContextMenu_Show
│ ├── ContextMenu_Hide
│ ├── ContextMenu_InfoBtnClicked
│ ├── UtilityMenu_Show
│ ├── UtilityMenu_Hide
│ ├── ShareButton_Show
│ ├── ShareButton_Hide
│ ├── ViewInYourSpaceButton_Show
│ ├── ViewInYourSpaceButton_Hide
│ ├── ResetButton_Show
│ ├── ResetButton_Hide
│ ├── DimensionsButton_Show
│ ├── DimensionsButton_Hide
│ ├── Instructions_Show
│ ├── ReviewCart_Shown
│ └── ReviewCart_Hidden
├── SCENE
│ ├── Item_Added
│ ├── Item_Removed
│ ├── Items_Updated
│ ├── FittingSkuIds_Updated
│ ├── CartItems_Updated
│ ├── Hotspot_Enter
│ ├── Hotspot_Exit
│ ├── SavedConfiguration_Loaded
│ ├── MaterialOverrides_Exists
│ ├── Cart_Checkout
│ ├── Cart_OutOfStock
│ ├── Cart_StatusUpdated
│ ├── ReplaceableCategory_Updated
│ ├── GlobalVariant_Updated
│ ├── CategoryData_Updated
│ ├── GlobalGeometryVariant_Updated
│ ├── Ghost_Loaded
│ ├── Model_Loaded
│ ├── Model_Removed
│ ├── Scene_Cleared
│ ├── Inventory_Updated
│ ├── DraggingOnDrop_CollisionDetected
│ ├── ItemRemoveModalTriggered
│ ├── ActionButton_Clicked
│ └── CartMessage_Update
└── CONFIGURATION
├── OnClickItem
└── CameraDetails_Update
Preload Events
These string-based events track asset loading progress. They are useful if you want to build a custom loading indicator.
| Event | Description |
|---|---|
preload:begin | Asset preloading has started |
preload:update | Preloading progress update -- carries a progress property (0--100) |
preload:end | Asset preloading is complete |
configurator.addEventListener("preload:update", (event) => {
console.log(`Loading: ${event.progress}%`);
});Further Reading
- API Reference -- Full method and property reference for the Core API
- Building a Custom UI -- Headless mode setup and basic API usage
- Implementing Drag and Drop -- Drag-and-drop with custom context menu events
Updated about 1 month ago
