<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="theme-color" content="#090d14">
<title>REBAIXADOS BRASIL 3D</title>
<style>
*{box-sizing:border-box}
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#090d14;font-family:Arial;color:white;touch-action:none}
#game{position:fixed;inset:0}
canvas{display:block}
#top{position:fixed;top:12px;left:12px;right:12px;display:flex;justify-content:space-between;z-index:3;pointer-events:none}
.logo{font-weight:900;font-size:16px;text-shadow:0 2px 8px #000}
.logo span{color:#ff334c}
.panel{background:#07101dcc;border:1px solid #ffffff30;border-radius:12px;padding:9px;font-size:11px;line-height:1.5}
#hint{position:fixed;top:65px;left:12px;background:#07101dcc;padding:8px;border-radius:9px;font-size:11px;z-index:3}
#controls{position:fixed;bottom:15px;left:0;right:0;display:flex;justify-content:space-between;align-items:end;padding:0 12px;z-index:4}
.group{display:flex;gap:7px;align-items:end}
.control{width:58px;height:58px;border:1px solid #ffffff55;border-radius:15px;background:#101b2ddd;color:white;font-size:11px;font-weight:bold;touch-action:none}
.control:active,.control.active{background:#ff334c}
.small{width:52px;height:52px;font-size:9px}
#status{position:fixed;bottom:85px;left:50%;transform:translateX(-50%);background:#07101dcc;padding:7px 12px;border-radius:20px;font-size:11px;white-space:nowrap;z-index:3}
#start{position:fixed;inset:0;z-index:10;display:flex;align-items:center;justify-content:center;background:#080d16eF;padding:22px;text-align:center}
.startbox{max-width:350px;background:#111a28;border:1px solid #ffffff30;border-radius:20px;padding:25px}
.startbox h1{font-size:25px;margin:0}
.startbox h1 span{color:#ff334c}
.startbox p{color:#cbd5e1;font-size:13px;line-height:1.5}
#play{border:0;border-radius:12px;background:#ff334c;color:white;font-weight:900;padding:15px 25px;font-size:15px}
</style>
<script type="importmap">
{"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js"}}
</script>
</head>
<body>
<div id="game"></div>
<div id="top">
<div class="logo">REBAIXADOS <span>BRASIL 3D</span></div>
<div class="panel">CIDADE BRASILEIRA<br>SEDAN TURBO</div>
</div>
<div id="hint">Explore a cidade • Dirija seu carro</div>
<div id="status">Suspensão baixa • Som desligado</div>
<div id="controls">
<div class="group">
<button class="control" data-key="left">◀<br>VIRAR</button>
<button class="control" data-key="right">▶<br>VIRAR</button>
</div>
<div class="group">
<button class="control small" id="susp">SUSPENSÃO</button>
<button class="control small" id="sound">SOM 🔊</button>
<button class="control" data-key="brake">FREIO</button>
<button class="control" data-key="gas">ACELERAR</button>
</div>
</div>
<div id="start">
<div class="startbox">
<h1>REBAIXADOS <span>BRASIL 3D</span></h1>
<p>Uma cidade 3D para passear com seu carro rebaixado. Entre e comece a dirigir!</p>
<button id="play">ENTRAR NA CIDADE</button>
</div>
</div>
<script type="module">
import * as THREE from 'three';
const scene=new THREE.Scene();
scene.background=new THREE.Color(0x91b8d1);
scene.fog=new THREE.Fog(0x91b8d1,75,230);
const camera=new THREE.PerspectiveCamera(62,innerWidth/innerHeight,.1,500);
const renderer = new THREE.WebGLRenderer({
antialias: true,
powerPreference: "high-performance"
});
renderer.setSize(innerWidth, innerHeight);
renderer.setPixelRatio(Math.min(devicePixelRatio, 1.5));
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
renderer.toneMappingExposure = 1.15;
document.body.appendChild(renderer.domElement);
scene.add(new THREE.HemisphereLight(
0xc8e6ff,
0x35402e,
2.2
));
const sun = new THREE.DirectionalLight(0xffe2bd, 3);
sun.position.set(-25, 40, 20);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);
sun.shadow.camera.left = -45;
sun.shadow.camera.right = 45;
sun.shadow.camera.top = 45;
sun.shadow.camera.bottom = -45;
sun.shadow.bias = -0.0003;
scene.add(sun);
const mat=(c,r=.85,m=0)=>new THREE.MeshStandardMaterial({color:c,roughness:r,metalness:m});
const asphalt=mat(0x303640),sidewalk=mat(0xb9b8ae);
const yellow=mat(0xf4c542),grass=mat(0x477c49);
const glass=mat(0x162d3b,.2,.35),black=mat(0x101216);
const red = new THREE.MeshPhysicalMaterial({
color: 0xc51e32,
metalness: 0.65,
roughness: 0.22,
clearcoat: 1,
clearcoatRoughness: 0.08
});
function box(w,h,d,material,x,y,z,parent=scene){
const o=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),material);
o.position.set(x,y,z);o.castShadow=true;o.receiveShadow=true;
parent.add(o);return o;
}
// Terreno e ruas
box(260,.3,260,grass,0,-.28,0);
box(18,.12,220,asphalt,0,-.05,0);
box(220,.12,18,asphalt,0,-.05,0);
box(2,.18,220,sidewalk,-10,.02,0);
box(2,.18,220,sidewalk,10,.02,0);
box(220,.18,2,sidewalk,0,.02,-10);
box(220,.18,2,sidewalk,0,.02,10);
for(let i=-100;i<=100;i+=12){
box(.18,.02,5,yellow,0,.03,i);
box(5,.02,.18,yellow,i,.03,0);
}
// Prédios da cidade
const colors=[0xd8c6a8,0xe0e3e6,0xd1a18c,0x9db7bd,0xe8d8b6,0xb7b2c9,0xd0d6c6];
for(let x=-5;x<=5;x++){
for(let z=-5;z<=5;z++){
if(Math.abs(x)<2&&Math.abs(z)<2)continue;
const bx=x*19+(Math.random()-.5)*3;
const bz=z*19+(Math.random()-.5)*3;
const w=8+Math.random()*5,d=8+Math.random()*5;
const h=7+Math.random()*20;
const facade=mat(colors[Math.floor(Math.random()*colors.length)]);
box(w,h,d,facade,bx,h/2,bz);
box(w+.25,.35,d+.25,mat(0x454b54),bx,h+.15,bz);
for(let yy=2.2;yy<h-1;yy+=2.8){
for(let xx=-w/2+1.2;xx<w/2-.5;xx+=2.1){
box(.95,1.25,.08,glass,bx+xx,yy,bz+d/2+.05);
}
}
if(h<13){
box(w*.72,1.4,.12,mat(0x263e50),bx,1.6,bz+d/2+.12);
box(w*.85,.22,.35,red,bx,2.65,bz+d/2+.2);
}
}
}
// Árvores e postes
for(let i=-90;i<=90;i+=18){
for(const s of [-1,1]){
const tx=s*13,tz=i;
box(.55,3,.55,mat(0x765034),tx,1.5,tz);
const crown=new THREE.Mesh(new THREE.SphereGeometry(2.1,10,8),grass);
crown.position.set(tx,4.2,tz);scene.add(crown);
box(.12,5,.12,black,s*8,2.5,tz);
box(1.3,.12,.12,yellow,s*8,5,tz);
}
}
// Praça
box(22,.2,22,mat(0x9d9a87),38,.05,35);
for(let i=0;i<4;i++){
const tree=new THREE.Mesh(new THREE.CylinderGeometry(.2,.35,2,8),mat(0x8b5b36));
tree.position.set(31+(i%2)*12,1,28+Math.floor(i/2)*12);
scene.add(tree);
}
let speed=0,steer=0,suspension=.12;
let soundOn=false,audio=null,osc=null;
const keys={left:false,right:false,gas:false,brake:false};
document.querySelectorAll('[data-key]').forEach(btn=>{
const k=btn.dataset.key;
const on=e=>{e.preventDefault();keys[k]=true;btn.classList.add('active')};
const off=e=>{e.preventDefault();keys[k]=false;btn.classList.remove('active')};
btn.addEventListener('pointerdown',on);
['pointerup','pointercancel','pointerleave'].forEach(ev=>btn.addEventListener(ev,off));
});
// CARRO REBAIXADO - MODELO ESPORTIVO
const car = new THREE.Group();
scene.add(car);
// Materiais
const paintDark = mat(0x75101e, 0.25, 0.55);
const chrome = mat(0xcbd5df, 0.2, 0.9);
const rubber = mat(0x090b0e, 0.95);
const headlight = new THREE.MeshStandardMaterial({
color: 0xffffff,
emissive: 0xffe6b0,
emissiveIntensity: 1.2
});
const tailLight = new THREE.MeshStandardMaterial({
color: 0xff1028,
emissive: 0x990014,
emissiveIntensity: 0.8
});
// Carroceria principal
box(2.05, 0.58, 4.35, red, 0, 0.82, 0, car);
// Capô e porta-malas
box(1.95, 0.16, 1.05, red, 0, 1.12, 1.55, car);
box(1.95, 0.16, 0.75, red, 0, 1.12, -1.8, car);
// Teto
box(1.72, 0.12, 1.85, paintDark, 0, 1.78, -0.25, car);
// Para-brisa e vidros
box(1.62, 0.62, 0.09, glass, 0, 1.48, 0.82, car);
box(1.62, 0.58, 0.09, glass, 0, 1.48, -1.32, car);
box(0.08, 0.55, 1.8, glass, -0.83, 1.48, -0.25, car);
box(0.08, 0.55, 1.8, glass, 0.83, 1.48, -0.25, car);
// Para-choques
box(2.12, 0.22, 0.28, paintDark, 0, 0.55, 2.22, car);
box(2.12, 0.22, 0.28, paintDark, 0, 0.55, -2.22, car);
// Grade frontal
box(0.85, 0.22, 0.05, black, 0, 0.91, 2.39, car);
box(0.55, 0.035, 0.06, chrome, 0, 0.93, 2.42, car);
// Faróis e lanternas
for (const x of [-0.72, 0.72]) {
box(0.42, 0.22, 0.08, headlight, x, 0.98, 2.27, car);
box(0.42, 0.22, 0.08, tailLight, x, 0.98, -2.27, car);
}
// Retrovisores
for (const x of [-1, 1]) {
box(0.22, 0.16, 0.25, paintDark, x * 1.02, 1.48, 0.45, car);
}
// Saias laterais
for (const x of [-1, 1]) {
box(0.12, 0.16, 2.7, paintDark, x * 1.02, 0.52, -0.1, car);
}
// Rodas esportivas
for (const x of [-1, 1]) {
for (const z of [-1.48, 1.48]) {
const tire = new THREE.Mesh(
new THREE.CylinderGeometry(0.43, 0.43, 0.32, 32),
rubber
);
tire.rotation.z = Math.PI / 2;
tire.position.set(x * 1.08, 0.52, z);
car.add(tire);
const rim = new THREE.Mesh(
new THREE.CylinderGeometry(0.34, 0.34, 0.34, 32),
chrome
);
rim.rotation.z = Math.PI / 2;
rim.position.set(x * 1.08, 0.52, z);
car.add(rim);
const hub = new THREE.Mesh(
new THREE.CylinderGeometry(0.11, 0.11, 0.36, 20),
black
);
hub.rotation.z = Math.PI / 2;
hub.position.set(x * 1.08, 0.52, z);
car.add(hub);
// Pinça de freio esportiva
const caliper = new THREE.Mesh(
new THREE.BoxGeometry(0.12, 0.28, 0.18),
new THREE.MeshStandardMaterial({
color: 0xe51b32,
metalness: 0.35,
roughness: 0.3
})
);
caliper.position.set(x * 1.27, 0.62, z + 0.22);
car.add(caliper);
// Raios das rodas
for (let i = 0; i < 5; i++) {
const spoke = box(
0.07, 0.28, 0.055,
chrome,
x * 1.255,
0.52,
z,
car
);
spoke.rotation.x = i * Math.PI / 5;
}
}
}
// Posição inicial
car.position.set(0, 0, 5);
function updateStatus(){
document.getElementById('status').textContent=
`Suspensão ${suspension<.2?'baixa':'alta'} • Som ${soundOn?'ligado':'desligado'}`;
}
document.getElementById('susp').onclick=()=>{
suspension=suspension<.2?.38:.12;
updateStatus();
};
document.getElementById('sound').onclick=()=>{
soundOn=!soundOn;
if(soundOn){
audio=audio||new (window.AudioContext||window.webkitAudioContext)();
audio.resume();
osc=audio.createOscillator();
const gain=audio.createGain();
osc.type='sawtooth';
osc.frequency.value=65;
gain.gain.value=.025;
osc.connect(gain);gain.connect(audio.destination);
osc.start();window.engineGain=gain;
}else if(osc){osc.stop();osc=null}
updateStatus();
};
document.getElementById('play').onclick=()=>{
document.getElementById('start').style.display='none';
};
let last=performance.now();
function animate(now){
requestAnimationFrame(animate);
const dt=Math.min((now-last)/1000,.04);
last=now;
if(keys.gas)speed=Math.min(speed+dt*7,19);
else speed*=Math.pow(.985,dt*60);
if(keys.brake)speed=Math.max(speed-dt*15,-5);
if(keys.left)steer=Math.min(steer+dt*2.4,.65);
else if(keys.right)steer=Math.max(steer-dt*2.4,-.65);
else steer*=Math.pow(.9,dt*60);
car.rotation.y+=steer*speed*.025*dt;
car.position.x+=Math.sin(car.rotation.y)*speed*dt;
car.position.z+=Math.cos(car.rotation.y)*speed*dt;
car.position.x=THREE.MathUtils.clamp(car.position.x,-105,105);
car.position.z=THREE.MathUtils.clamp(car.position.z,-105,105);
car.position.y=suspension+Math.sin(now*.012)*Math.min(Math.abs(speed)*.001,.025);
if(soundOn&&osc){
osc.frequency.setTargetAtTime(55+Math.abs(speed)*8,audio.currentTime,.08);
}
const behind=new THREE.Vector3(0,5.2,-10).applyAxisAngle(new THREE.Vector3(0,1,0),car.rotation.y);
camera.position.lerp(new THREE.Vector3(car.position.x+behind.x,car.position.y+behind.y,car.position.z+behind.z),.09);
camera.lookAt(car.position.x,car.position.y+1,car.position.z+2);
renderer.render(scene,camera);
}
requestAnimationFrame(animate);
addEventListener('resize',()=>{
camera.aspect=innerWidth/innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth,innerHeight);
});
</script>
</body>
</html>