martymarkenson of Ninjas
9/11/2017 - 6:55 PM

The ability to continuously move a 3D widget in a direction, and stop in from moving

The ability to continuously move a 3D widget in a direction, and stop in from moving

var timerId = -1;
var timingInterval = 30; //frequency at which position of widget is updated

//starts moving the model forward
$scope.moveForward = function() {
    timerId = setInterval(function () {
      $scope.$apply(function () {     
        $scope.view.wdg[__studioIDofWidget__]['x'] -= .01;
        });
    }, timingInterval);
}

//stops the position from being updated
$scope.stop = function() {
clearInterval(timerId);
}