Back to Demos

This demo shows how you can switch from one camera to another with an animation.

Clara.io demo resources:

Visit Base Scene


var api = claraplayer('player');
var sceneId = 'd7861e61-a55a-4d15-94fe-6d5c34c2d204'
api.sceneIO.fetchAndUse(sceneId);
api.on('loaded', function()  {
  var cameras = api.scene.getAll({type: 'Camera', property: 'name'});
  for(var id in cameras) {
    var button = document.createElement('button');
    button.innerText = cameras[id];
    button.onclick = onClick(id);
    document.getElementById('buttons').appendChild(button);
  }
document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+sceneId);
});

function onClick(id) {
    return function(ev) {
        return api.player.animateCameraTo(id, 500)
    }
}