This demo shows how you can take snapshot of a scene.
var api = claraplayer('player');
var sceneId = 'd7861e61-a55a-4d15-94fe-6d5c34c2d204';
api.sceneIO.fetchAndUse(sceneId).then(function(){
document.getElementById('snapshot').onclick = clickHandler;
document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+sceneId);
});
function clickHandler() {
var dataType = document.getElementById('dataType').value;
var camera = document.getElementById('Camera').value;
var width = Number(document.getElementById('width').value);
var height = Number(document.getElementById('height').value);
camera = camera === 'Default' ? null : camera;
api.commands.setCommandOptions('snapshot', {
dataType: dataType,
camera: camera,
width: width,
height: height,
});
var result = api.commands.runCommand('snapshot');
if (result) {
var resultImage = document.getElementById('resultImage');
resultImage.src =
dataType === 'dataURL' ? result : URL.createObjectURL(result);
}
}