Model not showing up with "ShapeDiver API - First Example"

Hi to all. I’m new to ShapeDiver and working to get a configurator built and integrated with WooCommerce. To get the ball rolling I tried to run the “First Example” provided in the API docs. I copied the html and javascript code to their respective files, but when I view the screen all I see is the container, slider and buttons. The actual sofa model doesn’t appear as it does in the example in the API. Clicking on the “get data” button returns NumberOfSeats: 2, so I presume at least some discussion is happening over the API. The browser consoles (firefox and chrome) show no issues and I’m seeing the response from ShapeDiver that they’re hiring. Any suggestions as to why the model won’t show? In comparing the source from the live example and mine, the canvas doesn’t load in the container on mine.

For reference, the example is https://support.shapediver.com/hc/en-us/articles/360014884512-First-steps-with-the-API and my test implementation is at http://creativejunction.com/shapediver.php.

Thank you for any guidance you can offer.

The problem is that the code for this simple example did not check for the loading state of the DOM elements in the page. Unfortunately, in your app the viewer seems to be initialized before the DOM content is loaded, although the viewer needs a defined container to load properly. I updated the code to contain this instruction:

if (document.readyState === "loading") {
  document.addEventListener("DOMContentLoaded", initSdvApp, false);
} 

If you use the updated code from this page, your app should work fine.

I also copied this example in the set of CodePen basic code examples we are now working on, have a look there if you need help with more API questions: https://codepen.io/collection/DzZKPK/?grid_type=list

Worked well, thank you Mathieu.