Hola, puedes implementar este fondo animado usando html, css , js y que se adapte al movil:
import { useEffect } from 'react';
import HALO from 'vanta/src/vanta.halo'
i.x + vec3(0.0, i1.x, 1.0 ));
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy),
dot(x12.zw,x12.zw)), 0.0);
m = mm ;
m = mm ;
vec3 x = 2.0 * fract(p * C.www) - 1.0;
vec3 h = abs(x) - 0.5;
vec3 ox = floor(x + 0.5);
vec3 a0 = x - ox;
m = 1.79284291400159 - 0.85373472095314 * ( a0a0 + h*h );
vec3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
return 130.0 * dot(m, g);
}
vec2 sincos( float x ){return vec2(sin(x), cos(x));}
vec2 rotate2d(vec2 uv, float phi){vec2 t = sincos(phi); return vec2(uv.xt.y-uv.yt.x, uv.xt.x+uv.yt.y);}
vec3 rotate3d(vec3 p, vec3 v, float phi){ v = normalize(v); vec2 t = sincos(-phi); float s = t.x, c = t.y, x =-v.x, y =-v.y, z =-v.z; mat4 M = mat4(xx(1.-c)+c,xy(1.-c)-zs,xz*(1.-c)+ys,0.,yx*(1.-c)+zs,yy*(1.-c)+c,yz(1.-c)-xs,0.,zx*(1.-c)-ys,zy*(1.-c)+xs,zz*(1.-c)+c,0.,0.,0.,0.,1.);return (vec4(p,1.)*M).xyz;}
// Classic Perlin 3D Noise
// by Stefan Gustavson
vec4 permute(vec4 x){return mod(((x34.0)+1.0)x, 289.0);}
vec4 taylorInvSqrt(vec4 r){return 1.79284291400159 - 0.85373472095314 * r;}
vec3 fade(vec3 t) {return ttt*(t*(t*6.0-15.0)+10.0);}
float p3d(vec3 P){
vec3 Pi0 = floor(P); // Integer part for indexing
vec3 Pi1 = Pi0 + vec3(1.0); // Integer part + 1
Pi0 = mod(Pi0, 289.0);
Pi1 = mod(Pi1, 289.0);
vec3 Pf0 = fract(P); // Fractional part for interpolation
vec3 Pf1 = Pf0 - vec3(1.0); // Fractional part - 1.0
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
vec4 iz0 = Pi0.zzzz;
vec4 iz1 = Pi1.zzzz;
¡Hola! Para replicar el fondo animado tipo HALO que usa Vanta.js pero sin React ni dependencias externas (vanta.halo requiere Three.js y un entorno React para init), vamos a:
Incluir Three.js
Incluir la librería Vanta Halo desde CDN
Hacer la inicialización con JS puro
Añadir el cambio de tamaño vía scroll que cambia la opción size según el scroll
Asegurar que el canvas ocupe toda la pantalla y se adapte a móvil
Código completo HTML + CSS + JS
html
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Fondo Vanta HALO Adaptable</title>
<style>
/* Hacemos que el fondo ocupe toda la pantalla */
html, body {
margin: 0;
height: 100%;
overflow-x: hidden;
background-color: #102033;
}
#vanta-bg {
position: fixed;
top: 0; left: 0;
width: 100vw;
height: 100vh;
z-index: -1;
opacity: 0.5;
user-select: none;
pointer-events: none;
}
/* Contenido de prueba para scroll */
main {
position: relative;
z-index: 10;
padding: 2rem;
color: white;
font-family: Arial, sans-serif;
min-height: 200vh; /* Para que haya scroll */
}
</style>
</head>
<body>
<div id="vanta-bg"></div>
<main>
<h1>Fondo Animado Vanta HALO</h1>
<p>Desplázate hacia abajo para ver cómo cambia el tamaño del halo.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vehicula...</p>
<!-- más contenido para scroll -->
</main>
<!-- Cargamos Three.js desde CDN -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<!-- Cargamos Vanta Halo desde CDN -->
<script src="https://cdn.jsdelivr.net/npm/vanta@latest/dist/vanta.halo.min.js"></script>
<script>
let haloEffect = null;
const el = document.getElementById('vanta-bg');
function initVanta() {
haloEffect = VANTA.HALO({
el: el,
THREE: THREE,
baseColor: 0x000000,
backgroundColor: 0x102033,
amplitudeFactor: 1.0,
size: 1.0,
gyroControls: false,
scale: 1,
scaleMobile: 1
});
}
function onScroll() {
if (!haloEffect) return;
const scrollY = window.scrollY || window.pageYOffset;
// Incrementa el tamaño mínimo 1 y máximo 2 (ajustable) según scroll
let incrementor = Math.min(Math.max(scrollY / 170, 1), 2);
haloEffect.setOptions({ size: incrementor });
}
window.addEventListener('load', () => {
initVanta();
window.addEventListener('scroll', onScroll);
});
window.addEventListener('resize', () => {
// Vanta maneja el resize internamente
// Si necesitas, podrías resetear o ajustar aquí
});
</script>
</body>
</html>
Explicación
Se usa VANTA.HALO con la configuración base del ejemplo.
El canvas queda fijo y en fondo (z-index: -1), con opacidad 0.5.
El size se modifica según scroll con límites entre 1 y 2 para que no quede exagerado.
Se carga Three.js, obligatorio para Vanta.js, desde CDN y también la librería Vanta halo.
Usa viewport meta para adaptarse a móviles.
El efecto debe funcionar igual en desktop y móvil.
La página tiene contenido para hacer scroll y ver la animación reaccionar.
Si quieres hacer un proyecto reactivo en React o Next.js usando exactamente ese código con import y hooks, dime y te ayudo con esa versión también. Pero para usar en puro HTML/JS/CSS esta es la forma correcta.