<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name="theme-color" content="#080b12">
<title>REBAIXADOS BRASIL 3D</title>
<style>
*{box-sizing:border-box}
body{margin:0;overflow:hidden;background:#080b12;color:white;font-family:Arial,sans-serif}
canvas{display:block}
button,select,input{font:inherit}
button{border:0;border-radius:12px;padding:13px 17px;background:#e32636;color:white;font-weight:bold}
#garage{
position:fixed;inset:0;z-index:5;background:linear-gradient(140deg,rgba(5,8,15,.97),rgba(18,25,39,.95));
display:flex;align-items:center;justify-content:center;padding:18px;overflow:auto
}
.panel{width:min(100%,520px);background:#111827;border:1px solid #344054;border-radius:22px;padding:20px;box-shadow:0 15px 50px #0009}
h1{font-size:26px;margin:0 0 5px;color:#ff394b}
.sub{color:#aab4c5;margin:0 0 20px;font-size:13px}
label{display:block;font-size:13px;color:#cbd5e1;margin:15px 0 7px}
select,input[type=color]{width:100%;height:45px;border-radius:10px;border:1px solid #475569;background:#202b3d;color:white;padding:8px}
input[type=range]{width:100%;accent-color:#f43f5e}
.value{color:#5eead4;font-weight:bold}
#driveBtn{width:100%;margin-top:20px;font-size:16px;padding:16px}
#hud{display:none;position:fixed;inset:0;z-index:3;pointer-events:none}
#topbar{position:absolute;top:12px;left:12px;right:12px;display:flex;justify-content:space-between;align-items:center}
.pill{background:#101827dd;border:1px solid #ffffff25;padding:10px 13px;border-radius:12px;font-size:12px}
#controls{position:absolute;bottom:20px;left:15px;right:15px;display:flex;justify-content:space-between;align-items:end}
.pad{display:flex;gap:9px;pointer-events:auto}
.control{width:62px;height:62px;border-radius:18px;background:#111827dd;border:1px solid #ffffff55;font-size:23px;touch-action:none}
.control.big{width:75px;height:75px;background:#c91e31}
#backBtn{pointer-events:auto;background:#334155;padding:9px 12px}
#hint{position:absolute;top:65px;left:50%;transform:translateX(-50%);white-space:nowrap;background:#111827cc;padding:8px 12px;border-radius:10px;font-size:11px}
</style>
<script type="importmap">
{
"imports":{
"three":"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js"
}
}
</script>
</head>
<body>
<div id="garage">
<div class="panel">
<h1>REBAIXADOS BRASIL 3D</h1>
<p class="sub">SUA GARAGEM • PERSONALIZE E DIRIJA</p>
<label>Escolha seu veículo</label>
<select id="carType">
<option value="sedan">Sedan esportivo</option>
<option value="hatch">Hatch compacto</option>
<option value="pickup">Picape rebaixada</option>
</select>
<label>Cor da pintura</label>
<input id="paint" type="color" value="#e32636">
<label>Modelo das rodas</label>
<select id="wheel">
<option value="black">Rodas pretas</option>
<option value="silver">Rodas prata</option>
<option value="gold">Rodas douradas</option>
</select>
<label>Altura da suspensão: <span class="value" id="heightValue">Baixa</span></label>
<input id="height" type="range" min="0.12" max="0.65" step="0.01" value="0.22">
<button id="driveBtn">SALVAR E DIRIGIR 🚗</button>
</div>
</div>
<div id="hud">
<div id="topbar">
<div class="pill">🇧🇷 REBAIXADOS BRASIL 3D</div>
<button id="backBtn">GARAGEM</button>
</div>
<div id="hint">Use os controles para dirigir pela cidade</div>
<div id="controls">
<div class="pad">
<button class="control" id="left">◀</button>
<button class="control" id="right">▶</button>
</div>
<div class="pad">
<button class="control" id="horn">📢</button>
<button class="control big" id="brake">▼</button>
<button class="control big" id="gas">▲</button>
</div>
</div>
</div>
<script type="module">
import * as THREE from "three";
const scene = new THREE.Scene();
scene.background = new THREE.Color(0x91b4ce);
scene.fog = new THREE.Fog(0x91b4ce, 45, 180);
const camera = new THREE.PerspectiveCamera(65,innerWidth/innerHeight,.1,300);
camera.position.set(0,7,12);
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.scene.add(new THREE.HemisphereLight(
0xc8e6ff,
0x35402e,
2.2
const sun = new THREE.DirectionalLight(0xffffff,2.2);
sun.position.set(-25,35,20);
sun.castShadow=true;
scene.add(sun);
function material(color,roughness=.8){
return new THREE.MeshStandardMaterial({color,roughness});
}
function cube(parent,x,y,z,w,h,d,mat){
const mesh=new THREE.Mesh(new THREE.BoxGeometry(w,h,d),mat);
mesh.position.set(x,y,z);
mesh.castShadow=true;
mesh.receiveShadow=true;
parent.add(mesh);
return mesh;
}
// Cidade
const ground = new THREE.Mesh(
new THREE.PlaneGeometry(220,220),
material(0x536b50)
);
ground.rotation.x=-Math.PI/2;
ground.position.y=-.12;
ground.receiveShadow=true;
scene.add(ground);
const roadMat=material(0x252a31);
const lineMat=material(0xf5d34b);
cube(scene,0,-.04,0,13,.12,220,roadMat);
cube(scene,0,-.03,0,220,.12,13,roadMat);
for(let i=-100;i<=100;i+=10){
cube(scene,0,.035,i,.18,.025,4,lineMat);
cube(scene,i,.035,0,4,.025,.18,lineMat);
}
const sidewalk=material(0xa5a5a0);
cube(scene,-7,.02,0,1,.18,220,sidewalk);
cube(scene,7,.02,0,1,.18,220,sidewalk);
cube(scene,0,.02,-7,220,.18,1,sidewalk);
cube(scene,0,.02,7,220,.18,1,sidewalk);
const buildingColors=[0xc5b7a3,0x8d9ba7,0xb6a0a0,0xd0c7b7,0x777f8c];
for(let x=-90;x<=90;x+=18){
for(let z=-90;z<=90;z+=18){
if(Math.abs(x)<17 || Math.abs(z)<17) continue;
const w=8+Math.random()*4;
const d=8+Math.random()*4;
const h=7+Math.random()*17;
const b=cube(scene,x,h/2,z,w,h,d,material(buildingColors[Math.floor(Math.random()*buildingColors.length)]));
b.castShadow=true;
for(let yy=2;yy<h-1;yy+=3){
for(let xx=-w/2+1;xx<w/2-0.5;xx+=2.3){
cube(scene,x+xx,yy,z+d/2+.04,1.1,1.3,.08,material(0x344d60));
}
}
}
}
// Árvores
const trunkMat=material(0x62432a);
const leafMat=material(0x27633d);
for(let i=0;i<45;i++){
const x=(Math.random()-.5)*180;
const z=(Math.random()-.5)*180;
if(Math.abs(x)<10 || Math.abs(z)<10) continue;
cube(scene,x,1,z,.35,2,.35,trunkMat);
const top=new THREE.Mesh(new THREE.SphereGeometry(1.5,8,7),leafMat);
top.position.set(x,3,z);
top.castShadow=true;
scene.add(top);
}
// Carro
let car=new THREE.Group();
scene.add(car);
let wheelMeshes=[];
let bodyMat;
let speed=0;
let steering=0;
let driving=false;
let selectedHeight=.22;
function buildCar(){
scene.remove(car);
car=new THREE.Group();
scene.add(car);
wheelMeshes=[];
const type=document.getElementById("carType").value;
const color=document.getElementById("paint").value;
const wheelColor=document.getElementById("wheel").value;
selectedHeight=Number(document.getElementById("height").value);
const sizes={
sedan:{w:2.15,l:4.5,h:1.0},
hatch:{w:2.05,l:3.7,h:.95},
pickup:{w:2.25,l:5.0,h:1.0}
}[type];
bodyMat=material(color,.3);
const glass= new THREE.MeshStandardMaterial({color:0x172c3c,metalness:.35,roughness:.2});
const chrome=material(0xb9c1c9,.25);
const tireMat=material(0x101114);
const rimMat=material(wheelColor==="gold"?0xd5a52b:wheelColor==="silver"?0xc5cbd2:0x22252b,.3);
cube(car,0,.75,0,sizes.w,.65,sizes.l,bodyMat);
cube(car,0,1.25,-.25,sizes.w*.84,.65,sizes.l*.48,bodyMat);
cube(car,1.0,1.27,-.25,.025,.42,sizes.l*.43,chrome);
// Para-brisa e vidros
cube(car,0,1.31,-.26,sizes.w*.77,.42,sizes.l*.43,glass);
cube(car,0,1.31,.82,sizes.w*.76,.4,.04,glass);
if(type==="pickup"){
cube(car,0,1.0,-1.65,sizes.w*.9,.42,1.2,bodyMat);
cube(car,0,1.28,-1.65,sizes.w*.85,.08,1.15,chrome);
}
// Para-choques e faróis
cube(car,0,.55,sizes.l/2,.15,.18,.12,chrome);
cube(car,0,.55,-sizes.l/2,.15,.18,.12,chrome);
for(const side of [-1,1]){
cube(car,side*.72,.83,sizes.l/2+.065,.42,.18,.08,material(0xfff2c4));
cube(car,side*.72,.83,-sizes.l/2-.065,.42,.18,.08,material(0xe32636));
}
// Rodas
for(const x of [-sizes.w/2-.02,sizes.w/2+.02]){
for(const z of [-sizes.l*.32,sizes.l*.32]){
const tire=new THREE.Mesh(new THREE.CylinderGeometry(.48,.48,.28,20),tireMat);
tire.rotation.z=Math.PI/2;
tire.position.set(x,.48,z);
tire.castShadow=true;
car.add(tire);
const rim=new THREE.Mesh(new THREE.CylinderGeometry(.29,.29,.3,16),rimMat);
rim.rotation.z=Math.PI/2;
rim.position.set(x*1.015,.48,z);
car.add(rim);
wheelMeshes.push(tire,rim);
}
}
// Posição inicial
car.position.set(0,selectedHeight,0);
car.rotation.y=0;
}
buildCar();
function updateHeight(){
selectedHeight=Number(document.getElementById("height").value);
document.getElementById("heightValue").textContent=
selectedHeight<.25?"No chão":selectedHeight<.42?"Baixa":"Alta";
car.position.y=selectedHeight;
}
document.getElementById("carType").onchange=buildCar;
document.getElementById("paint").oninput=buildCar;
document.getElementById("wheel").onchange=buildCar;
document.getElementById("height").oninput=updateHeight;
// Controles
const keys={left:false,right:false,gas:false,brake:false};
function hold(id,key){
const el=document.getElementById(id);
el.addEventListener("pointerdown",e=>{e.preventDefault();keys[key]=true;});
["pointerup","pointerleave","pointercancel"].forEach(evt=>
el.addEventListener(evt,()=>keys[key]=false)
);
}
hold("left","left");
hold("right","right");
hold("gas","gas");
hold("brake","brake");
addEventListener("keydown",e=>{
if(e.key==="ArrowUp"||e.key==="w")keys.gas=true;
if(e.key==="ArrowDown"||e.key==="s")keys.brake=true;
if(e.key==="ArrowLeft"||e.key==="a")keys.left=true;
if(e.key==="ArrowRight"||e.key==="d")keys.right=true;
});
addEventListener("keyup",e=>{
if(e.key==="ArrowUp"||e.key==="w")keys.gas=false;
if(e.key==="ArrowDown"||e.key==="s")keys.brake=false;
if(e.key==="ArrowLeft"||e.key==="a")keys.left=false;
if(e.key==="ArrowRight"||e.key==="d")keys.right=false;
});
let audioCtx;
function horn(){
try{
audioCtx=audioCtx||new AudioContext();
const osc=audioCtx.createOscillator();
const gain=audioCtx.createGain();
osc.type="sawtooth";
osc.frequency.value=220;
gain.gain.value=.12;
osc.connect(gain);
gain.connect(audioCtx.destination);
osc.start();
osc.stop(audioCtx.currentTime+.35);
}catch(e){}
}
document.getElementById("horn").addEventListener("pointerdown",horn);
// Entrar e sair da garagem
document.getElementById("driveBtn").onclick=()=>{
buildCar();
driving=true;
document.getElementById("garage").style.display="none";
document.getElementById("hud").style.display="block";
};
document.getElementById("backBtn").onclick=()=>{
driving=false;
speed=0;
document.getElementById("garage").style.display="flex";
document.getElementById("hud").style.display="none";
};
// Animação
const clock=new THREE.Clock();
function animate(){
requestAnimationFrame(animate);
const dt=Math.min(clock.getDelta(),.04);
if(driving){
if(keys.gas) speed=Math.min(speed+dt*5,13);
else speed*=.985;
if(keys.brake) speed=Math.max(speed-dt*12,-3);
if(keys.left) steering=Math.min(steering+dt*2.5,.65);
else if(keys.right) steering=Math.max(steering-dt*2.5,-.65);
else steering*=.88;
car.rotation.y+=steering*speed*.012;
car.translateZ(-speed*dt*.65);
// Rodas giram
wheelMeshes.forEach(w=>w.rotation.x+=speed*dt*1.5);
const behind=new THREE.Vector3(0,5,10);
behind.applyAxisAngle(new THREE.Vector3(0,1,0),car.rotation.y);
const target=car.position.clone().add(behind);
camera.position.lerp(target,.08);
const look=car.position.clone();
look.y+=1;
camera.lookAt(look);
}else{
camera.position.lerp(new THREE.Vector3(0,7,12),.04);
camera.lookAt(0,0,0);
}
renderer.render(scene,camera);
}
animate();
addEventListener("resize",()=>{
camera.aspect=innerWidth/innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(innerWidth,innerHeight);
});
</script>
</body>
</html>