Initialization and options
SpaceViewer(iframe)
This constructor returns a new rooom viewer instance bound to the specified iframe element.
js
var iframe = document.getElementById("viewer"); // The iframe HTML element
var viewer = new SpaceViewer(iframe);
1
2
2
init(id, options)
This function initializes a viewer with the specified ID. The ID is the identifier part in a viewer URL. You can also pass an options object to this function - see available options.
js
viewer.init("123456789123456789", {
onSuccess: function onSuccessFn(api) {},
onError: function onErrorFn() {},
autostart: 1,
max_texture_size: 1024,
});
1
2
3
4
5
6
2
3
4
5
6
Customization
You can pass callbacks and customization options when you initialize a viewer.
js
viewer.init("123456789123456789", {
onSuccess: function onSuccessFn(api) {},
onError: function onErrorFn() {},
autostart: 1,
max_texture_size: 1024,
});
1
2
3
4
5
6
2
3
4
5
6
Alternatively, you can pass customization options as URL parameters, as 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 that allows you to interact with the viewer.
onError
- function()
This callback will be invoked when the viewer cannot be initialized.