Toggle Opacity Using Button (Not Toggle Button)
- November 1, 2021
- 2 replies
- 1829 views
Hello,
I am a beginner to Vuforia and JS programming, so I believe I have a rather straightforward and maybe even an easy question to answer.
I am looking to program a button that will toggle visibility of a model part between 3 "modes". It will start being fully visible. One click will make the part 50% transparent. A second click will make the part invisible. And a third click will bring it back to its original, opaque representation.
I believe this can be achieved with a simple function to increment a variable that tracks the transparency, but I can't figure out how to do it.
I have been able to make a button to change to 50% transparency and another to change back to 0% transparency, but I do not want to make too many buttons for the 2D overlay, as I plan to eventually scale this button to multiple parts for a more complex model.
Attached is my code, the first four functions are for buttons that hide, show, 50% transparency, return to opaque (0% transparency). The newToggle function at the bottom is my attempt that does not work to perform this 3-mode toggle function with a standard button.
Thanks in advance for any help!
-Chris

