cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to switch between sequences in Vuforia Studio?

Regular Member

How to switch between sequences in Vuforia Studio?

HI, I am trying to switch between different sequences using JS. I have created a .pvz file from Creo Illustrate with a couple different animations. I read somewhere in this community that I should copy the file, rename it to .zip and extract it to display the .pvi names. However it dont know how to make that work, I dont get a proper .zip file with that method. 

This JS I use, its binded to the model

$scope.view.wdg['robot-arm']['sequence'] = 'middle_servo_disassembly';

I have named my sequences in Creo Illustrate, is there some way I can use those names?

 

thank you 

3 REPLIES 3

Re: How to switch between sequences in Vuforia Studio?

I managed to switch between the sequences. I published the files from Creo Illustrate as Separate files so I could see in the folder what names they got. e.g 'l-Creo 3D - complete_5Fdisassembly.pvi'

Using this together with 

  $scope.setWidgetProp('robot_arm','sequence','l-Creo 3D - complete_5Fdisassembly.pvi');  

I made it working.

 

However, I try to combine the setWidgetProp with 

  $scope.$root.$broadcast('app.view["Home"].wdg["robot_arm"].svc.playAll'); 

in a function. When I click on the model to trigger the function, the sequence hasnt been changes. I wonder if it dont have the time to change when I write it this way?

 

thank you.

Re: How to switch between sequences in Vuforia Studio?

Try using $timeout for your PlayAll service call. This should help ensure that the sequence update completes before trying to play it. AngularJS documentation for $timeout can be found here: https://docs.angularjs.org/api/ng/service/$timeout

Re: How to switch between sequences in Vuforia Studio?

$timeout can help with this, but sometimes it's hard to determine the right delay to use--a delay that works on the browser preview might be too short to work on a device.

 

A more robust approach is to listen for the "sequenceloaded" event and use that to play the sequence, something like this:

...$scope.setWidgetProp('robot_arm','sequence','l-Creo 3D - complete_5Fdisassembly.pvi');

$scope.$on("sequenceloaded", function() {
    $scope.app.fn.triggerWidgetService("robot_arm", "playAll");
});

Note that this will also trigger when the experience first loads, if you have a default sequence configured for the model. If you want to avoid that, you can use a flag to keep track of whether this is the first time loading or not, like so:

$scope.firstSequence = true;

$scope.$on("sequenceloaded", function() {
    if ($scope.firstSequence) {
         // ignore for initial load
        $scope.firstSequence = false;
        return;
    }
    else {
        $scope.app.fn.triggerWidgetService("robot_arm", "playAll");
    }
});