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

Change a color of the 3D label via .js

SOLVED
MaximeDid
Regular Member

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.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Change a color of the 3D label via .js

Hi, @MaximeDid 

 

Please try the attachment.

View solution in original post

10 REPLIES 10

Re: Change a color of the 3D label via .js

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.

Re: Change a color of the 3D label via .js

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.

Re: Change a color of the 3D label via .js

Hi, @MaximeDid 

 

Please try the attachment.

View solution in original post

Re: Change a color of the 3D label via .js

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...

Re: Change a color of the 3D label via .js

Hi, @MaximeDid 

 

Which version of Vuforia Studio and browser are you using?

Could you attach your project?

Re: Change a color of the 3D label via .js

Hi @dsgnrClarK ,

I am using VuforiaStudio 8.5.15.4805 and Chrome Version 87.0.4280.88.

Please find my project in attachment.

Re: Change a color of the 3D label via .js

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

Sorry about that.

Re: Change a color of the 3D label via .js

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

Thank you for your help.

 

Re: Change a color of the 3D label via .js

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

}

Re: Change a color of the 3D label via .js

Thanks @sgreywilson ,

 

This is a smart solution.👍

Announcements
Join an
AR Working Group!

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