Back to Demos

This demo shows how you can load a template scene and add models from another scene.

Clara.io demo resources:


var templateScene = '7f16fad7-e107-4273-a8ed-2eb0cfccda71';
var modelScene = '38168340-1756-47b0-8c58-55aeac91db52';

var api = claraplayer('player');
api.sceneIO.fetchAndUse(templateScene);
document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+templateScene);
document.getElementById('modelScene').setAttribute('href','https://clara.io/view/'+modelScene);
api.on('loaded', function() {
  document.getElementById('load').onclick = function() {
    api.sceneIO.fetch(modelScene).then(function() {
      var newObjectsIds = api.scene.find({ from: { id: modelScene }, name: 'Objects' });
      api.scene.clone({
        from: { id: newObjectsIds },
        type: ['PolyMesh', 'Null']
      },
      { withNull: 'Import Null', includeDependencies: true })
      .then(function(nodeMap) {
        api.scene.set(
          { id: nodeMap['Import Null'], plug: 'Transform', property: 'translation' },
          { x: 0, y: -0.4, z: 0 }
        );
      });
    });
  }
});