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

How to play a sequence without bindings button and model

SOLVED
Highlighted
Amethyst

How to play a sequence without bindings button and model

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: How to play a sequence without bindings button and model

 

 

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();

View solution in original post

5 REPLIES 5
Highlighted

Re: How to play a sequence without bindings button and model

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

Highlighted

Re: How to play a sequence without bindings button and model

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. 

 

Highlighted

Re: How to play a sequence without bindings button and model

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

Tags (1)
Highlighted

Re: How to play a sequence without bindings button and model

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

Highlighted

Re: How to play a sequence without bindings button and model

 

 

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();

View solution in original post

Announcements
Join an
AR Working Group!

Topics available:
AR/VR for Data Optimization AR/VR for Security and Control AR/VR for Inspection