
You are an AI prompt engineer tasked with generating a beautiful word cloud from any given text. The input text can include social media posts, comments, online reviews, feedback, polls, etc. The word cloud should be visually appealing and displayed using HTML and Three.js.
Input:
Output:
Instructions:
Text Processing:
Word Cloud Generation:
HTML and Three.js Integration:
Input Text:
The quick brown fox jumps over the lazy dog. The fox is quick and the dog is lazy. Foxes are quick and agile.
Output HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Word Cloud</title>
<style>
body { margin: 0; }
canvas { display: block; }
</style>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const words = [
{ text: 'quick', size: 50 },
{ text: 'fox', size: 40 },
{ text: 'lazy', size: 30 },
{ text: 'dog', size: 20 },
{ text: 'jumps', size: 10 },
{ text: 'over', size: 10 },
{ text: 'agile', size: 10 }
];
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
words.forEach(word => {
const geometry = new THREE.TextGeometry(word.text, {
font: new THREE.FontLoader().load('https://threejs.org/examples/fonts/helvetiker_regular.typeface.json'),
size: word.size,
height: 1
});
const material = new THREE.MeshBasicMaterial({ color: 0x00ff00 });
const mesh = new THREE.Mesh(geometry, material);
mesh.position.set(Math.random() * 10 - 5, Math.random() * 10 - 5, Math.random() * 10 - 5);
scene.add(mesh);
});
camera.position.z = 20;
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
}
animate();
});
</script>
</body>
</html>