Initialization and options
ProductViewer(iframe)
This constructor returns a new rooom viewer instance bound to the given iframe element.
js
var iframe = document.getElementById("viewer"); // The iframe html element
var viewer = new ProductViewer(iframe);
init(id, options)
This function initializes a viewer with the given id. The id is the identifier part in a viewer URL. You can also pass an options object to this function. Available options.
js
viewer.init("123456789123456789", {
onSuccess: function onSuccessFn(api) {},
onError: function onErrorFn() {},
autospin: 1,
autostart: 1,
bg_color: "ffd700",
});
Customization
You can pass callbacks and customization options when you initialize a viewer.
js
viewer.init("123456789123456789", {
onSuccess: function onSuccessFn(api) {},
onError: function onErrorFn() {},
autospin: 1,
autostart: 1,
bg_color: "ffd700",
});
Or you can pass the customization as url-options, described here.
Callbacks
onSuccess
- function(api)
Required. This callback will be invoked when the viewer has been successfully initialized. It will be passed an api object so that you can interact with the viewer.
onError
- function()
This callback will be invoked when the viewer cannot be initialized.