Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i am trying to change the color of the lines in Vanta NET however only the dots are changing the color #190

Open
Potafe opened this issue Jul 6, 2024 · 3 comments

Comments

@Potafe
Copy link

Potafe commented Jul 6, 2024

Here is my code for reference:

const vantaRef = useRef(null);

useEffect(() => {
const vantaEffect = NET({
el: vantaRef.current,
THREE: THREE,
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.0,
minWidth: 200.0,
scale: 1.0,
scaleMobile: 1.0,
color: 0xff3f81,
lineColors: 0xff3f81,
backgroundColor: 0x0,
points: 20.0,
spacing: 17.0,
showDots: true,
maxDistance: 20.0,
});

console.log("Vanta Effect:" , vantaEffect);

return () => {
  if (vantaEffect) vantaEffect.destroy();
};

}, []);

@Potafe
Copy link
Author

Potafe commented Jul 6, 2024

image

@joujou144
Copy link

joujou144 commented Jul 12, 2024

I had the same issue with the Birds effect in my NextJs project. All the birds turned white only the backgroundColor changed. In my opinion, implementing Vanta in React/Next (and possibly other frameworks too) is extremely inconvenient. Even more so if you use Typescript. I believe libraries like Vanta is more compatible with vanilla projects.

If you evaluate the code in their src folder, the color value type is a number. And since youre using React for your project (and possibly tailwind), css is unable to read this value type as colors are set as strings e.g "#fff" The Vanta library expects color values as numbers, specifically in hexadecimal format. When converting these hexadecimal color values to formats like RGBA, we need to ensure the output remains a number.

You need to convert a hexadecimal color value to RGBA format and ensure it remains a number (not a string), you can create a function that performs this conversion directly while maintaining the numerical type expected by Vanta.. I created a function for the conversion but it didnt work. I gave up and decided to uninstall Vanta and implement a simple animation using CSS on my Hero component instead.

@Potafe
Copy link
Author

Potafe commented Jul 14, 2024

Thanks for your reply. Man i was just frustrated with this, atleast now i know that Vanta is the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants