Skip to main content
1-Visitor
September 21, 2020
Solved

How to play a sequence without bindings button and model

  • September 21, 2020
  • 2 replies
  • 4525 views

Goodmorning everyone,
I would like to create an AR experience that reproduces animation sequences without having to link the "Play" button with the corresponding model.

Looking at the bottom panel in Vuforia Studio, the button-template link corresponds to the command: app.view ["Maintenance"]. Wdg ["cart"]. Svc.play.

How can I use it in the javascript file?

Best answer by leonardosella

 

 

I found this solution: 

 

 

$scope.sequencePlay = function () {
	$scope.$root.$broadcast('app.view["Maintenance"].wdg["carrello"].svc.play');
 };

 

 

 In View, in 2D Canvas, in a Button Widget, in Events, in Click, press JS button and call this function:

sequencePlay();

2 replies

17-Peridot
September 21, 2020

Good morning Leonardosella,

 

  1. In View<View name>.js node (if View is named Home, node is named Home.js)
  2. Add a custom JavaScript function :

 

$scope.PlayMaintenanceSequnce = function () {
 console.log ("PlayMaintenanceSequnce");
 $scope.$root.$broadcast('app.view["Maintenance"].wdg["cart"].svc.play');
}

 

      3. In View, in 2D Canvas, in a Button Widget, in Events, in Click, press JS button and call this function:

 

PlayMaintenanceSequnce ();

 

 

Best regards,

Samuel

1-Visitor
September 21, 2020

Thank you for your reply. 

 

I tried your code but didn't work. 

In the inspection tab appear the message into the screen above. 

 

Any suggestions?

 

Thank you. 

 

17-Peridot
September 22, 2020

Hello Leonardosella,

 

I have updated code.

I did a bad copy and paste and I have missed to copy A into App instead of pp.

 

Added also $scope.$root.$broadcast who is needed.

 

Best regards,

Samuel

21-Topaz I
September 22, 2020

for the sake of completness here furhter addtional /alternative way's to play sequence via java code:

angular.element(document.getElementById('model-1')).scope().play(); 
// or for play all
angular.element(document.getElementById('model-1')).scope().playAll(); 

The code will be called in the current loaded view and will call the  play or playAll service of the Widget Id="model-1"

Here is also another way how to start a Widget service-> using the triggerWidgetService:

$scope.app.loadsequence = function()
	{ $scope.setWidgetProp('model-1', 'sequence', "app/resources/Uploaded/l-Creo 3D - TestFigure1.pvi"); 
 $timeout( function() { 
 twx.app.fn.triggerWidgetService("model-1", 'play'); 
 }, 1000);	//delayed the play 1 sec
 };


 Here we set the sequence property first to a figure and after delay 1 sec will call the play service for the first step

leonardosella1-VisitorAuthorAnswer
1-Visitor
September 22, 2020

 

 

I found this solution: 

 

 

$scope.sequencePlay = function () {
	$scope.$root.$broadcast('app.view["Maintenance"].wdg["carrello"].svc.play');
 };

 

 

 In View, in 2D Canvas, in a Button Widget, in Events, in Click, press JS button and call this function:

sequencePlay();