Absolutely! Below you'll find an updated HTML example that includes a variety of libraries that can create interesting 3D and animation effects similar to Vanta.js. I've added several examples, including libraries that simulate black holes, particles, and other dynamic backgrounds.
Complete HTML Example with Additional Libraries
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Backgrounds</title>
<style>
body {
margin: 0;
overflow: hidden;
font-family: Arial, sans-serif;
color: white;
text-align: center;
position: relative;
}
.background {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
<!-- Vanta.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.14/vanta.net.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.14/vanta.waves.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.14/vanta.cells.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.14/vanta.fog.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.14/vanta.birds.min.js"></script>
<!-- Particles.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/particles.js/2.0.0/particles.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- Black Hole Effect with Three.js -->
<script src="https://cdn.rawgit.com/stemkoski/stemkoski.github.com/6fa62ed3/Three.js/blackhole/BlackHole.js"></script>
</head>
<body>
<div class="background" id="background1"></div>
<div class="background" id="background2"></div>
<div class="background" id="background3"></div>
<div class="background" id="background4"></div>
<div class="background" id="background5"></div>
<div class="background" id="background6"></div>
<div class="background" id="background7"></div.
<script>
// Vanta.js Backgrounds
VANTA.NET({
el: "#background1",
color: 0x1a1a1a,
backgroundColor: 0x000000,
points: 12.00,
spacing: 20.00
});
VANTA.WAVES({
el: "#background2",
color: 0x0072ff,
backgroundColor: 0x000000,
amplitude: 20.00,
speed: 1.00,
zoom: 0.75
});
VANTA.CELLS({
el: "#background3",
color1: 0xff00ff,
color2: 0x00ffff,
backgroundColor: 0x000000
});
VANTA.FOG({
el: "#background4",
color: 0x1c1c1c,
backgroundColor: 0x000000
});
VANTA.BIRDS({
el: "#background5",
color1: 0x694dff,
color2: 0x36b749,
backgroundColor: 0x000000,
wingSpan: 20.0
});
// Particles.js Background
particlesJS("background6", {
particles: {
number: {
value: 80,
density: { enable: true, value_area: 800 }
},
color: { value: "#ffffff" },
shape: {
type: "circle",
stroke: { width: 0, color: "#000000" },
polygon: { nb_sides: 5 },
},
opacity: {
value: 0.5,
random: false,
anim: { enable: false },
},
size: {
value: 10,
random: true,
anim: { enable: false }
},
line_linked: {
enable: true,
distance: 150,
color: "#ffffff",
opacity: 0.4,
width: 1,
},
move: {
enable: true,
speed: 6,
direction: "none",
random: false,
straight: false,
out_mode: "out",
bounce: false
}
},
interactivity: {
events: {
onhover: { enable: true, mode: "grab" },
onclick: { enable: true, mode: "push" },
resize: true,
},
modes: {
grab: { distance: 400, line_linked: { opacity: 1 } },
bubble: { distance: 400, size: 40, duration: 2, opacity: 8, speed: 3 },
repulse: { distance: 200, duration: 2 },
}
},
retina_detect: true
});
// Black Hole effect using Three.js
let scene, camera, renderer, blackHole;
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);
renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.getElementById('background7').appendChild(renderer.domElement);
blackHole = new THREE.Mesh(
new THREE.SphereGeometry(0.5, 32, 32),
new THREE.MeshBasicMaterial({ color: 0x000000, transparent: true, opacity: 0.9 })
);
scene.add(blackHole);
camera.position.z = 2;
animate();
}
function animate() {
requestAnimationFrame(animate);
blackHole.rotation.y += 0.01;
renderer.render(scene, camera);
}
init();
</script>
</body>
</html>
Libraries Included:
- Vanta.js: Various effects such as
NET, WAVES, CELLS, FOG, BIRDS, and more.
- Particles.js: A particle system that creates an interactive background effect.
- Three.js: Used to create a 3D black hole effect, along with a spinning sphere representing the black hole.
Additional Background Libraries You Might Consider:
- Pixi.js: A powerful 2D rendering and animation library for creating beautiful interactive graphics.
- TsParticles: An alternative to particles.js that can create a variety of particle effects.
- WebGL: Custom shaders can be implemented for unique effects.
- Canvas API: For drawing custom animations using a canvas element.
Instructions:
- Complete Code: Copy the complete code into an HTML file.
- Customization: You can customize each of the background effects' parameters to fit your design needs.
- Testing: Open the file in your web browser to view the different background effects in action.
- Additional Features: Feel free to explore and add more libraries or effects as you see fit.
This compendium should give you a solid start on crafting backgrounds that leverage the beautiful dynamic capabilities of current libraries! Let me know if you need more specific effects or implementations!