Aqui está um exemplo de uma casa em tons de preto e dourado usando Three.js (WebGL) com animações:
html
<!DOCTYPE html>
<html>
<head>
<title>Casa Elegante</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>
// Configuração inicial
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);
// Materiais
const blackMaterial = new THREE.MeshPhongMaterial({
color: 0x111111,
specular: 0x333333,
shininess: 30
});
const goldMaterial = new THREE.MeshPhongMaterial({
color: 0xFFD700,
specular: 0xFFFFFF,
shininess: 100
});
// Construção da casa
function createHouse() {
const house = new THREE.Group();
// Base da casa
const base = new THREE.BoxGeometry(4, 3, 4);
const baseHouse = new THREE.Mesh(base, blackMaterial);
house.add(baseHouse);
// Telhado
const roofGeometry = new THREE.ConeGeometry(3, 2, 4);
const roof = new THREE.Mesh(roofGeometry, goldMaterial);
roof.position.y = 2.5;
house.add(roof);
// Porta
const doorGeometry = new THREE.BoxGeometry(0.8, 1.5, 0.1);
const door = new THREE.Mesh(doorGeometry, goldMaterial);
door.position.set(0, -0.75, 2);
house.add(door);
// Janelas
const windowGeometry = new THREE.BoxGeometry(0.8, 0.8, 0.1);
const window1 = new THREE.Mesh(windowGeometry, goldMaterial);
window1.position.set(-1, 0.5, 2);
house.add(window1);
const window2 = new THREE.Mesh(windowGeometry, goldMaterial);
window2.position.set(1, 0.5, 2);
house.add(window2);
return house;
}
const house = createHouse();
scene.add(house);
// Iluminação
const ambientLight = new THREE.AmbientLight(0xFFFFFF, 0.5);
scene.add(ambientLight);
const pointLight = new THREE.PointLight(0xFFFFFF, 1);
pointLight.position.set(5, 5, 5);
scene.add(pointLight);
camera.position.z = 10;
// Animações
let time = 0;
function animate() {
requestAnimationFrame(animate);
time += 0.01;
// Rotação suave da casa
house.rotation.y = Math.sin(time) * 0.2;
// Movimento flutuante
house.position.y = Math.sin(time) * 0.2;
// Efeito de luz girando
pointLight.position.x = Math.sin(time * 2) * 5;
pointLight.position.z = Math.cos(time * 2) * 5;
renderer.render(scene, camera);
}
// Responsividade
window.addEventListener('resize', onWindowResize, false);
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
animate();
</script>
</body>
</html>
Para usar este código, basta salvá-lo como um arquivo HTML e abri-lo em um navegador moderno que suporte WebGL.