Skip to main content
1-Visitor
August 16, 2019
Solved

Play sequence by buttons

  • August 16, 2019
  • 2 replies
  • 5189 views

Hi there,
I am working on a demonstration and there is a 3D model containing 2 - 3 sequences.
I knew that I can use the select widget to choose the target sequence, but I would prefer play different sequence by clicking buttons for a better trial experience.
For example, if I click button A, the first sequence is played. Likewise, if I click button B, another sequence will be played.
Is there any way to perform such function in Vuforia Studio? Or can I do that through writing a script?

Best answer by InfinityX

yes it is possible

u might have .pvz model with you . so do one thing save that file as .zip by renaming. and extract the file, you will get a lot files including .obj and .pvi

so in that .pvi files are nothing sequence file to run , suppose you have 4 sequences then you will find 4 .pvi files

now with the help of these files You can run 4 sequences with 4 different buttons

you need to provide 4 button in 2D canvas and bind all those button with model first and in home.js view you need to write javascript code for that given below:

$scope.r1= function()
{
$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - RED.pvi';

}

 

now this is javascript to run only 1 sequence , so if u have 4 sequence then you need to write above lines 4 times by making some changes in that

now in above javascript 

"r1" is assinged to respective button binding 

"l-Creo 3D - RED.pvi" is respective sequence file which we get from extract of zip file

suppose to bind A button to model to run sequence then u need to right below code in click area of A button 

r1();

means if u click on A button respective Sequence file will run

similarly u need to perform same procedure to other button by changing the red part in javascript

 

2 replies

16-Pearl
August 19, 2019

Yes, you'd just need to write some JS functions to set the sequence for the model widget and then kick off the playing of the sequence.

 

There's plenty of examples of setting the sequence via JS here in the forums, but here's and example of what you would do:

 

$scope.animation1 = function () {

  $scope.view.wdg['model-1']['sequence'] = "app/resources/Uploaded/l-Creo 3D - Figure 1.pvi";

   angular.element(document.getElementById('model-1')).scope().play();

}

 

Hope this helps. 

1-Visitor
August 26, 2019

Thanks for the help and sorry for the late reply.
Is this line: angular.element(document.getElementById('model-1')).scope().play();,
is the javascript for playing next step of the sequence?

So, if I want to rewind and play my sequence by clicking a button, can I write something like this?
angular.element(document.getElementById('model-1')).scope().rewind();
angular.element(document.getElementById('model-1')).scope().play();

1-Visitor
August 26, 2019

yes it is possible i guess 

just you need to use 2 button instead of 1

like for button 1 you need to apply  javascript:

angular.element(document.getElementById('model-1')).scope().rewind();

for button 2 you need to apply javascript:

angular.element(document.getElementById('model-1')).scope().play();

InfinityX1-VisitorAnswer
1-Visitor
August 19, 2019

yes it is possible

u might have .pvz model with you . so do one thing save that file as .zip by renaming. and extract the file, you will get a lot files including .obj and .pvi

so in that .pvi files are nothing sequence file to run , suppose you have 4 sequences then you will find 4 .pvi files

now with the help of these files You can run 4 sequences with 4 different buttons

you need to provide 4 button in 2D canvas and bind all those button with model first and in home.js view you need to write javascript code for that given below:

$scope.r1= function()
{
$scope.view.wdg['model-1']['sequence'] = 'app/resources/Uploaded/l-Creo 3D - RED.pvi';

}

 

now this is javascript to run only 1 sequence , so if u have 4 sequence then you need to write above lines 4 times by making some changes in that

now in above javascript 

"r1" is assinged to respective button binding 

"l-Creo 3D - RED.pvi" is respective sequence file which we get from extract of zip file

suppose to bind A button to model to run sequence then u need to right below code in click area of A button 

r1();

means if u click on A button respective Sequence file will run

similarly u need to perform same procedure to other button by changing the red part in javascript