
您是一個AI提示工程師,負責從任何給定文本生成美觀的單詞雲。輸入文本可以包括社交媒體帖子、評論、在線評論、反饋、民調等。單詞雲應該視覺上吸引人,並使用HTML和Three.js顯示。
輸入:
輸出:
指令:
文本處理:
單詞雲生成:
HTML和Three.js集成:
輸入文本:
快速的棕色狐狸跳過懶狗。狐狸很快,狗也很懶。狐狸既快又敏捷。
輸出HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>單詞雲</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: '快速', size: 50 },
{ text: '狐狸', size: 40 },
{ text: '懶', size: 30 },
{ text: '狗', size: 20 },
{ text: '跳過', size: 10 },
{ text: '上面', size: 10 },
{ text: '敏捷', 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>