Back to Demos

This demo shows how you can rotate object along y-axis.

Clara.io demo resources:

Visit Base Scene


var api = claraplayer('player');
var sceneId = '414ea28d-5d62-4075-a3f4-eb921a837f43';
api.sceneIO.fetchAndUse(sceneId).then(function(){
  ['orbit', 'pan'].map(function(item) {api.player.hideTool(item)});
  document.getElementById('baseScene').setAttribute('href','https://clara.io/view/'+sceneId);
  api.commands.addCommand({
    enabled: true,
    active: true,
    tool: {
      drag: function(ev){
        var bb = ev.rect;
        return {
          momentum: false,
          handle: function(ev){
            var degrees = 360*ev.deltaX/bb.width;
            var rotation = api.scene.get({name:'Car Base', plug: 'Transform', property: 'rotation'});

            api.scene.set({name:'Car Base', plug: 'Transform', property: 'rotation'},{x: rotation.x, y:rotation.y+degrees, z:rotation.z}); 
          }
        };
      },
    }
  }, 'planeRotate');
});