Differences and restrictions when working with iframes

Hello Everyone,
I have read somewhere that iframe has some limitation. Shapediver has got a page about it but it seems empty. Can any one help me with this before I commit to an embedding type?


1 Like

There are two types of differences:

Functionalities only available asynchronously
Through the iframe, none of the standard API functions can’t return immediate results but return instead a promise. One simple example is to list the model parameters. With the standard API, you could do:

let params = api.parameters.get().data;
console.log("There are " + params.length + " parameters in this model.");

With the iframe, you would have to use the alternative getAsync() function and wait for it to return before using the results:

let params;
api.parameters.getAsync().then(function(res) {
  params = res.data;
console.log("There are " + params.length + " parameters in this model.");

In general, this makes it slightly less convenient to use.

Functionalities unavailable through an iframe
There are a number of functionalities that are not available with iframe embedding, because it’s not possible or simply because it requires more effort to implement and we didn’t get to it yet.
In particular, this includes all functions related to selection, dragging and hovering.

We will publish an exhaustive list of the differences but this overview should already show you that if you plan to use the API to build a custom application, you should not use iframe embedding unless there is a very good reason to do so. The iframe is mostly a means for non-developers to embed models easily and share them privately with collaborators and clients.

Find more information about iframe embedding in the corresponding section of the API reference:

1 Like