Skip to main content
1-Visitor
April 15, 2020
Solved

Moving multiple models

  • April 15, 2020
  • 1 reply
  • 1957 views

I'm using the code below to move multiple models. The issue I'm having is they all have different starting locations. So they appear to 'jump' to that Y coordinate, and then move up. Is there a way to have the function inherit the original value and then move up?

 

$scope.posChange1 = function() {
$scope.app.params['ClipMovement']+=0.0001;
}

$scope.moveClip = function() {
$scope.app.params['ClipMovement'] = 1.329;
$scope.intervalPromise = $interval($scope.posChange1, 10, 100);
};

Best answer by micah

That works perfectly. Another issue I'm having is looping the movement.

I've tried:

 

$scope.moveClip = $interval(function() {
for(var i=0; i< 3; i++){
$scope.view.wdg[Objects[i]].y=start[i];
}
$scope.intervalPromise = $interval($scope.posChange1, 10, 100);
}, 1000);

 

Where moveClip(); is bound to a click function of a button. But the loop starts when the view is loaded rather than when the button is clicked.

 

(Also, how do you add code to post in that box?)

1 reply

14-Alexandrite
April 15, 2020

Hi,

 

you can write your objects in a list and loop through it like this:

 

var Objects =["3DGauge-1","3DGauge-2","3DGauge-3"];

$scope.posChange1 = function() {
 for(var i=0; i< 3; i++){
	$scope.app.view.Home.wdg[Objects[i]].y+=0.0001;
 }
}

$scope.moveClip = function() {
$scope.intervalPromise = $interval($scope.posChange1, 10, 100);
};
micah1-VisitorAuthor
1-Visitor
April 16, 2020

This isn't suitable for my situation because if I run that function twice it will incrementally add from the last position. I'd like the models to move from each of their original positions, and if the function is run again, go back to the original and then move up.

 

Is there a way to call back the original 'y' position of all the models?

micah1-VisitorAuthorAnswer
1-Visitor
April 19, 2020

That works perfectly. Another issue I'm having is looping the movement.

I've tried:

 

$scope.moveClip = $interval(function() {
for(var i=0; i< 3; i++){
$scope.view.wdg[Objects[i]].y=start[i];
}
$scope.intervalPromise = $interval($scope.posChange1, 10, 100);
}, 1000);

 

Where moveClip(); is bound to a click function of a button. But the loop starts when the view is loaded rather than when the button is clicked.

 

(Also, how do you add code to post in that box?)