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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Change a color of the 3D label via .js

MaximeDid
8-Gravel

Change a color of the 3D label via .js

Hi,

How can I change a color of a 3D label by clicking on a button?

I tried to write the code below but it doesn't work:

 

$scope.SwitchConf = function () {
$scope.app.view.Home.wdg["3DLabel-2"].fontColor= 'red';

 

When I click on the button, the function "SwitchConf" is called but the color don't change.

Is it possible to do this by this way?

Thanks for your help...

Maxime.

ACCEPTED SOLUTION

Accepted Solutions

Hi, @MaximeDid 

 

Please try the attachment.

View solution in original post

10 REPLIES 10

Hi, Maxime

 

What type of project did you create? Mobile or 3D eyewear?

 

I tried both codes below  and they work in my mobile project, in preview and on device.

$scope.setColorRGB = function(){
  $scope.view.wdg['3DLabel-1'].fontColor = "#ff0000";
}

or

$scope.setColorName = function(){
  $scope.view.wdg['3DLabel-1'].fontColor = "red";
}

 

Have you tried the code on device?

Sometimes it doesn't work in preview, but works on device.

Hi @dsgnrClarK ,

 

I created a mobile project.

I tried both code you send me, but in my app it doesn't works (in preview and on device).

I created also a new project and test the code but it doesn't work

 

I changed the code for check my function is called:

 

$scope.SwitchConf = function () {$scope.view.wdg['3DLabel-2'].visible = false;}

 

The result is OK.

Hi, @MaximeDid 

 

Please try the attachment.

Ok thanks,

I tried your code, and it's work.

So I copied and this is OK in my project also.

But I saw when I remove the line for modify the text, the color don't change. Do you know why?

The view does not seem to be refreshing...

Hi, @MaximeDid 

 

Which version of Vuforia Studio and browser are you using?

Could you attach your project?

Hi @dsgnrClarK ,

I am using VuforiaStudio 8.5.15.4805 and Chrome Version 87.0.4280.88.

Please find my project in attachment.

Now I see the issue, but I don't know the mechanism behind it.

Sorry about that.

OK no problem.
I will only have to change the text to update the color.

Thank you for your help.

 

It looks like an update bug a work around 

 

$scope.setColorName = function(){

var currentText = $scope.view.wdg['3DLabel-1'].text;
$scope.view.wdg['3DLabel-1'].fontColor = "red";
$scope.view.wdg['3DLabel-1'].text = currentText+ " ";

$timeout(function() {
$scope.view.wdg['3DLabel-1'].text = currentText;
}, 500);

}

Thanks @sgreywilson ,

 

This is a smart solution.👍

Announcements

Top Tags