@3dsource/metabox-front-api 3.0.13 → 3.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -807,38 +807,37 @@ A complete HTML example showing how to integrate the Metabox configurator with v
|
|
|
807
807
|
// Replace 'configurator-id' with your actual configurator ID from 3DSource
|
|
808
808
|
const configuratorId = 'configurator-id';
|
|
809
809
|
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
});
|
|
810
|
+
integrateMetabox(configuratorId, 'metabox-container', (apiInstance) => {
|
|
811
|
+
try {
|
|
812
|
+
api = apiInstance;
|
|
813
|
+
isApiReady = true;
|
|
814
|
+
setLoadingState(false);
|
|
815
|
+
console.log('Configurator ready!');
|
|
816
|
+
|
|
817
|
+
// Listen for configurator state changes
|
|
818
|
+
api.addEventListener('configuratorDataUpdated', (data) => {
|
|
819
|
+
console.log('Configurator state updated:', data);
|
|
820
|
+
// You can update your UI based on the current state
|
|
821
|
+
// For example, update available materials, products, etc.
|
|
822
|
+
});
|
|
823
|
+
|
|
824
|
+
// Listen for screenshot completion
|
|
825
|
+
api.addEventListener('screenshotReady', (imageData) => {
|
|
826
|
+
console.log('Screenshot captured successfully');
|
|
827
|
+
// Save the image with a timestamp
|
|
828
|
+
saveImage(imageData, `configurator-screenshot-${Date.now()}.png`);
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
// Listen for errors
|
|
832
|
+
api.addEventListener('error', (error) => {
|
|
833
|
+
console.error('Configurator error:', error);
|
|
834
|
+
showError('An error occurred in the configurator: ' + error.message);
|
|
835
|
+
});
|
|
836
|
+
} catch (error) {
|
|
837
|
+
console.error('Error setting up API:', error);
|
|
838
|
+
showError('Failed to initialize configurator API: ' + error.message);
|
|
839
|
+
}
|
|
840
|
+
});
|
|
842
841
|
} catch (error) {
|
|
843
842
|
console.error('Error initializing configurator:', error);
|
|
844
843
|
showError('Failed to load configurator: ' + error.message);
|