Hi Shapediver Team
I have a technichal issue im wondering if you can assist me with.
Im attempting to embed the Shapediver viewer into a Webflow powered site using
custom components running the script below, however it is returning a CORS error when trying to load sdv.min.js.
You can find the site here :
I looked online and seems some others have encountered this issue with Shapediver but could not find a solution that didnt require reaching out
Please let me know if you have any ideas
Best regards
Chris
Script
<script>
// Function to load an external script dynamically
function loadScript(url, callback) {
var script = document.createElement("script");
script.src = url;
script.onload = callback;
script.onerror = function(e) {
console.error("Failed to load script:", url, e);
};
document.head.appendChild(script);
}
// Load the ShapeDiver viewer script and initialize the viewer when done
loadScript("https://viewer.shapediver.com/v3/3.9.4/sdv.min.js", function() {
console.log("ShapeDiver script loaded.");
document.addEventListener("DOMContentLoaded", function() {
(async function() {
try {
const viewer = new SDVApp.ParametricViewer({
container: document.getElementById("sd-viewer"),
model: "TICKET HAS BEEN PLACED HERE BUT REMOVED FOR THIS POST", // Replace with your embedding ticket
showSceneTransition: true
});
await viewer.init();
console.log("ShapeDiver model loaded successfully.");
// (Optional) Log parameters
const parameters = await viewer.parameters.get();
console.log("ShapeDiver parameters:", parameters);
} catch (error) {
console.error("Error initializing ShapeDiver viewer:", error);
}
})();
});
});
</script>