diff --git a/.github/workflows/vice-apk.yml b/.github/workflows/vice-apk.yml
index 629baae7..2458c9d3 100644
--- a/.github/workflows/vice-apk.yml
+++ b/.github/workflows/vice-apk.yml
@@ -5,7 +5,7 @@ name: VICE VI Mobile APK
on:
push:
- branches: [ "main", "arena/2261e308-nextvr-android" ]
+ branches: [ "main", "arena/bb935b38-nextvr-android" ]
pull_request:
paths:
- 'vice-game/**'
@@ -73,20 +73,20 @@ jobs:
ls -lh vice6-mobile.zip
- name: Publish release with direct APK & ZIP download links
- if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'arena/2261e308-nextvr-android')
+ if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'arena/bb935b38-nextvr-android')
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
APK=$(find "$GITHUB_WORKSPACE/vice-game/android/app/build/outputs/apk" -name '*.apk' -print -quit)
cp "$APK" "$GITHUB_WORKSPACE/vice6-mobile.apk"
- TAG="vice6-mobile-v0.2.0"
- NOTES="VICE VI Mobile (GTA 6 Mobile) v0.2.0 com os 8 modelos 3D .glb integrados (Corvette Stingray, Fiesta, Pontiac GTO, Cruze Police, Moto 004, Motorhome Triple E Commander, Standing Man + Citizen NPC Pack). Commit ${GITHUB_SHA}."
+ TAG="vice6-mobile-v0.7.0"
+ NOTES="VICE VI Mobile (GTA 6 Mobile) v0.7.0 — OCEANO REALISTA: ondas vértice a vértice com arrebentação 3D em 4 faixas e espuma volumétrica, ARQUIPÉLAGO DE ILHAS no horizonte (Starfish Cay, Pelican Reef Resort, Ilha Esmeralda e Serra Costeira com faróis giratórios, resorts e veleiros), fim do 'água até o infinito'! BANCO NACIONAL MONUMENTAL: pedra neoclássica texturizada, 4 colunas coríntias, frontão triangular com sol dourado, escadaria + tapete vermelho, torre corporativa de vidro espelhado com antena dourada e lustres de cristal no saguão com o COFRE (6 estrelas)! MALHA VIÁRIA COMPLETA: Avenidas AMPLAS com canteiro central (28m), Normais (18m) e RUAS ESTREITAS/Becos (9m) em toda a cidade! GRANDES PONTES ESTAIADAS MONUMENTAIS com torres H-frame de 40-46m e estais em leque ligando Vice Leonida ↔ Palm Bay City ↔ Vice Keys + Viaduto do Aeroporto! MAPA GPS EXPANDIDO NÍTIDA EM HiDPI/devicePixelRatio com estética GTA V moderna (oceano gradiente, contornos batimétricos, hierarquia viária âmbar, metrorail tracejado, pista do aeroporto, rosa dos ventos, escala 500m e moldura neon)! TÚNEIS rodoviários iluminados com portal e morro por cima! TREM EXPRESSO METRORAIL em movimento com buzina, 2 ESTAÇÕES caminháveis (plataformas, cobertas, bancos e letreiro) e embarque grátis! AEROPORTO INTERNACIONAL VIA: pista zebrada listrada, luzes de borda, jatos comerciais e executivo 3D, torre com radar giratório, terminal ENTRÁVEL com check-in, assentos e painel de partidas + avião no circuito de tráfego! LOJAS ENTRÁVEIS A PÉ literalmente (24/7 Vice Mart, Ammu-Nation e Neon Threads) com interior completo, atendentes, prateleiras e COMPRA DIRETA NO INTERIOR! Commit ${GITHUB_SHA}."
if ! gh release view "$TAG" > /dev/null 2>&1; then
- gh release create "$TAG" --title "VICE VI Mobile (GTA 6 Mobile) v0.2.0 — Modelos 3D .GLB" \
+ gh release create "$TAG" --title "VICE VI Mobile (GTA 6 Mobile) v0.7.0 — Oceano Real, Ilhas, Banco Monumental, Pontes Gigantes, Metrorail, Aeroporto & Lojas Entráveis" \
--notes "$NOTES" --target "$GITHUB_SHA" --prerelease
else
- gh release edit "$TAG" --title "VICE VI Mobile (GTA 6 Mobile) v0.2.0 — Modelos 3D .GLB" \
+ gh release edit "$TAG" --title "VICE VI Mobile (GTA 6 Mobile) v0.7.0 — Oceano Real, Ilhas, Banco Monumental, Pontes Gigantes, Metrorail, Aeroporto & Lojas Entráveis" \
--notes "$NOTES" --target "$GITHUB_SHA" --prerelease
gh api --method PATCH "repos/$GITHUB_REPOSITORY/git/refs/tags/$TAG" \
-f sha="$GITHUB_SHA" -F force=true > /dev/null
diff --git a/tests/vice-game.test.mjs b/tests/vice-game.test.mjs
index a7f7f4c1..c55c57c1 100644
--- a/tests/vice-game.test.mjs
+++ b/tests/vice-game.test.mjs
@@ -3,19 +3,46 @@ import assert from 'node:assert/strict';
import { readFile, stat } from 'node:fs/promises';
import {
+ MAP_HALF,
AVENUES_X,
STREETS_Z,
+ INTERCITY_BRIDGES,
+ SCENIC_ROADS,
+ NARROW_ROADS,
+ OFFSHORE_ISLANDS,
+ ROAD_TUNNELS,
+ AIRPORT_DATA,
+ TRAIN_LINE,
+ ENTERABLE_SHOPS,
+ BANK_INTERIOR,
+ getAvenueWidth,
+ getStreetWidth,
+ CORVETTE_CONTAINER,
+ FERRIS_WHEEL,
DISTRICTS,
POINTS_OF_INTEREST,
districtAt,
isWaterAt,
isRoadAt,
+ isNarrowRoadAt,
isOnBridge,
generateCityLayout
} from '../vice-game/src/data/city.js';
import { VEHICLE_MODELS, RADIO_STATIONS, getVehicleModel } from '../vice-game/src/data/vehicles.js';
import { CHARACTERS, WEAPONS, MISSIONS, nextAvailableMission } from '../vice-game/src/data/missions.js';
import { defaultProfile, loadProfile, saveProfile, STORAGE_KEY } from '../vice-game/src/state.js';
+import {
+ sanitizePbrMaterial,
+ instantiateNormalizedVehicle,
+ instantiateRiggedProtagonist,
+ buildArticulatedCitizenTemplate,
+ instantiateArticulatedCitizen,
+ retargetMixamoClip
+} from '../vice-game/src/world/glb-loader.js';
+import { buildRealisticWeaponRig } from '../vice-game/src/world/entities.js';
+import { buildCityScene } from '../vice-game/src/world/city-mesh.js';
+import { DAY_TO_NIGHT_SECONDS, GAME_HOURS_PER_SECOND, createCelestialRig, THREE } from '../vice-game/src/world/engine.js';
+import { GLTFLoader } from '../vice-game/vendor/GLTFLoader.js';
import { startViceServer } from '../vice-game/serve.mjs';
test('mapa de Vice Leonida: bairros, pontes sobre o canal, praia, oceano e prédios sem invadir avenidas', () => {
@@ -52,24 +79,30 @@ test('mapa de Vice Leonida: bairros, pontes sobre o canal, praia, oceano e préd
}
});
-test('catálogo de protagonistas (Lucia & Jason), veículos, estações FM e campanha de missões', () => {
- assert.deepEqual(CHARACTERS.map(c => c.id), ['lucia', 'jason']);
- assert.ok(VEHICLE_MODELS.length >= 7);
+test('catálogo: protagonista único Rafael, Corvette raro no Container, armas com grip realista e campanha v0.6.0', () => {
+ assert.deepEqual(CHARACTERS.map(c => c.id), ['rafael']);
+ assert.equal(CHARACTERS[0].name, 'Rafael');
+
+ assert.ok(VEHICLE_MODELS.length >= 8);
assert.ok(VEHICLE_MODELS.some(v => v.isBike), 'inclui moto esportiva');
assert.ok(VEHICLE_MODELS.some(v => v.isPolice), 'inclui viatura policial VCPD');
- assert.equal(getVehicleModel('cheetah-vice').category, 'super');
+ const corvette = getVehicleModel('cheetah-vice');
+ assert.equal(corvette.category, 'super');
+ assert.equal(corvette.specialContainerOnly, true, 'Corvette Stingray é carro raro exclusivo do container');
assert.ok(RADIO_STATIONS.length >= 5);
assert.ok(WEAPONS.length >= 5);
+ assert.equal(WEAPONS.find(w => w.id === 'pistol')?.grip, 'pistol');
+ assert.equal(WEAPONS.find(w => w.id === 'rifle')?.grip, 'rifle');
assert.ok(MISSIONS.length >= 4);
const first = nextAvailableMission([]);
assert.equal(first.id, 'welcome-vice');
const second = nextAvailableMission(['welcome-vice']);
- assert.equal(second.id, 'neon-sprint');
+ assert.equal(second.id, 'corvette-container');
});
-test('persistência de perfil em localStorage (dinheiro, protagonista, armas e missões)', () => {
+test('persistência de perfil em localStorage (protagonista único Rafael, céu rosa de fim de tarde e missões)', () => {
const mem = new Map();
const fakeStorage = {
getItem: k => (mem.has(k) ? mem.get(k) : null),
@@ -77,15 +110,15 @@ test('persistência de perfil em localStorage (dinheiro, protagonista, armas e m
};
const p = defaultProfile();
- assert.equal(p.characterId, 'lucia');
- p.characterId = 'jason';
+ assert.equal(p.characterId, 'rafael');
+ assert.equal(p.settings.timeMode, 'sunset', 'fim de tarde rosa é o padrão');
p.money = 19500;
p.completedMissions.push('welcome-vice');
assert.equal(saveProfile(p, fakeStorage), true);
assert.ok(mem.has(STORAGE_KEY));
const loaded = loadProfile(fakeStorage);
- assert.equal(loaded.characterId, 'jason');
+ assert.equal(loaded.characterId, 'rafael');
assert.equal(loaded.money, 19500);
assert.deepEqual(loaded.completedMissions, ['welcome-vice']);
assert.ok(loaded.ownedWeapons.includes('fist'));
@@ -109,7 +142,7 @@ test('servidor HTTP de VICE VI Mobile serve index.html, módulos ES e three.js l
const studioRes = await fetch(`${url}/upload-glb.html`);
assert.equal(studioRes.status, 200);
- assert.match(await studioRes.text(), /ENVIAR \.GLB/);
+ assert.match(await studioRes.text(), /palm\.glb/);
const listRes = await fetch(`${url}/api/models`);
assert.equal(listRes.status, 200);
@@ -161,3 +194,355 @@ test('todos os 8 modelos .glb enviados existem, têm assinatura glTF válida e e
assert.ok(v.glbUrl && v.glbUrl.startsWith('assets/brand/'), `veículo ${v.id} aponta para um modelo .glb real`);
}
});
+
+test('higienização PBR corrige materiais escuros (moto_004 e triple_e_commander) e normaliza rigging/escala 3D', async () => {
+ // Simula material exportado do Redshift/FBX com metalness=1 e roughness=1 sobre mapa difuso
+ const brokenMat = {
+ name: 'rsMaterial1SG',
+ map: { colorSpace: '' },
+ metalness: 1,
+ roughness: 1,
+ envMapIntensity: 1
+ };
+ sanitizePbrMaterial(brokenMat);
+ assert.ok(brokenMat.metalness < 0.4, 'metalness excessivo sem metalnessMap é corrigido para exibir a textura');
+ assert.ok(brokenMat.roughness < 0.6, 'roughness recebe acabamento automotivo brilhante');
+ assert.ok(brokenMat.envMapIntensity >= 1.35, 'envMapIntensity reforçado para reflexo IBL de Leonida');
+
+ // Faz parse real em memória de moto_004.glb e standing_man.glb para validar escala, chão (minY=0) e esqueleto
+ const prevBitmap = globalThis.createImageBitmap;
+ const prevSelf = globalThis.self;
+ globalThis.self = globalThis;
+ globalThis.createImageBitmap = async () => ({ width: 2, height: 2, close() {} });
+ try {
+ const loader = new GLTFLoader();
+ const parseGlb = async relPath => {
+ const buf = await readFile(relPath);
+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+ return new Promise((res, rej) => loader.parse(ab, '', res, rej));
+ };
+
+ const commanderGltf = await parseGlb('vice-game/assets/brand/triple_e_commander.glb');
+ const commanderInst = instantiateNormalizedVehicle(commanderGltf, { targetLength: 8.2, yawOffset: Math.PI });
+ assert.ok(commanderInst?.node, 'triple_e_commander instanciado com sucesso');
+ let camperMat = null;
+ commanderInst.node.traverse(o => {
+ if (o.isMesh && o.material && /camper/.test(o.material.name || '')) camperMat = o.material;
+ });
+ assert.ok(camperMat && camperMat.metalness < 0.4, 'material de triple_e_commander foi higienizado contra preto PBR');
+
+ const motoGltf = await parseGlb('vice-game/assets/brand/moto_004.glb');
+ const motoInst = instantiateNormalizedVehicle(motoGltf, { targetLength: 2.28, yawOffset: -Math.PI / 2, isBike: true });
+ assert.ok(motoInst?.node, 'moto_004 instanciada com sucesso');
+ let motoMat = null;
+ motoInst.node.traverse(o => {
+ if (o.isMesh && o.material && typeof o.material.envMapIntensity === 'number') motoMat = o.material;
+ });
+ assert.ok(motoMat && motoMat.envMapIntensity >= 1.35, 'material ORM da moto_004 recebe reforço de IBL');
+
+ const manGltf = await parseGlb('vice-game/assets/brand/standing_man.glb');
+ const manInst = instantiateRiggedProtagonist(manGltf, { outfitTint: '#ff2a85' });
+ assert.ok(manInst?.node, 'protagonista Mixamo instanciado com sucesso');
+ manInst.animateRig(0.016, 4.0, false, { mode: 'foot', steer: 0 });
+ manInst.animateRig(0.016, 8.5, false, { mode: 'foot', steer: 0.25 });
+ manInst.animateRig(0.016, 18.0, false, { mode: 'bike', steer: -0.4 });
+ manInst.animateRig(0.016, 0.0, false, { mode: 'ragdoll', ragdollTime: 0.35 });
+ manInst.animateRig(0.016, 0.0, true, { mode: 'foot' });
+
+ // Valida retargeting automático de clipes Mixamo (ex.: mixamorig:LeftUpLeg -> mixamorigLeftUpLeg_055)
+ const sampleClip = new THREE.AnimationClip('walk', 1.0, [
+ new THREE.QuaternionKeyframeTrack('mixamorig:LeftUpLeg.quaternion', [0, 1], [0, 0, 0, 1, 0.2, 0, 0, 0.98]),
+ new THREE.VectorKeyframeTrack('mixamorig:Hips.position', [0, 1], [0, 1, 0, 0, 1, 2])
+ ]);
+ const retargeted = retargetMixamoClip(sampleClip, manInst.node);
+ assert.ok(retargeted && retargeted.tracks.length === 1, 'retarget mapeia ossos Mixamo e remove root-motion X/Z do Hips');
+ assert.match(retargeted.tracks[0].name, /mixamorigLeftUpLeg_\d+\.quaternion/);
+ } finally {
+ globalThis.createImageBitmap = prevBitmap;
+ globalThis.self = prevSelf;
+ }
+});
+
+test('ciclo Dia <-> Noite de 10 minutos, abóbada celeste (Sol, Lua, estrelas e nuvens) e casas residenciais', () => {
+ // 10 minutos (600s) avançam exatamente 12 horas do jogo (Dia -> Noite ou Noite -> Dia)
+ assert.equal(DAY_TO_NIGHT_SECONDS, 600);
+ assert.ok(Math.abs(GAME_HOURS_PER_SECOND * 600 - 12) < 1e-9, '600 segundos correspondem a exatas 12 horas no jogo');
+
+ const sky = createCelestialRig(460);
+ // Meio-dia (12h, nightFactor=0): Sol visível no alto, estrelas invisíveis, nuvens claras
+ sky.update(12.0, 0, 0, 0, 0.016);
+ assert.equal(sky.sunGroup.visible, true, 'Sol visível ao meio-dia');
+ assert.equal(sky.stars.visible, false, 'estrelas ocultas ao meio-dia');
+ assert.ok(sky.cloudsGroup.children.length >= 18, 'céu diurno possui nuvens 3D');
+
+ // Meia-noite (0h, nightFactor=1): Lua visível no alto, estrelas acesas no céu escuro, Sol abaixo do horizonte
+ sky.update(0.0, 0, 0, 1, 0.016);
+ assert.equal(sky.moonGroup.visible, true, 'Lua brilhante visível à meia-noite');
+ assert.equal(sky.stars.visible, true, 'estrelas acesas à meia-noite');
+ assert.equal(sky.sunGroup.visible, false, 'Sol oculto à meia-noite');
+
+ // Cidade possui casas/mansões residenciais além dos prédios comerciais e nenhuma invade ruas/avenidas
+ const layout = generateCityLayout();
+ assert.ok(Array.isArray(layout.houses) && layout.houses.length >= 25, 'cidade possui dezenas de casas e mansões residenciais');
+ assert.ok(layout.buildings.length >= 80, 'cidade densa com prédios e casas');
+ for (const h of layout.houses) {
+ assert.equal(isRoadAt(h.x, h.z), false, `casa ${h.id} fica fora da pista asfaltada`);
+ }
+});
+
+test('rodas giram em todos os 7 veículos .glb, porta do motorista abre/fecha, ônibus olha +Z e cidadãos têm braços naturais', async () => {
+ const prevBitmap = globalThis.createImageBitmap;
+ const prevSelf = globalThis.self;
+ globalThis.self = globalThis;
+ globalThis.createImageBitmap = async () => ({ width: 2, height: 2, close() {} });
+
+ try {
+ const loader = new GLTFLoader();
+ const parseGlb = async relPath => {
+ const buf = await readFile(relPath);
+ const ab = buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
+ return new Promise((res, rej) => loader.parse(ab, '', res, rej));
+ };
+
+ // 1. Verifica extração/pivôs de rodas giratórias + porta articulada em TODOS os veículos do catálogo!
+ for (const spec of VEHICLE_MODELS) {
+ const gltf = await parseGlb(`vice-game/${spec.glbUrl}`);
+ const inst = instantiateNormalizedVehicle(gltf, {
+ targetLength: spec.length,
+ yawOffset: spec.glbYaw || 0,
+ isBike: Boolean(spec.isBike),
+ bodyColor: spec.colors[0]
+ });
+ const expectedMinWheels = spec.isBike ? 2 : 4;
+ assert.ok(
+ inst.wheelCount >= expectedMinWheels,
+ `${spec.id} extraiu pelo menos ${expectedMinWheels} rodas giratórias (obteve ${inst.wheelCount})`
+ );
+
+ // Gira as rodas a 18 m/s com esterço e confirma rotação real de spinPivot!
+ inst.updateWheels(0.1, 18.0, 0.5);
+ let spunCount = 0;
+ inst.node.traverse(o => {
+ if (o.isGroup && Math.abs(o.rotation.x) > 0.2) spunCount += 1;
+ });
+ assert.ok(spunCount >= expectedMinWheels, `${spec.id} gira todas as rodas ao andar`);
+
+ if (!spec.isBike) {
+ inst.setDoorAngle(1.05);
+ let openDoorFound = false;
+ inst.node.traverse(o => {
+ if (o.isGroup && o.visible && Math.abs(o.rotation.y + 1.05) < 0.02) openDoorFound = true;
+ });
+ assert.equal(openDoorFound, true, `${spec.id} abre a porta articulada do motorista`);
+ inst.setDoorAngle(0);
+ }
+
+ // Garante que o ônibus/motorhome (cavalcade-suv) tem as rodas dianteiras na frente (+Z > 2.5m)!
+ if (spec.id === 'cavalcade-suv') {
+ assert.equal(spec.glbYaw, Math.PI, 'cavalcade-suv usa glbYaw=PI para que a cabine fique na frente (+Z)');
+ }
+ }
+
+ // 2. Verifica que o protagonista executa enterCar / exitCar sem NaN e com inclinação realista
+ const manGltf = await parseGlb('vice-game/assets/brand/standing_man.glb');
+ const manInst = instantiateRiggedProtagonist(manGltf, { outfitTint: '#ff2a85' });
+ for (const p of [0.1, 0.35, 0.55, 0.85, 1.0]) {
+ manInst.animateRig(0.05, 0, false, { mode: 'enterCar', doorProgress: p });
+ }
+ manInst.node.traverse(o => {
+ if (o.isBone) {
+ assert.ok(!Number.isNaN(o.quaternion.x), `osso ${o.name} válido após animação enterCar`);
+ }
+ });
+
+ // 3. Verifica que os NPCs do Citizen Pack dobram os braços (fim da A-pose!) e animam braços/pernas!
+ const citGltf = await parseGlb('vice-game/assets/brand/citizen_npc_pack_1_character_lowpoly_mobile.glb');
+ citGltf.scene.updateMatrixWorld(true);
+ const firstMeshes = [];
+ citGltf.scene.traverse(o => {
+ if (o.isMesh && /Citizen_00amza_001/.test(o.name)) firstMeshes.push(o);
+ });
+ assert.ok(firstMeshes.length >= 2, 'encontrou malhas de corpo e cabeça do Citizen 001');
+
+ // Carrega via módulo e valida que a largura pós-rigging reduziu os braços abertos (~1.29m -> ~0.64m) e anima!
+ const rawBox = new THREE.Box3();
+ for (const m of firstMeshes) rawBox.expandByObject(m);
+ const rawSize = new THREE.Vector3();
+ rawBox.getSize(rawSize);
+ assert.ok(rawSize.x > 1.1, 'malha original vinha de braços abertos em A-pose (>1.1m)');
+
+ const tpl = buildArticulatedCitizenTemplate('001', firstMeshes);
+ tpl.bodyGeo.computeBoundingBox();
+ const relaxedWidth = tpl.bodyGeo.boundingBox.max.x - tpl.bodyGeo.boundingBox.min.x;
+ assert.ok(relaxedWidth < 0.78, `cidadão agora tem braços abaixados junto ao corpo (largura ${relaxedWidth.toFixed(2)}m)`);
+
+ const citInst = instantiateArticulatedCitizen(tpl);
+ citInst.animateCitizen(0.12, 2.2); // caminhando
+ let movedArm = false;
+ citInst.node.traverse(o => {
+ if (o.isBone && o.name === 'armL' && Math.abs(o.rotation.x) > 0.02) movedArm = true;
+ });
+ assert.equal(movedArm, true, 'cidadão balança os braços e pernas ao caminhar');
+
+ // 4. Verifica poses dedicadas de Pistola, Fuzil, Rendição (`surrender`) e Cabine da Roda-Gigante (`ferrisSit`) em Rafael!
+ for (const opts of [
+ { mode: 'foot', weaponGrip: 'pistol' },
+ { mode: 'foot', weaponGrip: 'rifle' },
+ { mode: 'surrender' },
+ { mode: 'ferrisSit' }
+ ]) {
+ manInst.animateRig(0.05, 0, true, opts);
+ manInst.node.traverse(o => {
+ if (o.isBone) assert.ok(!Number.isNaN(o.quaternion.x), `osso ${o.name} válido em ${opts.mode}/${opts.weaponGrip || ''}`);
+ });
+ }
+
+ // 5. Verifica poses de praia (banhista na cadeira de sol, vôlei de praia e altinha) no Citizen Pack!
+ for (const act of ['sunbathe', 'volleyball', 'altinha']) {
+ citInst.animateCitizen(0.1, 0, act);
+ citInst.node.traverse(o => {
+ if (o.isBone) assert.ok(!Number.isNaN(o.rotation.x), `osso cidadão válido na atividade ${act}`);
+ });
+ }
+ } finally {
+ globalThis.createImageBitmap = prevBitmap;
+ globalThis.self = prevSelf;
+ }
+});
+
+test('v0.6.0: 3 cidades conectadas por pontes, estradas curvas, Roda-Gigante 3D ($70), Banco com Cofre, pegadas na areia, postes noturnos e armas 3D', () => {
+ assert.equal(MAP_HALF, 920);
+ assert.equal(districtAt(0, -680).id, 'palm-bay', 'Palm Bay City ao norte');
+ assert.equal(districtAt(180, 680).id, 'vice-keys', 'Vice Keys Island ao sul');
+ assert.ok(INTERCITY_BRIDGES.length >= 3, 'pontes estaiadas intermunicipais conectam as ilhas');
+ assert.equal(isWaterAt(40, -530), false, 'ponte norte leste é seca e dirigível sobre o mar');
+ assert.equal(isWaterAt(170, 530), false, 'ponte sul Overseas para Vice Keys é seca e dirigível');
+ assert.ok(SCENIC_ROADS.length >= 5, 'possui rodovias curvas e diagonais');
+ assert.equal(FERRIS_WHEEL.ticketPrice, 70, 'Roda-Gigante custa exatamente $70');
+ assert.equal(FERRIS_WHEEL.cabins, 10, 'Roda-Gigante possui 10 cabines reais');
+
+ const layout = generateCityLayout();
+ assert.ok(layout.streetlights.length >= 40, 'possui dezenas de postes de luz nas calçadas');
+ assert.ok(layout.trees.length >= 30, 'possui árvores copadas além das palmeiras');
+ assert.ok(layout.beachAccesses.length >= 4, 'possui passarelas abertas para a areia');
+ assert.ok(layout.beachCourts.length >= 3, 'possui quadras de vôlei de praia e rodas de altinha');
+
+ // Cena 3D completa: Roda-Gigante gira cabines verticalmente, pegadas na areia incrementam e postes acendem à noite!
+ const scene = new THREE.Scene();
+ const city = buildCityScene(scene, { shadows: false });
+ assert.equal(city.ferrisCabins.length, 10);
+ assert.ok(city.lootGroup.visible, 'Cofre do Banco Nacional possui barras de ouro e notas visíveis');
+
+ // Verifica que a entrada leste do Banco (X = -252, Z = -65) está ABERTA sem parede bloqueando!
+ const doorBlocked = city.colliders.some(c => (-252 > c.minX && -252 < c.maxX && -65 > c.minZ && -65 < c.maxZ));
+ assert.equal(doorBlocked, false, 'porta principal do Banco Nacional permite entrada a pé até o cofre');
+
+ // Testa pegadas na areia e rotação real da Roda-Gigante + iluminação noturna dos postes
+ assert.equal(city.getFootprintCount(), 0);
+ city.addSandFootprint(390, 10, 0, true);
+ city.addSandFootprint(390, 10.85, 0, false);
+ assert.equal(city.getFootprintCount(), 2, 'pegadas esquerda/direita registradas na areia');
+
+ city.tickCity(5.0, { nightFactor: 1.0, focusX: 300, focusZ: 28 });
+ assert.ok(Math.abs(city.ferrisCabins[0].pivot.rotation.z) > 0.1, 'cabine compensa a rotação da roda para ficar sempre em pé');
+
+ // Testa modelos 3D detalhados de pistola, submetralhadora, escopeta e fuzil (zero bloco preto simples!)
+ const wRig = buildRealisticWeaponRig();
+ for (const wid of ['pistol', 'smg', 'shotgun', 'rifle']) {
+ wRig.setActiveWeapon(wid, true);
+ let meshParts = 0;
+ wRig.holder.traverse(o => {
+ if (o.isMesh && o.visible) meshParts += 1;
+ });
+ assert.ok(meshParts >= 5, `arma ${wid} possui múltiplas peças 3D metálicas detalhadas (${meshParts} partes)`);
+ }
+});
+
+
+
+
+
+test('v0.7.0: oceano realista, arquipélago, 3 larguras de via, pontes monumentais, túneis, Metrorail, aeroporto e lojas literalmente entráveis', () => {
+ assert.equal(MAP_HALF, 920, 'mundo expandido v0.7.0');
+
+ // 1. Ruas estreitas, amplas e normais com larguras distintas e reais!
+ assert.ok(NARROW_ROADS.length >= 5, 'becos e ruas estreitas mapeadas');
+ assert.ok(NARROW_ROADS.every(nr => nr.width === 9), 'ruas estreitas têm 9m de largura');
+ assert.ok(getAvenueWidth(-240) >= 26, 'Grand Financial Boulevard é avenida AMPLA (canteiro central)');
+ assert.ok(getAvenueWidth(40) >= 24, 'Leonida Central Parkway é avenida AMPLA');
+ assert.ok(getAvenueWidth(-90) <= 18, 'avenida normal mantém ~16-18m');
+ assert.ok(getStreetWidth(0) >= 26, 'Vice Bay Causeway é via AMPLA Leste-Oeste (28m)');
+ assert.ok(isNarrowRoadAt(236, 0, 0), 'Beco Art Déco (9m) é transitável e reconhecido');
+ assert.ok(isRoadAt(236, 0), 'beco estreito conta como via dirigível');
+
+ // 2. Ilhas no horizonte oceânico (fim do "água atrás de água") + pontes monumentais!
+ assert.ok(OFFSHORE_ISLANDS.length >= 4, 'arquipélago atlântico visível da praia');
+ assert.ok(isWaterAt(658, -75) === false || isWaterAt(645, -265) === false, 'ilha Esmeralda/Starfish é terra firme (não água!)');
+ assert.ok(INTERCITY_BRIDGES.length >= 4, '3 pontes intermunicipais + viaduto do aeroporto');
+ assert.ok(INTERCITY_BRIDGES.every(br => br.width >= 26), 'pontes monumentais têm 26m+ de largura');
+ assert.ok(INTERCITY_BRIDGES.every(br => (br.pylonHeight || 0) >= 28), 'torres H-frame imponentes (28m+)');
+ assert.ok(isOnBridge(40, -550), 'Golden Neon Suspension Bridge liga Vice Leonida a Palm Bay');
+ assert.ok(isOnBridge(170, 550), 'Seven Mile Overseas Skybridge liga Vice Leonida a Vice Keys');
+
+ // 3. Túneis rodoviários + Metrorail com 2 estações + Aeroporto!
+ assert.ok(ROAD_TUNNELS.length >= 2, 'dois túneis rodoviários com portais iluminados');
+ assert.equal(TRAIN_LINE.stations.length, 2, 'duas estações de trem caminháveis');
+ assert.equal(TRAIN_LINE.trackX, -62, 'linha Metrorail corre ao longo de X = -62');
+ for (const st of TRAIN_LINE.stations) {
+ assert.ok(Math.abs(st.x - TRAIN_LINE.trackX) < 0.001, 'estação fica sobre a linha férrea');
+ assert.ok(st.platformLength >= 40, 'plataforma longa o suficiente para o Metrorail');
+ }
+ assert.ok(AIRPORT_DATA.runwayZMax - AIRPORT_DATA.runwayZMin >= 500, 'pista de pouso internacional de 500m+');
+ assert.ok(AIRPORT_DATA.terminalX > AIRPORT_DATA.runwayX, 'terminal a leste da pista (acesso pelo pátio)');
+
+ // 4. Lojas literalmente entráveis a pé + interior caminhável!
+ assert.equal(ENTERABLE_SHOPS.length, 3, 'três lojas entráveis (market, armas, moda)');
+ assert.deepEqual(ENTERABLE_SHOPS.map(s => s.kind).sort(), ['clothing', 'market', 'weapons']);
+ for (const shop of ENTERABLE_SHOPS) {
+ assert.ok(shop.itemPrice > 0 && shop.itemLabel.length > 8, `${shop.name} vende item real no interior`);
+ assert.ok(shop.doorSide === 'east' || shop.doorSide === 'west', 'porta aberta definida');
+ }
+
+ // 5. Cena 3D completa: portais das lojas/estações/terminal ABERTOS, trem em movimento!
+ const scene = new THREE.Scene();
+ const city = buildCityScene(scene, { shadows: false });
+
+ // Porta aberta de cada loja: ponto exatamente na porta NÃO pode estar bloqueado!
+ for (const shop of ENTERABLE_SHOPS) {
+ const doorWallX = shop.doorSide === 'east' ? shop.centerX + shop.width * 0.5 : shop.centerX - shop.width * 0.5;
+ const blocked = city.colliders.some(c =>
+ doorWallX > c.minX && doorWallX < c.maxX && shop.centerZ > c.minZ && shop.centerZ < c.maxZ);
+ assert.equal(blocked, false, `portal aberto da loja ${shop.name} permite entrada a pé`);
+ const insideBlocked = city.colliders.some(c =>
+ shop.centerX > c.minX && shop.centerX < c.maxX && shop.centerZ > c.minZ && shop.centerZ < c.maxZ);
+ assert.equal(insideBlocked, false, `interior da loja ${shop.name} é caminhável`);
+ }
+
+ // Portal do terminal do aeroporto (leste, X = -614, Z = -140) também aberto!
+ const terminalDoorX = AIRPORT_DATA.terminalX + AIRPORT_DATA.terminalW * 0.5;
+ const terminalBlocked = city.colliders.some(c =>
+ terminalDoorX > c.minX && terminalDoorX < c.maxX && AIRPORT_DATA.terminalZ > c.minZ && AIRPORT_DATA.terminalZ < c.maxZ);
+ assert.equal(terminalBlocked, false, 'portal do terminal VIA permite entrada a pé');
+
+ // Estações: jogador pode caminhar no centro da plataforma sem atravessar parede
+ for (const st of TRAIN_LINE.stations) {
+ const platformX = st.x + 8; // plataforma leste da estação
+ const stationBlocked = city.colliders.some(c =>
+ platformX > c.minX && platformX < c.maxX && st.z > c.minZ && st.z < c.maxZ);
+ assert.equal(stationBlocked, false, `plataforma da ${st.name} é caminhável`);
+ }
+
+ // O TREM anda de verdade: avança pela linha após alguns segundos simulados!
+ const initialTrainZ = city.train.getZ();
+ for (let t = 0.016; t <= 14; t += 0.016) {
+ city.tickCity(t, { nightFactor: 0.4, focusX: 0, focusZ: 0 });
+ }
+ assert.ok(Math.abs(city.train.getZ() - initialTrainZ) > 30, 'Metrorail acelera e percorre a linha');
+
+ // Túneis: paredes laterais colidíveis, mas a boca é atravessável por carros e pedestres
+ for (const tn of ROAD_TUNNELS) {
+ const mouthBlocked = city.colliders.some(c =>
+ tn.x > c.minX && tn.x < c.maxX && ((tn.zMin - 1) > c.minZ && (tn.zMin - 1) < c.maxZ));
+ assert.equal(mouthBlocked, false, `boca do ${tn.name} está aberta`);
+ }
+});
diff --git a/vice-game/android/app/build.gradle b/vice-game/android/app/build.gradle
index f19cc284..17df64ee 100644
--- a/vice-game/android/app/build.gradle
+++ b/vice-game/android/app/build.gradle
@@ -14,8 +14,8 @@ android {
applicationId "com.nextvr.vice6"
minSdkVersion 26
targetSdkVersion 35
- versionCode 2
- versionName "0.2.0"
+ versionCode 7
+ versionName "0.7.0"
}
compileOptions {
diff --git a/vice-game/dev.html b/vice-game/dev.html
new file mode 100644
index 00000000..fe5017dd
--- /dev/null
+++ b/vice-game/dev.html
@@ -0,0 +1,219 @@
+
+
+
+
+
+
+ VICE VI Mobile — Playtest Local
+
+
+
+
+
+
+
+
+
+
+
+
VICE VI MOBILE
+ PLAYTEST LOCAL · BUILD 7E4677A · v0.8.0-dev
+
+
+
● SERVIDOR LOCAL ONLINE · :8090
+
+
+
+ 🧯 Git fora do ar? Sem stress. Este playtest roda 100% local (bundle + assets nesta máquina) —
+ não depende de GitHub, git ou internet. O progresso do jogo nunca passa pela rede.
+
+
+
+
+
+
Entre em Vice Leonida e suma no horizonte.
+
Mar novo até onde a vista alcança, mira Complex do GTA VI, HUD minimalista, casas da Flórida
+ e placas das ruas de Miami. Rafael te espera no Calçadão.
No celular: analógico esquerdo + botões contextuais na tela; toque no radar abre o mapa.
+ Tudo que era pílula fixa virou ☰ (menu) + toasts — igual GTA VI.
Arraste .glb na página de envio e eles caem em assets/models/.
+ Detecção automática por nome: palm|tree|building|car-extra.glb viram cenário/carros extras;
+ slots rafael|lucia|jason|supercar|cabrio|muscle|bike|police.glb substituem os modelos padrão.
+ Clipes Mixamo (run|idle|jump|fall|bike|aim...) entram nas animações.
+
+
+
+
+
Roteiro de teste rápido
+
+
Nasça no calçadão da OCEAN DR e olhe para o mar: a água vai até o horizonte, sem listras.
+
Ande pela COLLINS AVE / WASHINGTON AVE: confira as placas verdes nos cruzamentos.
+
Procure uma casa pastel com telhado de barril terracota (Mediterrâneo) e uma de laje plana com neon de canto (Streamline).
+
Atire uma vez e veja a mira Complex (3 linhas + ponto) do GTA VI.
+
Abra o ☰ (ou Esc): mapa, missões, carros 3D, Ammu-Nation e sistema — HUD limpo.
+
Toque no radar circular para abrir o mapa; o bairro agora aparece só como toast na chegada.
+
Roube o carro, corra pela praia e veja o velocímetro; a polícia dispara 6 estrelas no cofre do Banco.
+
+
+
+
+
+
+
+
+
+
diff --git a/vice-game/src/data/city.js b/vice-game/src/data/city.js
index 02c44886..4e88f3c6 100644
--- a/vice-game/src/data/city.js
+++ b/vice-game/src/data/city.js
@@ -1,137 +1,562 @@
-// Dados puros da cidade de Vice Leonida (GTA VI Mobile) — sem DOM, 100% testáveis.
-//
-// O mapa cobre 1400 × 1400 metros em torno da ilha de Vice Beach, com bairros,
-// vias asfaltadas (avenidas norte-sul e ruas leste-oeste), ponte para Downtown,
-// praia a leste, baía a oeste, garagens/lojas, delegacia, hospital, concessionária
-// e pontos de missões.
-
-export const MAP_HALF = 680;
+// Dados puros do mundo aberto expandido de Vice Leonida, Palm Bay City (Norte) e Vice Keys (Sul) — v0.7.0:
+// - Malha viária completa com 3 larguras reais: Amplas/Boulevards (28m com canteiro central), Normais (18m) e Ruas Estreitas/Becos (9m);
+// - Grandes Pontes Estaiadas Monumentais (26m a 30m de largura, 230m+ de vão livre!) interligando as 3 Cidades;
+// - Arquipélago e Ilhas costeiras no horizonte leste (fim do "tudo água vazia" atrás do mar!);
+// - TÚNEIS Rodoviários iluminados, TREM expresso Metrorail em movimento + 2 ESTAÇÕES DE TREM caminháveis;
+// - AEROPORTO Internacional de Leonida (pista zebrada de pouso, jatos 3D, torre de controle e terminal aberto);
+// - BANCO Nacional Monumental com textura neoclássica + LOJAS REAIS ENTRÁVEIS a pé (Ammu-Nation, Vice Mart 24h e Neon Moda)!
+
+export const MAP_HALF = 920;
export const ROAD_WIDTH = 18;
+export const WIDE_ROAD_WIDTH = 28;
+export const NARROW_ROAD_WIDTH = 9;
export const SIDEWALK_WIDTH = 4.5;
-// Coordenadas das avenidas norte-sul (X fixo) e ruas leste-oeste (Z fixo)
+// Avenidas Norte-Sul de Vice Leonida central (com larguras variadas: Amplas 28m vs Normais 18m!)
export const AVENUES_X = Object.freeze([-420, -240, -90, 40, 170, 300]);
+export const AVENUE_WIDTHS = Object.freeze({
+ '-420': 18,
+ '-240': 28, // Grand Financial Boulevard (Avenida Ampla com canteiro central!)
+ '-90': 16,
+ '40': 26, // Leonida Central Parkway (Avenida Ampla!)
+ '170': 18,
+ '300': 24 // Ocean Drive Promenade
+});
+
+export function getAvenueWidth(ax) {
+ return AVENUE_WIDTHS[String(ax)] || ROAD_WIDTH;
+}
+
+// Ruas Leste-Oeste de Vice Leonida (com larguras variadas: Amplas 26m vs Normais 18m!)
export const STREETS_Z = Object.freeze([-440, -280, -140, 0, 140, 280, 430]);
+export const STREET_WIDTHS = Object.freeze({
+ '-440': 18,
+ '-280': 16,
+ '-140': 24,
+ '0': 28, // Vice Bay Causeway (Eixo Monumental Amplo!)
+ '140': 18,
+ '280': 22,
+ '430': 18
+});
+
+export function getStreetWidth(sz) {
+ return STREET_WIDTHS[String(sz)] || ROAD_WIDTH;
+}
+
+// RUAS ESTREITAS E BECOS URBANOS (9m de largura — atalhos de fuga entre quarteirões!)
+export const NARROW_ROADS = Object.freeze([
+ { id: 'alley-art-deco', axis: 'z', x: 236, zMin: -268, zMax: 268, width: NARROW_ROAD_WIDTH, name: 'Beco Art Déco' },
+ { id: 'alley-strip-north', axis: 'x', z: -210, xMin: 52, xMax: 288, width: NARROW_ROAD_WIDTH, name: 'Travessa Babylon' },
+ { id: 'alley-strip-south', axis: 'x', z: 70, xMin: -78, xMax: 158, width: NARROW_ROAD_WIDTH, name: 'Rua do Mercado' },
+ { id: 'alley-downtown', axis: 'z', x: -332, zMin: -268, zMax: 128, width: NARROW_ROAD_WIDTH, name: 'Travessa Financeira' },
+ { id: 'alley-palm-bay', axis: 'z', x: -95, zMin: -815, zMax: -645, width: NARROW_ROAD_WIDTH, name: 'Viela Palm Bay' }
+]);
-// Faixa costeira: x > 350 é areia de Vice Beach, x > 455 é o Oceano Atlântico.
-// A oeste: entre x = -185 e x = -125 corre o canal da baía (atravessado por pontes nas ruas Z = -140, 0, 140).
-export const BEACH_SAND_X = 345;
-export const OCEAN_WATER_X = 455;
+// Faixa costeira de Vice Beach + Arquipélago de Ilhas no Oceano Atlântico (fim do "só água vazia" ao fundo!)
+export const BEACH_SAND_X = 344;
+export const OCEAN_WATER_X = 462;
export const CANAL_MIN_X = -180;
export const CANAL_MAX_X = -128;
-export const BRIDGE_ZS = Object.freeze([-140, 0, 140]);
+export const BRIDGE_ZS = Object.freeze([-280, -140, 0, 140, 280]);
+
+// Ilhas Visíveis e Costeiras no Oceano Atlântico Leste (para horizonte oceânico rico e realista!)
+export const OFFSHORE_ISLANDS = Object.freeze([
+ { id: 'starfish-cay', name: 'Ilha Starfish Cay', x: 645, z: -265, rx: 78, rz: 105, hasLighthouse: true, height: 14 },
+ { id: 'pelican-reef', name: 'Atol Pelican Reef', x: 690, z: 95, rx: 92, rz: 130, hasResort: true, height: 18 },
+ { id: 'emerald-shoal', name: 'Ilha Esmeralda', x: 625, z: 410, rx: 68, rz: 88, hasLighthouse: false, height: 11 },
+ { id: 'sunset-ridge', name: 'Serra Costeira Norte', x: 585, z: -640, rx: 95, rz: 120, hasResort: false, height: 26 }
+]);
+
+// GRANDES PONTES ESTAIADAS MONUMENTAIS INTERLIGANDO AS 3 CIDADES (26m a 30m de largura e ~190m de extensão!)
+export const INTERCITY_BRIDGES = Object.freeze([
+ {
+ id: 'bridge-north-east',
+ name: 'Golden Neon Suspension Bridge (Palm Bay Leste)',
+ x: 40,
+ zMin: -635,
+ zMax: -468,
+ width: 28,
+ pylonHeight: 42,
+ color: '#ff2a85'
+ },
+ {
+ id: 'bridge-north-west',
+ name: 'Ponte Estaiada Atlântica (Palm Bay Oeste)',
+ x: -240,
+ zMin: -635,
+ zMax: -468,
+ width: 28,
+ pylonHeight: 40,
+ color: '#00f5d4'
+ },
+ {
+ id: 'bridge-south-keys',
+ name: 'Seven Mile Overseas Skybridge (Vice Keys)',
+ x: 170,
+ zMin: 468,
+ zMax: 635,
+ width: 30,
+ pylonHeight: 46,
+ color: '#ffd166'
+ },
+ {
+ id: 'bridge-airport-causeway',
+ name: 'Viaduto Internacional do Aeroporto',
+ x: -555,
+ zMin: -165,
+ zMax: -115,
+ width: 26,
+ pylonHeight: 28,
+ isEastWest: true,
+ xMin: -595,
+ xMax: -515,
+ z: -140,
+ color: '#38d6ff'
+ }
+]);
+
+// TÚNEIS RODOVIÁRIOS ILUMINADOS (com arcos de concreto, luzes âmbar internas e morro paisagístico por cima!)
+export const ROAD_TUNNELS = Object.freeze([
+ {
+ id: 'tunnel-downtown-express',
+ name: 'Túnel Expresso Downtown',
+ axis: 'z',
+ x: -420,
+ zMin: -108,
+ zMax: -22,
+ width: 21,
+ height: 7.4
+ },
+ {
+ id: 'tunnel-bay-underpass',
+ name: 'Túnel Costeiro Palm Bay',
+ axis: 'z',
+ x: 40,
+ zMin: -425,
+ zMax: -340,
+ width: 26,
+ height: 7.8
+ }
+]);
+
+// AEROPORTO INTERNACIONAL DE VICE LEONIDA (Oeste de Downtown: X = -855..-585, Z = -430..160)
+export const AIRPORT_DATA = Object.freeze({
+ centerX: -720,
+ centerZ: -135,
+ landXMin: -865,
+ landXMax: -582,
+ landZMin: -445,
+ landZMax: 175,
+ runwayX: -765,
+ runwayZMin: -405,
+ runwayZMax: 135,
+ runwayWidth: 36,
+ terminalX: -632, // Terminal de passageiros entrável a pé!
+ terminalZ: -140,
+ terminalW: 36,
+ terminalD: 74,
+ towerX: -642,
+ towerZ: -45
+});
+
+// LINHA DE TREM EXPRESSO METRORAIL + 2 ESTAÇÕES DE TREM CAMINHÁVEIS!
+// O trem percorre um grande circuito elevado/superfície ao longo de X = -62 entre Palm Bay (Z = -715) e Sul (Z = +415)!
+export const TRAIN_LINE = Object.freeze({
+ trackX: -62,
+ zMin: -720,
+ zMax: 420,
+ deckY: 0.32,
+ stations: [
+ {
+ id: 'station-central',
+ name: 'Estação Central Leonida Metrorail',
+ x: -62,
+ z: -62,
+ platformLength: 46,
+ platformWidth: 11
+ },
+ {
+ id: 'station-palm-bay',
+ name: 'Estação Norte Palm Bay',
+ x: -62,
+ z: -685,
+ platformLength: 42,
+ platformWidth: 11
+ }
+ ]
+});
+
+// LOJAS ENTRÁVEIS A PÉ (Portas abertas sem parede bloqueando, prateleiras iluminadas, balcão, atendente e compra interativa!)
+export const ENTERABLE_SHOPS = Object.freeze([
+ {
+ id: 'shop-vice-mart',
+ name: '24/7 Vice SuperMart',
+ kind: 'market',
+ badge: 'CONVENIÊNCIA & KIT MÉDICO',
+ doorSide: 'east', // Porta aberta voltada para a Ocean Drive (X = 284, Z = -28)
+ centerX: 271,
+ centerZ: -28,
+ width: 24,
+ depth: 20,
+ height: 6.8,
+ wallColor: '#fff1e6',
+ neonColor: '#00f5d4',
+ itemLabel: 'Comprar Kit Médico Completo (+100 Vida)',
+ itemPrice: 120,
+ rewardType: 'heal'
+ },
+ {
+ id: 'shop-ammu-nation',
+ name: 'Ammu-Nation Leonida',
+ kind: 'weapons',
+ badge: 'ARMAS & MUNIÇÃO PESADA',
+ doorSide: 'west', // Porta aberta voltada para Washington Ave (X = 186, Z = 48)
+ centerX: 199,
+ centerZ: 48,
+ width: 24,
+ depth: 22,
+ height: 7.2,
+ wallColor: '#2b2d42',
+ neonColor: '#ff2a85',
+ itemLabel: 'Pacote Tático: Fuzil M4-AR + Colete + Munição',
+ itemPrice: 650,
+ rewardType: 'arsenal'
+ },
+ {
+ id: 'shop-neon-threads',
+ name: 'Vice Neon Threads Boutique',
+ kind: 'clothing',
+ badge: 'MODA & ESTILO DE VICE',
+ doorSide: 'east', // Porta aberta voltada para Central Parkway (X = 24, Z = 62)
+ centerX: 12,
+ centerZ: 62,
+ width: 22,
+ depth: 20,
+ height: 6.8,
+ wallColor: '#f6eaff',
+ neonColor: '#ffd166',
+ itemLabel: 'Trocar Traje de Gala de Rafael + Disfarçar da Polícia',
+ itemPrice: 250,
+ rewardType: 'outfit'
+ }
+]);
+
+// Rodovias curvas e diagonais reais (`SCENIC_ROADS`)
+export const SCENIC_ROADS = Object.freeze([
+ {
+ id: 'palm-bay-loop',
+ width: 20,
+ points: [
+ [300, -440], [235, -464], [135, -468], [40, -468],
+ [40, -635], [105, -675], [175, -720], [125, -785],
+ [15, -805], [-115, -795], [-210, -745], [-240, -675],
+ [-240, -635], [-240, -440]
+ ]
+ },
+ {
+ id: 'palm-bay-cross',
+ width: 18,
+ points: [
+ [-240, -700], [-105, -695], [40, -685], [165, -715]
+ ]
+ },
+ {
+ id: 'vice-keys-highway',
+ width: 20,
+ points: [
+ [-420, 430], [-265, 456], [-85, 462], [85, 462], [170, 468],
+ [170, 635], [215, 675], [268, 718], [248, 778],
+ [165, 802], [72, 782], [48, 718], [105, 662], [170, 638]
+ ]
+ },
+ {
+ id: 'airport-access-loop',
+ width: 20,
+ points: [
+ [-420, -140], [-595, -140], [-612, -140], [-612, -260], [-695, -295]
+ ]
+ },
+ {
+ id: 'port-diagonal',
+ width: 16,
+ points: [
+ [-240, 140], [-325, 215], [-420, 280]
+ ]
+ },
+ {
+ id: 'ocean-south-curve',
+ width: 18,
+ points: [
+ [300, 420], [260, 452], [170, 468]
+ ]
+ }
+]);
+
+// Coordenadas exatas do EDIFÍCIO DO BANCO NACIONAL DE LEONIDA (Neoclássico monumental com colunas, frontão, torre de vidro e Cofre!)
+export const BANK_INTERIOR = Object.freeze({
+ doorSideX: -254, // Entrada aberta voltada para o Grand Boulevard X = -240
+ centerX: -276,
+ centerZ: -65,
+ width: 44, // X de -298 até -254
+ depth: 34, // Z de -82 até -48
+ height: 14,
+ towerHeight: 42, // Torre corporativa espelhada do Banco erguendo-se acima do pódio de granito!
+ vaultX: -292, // Cofre dourado nos fundos do banco
+ vaultZ: -65,
+ vaultRadius: 4.8
+});
+
+// Container especial nas docas de Port Gellhorn onde fica guardado o Corvette Stingray exclusivo!
+export const CORVETTE_CONTAINER = Object.freeze({
+ x: -446,
+ z: 320,
+ yaw: 0,
+ width: 4.4,
+ length: 11.5,
+ height: 3.8
+});
+
+// Roda-Gigante no Píer de Vice Beach ($70 para embarcar na cabine e dar a volta panorâmica real!)
+export const FERRIS_WHEEL = Object.freeze({
+ x: 454,
+ z: -140,
+ baseY: 1.1,
+ wheelCenterY: 20.5,
+ radius: 16.5,
+ cabins: 10,
+ ticketPrice: 70,
+ boardX: 446,
+ boardZ: -131.5
+});
export const DISTRICTS = Object.freeze([
+ {
+ id: 'palm-bay',
+ name: 'Palm Bay City (Norte)',
+ subtitle: 'Metrópole norte conectada pelas Grandes Pontes Estaiadas e Metrorail',
+ bounds: { xMin: -360, xMax: 260, zMin: -860, zMax: -620 },
+ color: '#00f5d4'
+ },
+ {
+ id: 'vice-keys',
+ name: 'Ilha de Vice Keys (Sul)',
+ subtitle: 'Arquipélago tropical ao sul ligado pela Overseas Skybridge',
+ bounds: { xMin: 10, xMax: 330, zMin: 620, zMax: 860 },
+ color: '#ffd166'
+ },
+ {
+ id: 'leonida-airport',
+ name: 'Aeroporto Internacional VIA',
+ subtitle: 'Pista de pouso, jatos executivos, torre de controle e terminal aberto',
+ bounds: { xMin: -880, xMax: -575, zMin: -455, zMax: 185 },
+ color: '#38d6ff'
+ },
{
id: 'ocean-drive',
name: 'Ocean Drive · Vice Beach',
- subtitle: 'Hotéis Art Déco, letreiros neon e calçadão à beira-mar',
- bounds: { xMin: 210, xMax: 460, zMin: -480, zMax: 480 },
+ subtitle: 'Hotéis Art Déco, loja Vice Mart 24h, Roda-Gigante e calçadão',
+ bounds: { xMin: 210, xMax: 344, zMin: -495, zMax: 495 },
color: '#ff4fa3'
},
+ {
+ id: 'vice-beach-sand',
+ name: 'Praia de Vice Beach',
+ subtitle: 'Areia branca, ondas reais quebrando, vôlei, altinha e ilhas ao fundo',
+ bounds: { xMin: 344, xMax: 462, zMin: -495, zMax: 495 },
+ color: '#ffd166'
+ },
{
id: 'washington-strip',
name: 'Washington Strip',
- subtitle: 'Boates, lojas 24h, palmeiras e vida noturna',
- bounds: { xMin: 80, xMax: 210, zMin: -480, zMax: 480 },
+ subtitle: 'Ammu-Nation entrável, boates, becos estreitos e comércio neon',
+ bounds: { xMin: 80, xMax: 210, zMin: -495, zMax: 495 },
color: '#ff8a3d'
},
{
id: 'midtown-vice',
- name: 'Midtown Leonida',
- subtitle: 'Comércio central, oficinas Pay & Spray e praças',
- bounds: { xMin: -128, xMax: 80, zMin: -480, zMax: 480 },
+ name: 'Midtown & Estação Central',
+ subtitle: 'Estação de Trem Metrorail, Boutique Neon Threads e Oficina Customs',
+ bounds: { xMin: -128, xMax: 80, zMin: -495, zMax: 495 },
color: '#38d6ff'
},
{
id: 'biscayne-canal',
name: 'Canal de Biscayne',
- subtitle: 'Pontes iluminadas sobre as águas turquesa da baía',
- bounds: { xMin: -185, xMax: -128, zMin: -520, zMax: 520 },
+ subtitle: 'Cinco pontes iluminadas cruzando as águas turquesa da baía',
+ bounds: { xMin: -185, xMax: -128, zMin: -495, zMax: 495 },
color: '#19e3c6'
},
{
id: 'downtown-leonida',
- name: 'Downtown Leonida',
- subtitle: 'Arranha-céus corporativos, banco central e heliporto',
- bounds: { xMin: -560, xMax: -185, zMin: -480, zMax: 120 },
+ name: 'Downtown Financial District',
+ subtitle: 'Edifício do Banco Nacional de Leonida, Túnel Expresso e arranha-céus',
+ bounds: { xMin: -560, xMax: -185, zMin: -495, zMax: 120 },
color: '#9b6bff'
},
{
id: 'port-gellhorn',
- name: 'Porto & Distrito Industrial',
- subtitle: 'Galpões portuários, docas de carga e corridas clandestinas',
- bounds: { xMin: -560, xMax: -185, zMin: 120, zMax: 520 },
+ name: 'Porto & Container Secreto',
+ subtitle: 'Docas industriais onde repousa o container do Corvette Especial',
+ bounds: { xMin: -560, xMax: -185, zMin: 120, zMax: 495 },
color: '#ffb838'
}
]);
export function districtAt(x, z) {
- if (x >= OCEAN_WATER_X) {
+ for (const d of DISTRICTS) {
+ const b = d.bounds;
+ if (x >= b.xMin && x <= b.xMax && z >= b.zMin && z <= b.zMax) return d;
+ }
+ if (x >= OCEAN_WATER_X && z >= -550 && z <= 550) {
return {
id: 'atlantic-ocean',
- name: 'Oceano Atlântico',
- subtitle: 'Águas costeiras de Vice Beach',
+ name: 'Oceano Atlântico & Arquipélago',
+ subtitle: 'Ondas oceânicas e ilhas costeiras de Vice Leonida',
color: '#00b4d8'
};
}
- if (x >= BEACH_SAND_X) {
- return {
- id: 'vice-beach-sand',
- name: 'Praia de Vice Beach',
- subtitle: 'Areia branca, postos salva-vidas e quiosques',
- color: '#ffd166'
- };
+ return DISTRICTS[3];
+}
+
+function distToSegmentSq(px, pz, x1, z1, x2, z2) {
+ const vx = x2 - x1;
+ const vz = z2 - z1;
+ const wx = px - x1;
+ const wz = pz - z1;
+ const lenSq = vx * vx + vz * vz;
+ if (lenSq < 0.0001) return wx * wx + wz * wz;
+ const t = Math.max(0, Math.min(1, (wx * vx + wz * vz) / lenSq));
+ const cx = x1 + t * vx;
+ const cz = z1 + t * vz;
+ return (px - cx) * (px - cx) + (pz - cz) * (pz - cz);
+}
+
+export function isOnBridge(x, z) {
+ // Pontes Leste-Oeste sobre o Canal de Biscayne
+ if (x >= CANAL_MIN_X - 8 && x <= CANAL_MAX_X + 8) {
+ for (const bz of BRIDGE_ZS) {
+ if (Math.abs(z - bz) <= getStreetWidth(bz) * 0.8) return true;
+ }
}
- for (const d of DISTRICTS) {
- const b = d.bounds;
- if (x >= b.xMin && x <= b.xMax && z >= b.zMin && z <= b.zMax) return d;
+ // Grandes Pontes Intermunicipais (Norte, Sul e Viaduto do Aeroporto!)
+ for (const br of INTERCITY_BRIDGES) {
+ if (br.isEastWest) {
+ if (x >= br.xMin - 8 && x <= br.xMax + 8 && Math.abs(z - br.z) <= br.width * 0.72) return true;
+ } else if (z >= br.zMin - 8 && z <= br.zMax + 8 && Math.abs(x - br.x) <= br.width * 0.72) {
+ return true;
+ }
}
- return DISTRICTS[0];
+ // Ponte Ferroviária do Trem Metrorail ao norte (X = -62, Z = -638..-475)
+ if (Math.abs(x - TRAIN_LINE.trackX) <= 6.5 && z >= -640 && z <= -475) {
+ return true;
+ }
+ // Píer da Roda-Gigante em Vice Beach
+ if (x >= 342 && x <= 515 && Math.abs(z - (-140)) <= 15) {
+ return true;
+ }
+ return false;
}
-export function isOnBridge(x, z) {
- if (x < CANAL_MIN_X - 8 || x > CANAL_MAX_X + 8) return false;
- for (const bz of BRIDGE_ZS) {
- if (Math.abs(z - bz) <= ROAD_WIDTH * 0.85) return true;
+export function isLandMassAt(x, z) {
+ // 1. Cidade Norte: Palm Bay City
+ if (x >= -335 && x <= 245 && z >= -845 && z <= -628) return true;
+ // 2. Ilha Sul: Vice Keys
+ if (x >= 25 && x <= 315 && z >= 628 && z <= 845) return true;
+ // 3. Península do Aeroporto Internacional (Oeste)
+ if (x >= AIRPORT_DATA.landXMin && x <= AIRPORT_DATA.landXMax && z >= AIRPORT_DATA.landZMin && z <= AIRPORT_DATA.landZMax) return true;
+ // 4. Continente Oeste (Downtown + Porto)
+ if (x >= -555 && x < CANAL_MIN_X && z >= -492 && z <= 485) return true;
+ // 5. Continente Leste (Midtown + Strip + Ocean Drive + Areia da Praia)
+ if (x > CANAL_MAX_X && x < OCEAN_WATER_X + 2.5 && z >= -492 && z <= 485) return true;
+ // 6. Ilhas do Arquipélago Atlântico a Leste!
+ for (const isl of OFFSHORE_ISLANDS) {
+ const nx = (x - isl.x) / isl.rx;
+ const nz = (z - isl.z) / isl.rz;
+ if (nx * nx + nz * nz <= 1.0) return true;
}
return false;
}
export function isWaterAt(x, z) {
- if (x >= OCEAN_WATER_X) return true;
- if (x >= CANAL_MIN_X && x <= CANAL_MAX_X && !isOnBridge(x, z)) return true;
- if (Math.abs(x) > MAP_HALF + 25 || Math.abs(z) > MAP_HALF + 25) return true;
+ if (isOnBridge(x, z)) return false;
+ if (isLandMassAt(x, z)) return false;
+ return true;
+}
+
+export function isBeachSandAt(x, z) {
+ if (x >= BEACH_SAND_X && x <= OCEAN_WATER_X + 2 && z >= -485 && z <= 480) {
+ if (x >= 345 && Math.abs(z - (-140)) <= 13) return false;
+ return true;
+ }
+ if (x >= 245 && x <= 315 && z >= 640 && z <= 835) return true;
+ return false;
+}
+
+export function isNarrowRoadAt(x, z, extra = 0) {
+ for (const nr of NARROW_ROADS) {
+ const half = nr.width * 0.54 + extra;
+ if (nr.axis === 'z') {
+ if (Math.abs(x - nr.x) <= half && z >= nr.zMin - extra && z <= nr.zMax + extra) return true;
+ } else if (Math.abs(z - nr.z) <= half && x >= nr.xMin - extra && x <= nr.xMax + extra) {
+ return true;
+ }
+ }
+ return false;
+}
+
+export function isScenicRoadAt(x, z, extraMargin = 0) {
+ for (const sr of SCENIC_ROADS) {
+ const half = sr.width * 0.54 + extraMargin;
+ const halfSq = half * half;
+ const pts = sr.points;
+ for (let i = 0; i < pts.length - 1; i += 1) {
+ const [x1, z1] = pts[i];
+ const [x2, z2] = pts[i + 1];
+ if (distToSegmentSq(x, z, x1, z1, x2, z2) <= halfSq) return true;
+ }
+ }
return false;
}
export function isRoadAt(x, z) {
- const half = ROAD_WIDTH * 0.52;
for (const ax of AVENUES_X) {
- if (Math.abs(x - ax) <= half && Math.abs(z) <= 465) return true;
+ if (Math.abs(x - ax) <= getAvenueWidth(ax) * 0.52 && z >= -475 && z <= 465) return true;
}
for (const sz of STREETS_Z) {
- if (Math.abs(z - sz) <= half && x >= -455 && x <= 335) {
+ if (Math.abs(z - sz) <= getStreetWidth(sz) * 0.52 && x >= -465 && x <= 335) {
if (x >= CANAL_MIN_X && x <= CANAL_MAX_X && !BRIDGE_ZS.includes(sz)) continue;
return true;
}
}
+ for (const br of INTERCITY_BRIDGES) {
+ if (br.isEastWest) {
+ if (x >= br.xMin && x <= br.xMax && Math.abs(z - br.z) <= br.width * 0.55) return true;
+ } else if (z >= br.zMin && z <= br.zMax && Math.abs(x - br.x) <= br.width * 0.55) {
+ return true;
+ }
+ }
+ if (isNarrowRoadAt(x, z, 0)) return true;
+ if (isScenicRoadAt(x, z, 0)) return true;
return false;
}
export const POINTS_OF_INTEREST = Object.freeze([
{ id: 'hotel-colony', name: 'Hotel Ocean Star (Safehouse)', kind: 'safehouse', x: 274, z: 36, color: '#ff4fa3', icon: 'H' },
- { id: 'pay-spray-mid', name: 'Oficina Neon Customs (Pintura & Reparo)', kind: 'garage', x: 40, z: -68, color: '#2ee59d', icon: '🔧' },
- { id: 'pay-spray-west', name: 'Westside Customs', kind: 'garage', x: -240, z: 70, color: '#2ee59d', icon: '🔧' },
- { id: 'vice-pd', name: 'Delegacia VCPD', kind: 'police', x: -90, z: -210, color: '#4da3ff', icon: '★' },
- { id: 'hospital-leonida', name: 'Hospital Central de Leonida', kind: 'hospital', x: 40, z: 210, color: '#ff5c77', icon: '+' },
- { id: 'club-malibu', name: 'Boate Babylon Club', kind: 'club', x: 170, z: -205, color: '#d06bff', icon: '♪' },
- { id: 'bank-leonida', name: 'Banco Nacional de Leonida', kind: 'bank', x: -240, z: -65, color: '#ffd166', icon: '$' },
- { id: 'marina-docks', name: 'Píer & Marina Vice Beach', kind: 'pier', x: 385, z: -140, color: '#19e3c6', icon: '⚓' },
- { id: 'sunshine-autos', name: 'Concessionária Vice Motors', kind: 'dealership', x: -420, z: 210, color: '#ff9f1c', icon: '🚗' }
+ { id: 'bank-leonida', name: 'Edifício Banco Nacional (Cofre 6★)', kind: 'bank', x: -254, z: -65, color: '#ffd166', icon: '🏦' },
+ { id: 'airport-via', name: 'Aeroporto Internacional Leonida', kind: 'airport', x: -632, z: -140, color: '#38d6ff', icon: '✈️' },
+ { id: 'train-central', name: 'Estação Central de Trem Metrorail', kind: 'station', x: -62, z: -62, color: '#00f5d4', icon: '🚆' },
+ { id: 'shop-vice-mart-poi', name: 'Loja 24/7 Vice Mart (Entrável)', kind: 'shop', x: 284, z: -28, color: '#06d6a0', icon: '🛒' },
+ { id: 'shop-ammu-poi', name: 'Loja Ammu-Nation (Entrável)', kind: 'shop', x: 186, z: 48, color: '#ff2a85', icon: '🔫' },
+ { id: 'shop-boutique-poi', name: 'Loja Neon Threads (Entrável)', kind: 'shop', x: 24, z: 62, color: '#ffd166', icon: '👕' },
+ { id: 'corvette-container', name: 'Container do Corvette (Porto)', kind: 'container', x: -446, z: 320, color: '#00f5d4', icon: '📦' },
+ { id: 'ferris-pier', name: 'Roda-Gigante Vice Pier ($70)', kind: 'ferris', x: 454, z: -140, color: '#ff2a85', icon: '🎡' },
+ { id: 'pay-spray-mid', name: 'Oficina Neon Customs', kind: 'garage', x: 40, z: -102, color: '#2ee59d', icon: '🔧' },
+ { id: 'palm-bay-plaza', name: 'Palm Bay City & Estação Norte', kind: 'city', x: 40, z: -690, color: '#00f5d4', icon: '🏙' },
+ { id: 'vice-keys-lighthouse', name: 'Ilha de Vice Keys (Sul)', kind: 'city', x: 245, z: 730, color: '#ffd166', icon: '🏝' },
+ { id: 'vice-pd', name: 'Delegacia Central VCPD', kind: 'police', x: -90, z: -210, color: '#4da3ff', icon: '★' },
+ { id: 'hospital-leonida', name: 'Hospital Central de Leonida', kind: 'hospital', x: 40, z: 210, color: '#ff5c77', icon: '+' }
]);
-// Gera de forma determinística os quarteirões e prédios da cidade (usado tanto na cena 3D quanto na colisão/minimapa).
function seeded(seed) {
let s = seed >>> 0;
return () => {
@@ -162,55 +587,119 @@ const MIDTOWN_PALETTE = [
{ wall: '#e2ece9', accent: '#2ec4b6', neon: '#19e3c6' }
];
+const HOUSE_PALETTE = [
+ { wall: '#fff8f0', accent: '#bc4749', roof: '#9b2226', neon: '#ffd166' },
+ { wall: '#fefae0', accent: '#d4a373', roof: '#9c6644', neon: '#ff9f1c' },
+ { wall: '#e8f8f5', accent: '#2a9d8f', roof: '#264653', neon: '#00f5d4' },
+ { wall: '#fde2e4', accent: '#e07a5f', roof: '#81b29a', neon: '#ff4fa3' },
+ { wall: '#edf2fb', accent: '#457b9d', roof: '#1d3557', neon: '#48bfe3' }
+];
+
let cachedCityLayout = null;
+function overlapsAnyRoadOrSpecial(cx, cz, w, d) {
+ const rx = w * 0.5 + 4.5;
+ const rz = d * 0.5 + 4.5;
+ for (const ax of AVENUES_X) {
+ if (Math.abs(cx - ax) < getAvenueWidth(ax) * 0.5 + rx && Math.abs(cz) < 485) return true;
+ }
+ for (const sz of STREETS_Z) {
+ if (Math.abs(cz - sz) < getStreetWidth(sz) * 0.5 + rz && cx > -485 && cx < 345) return true;
+ }
+ if (isNarrowRoadAt(cx, cz, Math.max(rx, rz))) return true;
+ if (isScenicRoadAt(cx, cz, Math.max(rx, rz))) return true;
+ // Linha de Trem Metrorail (X = -62) + Estações
+ if (Math.abs(cx - TRAIN_LINE.trackX) < 8 + rx && cz >= TRAIN_LINE.zMin - 15 && cz <= TRAIN_LINE.zMax + 15) return true;
+ // Reserva espaço livre para o Banco Nacional, Lojas Entráveis, Túneis, Oficina e Container!
+ if (Math.abs(cx - BANK_INTERIOR.centerX) < 36 && Math.abs(cz - BANK_INTERIOR.centerZ) < 30) return true;
+ for (const sh of ENTERABLE_SHOPS) {
+ if (Math.abs(cx - sh.centerX) < sh.width * 0.5 + rx + 4 && Math.abs(cz - sh.centerZ) < sh.depth * 0.5 + rz + 4) return true;
+ }
+ for (const tn of ROAD_TUNNELS) {
+ if (Math.abs(cx - tn.x) < tn.width + rx + 8 && cz >= tn.zMin - 14 && cz <= tn.zMax + 14) return true;
+ }
+ if (Math.hypot(cx - 40, cz - (-102)) < 26) return true;
+ if (Math.hypot(cx - CORVETTE_CONTAINER.x, cz - CORVETTE_CONTAINER.z) < 26) return true;
+ return false;
+}
+
export function generateCityLayout() {
if (cachedCityLayout) return cachedCityLayout;
- const rand = seeded(6022026);
+ const rand = seeded(6072026);
const buildings = [];
+ const houses = [];
const palms = [];
- const props = [];
+ const trees = [];
+ const streetlights = [];
+ const beachSets = [];
+ const beachCourts = [];
+ const beachAccesses = [];
- // Intervalos de X entre avenidas para posicionar prédios sem invadir as ruas
const xBands = [
{ xMin: -515, xMax: -442, zone: 'downtown' },
- { xMin: -398, xMax: -262, zone: 'downtown' },
+ { xMin: -398, xMax: -264, zone: 'downtown' },
{ xMin: -218, xMax: -188, zone: 'canal-west' },
- { xMin: -118, xMax: -110, zone: 'canal-east' },
- { xMin: -68, xMax: 18, zone: 'midtown' },
- { xMin: 62, xMax: 148, zone: 'strip' },
+ { xMin: -120, xMax: -104, zone: 'canal-villas' },
+ { xMin: -46, xMax: 18, zone: 'midtown' },
+ { xMin: 64, xMax: 148, zone: 'strip' },
{ xMin: 192, xMax: 278, zone: 'ocean-west' },
- { xMin: 320, xMax: 342, zone: 'beachfront' }
+ { xMin: 322, xMax: 340, zone: 'beachfront' }
];
const zBands = [];
for (let i = 0; i < STREETS_Z.length - 1; i += 1) {
zBands.push({
- zMin: STREETS_Z[i] + ROAD_WIDTH * 0.5 + 8,
- zMax: STREETS_Z[i + 1] - ROAD_WIDTH * 0.5 - 8
+ zMin: STREETS_Z[i] + getStreetWidth(STREETS_Z[i]) * 0.5 + 8,
+ zMax: STREETS_Z[i + 1] - getStreetWidth(STREETS_Z[i + 1]) * 0.5 - 8
});
}
let bId = 1;
+ let hId = 1;
for (const xb of xBands) {
- if (xb.zone === 'canal-east') continue;
for (const zb of zBands) {
const spanX = xb.xMax - xb.xMin;
const spanZ = zb.zMax - zb.zMin;
- if (spanX < 16 || spanZ < 24) continue;
+ if (spanX < 14 || spanZ < 24) continue;
+
+ if (xb.zone === 'canal-villas') {
+ const houseRows = 3;
+ const rowStep = spanZ / houseRows;
+ for (let r = 0; r < houseRows; r += 1) {
+ const cz = zb.zMin + rowStep * (r + 0.5);
+ if (overlapsAnyRoadOrSpecial(-112, cz, 13.5, 18)) continue;
+ const hp = HOUSE_PALETTE[Math.floor(rand() * HOUSE_PALETTE.length)];
+ const house = {
+ id: `h-${hId++}`,
+ x: -112,
+ z: Number(cz.toFixed(1)),
+ w: 13.5,
+ d: 18,
+ h: 6.8 + Number((rand() * 2.4).toFixed(1)),
+ style: 'house',
+ wall: hp.wall,
+ accent: hp.accent,
+ roof: hp.roof,
+ neon: hp.neon,
+ hasPool: rand() > 0.35
+ };
+ houses.push(house);
+ buildings.push(house);
+ }
+ continue;
+ }
if (xb.zone === 'beachfront') {
- // Postos salva-vidas / quiosques baixos na orla
- if (rand() < 0.72) {
- const cz = (zb.zMin + zb.zMax) * 0.5;
+ const cz = (zb.zMin + zb.zMax) * 0.5;
+ if (Math.abs(cz - (-140)) > 30 && rand() < 0.55) {
const pal = ART_DECO_PALETTE[Math.floor(rand() * ART_DECO_PALETTE.length)];
buildings.push({
id: `b-${bId++}`,
x: 332,
z: cz,
- w: 12,
- d: 14,
- h: 5.5,
+ w: 10,
+ d: 12,
+ h: 5.2,
style: 'lifeguard',
wall: pal.wall,
accent: pal.accent,
@@ -220,8 +709,47 @@ export function generateCityLayout() {
continue;
}
- const cols = spanX > 70 ? 2 : 1;
- const rows = spanZ > 95 ? 2 : 1;
+ const isResidentialBlock =
+ (xb.zone === 'ocean-west' && (zb.zMin > 145 || zb.zMax < -285)) ||
+ (xb.zone === 'strip' && zb.zMin > 285) ||
+ (xb.zone === 'midtown' && zb.zMax < -285);
+
+ if (isResidentialBlock) {
+ const hCols = 2;
+ const hRows = 3;
+ const cW = spanX / hCols;
+ const cD = spanZ / hRows;
+ for (let c = 0; c < hCols; c += 1) {
+ for (let r = 0; r < hRows; r += 1) {
+ const cx = xb.xMin + cW * (c + 0.5);
+ const cz = zb.zMin + cD * (r + 0.5);
+ const hw = Math.min(20, cW * 0.60);
+ const hd = Math.min(20, cD * 0.58);
+ if (overlapsAnyRoadOrSpecial(cx, cz, hw, hd)) continue;
+ const hp = HOUSE_PALETTE[Math.floor(rand() * HOUSE_PALETTE.length)];
+ const house = {
+ id: `h-${hId++}`,
+ x: Number(cx.toFixed(1)),
+ z: Number(cz.toFixed(1)),
+ w: Number(hw.toFixed(1)),
+ d: Number(hd.toFixed(1)),
+ h: Number((5.8 + rand() * 3.6).toFixed(1)),
+ style: 'house',
+ wall: hp.wall,
+ accent: hp.accent,
+ roof: hp.roof,
+ neon: hp.neon,
+ hasPool: c === 0 && rand() > 0.45
+ };
+ houses.push(house);
+ buildings.push(house);
+ }
+ }
+ continue;
+ }
+
+ const cols = 2;
+ const rows = spanZ > 95 ? 3 : 2;
const cellW = spanX / cols;
const cellD = spanZ / rows;
@@ -229,12 +757,9 @@ export function generateCityLayout() {
for (let r = 0; r < rows; r += 1) {
const cx = xb.xMin + cellW * (c + 0.5);
const cz = zb.zMin + cellD * (r + 0.5);
-
- // Reserva espaço livre perto da oficina central para o jogador entrar fácil
- if (Math.hypot(cx - 40, cz - (-68)) < 26) continue;
-
- const w = Math.max(16, Math.min(46, cellW * (0.68 + rand() * 0.16)));
- const d = Math.max(16, Math.min(48, cellD * (0.66 + rand() * 0.18)));
+ const w = Math.max(15, Math.min(40, cellW * (0.64 + rand() * 0.14)));
+ const d = Math.max(15, Math.min(42, cellD * (0.62 + rand() * 0.14)));
+ if (overlapsAnyRoadOrSpecial(cx, cz, w, d)) continue;
let h = 18;
let palette = MIDTOWN_PALETTE;
@@ -252,9 +777,9 @@ export function generateCityLayout() {
h = 22 + Math.floor(rand() * 34);
palette = MIDTOWN_PALETTE;
style = 'midtown';
- } else if (xb.zone === 'downtown' || xb.zone === 'canal-west') {
+ } else {
const industrial = cz > 150;
- h = industrial ? (12 + Math.floor(rand() * 14)) : (42 + Math.floor(rand() * 68));
+ h = industrial ? (12 + Math.floor(rand() * 14)) : (42 + Math.floor(rand() * 64));
palette = industrial ? MIDTOWN_PALETTE : DOWNTOWN_PALETTE;
style = industrial ? 'industrial' : 'skyscraper';
}
@@ -270,37 +795,143 @@ export function generateCityLayout() {
style,
wall: pal.wall,
accent: pal.accent,
- neon: pal.neon,
- hasHelipad: style === 'skyscraper' && h >= 82
+ neon: pal.neon
});
}
}
}
}
- // Palmeiras ao longo da Ocean Drive (X=300), Washington (X=170) e calçadão da praia
- for (let z = -450; z <= 450; z += 30) {
- if (STREETS_Z.some(sz => Math.abs(z - sz) < 15)) continue;
- palms.push({ x: 313, z, scale: 0.95 + rand() * 0.3 });
- palms.push({ x: 287, z: z + 8, scale: 0.9 + rand() * 0.25 });
- palms.push({ x: 356, z: z - 6, scale: 1.0 + rand() * 0.35 });
- if (Math.abs(z) % 60 === 0) {
- palms.push({ x: 183, z, scale: 0.9 + rand() * 0.25 });
- palms.push({ x: -116, z, scale: 0.92 + rand() * 0.25 });
+ // Prédios e casas da Cidade Norte (PALM BAY CITY — fora dos eixos das avenidas!)
+ const palmBaySpots = [
+ [-292, -665, 32, 30, 52, 'skyscraper'], [-292, -745, 28, 28, 38, 'midtown'],
+ [-165, -655, 30, 26, 46, 'skyscraper'], [-152, -748, 26, 26, 32, 'art-deco'],
+ [-18, -748, 28, 26, 36, 'art-deco'], [96, -652, 26, 24, 30, 'art-deco'],
+ [206, -675, 22, 22, 24, 'art-deco'], [82, -745, 20, 20, 8, 'house'],
+ [204, -772, 20, 20, 7.5, 'house']
+ ];
+ for (const [bx, bz, bw, bd, bh, st] of palmBaySpots) {
+ if (isScenicRoadAt(bx, bz, Math.max(bw, bd) * 0.55)) continue;
+ const pal = st === 'house'
+ ? HOUSE_PALETTE[Math.floor(rand() * HOUSE_PALETTE.length)]
+ : (st === 'skyscraper' ? DOWNTOWN_PALETTE : ART_DECO_PALETTE)[Math.floor(rand() * 4)];
+ const obj = {
+ id: st === 'house' ? `h-${hId++}` : `b-${bId++}`,
+ x: bx, z: bz, w: bw, d: bd, h: bh, style: st,
+ wall: pal.wall, accent: pal.accent, roof: pal.roof || '#2b2d42', neon: pal.neon
+ };
+ if (st === 'house') houses.push(obj);
+ buildings.push(obj);
+ }
+
+ // Resorts e bangalôs tropicais da Ilha Sul (VICE KEYS — fora dos eixos das avenidas!)
+ const viceKeysSpots = [
+ [132, 708, 22, 20, 14, 'art-deco'], [206, 722, 24, 22, 16, 'art-deco'],
+ [125, 752, 18, 18, 7.2, 'house'], [208, 762, 18, 18, 7.4, 'house'],
+ [95, 735, 16, 16, 6.8, 'house'], [282, 735, 14, 14, 24, 'art-deco']
+ ];
+ for (const [bx, bz, bw, bd, bh, st] of viceKeysSpots) {
+ if (isScenicRoadAt(bx, bz, Math.max(bw, bd) * 0.55)) continue;
+ const pal = st === 'house'
+ ? HOUSE_PALETTE[Math.floor(rand() * HOUSE_PALETTE.length)]
+ : ART_DECO_PALETTE[Math.floor(rand() * ART_DECO_PALETTE.length)];
+ const obj = {
+ id: st === 'house' ? `h-${hId++}` : `b-${bId++}`,
+ x: bx, z: bz, w: bw, d: bd, h: bh, style: st,
+ wall: pal.wall, accent: pal.accent, roof: pal.roof || '#9b2226', neon: pal.neon
+ };
+ if (st === 'house') houses.push(obj);
+ buildings.push(obj);
+ }
+
+ // Palmeiras costeiras + Árvores copadas nos boulevards amplos, parques e ilhas oceânicas!
+ let palmStep = 0;
+ for (let z = -440; z <= 440; z += 34) {
+ if (STREETS_Z.some(sz => Math.abs(z - sz) < 18)) continue;
+ palmStep += 1;
+ palms.push({ x: 315, z, scale: 0.95 + rand() * 0.3 });
+ palms.push({ x: 285, z: z + 8, scale: 0.9 + rand() * 0.25 });
+ palms.push({ x: 350, z: z - 6, scale: 1.0 + rand() * 0.35 });
+ // Canteiros centrais arborizados das Avenidas Amplas (-240 e +40)!
+ if (z < -120 || z > -10) palms.push({ x: -240, z, scale: 0.92 + rand() * 0.2 });
+ if (z < -435 || z > -330) trees.push({ x: 40, z, scale: 0.92 + rand() * 0.25 });
+
+ if (palmStep % 2 === 0) {
+ trees.push({ x: 183, z: z + 6, scale: 0.95 + rand() * 0.35 });
+ trees.push({ x: -103, z, scale: 0.9 + rand() * 0.3 });
+ }
+ }
+ for (let i = 0; i < 24; i += 1) {
+ palms.push({ x: 80 + (i % 6) * 28, z: 650 + Math.floor(i / 6) * 44, scale: 1.0 + rand() * 0.3 });
+ trees.push({ x: -260 + (i % 6) * 72, z: -645 - Math.floor(i / 6) * 42, scale: 1.0 + rand() * 0.3 });
+ }
+ // Palmeiras nas Ilhas Costeiras do Atlântico (para dar silhueta tropical linda vista da praia!)
+ for (const isl of OFFSHORE_ISLANDS) {
+ for (let k = 0; k < 10; k += 1) {
+ const ang = (k / 10) * Math.PI * 2;
+ palms.push({
+ x: isl.x + Math.cos(ang) * isl.rx * 0.45,
+ z: isl.z + Math.sin(ang) * isl.rz * 0.45,
+ scale: 1.35 + rand() * 0.35
+ });
+ }
+ }
+
+ // Postes de luz nas calçadas das avenidas, ruas estreitas, pontes monumentais e aeroporto!
+ for (const ax of AVENUES_X) {
+ const hw = getAvenueWidth(ax) * 0.5 + 1.6;
+ for (let z = -420; z <= 420; z += 56) {
+ if (STREETS_Z.some(sz => Math.abs(z - sz) < 18)) continue;
+ streetlights.push({ x: ax + hw, z, yaw: -Math.PI * 0.5 });
+ streetlights.push({ x: ax - hw, z: z + 28, yaw: Math.PI * 0.5 });
+ }
+ }
+ for (let z = -420; z <= 420; z += 64) {
+ streetlights.push({ x: 342, z, yaw: 0 });
+ }
+ for (const br of INTERCITY_BRIDGES) {
+ if (!br.isEastWest) {
+ for (let z = br.zMin + 16; z <= br.zMax - 16; z += 34) {
+ streetlights.push({ x: br.x + br.width * 0.5 + 1.2, z, yaw: -Math.PI * 0.5 });
+ streetlights.push({ x: br.x - br.width * 0.5 - 1.2, z, yaw: Math.PI * 0.5 });
+ }
}
}
- // Guarda-sóis na praia de Vice Beach
+ for (const az of [-280, -60, 32, 140, 280]) {
+ beachAccesses.push({ x: 344, z: az, width: 8.5, length: 24 });
+ }
+
const umbrellaColors = ['#ff4fa3', '#00e5ff', '#ffd166', '#06d6a0', '#ff6b6b', '#9b6bff'];
- for (let z = -380; z <= 380; z += 38) {
- props.push({
- kind: 'umbrella',
- x: 392 + (rand() - 0.5) * 26,
- z: z + (rand() - 0.5) * 14,
- color: umbrellaColors[Math.floor(rand() * umbrellaColors.length)]
+ for (let z = -390; z <= 390; z += 34) {
+ if (Math.abs(z - (-140)) < 26) continue;
+ beachSets.push({
+ x: 398 + (rand() - 0.5) * 28,
+ z: z + (rand() - 0.5) * 10,
+ color: umbrellaColors[Math.floor(rand() * umbrellaColors.length)],
+ hasSunbather: rand() < 0.68
});
}
- cachedCityLayout = { buildings, palms, props };
+ beachCourts.push(
+ { x: 378, z: 18, kind: 'volleyball' },
+ { x: 382, z: -72, kind: 'altinha' },
+ { x: 378, z: 112, kind: 'volleyball' },
+ { x: 384, z: -215, kind: 'altinha' }
+ );
+
+ const props = beachSets.map(bs => ({ kind: 'umbrella', x: bs.x, z: bs.z, color: bs.color }));
+
+ cachedCityLayout = {
+ buildings,
+ houses,
+ palms,
+ trees,
+ streetlights,
+ beachSets,
+ beachCourts,
+ beachAccesses,
+ props
+ };
return cachedCityLayout;
}
diff --git a/vice-game/src/data/missions.js b/vice-game/src/data/missions.js
index 4f956605..42fcbfd6 100644
--- a/vice-game/src/data/missions.js
+++ b/vice-game/src/data/missions.js
@@ -1,29 +1,16 @@
-// Protagonistas, armas e campanha de missões de Vice Leonida (GTA VI Mobile).
+// Protagonista único (Rafael), arsenal 3D realista e campanha de missões de Vice Leonida (GTA VI Mobile).
export const CHARACTERS = Object.freeze([
{
- id: 'lucia',
- name: 'Lucia Caminos',
- role: 'Especialista em assaltos e velocidade',
- bio: 'Nascida para dominar as ruas de Leonida. Ágil a pé, mira firme e reflexos rápidos no volante.',
- outfitTop: '#ff2a85',
- outfitBottom: '#2b4570',
- skin: '#c98a63',
- hair: '#1f1412',
+ id: 'rafael',
+ name: 'Rafael',
+ role: 'Protagonista · Rei das Ruas de Vice Leonida',
+ bio: 'Especialista em fugas de alta velocidade, assaltos a cofres bancários e combate tático pelas pontes e rodovias de Leonida.',
+ outfitTop: '#1f6feb',
+ outfitBottom: '#1c2541',
+ skin: '#d49a74',
+ hair: '#1b1411',
speedBonus: 1.06,
- maxHealth: 120,
- maxArmor: 100
- },
- {
- id: 'jason',
- name: 'Jason Duval',
- role: 'Piloto de fuga e força tática',
- bio: 'Veterano das estradas costeiras de Vice. Aguenta mais impacto e domina muscle cars e motos.',
- outfitTop: '#2ec4b6',
- outfitBottom: '#3d405b',
- skin: '#dca884',
- hair: '#5c4028',
- speedBonus: 1.0,
maxHealth: 135,
maxArmor: 100
}
@@ -33,10 +20,12 @@ export function getCharacter(id) {
return CHARACTERS.find(c => c.id === id) || CHARACTERS[0];
}
+// `grip`: 'none' | 'pistol' | 'rifle' (usado pela animação 3D das mãos/braços e pela malha 3D detalhada!)
export const WEAPONS = Object.freeze([
{
id: 'fist',
name: 'Punhos',
+ grip: 'none',
slot: 0,
damage: 24,
range: 2.8,
@@ -49,11 +38,12 @@ export const WEAPONS = Object.freeze([
{
id: 'pistol',
name: 'Pistola 9mm Tática',
+ grip: 'pistol',
slot: 1,
- damage: 34,
- range: 52,
+ damage: 36,
+ range: 55,
fireRate: 0.24,
- spread: 0.025,
+ spread: 0.022,
ammoCost: 1,
defaultAmmo: 120,
price: 650,
@@ -61,12 +51,13 @@ export const WEAPONS = Object.freeze([
},
{
id: 'smg',
- name: 'Micro-SMG Vice',
+ name: 'Submetralhadora MP-Vice',
+ grip: 'pistol',
slot: 2,
- damage: 22,
- range: 46,
+ damage: 24,
+ range: 48,
fireRate: 0.095,
- spread: 0.055,
+ spread: 0.05,
ammoCost: 1,
defaultAmmo: 240,
price: 1800,
@@ -74,13 +65,14 @@ export const WEAPONS = Object.freeze([
},
{
id: 'shotgun',
- name: 'Escopeta Leonida',
+ name: 'Escopeta Tática 12GA',
+ grip: 'rifle',
slot: 3,
- damage: 19,
+ damage: 21,
pellets: 6,
- range: 26,
- fireRate: 0.68,
- spread: 0.14,
+ range: 28,
+ fireRate: 0.66,
+ spread: 0.13,
ammoCost: 1,
defaultAmmo: 48,
price: 2600,
@@ -88,14 +80,15 @@ export const WEAPONS = Object.freeze([
},
{
id: 'rifle',
- name: 'Carabina Assalto AR',
+ name: 'Fuzil Carabina M4-AR',
+ grip: 'rifle',
slot: 4,
- damage: 32,
- range: 74,
- fireRate: 0.12,
- spread: 0.03,
+ damage: 35,
+ range: 78,
+ fireRate: 0.115,
+ spread: 0.025,
ammoCost: 1,
- defaultAmmo: 210,
+ defaultAmmo: 240,
price: 4200,
color: '#9b6bff'
}
@@ -105,20 +98,20 @@ export function getWeapon(id) {
return WEAPONS.find(w => w.id === id) || WEAPONS[0];
}
-// Campanha de Missões em Vice Leonida: cada missão tem estágios claros com coordenadas no mapa
+// Campanha de Missões de Rafael em Vice Leonida, Palm Bay e Vice Keys
export const MISSIONS = Object.freeze([
{
id: 'welcome-vice',
number: 1,
- title: 'Bem-vindo a Vice Beach',
- giver: 'Lucia & Jason',
+ title: 'Chegada de Rafael em Vice Beach',
+ giver: 'Rafael · Safehouse',
reward: 2500,
start: { x: 274, z: 22 },
- summary: 'Pegue um esportivo na Ocean Drive, atravesse a cidade até o Clube Babylon e entregue a encomenda no Hotel.',
+ summary: 'Pegue um carro na Ocean Drive, passe pelo Clube Babylon e teste a ponte rumo ao continente.',
stages: [
{
type: 'enter-vehicle',
- prompt: 'Entre em qualquer carro ou moto na Ocean Drive (botão ENTRAR).',
+ prompt: 'Entre em um carro ou moto na Ocean Drive (botão ENTRAR).',
x: 300,
z: 18,
radius: 14
@@ -128,18 +121,18 @@ export const MISSIONS = Object.freeze([
prompt: 'Dirija até a frente do Clube Babylon na Washington Strip.',
x: 170,
z: -190,
- radius: 13
+ radius: 14
},
{
type: 'checkpoint',
- prompt: 'Atravesse o Midtown até o mirante do Canal de Biscayne.',
- x: -90,
+ prompt: 'Cruze a Ponte Central sobre o Canal de Biscayne.',
+ x: -154,
z: 0,
- radius: 14
+ radius: 16
},
{
type: 'checkpoint',
- prompt: 'Volte para o Hotel Ocean Star para guardar o dinheiro.',
+ prompt: 'Volte para o Hotel Ocean Star para guardar o pagamento.',
x: 300,
z: 36,
radius: 14
@@ -147,46 +140,31 @@ export const MISSIONS = Object.freeze([
]
},
{
- id: 'neon-sprint',
+ id: 'corvette-container',
number: 2,
- title: 'Corrida Neon na Orla',
- giver: 'Rafa · Street Club',
- reward: 5000,
- timeLimit: 95,
- start: { x: 300, z: -120 },
- summary: 'Complete o circuito de alta velocidade pela Ocean Drive e Washington Strip antes do cronômetro zerar.',
+ title: 'O Corvette Secreto do Container',
+ giver: 'Docas de Port Gellhorn',
+ reward: 6500,
+ start: { x: -240, z: 140 },
+ summary: 'Vá até o Pátio do Porto em Port Gellhorn, encontre o container especial aberto, resgate o Corvette Stingray exclusivo e leve-o até a praia!',
stages: [
- {
- type: 'enter-vehicle',
- prompt: 'Assuma o volante de um carro ou moto rápida para largar!',
- x: 300,
- z: -120,
- radius: 16
- },
- {
- type: 'checkpoint',
- prompt: 'Checkpoint 1/4 — Rasgue o sul da Ocean Drive!',
- x: 300,
- z: 275,
- radius: 15
- },
{
type: 'checkpoint',
- prompt: 'Checkpoint 2/4 — Curva fechada para a Washington Strip!',
- x: 170,
- z: 280,
- radius: 15
+ prompt: 'Vá até o container especial no Porto de Port Gellhorn (sudoeste).',
+ x: -432,
+ z: 312,
+ radius: 14
},
{
- type: 'checkpoint',
- prompt: 'Checkpoint 3/4 — Acelere rumo ao norte de Leonida!',
- x: 170,
- z: -280,
- radius: 15
+ type: 'enter-vehicle',
+ prompt: 'Entre no Corvette Stingray Especial guardado dentro do container!',
+ x: -432,
+ z: 320,
+ radius: 14
},
{
type: 'checkpoint',
- prompt: 'Linha de Chegada — Feche na frente do Píer de Vice Beach!',
+ prompt: 'Acelere com o Corvette Especial até a entrada do Píer da Roda-Gigante em Vice Beach!',
x: 300,
z: -140,
radius: 16
@@ -194,69 +172,69 @@ export const MISSIONS = Object.freeze([
]
},
{
- id: 'canal-courier',
+ id: 'bank-heist-leonida',
number: 3,
- title: 'Conexão Downtown',
- giver: 'Dre · Marina Docks',
- reward: 8500,
- start: { x: 335, z: -140 },
- summary: 'Busque a maleta blindada nas docas do Porto de Gellhorn, mas cuidado: a VCPD está monitorando a ponte!',
+ title: 'Golpe ao Cofre Nacional (6 Estrelas)',
+ giver: 'Rafael · Operação Cofre',
+ reward: 18000,
+ start: { x: -240, z: -30 },
+ summary: 'Entre a pé pelas portas abertas do Banco Nacional de Leonida, invada o cofre nos fundos (ativa 6 ESTRELAS na hora!) e escape para a cidade norte de Palm Bay!',
stages: [
{
type: 'checkpoint',
- prompt: 'Cruze a ponte central até o Distrito Portuário de Gellhorn.',
- x: -420,
- z: 240,
- radius: 14,
- addWanted: 2
+ prompt: 'Entre pela porta principal do Banco Nacional de Leonida e chegue até o COFRE nos fundos!',
+ x: -292,
+ z: -65,
+ radius: 5.5,
+ addWanted: 6
},
{
type: 'checkpoint',
- prompt: 'A polícia cercou a ponte! Passe na Oficina Neon Customs para despistar a VCPD ou fuja.',
+ prompt: '6 ESTRELAS ATIVADAS! Saia do banco, pegue o carro de fuga e atravesse a Ponte Norte rumo a Palm Bay!',
x: 40,
- z: -68,
- radius: 13,
- clearWanted: true
+ z: -650,
+ radius: 18
},
{
- type: 'checkpoint',
- prompt: 'Entregue a maleta limpa na cobertura comercial de Midtown.',
- x: -90,
- z: 140,
- radius: 14
+ type: 'escape-wanted',
+ prompt: 'Despiste a VCPD em Palm Bay ou passe numa Oficina Neon Customs!',
+ x: 40,
+ z: -68,
+ radius: 15,
+ clearWanted: true
}
]
},
{
- id: 'bank-heist-leonida',
+ id: 'keys-run',
number: 4,
- title: 'O Grande Golpe de Leonida',
- giver: 'Lucia & Jason · Plano Final',
- reward: 25000,
- start: { x: -216, z: -65 },
- summary: 'Invada o cofre externo do Banco Nacional em Downtown, enfrente o cerco policial de 4 estrelas e escape até a Marina!',
+ title: 'Fuga pelas Pontes de Vice Keys',
+ giver: 'Marina Sul',
+ reward: 12000,
+ timeLimit: 135,
+ start: { x: 170, z: 280 },
+ summary: 'Rasgue a rodovia costeira sul, atravesse a grande ponte oceânica até a ilha de Vice Keys e chegue ao Farol antes do tempo acabar!',
stages: [
{
- type: 'checkpoint',
- prompt: 'Posicione-se na porta do Banco Nacional de Leonida para abrir o cofre.',
- x: -240,
- z: -65,
- radius: 13,
- addWanted: 4
+ type: 'enter-vehicle',
+ prompt: 'Pegue um veículo veloz para cruzar a Ponte Oceânica Sul!',
+ x: 170,
+ z: 280,
+ radius: 16
},
{
- type: 'escape-wanted',
- prompt: 'Alarme disparado (4 ★)! Despiste as viaturas ou use uma Oficina Customs!',
- x: 40,
- z: -68,
- radius: 14
+ type: 'checkpoint',
+ prompt: 'Cruze a Ponte Suspensa sobre o mar rumo a Vice Keys!',
+ x: 170,
+ z: 530,
+ radius: 18
},
{
type: 'checkpoint',
- prompt: 'Leve o ouro até o Píer de Vice Beach para comemorar o golpe perfeito!',
- x: 375,
- z: -140,
- radius: 15
+ prompt: 'Contorne a estrada costeira da ilha de Vice Keys até o Farol!',
+ x: 245,
+ z: 690,
+ radius: 18
}
]
}
diff --git a/vice-game/src/data/vehicles.js b/vice-game/src/data/vehicles.js
index 57a6788f..06868374 100644
--- a/vice-game/src/data/vehicles.js
+++ b/vice-game/src/data/vehicles.js
@@ -4,24 +4,48 @@ export const VEHICLE_MODELS = Object.freeze([
{
id: 'cheetah-vice',
name: 'Corvette Stingray Unbound GT',
- brand: 'Chevrolet · Custom',
+ brand: 'Chevrolet · Raridade Container',
category: 'super',
+ specialContainerOnly: true,
glbUrl: 'assets/brand/harlows_chevrolet_corvette_stingray_nfs_unbound.glb',
glbYaw: 0,
- maxSpeed: 48,
- reverseSpeed: 16,
- accel: 28,
- brake: 40,
- turnRate: 2.4,
- driftGrip: 0.85,
+ maxSpeed: 52,
+ reverseSpeed: 17,
+ accel: 32,
+ brake: 42,
+ turnRate: 2.48,
+ driftGrip: 0.87,
mass: 1450,
- maxHp: 260,
+ maxHp: 320,
width: 2.08,
length: 4.65,
height: 1.24,
- price: 25000,
+ price: 45000,
colors: ['#ff2a85', '#00f5d4', '#ffd166', '#ffffff', '#7209b7']
},
+ {
+ id: 'leonida-gt-custom',
+ name: 'Leonida Street Custom GT',
+ brand: 'Vice Custom Import',
+ category: 'sports',
+ glbUrl: 'assets/brand/fiesta_2012.glb',
+ customSlot: 'carExtra',
+ glbYaw: Math.PI / 2,
+ tintGlb: true,
+ maxSpeed: 43,
+ reverseSpeed: 14,
+ accel: 25,
+ brake: 36,
+ turnRate: 2.52,
+ driftGrip: 0.85,
+ mass: 1380,
+ maxHp: 245,
+ width: 1.96,
+ length: 4.35,
+ height: 1.38,
+ price: 16500,
+ colors: ['#ff2a85', '#00bbf9', '#06d6a0', '#ffd166']
+ },
{
id: 'banshee-cabrio',
name: 'Fiesta Street Turbo 2012',
diff --git a/vice-game/src/main.js b/vice-game/src/main.js
index b008aba2..55cd7385 100644
--- a/vice-game/src/main.js
+++ b/vice-game/src/main.js
@@ -37,7 +37,10 @@ export function go(screenName, params = {}) {
activeWorld.dispose();
activeWorld = null;
}
- activeMenu = null;
+ if (activeMenu) {
+ activeMenu.dispose?.();
+ activeMenu = null;
+ }
clear(host);
document.body.dataset.screen = screenName;
@@ -46,6 +49,8 @@ export function go(screenName, params = {}) {
host,
profile,
initialMissionId: params.missionId || null,
+ initialVehicleId: params.vehicleId || null,
+ initialVehicleColor: params.vehicleColor || null,
toast,
onExitToMenu: () => go('menu')
});
@@ -55,7 +60,8 @@ export function go(screenName, params = {}) {
activeMenu = createMenuScreen({
profile,
toast,
- onPlay: ({ missionId = null } = {}) => go('world', { missionId })
+ onPlay: ({ missionId = null, vehicleId = null, vehicleColor = null } = {}) =>
+ go('world', { missionId, vehicleId, vehicleColor })
});
host.appendChild(activeMenu.node);
return activeMenu;
diff --git a/vice-game/src/screens/menu.js b/vice-game/src/screens/menu.js
index 870c31dd..aaeccb31 100644
--- a/vice-game/src/screens/menu.js
+++ b/vice-game/src/screens/menu.js
@@ -1,21 +1,152 @@
-// Menu Principal Neon de GTA VI Mobile (Vice Leonida) — 100% funcional, acessível e fluido em paisagem.
+// Menu Principal Neon de GTA VI Mobile (Vice Leonida) — com Showroom 3D interativo dos modelos .GLB!
import { CHARACTERS, MISSIONS } from '../data/missions.js';
import { VEHICLE_MODELS } from '../data/vehicles.js';
-import { QUALITY_PRESETS } from '../world/engine.js';
+import { THREE, QUALITY_PRESETS, createLeonidaEnvironmentMap } from '../world/engine.js';
+import { createCharacterMesh, createVehicleMesh } from '../world/entities.js';
+import { preloadAllViceModels, loadCitizenTemplates } from '../world/glb-loader.js';
import { saveProfile } from '../state.js';
import { uiClick } from '../audio.js';
import { el } from '../ui/dom.js';
+function mountTurntableStage(canvasHost, buildSubject) {
+ if (typeof window === 'undefined' || !canvasHost) return () => {};
+
+ let renderer = null;
+ let envRT = null;
+ let rafId = 0;
+ let disposed = false;
+
+ try {
+ const canvas = el('canvas', { class: 'vc-turntable__canvas' });
+ canvasHost.appendChild(canvas);
+
+ renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true });
+ renderer.setPixelRatio(Math.min(window.devicePixelRatio || 1, 2));
+ renderer.outputColorSpace = THREE.SRGBColorSpace;
+ renderer.toneMapping = THREE.ACESFilmicToneMapping;
+ renderer.toneMappingExposure = 1.22;
+
+ const scene = new THREE.Scene();
+ envRT = createLeonidaEnvironmentMap(renderer);
+ if (envRT) scene.environment = envRT.texture;
+
+ const hemi = new THREE.HemisphereLight('#ffe3f1', '#222b45', 1.25);
+ const keyLight = new THREE.DirectionalLight('#fff2d6', 1.75);
+ keyLight.position.set(5, 8, 6);
+ const rimPink = new THREE.PointLight('#ff2a85', 2.4, 18);
+ rimPink.position.set(-5, 3, -4);
+ const rimCyan = new THREE.PointLight('#00f5d4', 2.1, 18);
+ rimCyan.position.set(5, 2.5, -4);
+ scene.add(hemi, keyLight, rimPink, rimCyan);
+
+ // Piso circular neon giratório de showroom
+ const podium = new THREE.Group();
+ const disc = new THREE.Mesh(
+ new THREE.CylinderGeometry(3.4, 3.6, 0.14, 48),
+ new THREE.MeshStandardMaterial({ color: '#141933', metalness: 0.55, roughness: 0.28 })
+ );
+ disc.position.y = -0.07;
+ const ring = new THREE.Mesh(
+ new THREE.RingGeometry(3.22, 3.38, 48),
+ new THREE.MeshBasicMaterial({ color: '#00f5d4', side: THREE.DoubleSide })
+ );
+ ring.rotation.x = -Math.PI / 2;
+ ring.position.y = 0.01;
+ podium.add(disc, ring);
+ scene.add(podium);
+
+ const camera = new THREE.PerspectiveCamera(42, 16 / 10, 0.2, 80);
+ const subjectGroup = new THREE.Group();
+ podium.add(subjectGroup);
+
+ const state = {
+ yaw: 0.55,
+ autoSpin: true,
+ camDist: 6.8,
+ camHeight: 2.3,
+ lookY: 0.9,
+ tickSubject: null
+ };
+
+ // Permite girar o modelo 3D com o dedo ou mouse
+ let dragging = false;
+ let lastX = 0;
+ canvas.addEventListener('pointerdown', e => {
+ dragging = true;
+ state.autoSpin = false;
+ lastX = e.clientX;
+ canvas.setPointerCapture?.(e.pointerId);
+ });
+ canvas.addEventListener('pointermove', e => {
+ if (!dragging) return;
+ const dx = e.clientX - lastX;
+ lastX = e.clientX;
+ state.yaw += dx * 0.014;
+ });
+ const endDrag = () => { dragging = false; };
+ canvas.addEventListener('pointerup', endDrag);
+ canvas.addEventListener('pointercancel', endDrag);
+
+ buildSubject({ subjectGroup, podium, camera, state });
+
+ let lastT = performance.now();
+ function loop(now) {
+ if (disposed) return;
+ rafId = requestAnimationFrame(loop);
+ const dt = Math.min(0.05, Math.max(0.001, (now - lastT) / 1000));
+ lastT = now;
+
+ const w = Math.max(200, canvasHost.clientWidth || 420);
+ const h = Math.max(180, canvasHost.clientHeight || 260);
+ if (canvas.width !== Math.floor(w * renderer.getPixelRatio()) || canvas.height !== Math.floor(h * renderer.getPixelRatio())) {
+ renderer.setSize(w, h, false);
+ camera.aspect = w / h;
+ camera.updateProjectionMatrix();
+ }
+
+ if (state.autoSpin) state.yaw += dt * 0.58;
+ podium.rotation.y = state.yaw;
+ state.tickSubject?.(dt, now / 1000);
+
+ camera.position.set(0, state.camHeight, state.camDist);
+ camera.lookAt(0, state.lookY, 0);
+ renderer.render(scene, camera);
+ }
+ rafId = requestAnimationFrame(loop);
+ } catch {
+ // Em ambientes headless sem WebGL ativo, mantém a UI funcional sem quebrar
+ }
+
+ return () => {
+ disposed = true;
+ if (rafId) cancelAnimationFrame(rafId);
+ envRT?.dispose?.();
+ renderer?.dispose?.();
+ };
+}
+
export function createMenuScreen({ profile, onPlay, toast }) {
let subview = 'home'; // 'home' | 'characters' | 'missions' | 'garage' | 'settings'
+ let selectedGarageIdx = 0;
+ let selectedGarageColor = VEHICLE_MODELS[0].colors[0];
+ let activeStageCleanup = null;
+
+ preloadAllViceModels();
const root = el('div', { class: 'vc-menu' });
+ function cleanupStage() {
+ if (activeStageCleanup) {
+ activeStageCleanup();
+ activeStageCleanup = null;
+ }
+ }
+
function render() {
+ cleanupStage();
root.innerHTML = '';
- // Fundo estilizado pôr do sol Vice Beach com silhuetas de palmeiras e arranha-céus em SVG puro
const bg = el('div', { class: 'vc-menu__bg' },
el('div', { class: 'vc-menu__sun' }),
el('div', { class: 'vc-menu__grid-floor' })
@@ -26,7 +157,7 @@ export function createMenuScreen({ profile, onPlay, toast }) {
const topBar = el('header', { class: 'vc-menu__header' },
el('div', { class: 'vc-brand' },
- el('span', { class: 'vc-brand__kicker', text: 'BEM-VINDO AO ESTADO DE LEONIDA' }),
+ el('span', { class: 'vc-brand__kicker', text: 'BEM-VINDO AO ESTADO DE LEONIDA · 8 MODELOS .GLB ATIVOS' }),
el('h1', { class: 'vc-brand__title' },
'VICE ',
el('em', { class: 'vc-brand__vi', text: 'VI' }),
@@ -58,11 +189,11 @@ export function createMenuScreen({ profile, onPlay, toast }) {
onPlay({ missionId: null });
}
},
- el('span', { class: 'vc-hero-play__badge', text: 'MUNDO ABERTO 3D · 60 FPS' }),
+ el('span', { class: 'vc-hero-play__badge', text: 'MUNDO ABERTO 3D · 8 MODELOS .GLB NO JOGO' }),
el('strong', { class: 'vc-hero-play__title', text: 'ENTRAR EM VICE LEONIDA' }),
el('span', {
class: 'vc-hero-play__desc',
- text: 'Explore Ocean Drive, Downtown, Canal de Biscayne e Píer de Vice Beach com carros, motos, rádio FM e perseguições VCPD.'
+ text: 'Corvette Stingray, Fiesta Turbo, Pontiac GTO V8, Cruze VCPD, Moto 004, Motorhome Commander e cidadãos 3D já alinhados na Ocean Drive!'
}),
el('span', { class: 'vc-hero-play__cta', text: '▶ JOGAR AGORA' })
),
@@ -70,68 +201,124 @@ export function createMenuScreen({ profile, onPlay, toast }) {
el('button', {
type: 'button',
class: 'vc-tile',
- onclick: () => { uiClick(); subview = 'missions'; render(); }
+ onclick: () => { uiClick(); subview = 'garage'; render(); }
},
- el('strong', { text: 'CAMPANHA & GOLPES' }),
- el('span', { text: `${MISSIONS.length} missões de história em Vice Beach` })
+ el('strong', { text: '🚗 GARAGEM 3D (.GLB)' }),
+ el('span', { text: `Inspecione em 360° e saia dirigindo qualquer um dos ${VEHICLE_MODELS.length} veículos` })
),
el('button', {
type: 'button',
class: 'vc-tile',
onclick: () => { uiClick(); subview = 'characters'; render(); }
},
- el('strong', { text: 'LUCIA & JASON' }),
- el('span', { text: `Ativo: ${activeChar.name} · Trocar dupla` })
+ el('strong', { text: '👤 PROTAGONISTA: RAFAEL' }),
+ el('span', { text: 'Protagonista único articulado + armas 3D realistas (Pistola & Fuzil)' })
),
el('button', {
type: 'button',
class: 'vc-tile',
- onclick: () => { uiClick(); subview = 'garage'; render(); }
+ onclick: () => { uiClick(); subview = 'missions'; render(); }
},
- el('strong', { text: 'GARAGEM VICE MOTORS' }),
- el('span', { text: `${VEHICLE_MODELS.length} carros, motos e viaturas` })
+ el('strong', { text: '★ CAMPANHA & GOLPES' }),
+ el('span', { text: `${MISSIONS.length} missões de história em Vice Beach` })
),
el('button', {
type: 'button',
class: 'vc-tile',
onclick: () => { uiClick(); subview = 'settings'; render(); }
},
- el('strong', { text: 'GRÁFICOS & ÁUDIO' }),
+ el('strong', { text: '⚙ GRÁFICOS & ÁUDIO' }),
el('span', { text: `Qualidade: ${QUALITY_PRESETS[profile.settings.quality]?.label || 'Alta'}` })
)
)
);
content.appendChild(heroCards);
} else if (subview === 'characters') {
+ const stageBox = el('div', { class: 'vc-turntable' },
+ el('div', { class: 'vc-turntable__hint', text: 'Arraste para girar 360° · standing_man.glb + citizen_npc_pack.glb' })
+ );
+
content.append(
- subHeader('ESCOLHA SEU PROTAGONISTA'),
- el('div', { class: 'vc-sub-grid vc-sub-grid--two' },
- ...CHARACTERS.map(ch => {
- const selected = ch.id === profile.characterId;
- return el('div', { class: `vc-sub-card ${selected ? 'is-selected' : ''}` },
- el('div', {
- class: 'vc-char-swatch',
- style: { background: `linear-gradient(135deg, ${ch.outfitTop}, ${ch.outfitBottom})` }
- }, el('span', { text: ch.name[0] })),
- el('h3', { text: ch.name }),
- el('small', { class: 'vc-sub-card__role', text: ch.role }),
- el('p', { text: ch.bio }),
- el('button', {
- type: 'button',
- class: 'vc-action-btn',
- text: selected ? 'SELECIONADO ✓' : 'ESCOLHER PROTAGONISTA',
- onclick: () => {
- profile.characterId = ch.id;
- saveProfile(profile);
- uiClick();
- toast?.(`${ch.name} pronta para entrar em Leonida!`);
- render();
- }
- })
- );
- })
+ subHeader('PERSONAGENS 3D (.GLB) — PROTAGONISTA & CIDADÃOS'),
+ el('div', { class: 'vc-garage-showcase' },
+ stageBox,
+ el('div', { class: 'vc-sub-grid vc-sub-grid--two' },
+ ...CHARACTERS.map(ch => {
+ const selected = ch.id === profile.characterId;
+ return el('div', { class: `vc-sub-card ${selected ? 'is-selected' : ''}` },
+ el('div', {
+ class: 'vc-char-swatch',
+ style: { background: `linear-gradient(135deg, ${ch.outfitTop}, ${ch.outfitBottom})` }
+ }, el('span', { text: ch.name[0] })),
+ el('h3', { text: ch.name }),
+ el('small', { class: 'vc-sub-card__role', text: ch.role }),
+ el('p', { text: ch.bio }),
+ el('div', { class: 'vc-sub-card__row', style: { gap: '8px', flexWrap: 'wrap' } },
+ el('button', {
+ type: 'button',
+ class: 'vc-action-btn',
+ text: selected ? 'SELECIONADO ✓' : 'ESCOLHER',
+ onclick: () => {
+ profile.characterId = ch.id;
+ saveProfile(profile);
+ uiClick();
+ toast?.(`${ch.name} pronta para entrar em Leonida!`);
+ render();
+ }
+ }),
+ el('button', {
+ type: 'button',
+ class: 'vc-action-btn is-active',
+ text: '▶ JOGAR COM ' + ch.name.split(' ')[0].toUpperCase(),
+ onclick: () => {
+ profile.characterId = ch.id;
+ saveProfile(profile);
+ uiClick();
+ onPlay({ missionId: null });
+ }
+ })
+ )
+ );
+ })
+ )
)
);
+
+ requestAnimationFrame(() => {
+ const ch = CHARACTERS.find(c => c.id === profile.characterId) || CHARACTERS[0];
+ activeStageCleanup = mountTurntableStage(stageBox, ({ subjectGroup, state }) => {
+ state.camDist = 4.6;
+ state.camHeight = 1.65;
+ state.lookY = 0.95;
+
+ const protag = createCharacterMesh({
+ characterId: ch.id,
+ topColor: ch.outfitTop,
+ bottomColor: ch.outfitBottom,
+ skinColor: ch.skin,
+ hairColor: ch.hair,
+ isProtagonist: true
+ });
+ protag.root.position.set(0, 0, 0.35);
+ subjectGroup.add(protag.root);
+
+ // Exibe também 2 cidadãos do pacote citizen_npc_pack ao fundo no pódio!
+ loadCitizenTemplates().then(templates => {
+ if (!templates || templates.length < 2) return;
+ const c1 = templates[0].clone(true);
+ c1.position.set(-1.35, 0, -0.55);
+ c1.rotation.y = 0.35;
+ const c2 = templates[Math.min(5, templates.length - 1)].clone(true);
+ c2.position.set(1.35, 0, -0.55);
+ c2.rotation.y = -0.35;
+ subjectGroup.add(c1, c2);
+ });
+
+ state.tickSubject = dt => {
+ protag.animate(dt, 0, false, false);
+ };
+ });
+ });
} else if (subview === 'missions') {
content.append(
subHeader('MISSÕES DE HISTÓRIA — LEONIDA'),
@@ -159,21 +346,107 @@ export function createMenuScreen({ profile, onPlay, toast }) {
)
);
} else if (subview === 'garage') {
- content.append(
- subHeader('CATÁLOGO VICE MOTORS'),
- el('div', { class: 'vc-sub-grid' },
- ...VEHICLE_MODELS.map(v => el('div', { class: 'vc-sub-card' },
- el('small', { class: 'vc-sub-card__role', text: `${v.brand.toUpperCase()} · ${v.category.toUpperCase()}` }),
- el('h3', { text: v.name }),
- el('p', {
- text: `Vel. Máxima: ${Math.round(v.maxSpeed * 3.6)} km/h · Blindagem: ${v.maxHp} HP`
- }),
- el('div', { class: 'vc-color-dots' },
- ...v.colors.map(c => el('span', { class: 'vc-dot', style: { background: c } }))
- )
- ))
+ const activeSpec = VEHICLE_MODELS[selectedGarageIdx] || VEHICLE_MODELS[0];
+ const glbFilename = (activeSpec.glbUrl || '').split('/').pop();
+
+ const stageBox = el('div', { class: 'vc-turntable' },
+ el('div', { class: 'vc-turntable__hint', text: `Arraste para girar 360° · ${glbFilename}` })
+ );
+
+ let previewVehicleMesh = null;
+
+ const detailPanel = el('div', { class: 'vc-garage-detail' },
+ el('div', { class: 'vc-garage-selector' },
+ ...VEHICLE_MODELS.map((v, idx) => el('button', {
+ type: 'button',
+ class: `vc-garage-pill ${idx === selectedGarageIdx ? 'is-active' : ''}`,
+ text: v.name,
+ onclick: () => {
+ selectedGarageIdx = idx;
+ selectedGarageColor = v.colors[0];
+ uiClick();
+ render();
+ }
+ }))
+ ),
+ el('div', { class: 'vc-sub-card is-selected' },
+ el('small', { class: 'vc-sub-card__role', text: `${activeSpec.brand.toUpperCase()} · ARQUIVO 3D: ${glbFilename}` }),
+ el('h3', { text: activeSpec.name }),
+ el('p', {
+ text: `Velocidade Máxima: ${Math.round(activeSpec.maxSpeed * 3.6)} km/h · Blindagem: ${activeSpec.maxHp} HP · Comprimento: ${activeSpec.length}m`
+ }),
+ el('div', { class: 'vc-color-dots' },
+ ...activeSpec.colors.map(c => el('button', {
+ type: 'button',
+ class: 'vc-dot',
+ title: `Pintura ${c}`,
+ style: {
+ background: c,
+ outline: selectedGarageColor === c ? '2px solid #fff' : 'none',
+ border: 'none'
+ },
+ onclick: () => {
+ selectedGarageColor = c;
+ previewVehicleMesh?.setBodyColor(c);
+ uiClick();
+ }
+ }))
+ ),
+ el('div', { class: 'vc-sub-card__row', style: { marginTop: '10px', gap: '10px', flexWrap: 'wrap' } },
+ el('button', {
+ type: 'button',
+ class: 'vc-hero-play__cta',
+ style: { marginTop: '0', border: 'none' },
+ text: '▶ DIRIGIR ESTE MODELO AGORA',
+ onclick: () => {
+ uiClick();
+ onPlay({
+ missionId: null,
+ vehicleId: activeSpec.id,
+ vehicleColor: selectedGarageColor
+ });
+ }
+ })
+ )
)
);
+
+ content.append(
+ subHeader('GARAGEM VICE MOTORS — SHOWROOM 3D (.GLB)'),
+ el('div', { class: 'vc-garage-showcase' }, stageBox, detailPanel)
+ );
+
+ requestAnimationFrame(() => {
+ activeStageCleanup = mountTurntableStage(stageBox, ({ subjectGroup, disc, state }) => {
+ const isHuge = activeSpec.length > 6.5;
+ state.camDist = isHuge ? 10.5 : (activeSpec.isBike ? 4.4 : 6.6);
+ state.camHeight = isHuge ? 3.4 : 2.1;
+ state.lookY = isHuge ? 1.35 : 0.75;
+
+ previewVehicleMesh = createVehicleMesh(activeSpec.id, selectedGarageColor);
+ subjectGroup.add(previewVehicleMesh.root);
+
+ let previewRider = null;
+ if (activeSpec.isBike) {
+ const ch = CHARACTERS.find(c => c.id === profile.characterId) || CHARACTERS[0];
+ previewRider = createCharacterMesh({
+ characterId: ch.id,
+ topColor: ch.outfitTop,
+ bottomColor: ch.outfitBottom,
+ skinColor: ch.skin,
+ hairColor: ch.hair,
+ isProtagonist: true
+ });
+ previewRider.root.position.set(0, 0.04, -0.1);
+ previewVehicleMesh.root.add(previewRider.root);
+ }
+
+ state.tickSubject = (dt, elapsed) => {
+ previewVehicleMesh.updateVisuals(dt, 6, elapsed, Boolean(activeSpec.isPolice), 1);
+ previewRider?.animate(dt, 14, false, false, { mode: 'bike', steer: 0 });
+ };
+ });
+ });
} else if (subview === 'settings') {
content.append(
subHeader('AJUSTES MOBILE & GRÁFICOS'),
@@ -195,13 +468,13 @@ export function createMenuScreen({ profile, onPlay, toast }) {
)
),
el('div', { class: 'vc-setting-row' },
- el('span', { text: 'Clima / Iluminação de Leonida' }),
+ el('span', { text: 'Céu & Ciclo Dia / Noite de Leonida' }),
el('div', { class: 'vc-btn-group' },
...[
- ['dynamic', 'Ciclo Dinâmico'],
- ['sunset', 'Pôr do Sol Vice'],
- ['night', 'Noite Neon'],
- ['day', 'Sol Tropical']
+ ['sunset', '🌅 Fim de Tarde Rosa (Padrão Vice)'],
+ ['dynamic', 'Ciclo 10 min (Dia ↔ Noite)'],
+ ['day', '☀️ Dia Azul + Sol & Nuvens'],
+ ['night', '🌙 Noite Preta + Postes Acesos']
].map(([id, label]) => el('button', {
type: 'button',
class: `vc-action-btn ${profile.settings.timeMode === id ? 'is-active' : ''}`,
@@ -233,7 +506,7 @@ export function createMenuScreen({ profile, onPlay, toast }) {
}
const footer = el('footer', { class: 'vc-menu__footer' },
- el('span', { text: 'Toque: Analógico + Pedais + Arraste de Câmera · PC: WASD, F (Carro), Espaço (Drift/Pulo), J (Tiro), R (Rádio), M (Mapa)' })
+ el('span', { text: 'Toque: Analógico + Pedais + Botão CARROS 3D · PC: WASD, F (Carro), G (Garagem 3D), Espaço (Drift/Pulo), J (Tiro), R (Rádio), M (Mapa)' })
);
root.append(bg, topBar, content, footer);
@@ -259,6 +532,7 @@ export function createMenuScreen({ profile, onPlay, toast }) {
return {
node: root,
+ dispose: cleanupStage,
onBack: () => {
if (subview !== 'home') {
subview = 'home';
diff --git a/vice-game/src/state.js b/vice-game/src/state.js
index e3e19acd..f04f3b35 100644
--- a/vice-game/src/state.js
+++ b/vice-game/src/state.js
@@ -1,4 +1,4 @@
-// Perfil persistente do jogador em Vice Leonida (localStorage `vice6.profile.v1`).
+// Perfil persistente do jogador (Rafael) em Vice Leonida (`vice6.profile.v1`).
import { WEAPONS } from './data/missions.js';
@@ -6,32 +6,34 @@ export const STORAGE_KEY = 'vice6.profile.v1';
export function defaultProfile() {
return {
- version: 1,
- characterId: 'lucia',
+ version: 2,
+ characterId: 'rafael',
money: 3500,
completedMissions: [],
- ownedWeapons: ['fist', 'pistol', 'smg'],
+ ownedWeapons: ['fist', 'pistol', 'smg', 'rifle'],
ammo: {
pistol: WEAPONS.find(w => w.id === 'pistol').defaultAmmo,
smg: WEAPONS.find(w => w.id === 'smg').defaultAmmo,
- shotgun: 24,
- rifle: 120
+ shotgun: 36,
+ rifle: WEAPONS.find(w => w.id === 'rifle').defaultAmmo
},
ownedVehicles: ['banshee-cabrio'],
radioStation: 'flash-neon',
settings: {
- quality: 'high', // 'low' | 'medium' | 'high'
+ quality: 'medium', // Equilibrado por padrão para fluidez sem travamentos!
sound: true,
radioVolume: 0.55,
sfxVolume: 0.75,
- timeMode: 'dynamic', // 'dynamic' | 'sunset' | 'night' | 'day'
+ timeMode: 'sunset', // Céu meio rosa de fim de tarde como padrão!
touchSensitivity: 1.0
},
stats: {
distanceDrivenMeters: 0,
missionsPassed: 0,
maxWantedSurvived: 0,
- carsStolen: 0
+ carsStolen: 0,
+ banksRobbed: 0,
+ ferrisRides: 0
}
};
}
@@ -47,11 +49,12 @@ export function loadProfile(storage = globalThis.localStorage) {
return {
...base,
...parsed,
+ characterId: 'rafael', // Protagonista único: Rafael!
ammo: { ...base.ammo, ...(parsed.ammo || {}) },
settings: { ...base.settings, ...(parsed.settings || {}) },
stats: { ...base.stats, ...(parsed.stats || {}) },
completedMissions: Array.isArray(parsed.completedMissions) ? [...parsed.completedMissions] : base.completedMissions,
- ownedWeapons: Array.isArray(parsed.ownedWeapons) ? [...new Set(['fist', ...parsed.ownedWeapons])] : base.ownedWeapons,
+ ownedWeapons: Array.isArray(parsed.ownedWeapons) ? [...new Set(['fist', 'pistol', 'rifle', ...parsed.ownedWeapons])] : base.ownedWeapons,
ownedVehicles: Array.isArray(parsed.ownedVehicles) ? [...parsed.ownedVehicles] : base.ownedVehicles
};
} catch {
@@ -62,6 +65,7 @@ export function loadProfile(storage = globalThis.localStorage) {
export function saveProfile(profile, storage = globalThis.localStorage) {
if (!storage || typeof storage.setItem !== 'function') return false;
try {
+ profile.characterId = 'rafael';
storage.setItem(STORAGE_KEY, JSON.stringify(profile));
return true;
} catch {
diff --git a/vice-game/src/world/city-mesh.js b/vice-game/src/world/city-mesh.js
index a712914f..cd3f5dee 100644
--- a/vice-game/src/world/city-mesh.js
+++ b/vice-game/src/world/city-mesh.js
@@ -1,8 +1,27 @@
-// Construção 3D da cidade de Vice Leonida: ruas, avenidas, calçadão, praia de Vice Beach,
-// Canal de Biscayne com pontes iluminadas, prédios Art Déco e arranha-céus, palmeiras,
-// guarda-sóis, oficinas Customs e marcos luminosos de missão.
+// Construção 3D otimizada (60 FPS Mobile, InstancedMesh para zero travamento!) do Estado de Leonida — v0.7.0:
+// - OCEANO REALISTA: malha subdividida com ondas vértice a vértice animadas, cáusticas e 4 ondas 3D rolando/quebrando com espuma!
+// - ARQUIPÉLAGO no horizonte leste (ilhas com colinas, faróis girando, resorts, espuma na orla e veleiros balançando) — fim do "só água vazia"!
+// - Três cidades conectadas por GRANDES PONTES ESTAIADAS Monumentais (torres H-frame, estais em leque, guarda-neon e iluminação);
+// - Rodovias curvas e diagonais reais (`SCENIC_ROADS`) + 3 larguras de via: Avenidas AMPLAS com canteiro central, Normais e RUAS ESTREITAS/Becos!
+// - TÚNEIS rodoviários iluminados com portal de concreto, luzes âmbar internas e morro paisagístico por cima!
+// - TREM EXPRESSO METRORAIL em movimento com 2 ESTAÇÕES de trem caminháveis (plataformas, cobertura, bancos e letreiro)!
+// - AEROPORTO Internacional de Leonida (pista zebrada, jatos 3D, torre com radar girando, terminal entrável e avião voando no circuito!);
+// - LOJAS ENTRÁVEIS A PÉ (24/7 Vice Mart, Ammu-Nation, Neon Threads) com interior completo e balcão de compra!
+// - BANCO NACIONAL MONUMENTAL: pedra neoclássica texturizada, colunas, frontão, torre espelhada de vidro dourada e COFRE nos fundos!
+// - Píer de Vice Beach com Roda-Gigante 3D ($70), Container secreto do Corvette, Postes de luz noturnos e Pegadas na areia!
-import { THREE, buildingFacadeTexture, createRoadTexture } from './engine.js';
+import {
+ THREE,
+ buildingFacadeTexture,
+ createRoadTexture,
+ createSandTexture,
+ createOceanWaterTexture,
+ createBankStoneTexture,
+ createMarbleFloorTexture,
+ createRunwayTexture,
+ makeCanvasTexture
+} from './engine.js';
+import { loadGlbOnce, resolveEnvironmentPropGlbs } from './glb-loader.js';
import {
AVENUES_X,
STREETS_Z,
@@ -13,191 +32,2034 @@ import {
CANAL_MIN_X,
CANAL_MAX_X,
BRIDGE_ZS,
+ INTERCITY_BRIDGES,
+ SCENIC_ROADS,
+ NARROW_ROADS,
+ OFFSHORE_ISLANDS,
+ ROAD_TUNNELS,
+ AIRPORT_DATA,
+ TRAIN_LINE,
+ ENTERABLE_SHOPS,
+ BANK_INTERIOR,
+ CORVETTE_CONTAINER,
+ FERRIS_WHEEL,
POINTS_OF_INTEREST,
- generateCityLayout
+ generateCityLayout,
+ getAvenueWidth,
+ getStreetWidth
} from '../data/city.js';
-export function buildCityScene(scene, { shadows = true } = {}) {
+// Placa de texto em canvas para letreiros neon e placas de estação/aeroporto!
+function makeSignTexture(text, { w = 512, h = 128, bg = '#070b14', fg = '#00f5d4', font = '900 64px Arial Black, sans-serif' } = {}) {
+ return makeCanvasTexture(w, h, (ctx, cw, ch) => {
+ ctx.fillStyle = bg;
+ ctx.fillRect(0, 0, cw, ch);
+ ctx.strokeStyle = fg;
+ ctx.lineWidth = 6;
+ ctx.strokeRect(8, 8, cw - 16, ch - 16);
+ ctx.shadowColor = fg;
+ ctx.shadowBlur = 26;
+ ctx.fillStyle = fg;
+ ctx.font = font;
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText(text, cw * 0.5, ch * 0.54);
+ ctx.shadowBlur = 0;
+ ctx.fillText(text, cw * 0.5, ch * 0.54);
+ });
+}
+
+export function buildCityScene(scene, { shadows = false } = {}) {
const root = new THREE.Group();
root.name = 'vice-leonida-city';
const layout = generateCityLayout();
const colliders = []; // Caixas { minX, maxX, minZ, maxZ } para colisão rápida
- // 1. Oceano infinito ao redor da ilha + Canal de Biscayne
- const waterGeo = new THREE.PlaneGeometry(2600, 2600);
+ // 1. OCEANO ATLÂNTICO REALISTA: malha densa com ondas vértice a vértice + cáusticas + reflexo especular intenso!
+ const waterTex = createOceanWaterTexture();
+ const waterGeo = new THREE.PlaneGeometry(3600, 3600, 80, 80);
const waterMat = new THREE.MeshStandardMaterial({
- color: '#0096c7',
- roughness: 0.22,
- metalness: 0.35
+ map: waterTex || null,
+ color: '#0a8db8',
+ roughness: 0.055,
+ metalness: 0.62,
+ envMapIntensity: 2.1,
+ transparent: true,
+ opacity: 0.97
});
const water = new THREE.Mesh(waterGeo, waterMat);
water.rotation.x = -Math.PI / 2;
- water.position.y = -0.35;
+ water.position.y = -0.62; // manter abaixo do topo do solo (y=0) mesmo na crista máxima!
root.add(water);
+ // Guarda a posição original dos vértices para deslocar as ondas a cada frame!
+ const waterBasePositions = Float32Array.from(waterGeo.attributes.position.array);
- // 2. Solo gramado/urbano de Vice Beach (leste do canal) e Downtown (oeste do canal)
+ // Mar de ALCANCE TOTAL até o horizonte (malha plana enorme por baixo das ondas próximas):
+ // do Deck da praia, o olhar encontra água até onde o céu começa — igual praia real!
+ const farWaterTex = createOceanWaterTexture();
+ if (farWaterTex) {
+ farWaterTex.repeat.set(160, 160);
+ }
+ const farWater = new THREE.Mesh(
+ new THREE.PlaneGeometry(15000, 15000),
+ new THREE.MeshStandardMaterial({
+ map: farWaterTex || null,
+ color: '#0a7fa8', // quase o tom do mar próximo (#0a8db8) — transição invisível a ~1.8km de distância!
+ roughness: 0.09,
+ metalness: 0.5,
+ envMapIntensity: 1.6
+ })
+ );
+ farWater.rotation.x = -Math.PI / 2;
+ // Bem abaixo do fundo máximo das ondas (-0.62 - 0.6 = -1.22) — sem z-fighting nem flutuação no cavado das ondas!
+ farWater.position.y = -1.28;
+ root.add(farWater);
+
+ // Água rasa turquesa translúcida junto à arrebentação da praia
+ const shallowMat = new THREE.MeshStandardMaterial({
+ color: '#48cae4',
+ roughness: 0.10,
+ metalness: 0.35,
+ transparent: true,
+ opacity: 0.78
+ });
+ const shallowWater = new THREE.Mesh(new THREE.PlaneGeometry(32, 980), shallowMat);
+ shallowWater.rotation.x = -Math.PI / 2;
+ shallowWater.position.set(OCEAN_WATER_X + 12, -0.18, 0);
+ root.add(shallowWater);
+
+ // 2. Massas de Terra: Vice Leonida (Leste/Oeste), Palm Bay City (Norte) e Ilha de Vice Keys (Sul)
const grassMat = new THREE.MeshStandardMaterial({ color: '#3b6e52', roughness: 0.92 });
- const sandMat = new THREE.MeshStandardMaterial({ color: '#f6dfaa', roughness: 0.88 });
+ const sandTex = createSandTexture();
+ const sandMat = new THREE.MeshStandardMaterial({
+ map: sandTex || null,
+ color: '#f7e5be',
+ roughness: 0.86,
+ metalness: 0.02
+ });
+ const wetSandMat = new THREE.MeshStandardMaterial({
+ color: '#c9a978',
+ roughness: 0.22,
+ metalness: 0.25,
+ envMapIntensity: 1.25
+ });
const concreteMat = new THREE.MeshStandardMaterial({ color: '#b8b8c4', roughness: 0.85 });
// Massa Leste (Midtown + Washington + Ocean Drive)
- const eastLand = new THREE.Mesh(new THREE.BoxGeometry(474, 0.8, 1080), grassMat);
+ const eastLand = new THREE.Mesh(new THREE.BoxGeometry(474, 0.8, 980), grassMat);
eastLand.position.set((-128 + 346) * 0.5, -0.4, 0);
- eastLand.receiveShadow = shadows;
root.add(eastLand);
- // Faixa de Areia de Vice Beach
+ // Massa Oeste (Downtown Leonida & Porto)
+ const westLand = new THREE.Mesh(new THREE.BoxGeometry(378, 0.8, 980), grassMat);
+ westLand.position.set((-556 + CANAL_MIN_X) * 0.5, -0.4, 0);
+ root.add(westLand);
+
+ // Cidade Norte: PALM BAY CITY (X: -330..235, Z: -795..-582)
+ const northCityLand = new THREE.Mesh(new THREE.BoxGeometry(565, 0.8, 214), grassMat);
+ northCityLand.position.set((-330 + 235) * 0.5, -0.4, (-795 + -582) * 0.5);
+ root.add(northCityLand);
+
+ // Ilha Sul: VICE KEYS (X: 25..315, Z: 582..795) com orla de areia tropical!
+ const keysSandBase = new THREE.Mesh(new THREE.BoxGeometry(304, 0.72, 226), sandMat);
+ keysSandBase.position.set((25 + 315) * 0.5, -0.42, (582 + 795) * 0.5);
+ root.add(keysSandBase);
+ const keysGrassCore = new THREE.Mesh(new THREE.BoxGeometry(225, 0.8, 175), grassMat);
+ keysGrassCore.position.set(145, -0.38, 688);
+ root.add(keysGrassCore);
+
+ // PENÍNSULA DO AEROPORTO INTERNACIONAL DE LEONIDA (aterro a oeste de Downtown!)
+ const airportLandW = AIRPORT_DATA.landXMax - AIRPORT_DATA.landXMin;
+ const airportLandD = AIRPORT_DATA.landZMax - AIRPORT_DATA.landZMin;
+ const airportLand = new THREE.Mesh(new THREE.BoxGeometry(airportLandW, 0.8, airportLandD), grassMat);
+ airportLand.position.set((AIRPORT_DATA.landXMin + AIRPORT_DATA.landXMax) * 0.5, -0.4, (AIRPORT_DATA.landZMin + AIRPORT_DATA.landZMax) * 0.5);
+ root.add(airportLand);
+
+ // Faixa de Areia Principal de Vice Beach (X = 344 até 462, nivelada suavemente para acesso livre!)
const sandWidth = OCEAN_WATER_X - BEACH_SAND_X;
- const beachMesh = new THREE.Mesh(new THREE.BoxGeometry(sandWidth, 0.72, 1080), sandMat);
- beachMesh.position.set(BEACH_SAND_X + sandWidth * 0.5, -0.42, 0);
+ const beachMesh = new THREE.Mesh(new THREE.BoxGeometry(sandWidth, 0.76, 976), sandMat);
+ beachMesh.position.set(BEACH_SAND_X + sandWidth * 0.5, -0.38, 0);
beachMesh.receiveShadow = shadows;
root.add(beachMesh);
- // Espuma das ondas na beira do mar
- const foamMat = new THREE.MeshBasicMaterial({ color: '#caf0f8', transparent: true, opacity: 0.72 });
- const foam = new THREE.Mesh(new THREE.PlaneGeometry(5.5, 1080), foamMat);
- foam.rotation.x = -Math.PI / 2;
- foam.position.set(OCEAN_WATER_X - 1.5, 0.02, 0);
- root.add(foam);
+ // Faixa de Areia Molhada espelhada na beira d'água
+ const wetSand = new THREE.Mesh(new THREE.PlaneGeometry(11, 976), wetSandMat);
+ wetSand.rotation.x = -Math.PI / 2;
+ wetSand.position.set(OCEAN_WATER_X - 4.2, 0.015, 0);
+ root.add(wetSand);
+
+ // 2.5 ARQUIPÉLAGO OCEÂNICO NO HORIZONTE — adeus, "água atrás de água"!
+ const islandGrassMat = new THREE.MeshStandardMaterial({ color: '#2e6b4f', roughness: 0.88 });
+ const islandHillMat = new THREE.MeshStandardMaterial({ color: '#24503a', roughness: 0.92 });
+ const islandSandMat = new THREE.MeshStandardMaterial({ map: sandTex || null, color: '#efd9a4', roughness: 0.85 });
+ const foamRingMat = new THREE.MeshBasicMaterial({ color: '#eefcff', transparent: true, opacity: 0.6, depthWrite: false });
+ const lighthouseWhite = new THREE.MeshStandardMaterial({ color: '#f8f9fa', roughness: 0.55 });
+ const lighthouseRed = new THREE.MeshStandardMaterial({ color: '#d62828', roughness: 0.55 });
+ const lighthouseGlass = new THREE.MeshBasicMaterial({ color: '#ffe066' });
+ const resortMat = new THREE.MeshStandardMaterial({ color: '#fdf6ec', roughness: 0.5 });
+ const resortRoofMat = new THREE.MeshStandardMaterial({ color: '#e07a5f', roughness: 0.6 });
+ const poolGlowMat = new THREE.MeshBasicMaterial({ color: '#19e3c6' });
+ const lighthouseBeams = [];
+ const sailboats = [];
+
+ for (const isl of OFFSHORE_ISLANDS) {
+ const isleGroup = new THREE.Group();
+ isleGroup.position.set(isl.x, 0, isl.z);
+
+ // Orla de areia elíptica + espuma quebrando ao redor da ilha!
+ const sandDisc = new THREE.Mesh(new THREE.CylinderGeometry(1, 1.14, 2.1, 26), islandSandMat);
+ sandDisc.scale.set(isl.rx, 1, isl.rz);
+ sandDisc.position.y = -0.55;
+ isleGroup.add(sandDisc);
+ const foamRing = new THREE.Mesh(new THREE.RingGeometry(0.94, 1.13, 36), foamRingMat);
+ foamRing.rotation.x = -Math.PI / 2;
+ foamRing.scale.set(isl.rx, isl.rz, 1);
+ foamRing.position.y = 0.09;
+ isleGroup.add(foamRing);
+
+ // Domo/colina verde da ilha (quanto maior a altura declarada, mais monumental a colina!)
+ const domeH = Math.max(2.6, isl.height * 0.62);
+ const dome = new THREE.Mesh(new THREE.SphereGeometry(1, 22, 14, 0, Math.PI * 2, 0, Math.PI * 0.52), islandGrassMat);
+ dome.scale.set(isl.rx * 0.82, domeH, isl.rz * 0.82);
+ dome.position.y = 0.55;
+ isleGroup.add(dome);
+ const hill = new THREE.Mesh(new THREE.ConeGeometry(1, 1, 9), islandHillMat);
+ hill.scale.set(isl.rx * 0.42, isl.height, isl.rz * 0.42);
+ hill.position.set(isl.rx * 0.08, isl.height * 0.5 + 0.4, -isl.rz * 0.06);
+ isleGroup.add(hill);
- // Calçadão rosa/pastel estilo Ocean Drive entre X=312 e X=345
+ // FAROIL com feixe de luz giratório (visto de Vice Beach à noite!)
+ if (isl.hasLighthouse) {
+ const lh = new THREE.Group();
+ const lhBaseY = isl.height + 0.4;
+ const towerH = 11.5;
+ const segH = towerH / 5;
+ for (let s = 0; s < 5; s += 1) {
+ const seg = new THREE.Mesh(new THREE.CylinderGeometry(1.5 - s * 0.14, 1.66 - s * 0.14, segH + 0.08, 12), s % 2 === 0 ? lighthouseRed : lighthouseWhite);
+ seg.position.y = lhBaseY + segH * (s + 0.5);
+ lh.add(seg);
+ }
+ const lhCap = new THREE.Mesh(new THREE.CylinderGeometry(1.15, 1.5, 1.15, 12), new THREE.MeshStandardMaterial({ color: '#1b1e27', roughness: 0.6 }));
+ lhCap.position.y = lhBaseY + towerH + 0.55;
+ const lhLamp = new THREE.Mesh(new THREE.SphereGeometry(0.95, 12, 8), lighthouseGlass);
+ lhLamp.position.y = lhBaseY + towerH + 1.45;
+ const lhRoof = new THREE.Mesh(new THREE.ConeGeometry(1.3, 1.6, 12), new THREE.MeshStandardMaterial({ color: '#d62828', roughness: 0.5 }));
+ lhRoof.position.y = lhBaseY + towerH + 2.6;
+ // Feixe de luz rotativo (dois cones opostos translúcidos)
+ const beamGroup = new THREE.Group();
+ beamGroup.position.y = lhBaseY + towerH + 1.45;
+ const beamMat = new THREE.MeshBasicMaterial({ color: '#fff7ae', transparent: true, opacity: 0.32, depthWrite: false, side: THREE.DoubleSide });
+ for (const side of [1, -1]) {
+ const beam = new THREE.Mesh(new THREE.ConeGeometry(2.6, 34, 10, 1, true), beamMat);
+ beam.rotation.z = side * (Math.PI / 2 + 0.06);
+ beam.position.x = side * 17;
+ beamGroup.add(beam);
+ }
+ lh.add(lhCap, lhLamp, lhRoof, beamGroup);
+ lh.position.set(-isl.rx * 0.28, 0, isl.rz * 0.22);
+ isleGroup.add(lh);
+ lighthouseBeams.push(beamGroup);
+ }
+
+ // RESORT TROPICAL com piscina turquesa de borda infinita!
+ if (isl.hasResort) {
+ const resort = new THREE.Group();
+ const resortHeights = [9, 14, 6.5];
+ const resortOffsets = [[-16, -8], [2, 6], [17, -14]];
+ for (let rIdx = 0; rIdx < 3; rIdx += 1) {
+ const rh = resortHeights[rIdx];
+ const tower = new THREE.Mesh(new THREE.BoxGeometry(9.5, rh, 8), resortMat);
+ tower.position.set(resortOffsets[rIdx][0], rh * 0.5 + domeH * 0.32, resortOffsets[rIdx][1]);
+ const roof = new THREE.Mesh(new THREE.BoxGeometry(10.2, 0.7, 8.7), resortRoofMat);
+ roof.position.set(resortOffsets[rIdx][0], rh + domeH * 0.32 + 0.35, resortOffsets[rIdx][1]);
+ resort.add(tower, roof);
+ }
+ const pool = new THREE.Mesh(new THREE.PlaneGeometry(12, 6.5), poolGlowMat);
+ pool.rotation.x = -Math.PI / 2;
+ pool.position.set(0, domeH * 0.34 + 0.06, -1);
+ resort.add(pool);
+ isleGroup.add(resort);
+ }
+ root.add(isleGroup);
+
+ // Veleiros balançando perto da ilha (casco + mastro + vela triangular!)
+ for (let b = 0; b < 2; b += 1) {
+ const boat = new THREE.Group();
+ const hull = new THREE.Mesh(new THREE.CylinderGeometry(0.75, 0.42, 4.6, 8, 1), new THREE.MeshStandardMaterial({ color: b === 0 ? '#8d6346' : '#f8f9fa', roughness: 0.6 }));
+ hull.rotation.x = Math.PI / 2;
+ hull.scale.set(1, 1, 0.55);
+ hull.position.y = 0.16;
+ const mast = new THREE.Mesh(new THREE.CylinderGeometry(0.08, 0.1, 4.6, 6), new THREE.MeshStandardMaterial({ color: '#5a4632' }));
+ mast.position.y = 2.4;
+ const sailShape = new THREE.Shape();
+ sailShape.moveTo(0, 0);
+ sailShape.lineTo(0, 3.9);
+ sailShape.lineTo(2.35, 0.25);
+ sailShape.closePath();
+ const sail = new THREE.Mesh(new THREE.ShapeGeometry(sailShape), new THREE.MeshBasicMaterial({ color: '#ffffff', side: THREE.DoubleSide }));
+ sail.position.set(0.12, 0.55, 0);
+ boat.add(hull, mast, sail);
+ const ang = (b * 2.4 + isl.z * 0.01) % (Math.PI * 2);
+ boat.position.set(isl.x + Math.cos(ang) * (isl.rx + 16 + b * 9), 0, isl.z + Math.sin(ang) * (isl.rz + 13 + b * 7));
+ boat.rotation.y = ang + 1.2;
+ root.add(boat);
+ sailboats.push({ group: boat, phase: ang * 3, baseYaw: boat.rotation.y });
+ }
+ }
+
+ // 2.6 SERRAS COSTEIRAS NO HORIZONTE DISTANTE (silhuetas azuis esmaecidas ao longe!)
+ const mountainMat = new THREE.MeshStandardMaterial({ color: '#1a2f42', roughness: 0.95, flatShading: true });
+ const mountainSpots = [
+ [1420, -760, 210, 260], [1550, -180, 260, 320], [1380, 330, 180, 240], [1520, 830, 230, 290], [1250, 1080, 200, 250]
+ ];
+ for (const [mx, mz, mRadius, mHeight] of mountainSpots) {
+ const mountain = new THREE.Mesh(new THREE.ConeGeometry(1, 1, 7), mountainMat);
+ mountain.scale.set(mRadius, mHeight, mRadius * 0.8);
+ mountain.position.set(mx, mHeight * 0.5 - 6, mz);
+ root.add(mountain);
+ }
+
+ // 4 Faixas de Ondas 3D rolantes/quebrando com espuma branca volumétrica + contrafluxo na beira d'água!
+ const waveCrests = [];
+ const waveBodyMat = new THREE.MeshStandardMaterial({
+ color: '#0aa4cc',
+ roughness: 0.08,
+ metalness: 0.35,
+ transparent: true,
+ opacity: 0.9,
+ emissive: '#013b52',
+ emissiveIntensity: 0.35
+ });
+ const waveFaceMat = new THREE.MeshStandardMaterial({
+ color: '#5fd4e8',
+ roughness: 0.05,
+ metalness: 0.2,
+ transparent: true,
+ opacity: 0.72,
+ emissive: '#0b4b63',
+ emissiveIntensity: 0.6
+ });
+ const foamMat = new THREE.MeshBasicMaterial({
+ color: '#f4feff',
+ transparent: true,
+ opacity: 0.85,
+ depthWrite: false
+ });
+
+ for (let wIdx = 0; wIdx < 4; wIdx += 1) {
+ const wg = new THREE.Group();
+ // Corpo principal da onda: tubo cilíndrico achatado e alongado (cristas oceânicas!)
+ const waveTube = new THREE.Mesh(new THREE.CylinderGeometry(0.52, 0.78, 975, 12, 1), waveBodyMat);
+ waveTube.rotation.x = Math.PI / 2;
+ waveTube.scale.set(2.1, 1, 0.58);
+ // Face côncava vítrea voltada para a praia (reflexo turquesa-esmeralda!)
+ const waveFace = new THREE.Mesh(new THREE.CylinderGeometry(0.62, 0.62, 975, 12, 1, true, Math.PI * 1.15, Math.PI * 0.7), waveFaceMat);
+ waveFace.rotation.x = Math.PI / 2;
+ waveFace.scale.set(1.9, 1, 0.55);
+ waveFace.position.set(0.55, 0.12, 0);
+ // Espuma quebrando na crista
+ const foamStrip = new THREE.Mesh(new THREE.PlaneGeometry(5.4, 975), foamMat.clone());
+ foamStrip.rotation.x = -Math.PI / 2;
+ foamStrip.position.set(-2.1, 0.1, 0);
+ // Borrifo branco acima da crista
+ const sprayStrip = new THREE.Mesh(new THREE.PlaneGeometry(2.1, 975), foamMat.clone());
+ sprayStrip.rotation.x = -Math.PI / 2;
+ sprayStrip.position.set(0.35, 0.34, 0);
+ wg.add(waveTube, waveFace, foamStrip, sprayStrip);
+ wg.position.set(OCEAN_WATER_X + 14 + wIdx * 10.5, -0.02, 0);
+ root.add(wg);
+ waveCrests.push({ group: wg, foam: foamStrip, spray: sprayStrip, phaseOffset: (wIdx / 4) * Math.PI * 2 });
+ }
+
+ // Calçadão rosa/pastel estilo Ocean Drive + Rampas largas de madeira até a areia!
const boardwalkMat = new THREE.MeshStandardMaterial({ color: '#e6ccb2', roughness: 0.8 });
- const boardwalk = new THREE.Mesh(new THREE.BoxGeometry(28, 0.12, 980), boardwalkMat);
- boardwalk.position.set(328, 0.05, 0);
- boardwalk.receiveShadow = shadows;
+ const boardwalk = new THREE.Mesh(new THREE.BoxGeometry(28, 0.08, 960), boardwalkMat);
+ boardwalk.position.set(328, 0.04, 0);
root.add(boardwalk);
- // Píer de Vice Beach avançando sobre o Atlântico em Z = -140
- const pierWoodMat = new THREE.MeshStandardMaterial({ color: '#8d6346', roughness: 0.85 });
- const pier = new THREE.Mesh(new THREE.BoxGeometry(92, 0.6, 22), pierWoodMat);
- pier.position.set(478, 0.45, -140);
- pier.castShadow = shadows;
- pier.receiveShadow = shadows;
+ const pierWoodMat = new THREE.MeshStandardMaterial({ color: '#8d6346', roughness: 0.84 });
+ for (const acc of layout.beachAccesses) {
+ const walk = new THREE.Mesh(new THREE.BoxGeometry(acc.length, 0.07, acc.width), pierWoodMat);
+ walk.position.set(acc.x + acc.length * 0.35, 0.045, acc.z);
+ root.add(walk);
+ }
+
+ // 3. Píer de Vice Beach + RODA-GIGANTE 3D REAL ($70 para embarcar de verdade!)
+ const pier = new THREE.Mesh(new THREE.BoxGeometry(168, 0.65, 28), pierWoodMat);
+ pier.position.set(428, 0.38, FERRIS_WHEEL.z);
root.add(pier);
- // Massa Oeste (Downtown Leonida & Porto)
- const westLand = new THREE.Mesh(new THREE.BoxGeometry(390, 0.8, 1080), grassMat);
- westLand.position.set((-570 + CANAL_MIN_X) * 0.5, -0.4, 0);
- westLand.receiveShadow = shadows;
- root.add(westLand);
+ // Guarda-corpos iluminados do Píer (deixando a entrada oeste livre!)
+ const pierNeonMat = new THREE.MeshBasicMaterial({ color: '#ff2a85' });
+ for (const side of [-1, 1]) {
+ const rail = new THREE.Mesh(new THREE.BoxGeometry(164, 1.05, 0.35), pierNeonMat);
+ rail.position.set(428, 1.15, FERRIS_WHEEL.z + side * 13.6);
+ root.add(rail);
+ }
- // 3. Malha Viária: Avenidas Norte-Sul e Ruas Leste-Oeste
- const roadTex = createRoadTexture();
- const roadMatNS = new THREE.MeshStandardMaterial({
- map: roadTex,
- color: '#ffffff',
- roughness: 0.82
- });
+ // Construção da Roda-Gigante giratória com 10 cabines suspensas que se mantêm sempre na vertical!
+ const ferrisGroup = new THREE.Group();
+ ferrisGroup.position.set(FERRIS_WHEEL.x, FERRIS_WHEEL.baseY, FERRIS_WHEEL.z);
+ root.add(ferrisGroup);
+
+ const steelWhiteMat = new THREE.MeshStandardMaterial({ color: '#f8f9fa', metalness: 0.55, roughness: 0.32 });
+ const rimNeonCyan = new THREE.MeshBasicMaterial({ color: '#00f5d4' });
+ const rimNeonPink = new THREE.MeshBasicMaterial({ color: '#ff2a85' });
+
+ // Pilares em "A" de sustentação nos dois lados (Z - 3.6 e Z + 3.6)
+ const legLen = 22.5;
+ const legGeo = new THREE.CylinderGeometry(0.32, 0.45, legLen, 8);
+ for (const zSide of [-3.6, 3.6]) {
+ for (const xTilt of [-1, 1]) {
+ const leg = new THREE.Mesh(legGeo, steelWhiteMat);
+ leg.position.set(xTilt * 5.2, 9.8, zSide);
+ leg.rotation.z = xTilt * 0.26;
+ ferrisGroup.add(leg);
+ }
+ }
+ // Plataforma de embarque + bilheteria "$70"
+ const platform = new THREE.Mesh(new THREE.BoxGeometry(11, 0.5, 9), concreteMat);
+ platform.position.set(0, 0.45, 0);
+ const booth = new THREE.Mesh(
+ new THREE.BoxGeometry(2.6, 2.8, 2.4),
+ new THREE.MeshStandardMaterial({ color: '#ff2a85', roughness: 0.45 })
+ );
+ booth.position.set(-7.5, 1.7, 8.2);
+ const boothSign = new THREE.Mesh(new THREE.BoxGeometry(2.8, 0.65, 2.6), rimNeonCyan);
+ boothSign.position.set(-7.5, 3.35, 8.2);
+ ferrisGroup.add(platform, booth, boothSign);
+
+ // Roda giratória no plano X-Y (eixo de rotação em Z)
+ const ferrisWheelSpinner = new THREE.Group();
+ ferrisWheelSpinner.position.set(0, FERRIS_WHEEL.wheelCenterY - FERRIS_WHEEL.baseY, 0);
+ ferrisGroup.add(ferrisWheelSpinner);
+
+ const hub = new THREE.Mesh(new THREE.CylinderGeometry(1.3, 1.3, 7.6, 16), rimNeonPink);
+ hub.rotation.x = Math.PI / 2;
+ ferrisWheelSpinner.add(hub);
+
+ const rimGeo = new THREE.TorusGeometry(FERRIS_WHEEL.radius, 0.28, 10, 40);
+ for (const zSide of [-2.6, 2.6]) {
+ const rim = new THREE.Mesh(rimGeo, zSide < 0 ? rimNeonCyan : rimNeonPink);
+ rim.position.z = zSide;
+ ferrisWheelSpinner.add(rim);
+ }
+
+ const spokeGeo = new THREE.CylinderGeometry(0.10, 0.10, FERRIS_WHEEL.radius * 2, 6);
+ for (let s = 0; s < FERRIS_WHEEL.cabins / 2; s += 1) {
+ const ang = (s / (FERRIS_WHEEL.cabins / 2)) * Math.PI;
+ for (const zSide of [-2.6, 2.6]) {
+ const spoke = new THREE.Mesh(spokeGeo, steelWhiteMat);
+ spoke.rotation.z = ang;
+ spoke.position.z = zSide;
+ ferrisWheelSpinner.add(spoke);
+ }
+ }
+
+ const cabinColors = ['#ff2a85', '#00f5d4', '#ffd166', '#9b5de5', '#00bbf9'];
+ const ferrisCabins = [];
+ for (let c = 0; c < FERRIS_WHEEL.cabins; c += 1) {
+ const baseAngle = (c / FERRIS_WHEEL.cabins) * Math.PI * 2;
+ const cabinPivot = new THREE.Group();
+ cabinPivot.position.set(
+ Math.cos(baseAngle) * FERRIS_WHEEL.radius,
+ Math.sin(baseAngle) * FERRIS_WHEEL.radius,
+ 0
+ );
+
+ const hanger = new THREE.Mesh(new THREE.CylinderGeometry(0.08, 0.08, 5.2, 6), steelWhiteMat);
+ hanger.rotation.x = Math.PI / 2;
+ const gondolaMat = new THREE.MeshStandardMaterial({
+ color: cabinColors[c % cabinColors.length],
+ roughness: 0.32,
+ metalness: 0.35
+ });
+ // Gondola aberta na metade superior para enxergar Rafael sentado lá dentro e apreciar a vista 360°!
+ const gondolaFloor = new THREE.Mesh(new THREE.BoxGeometry(2.4, 1.15, 2.6), gondolaMat);
+ gondolaFloor.position.set(0, -1.65, 0);
+ const gondolaRoof = new THREE.Mesh(new THREE.BoxGeometry(2.5, 0.22, 2.7), steelWhiteMat);
+ gondolaRoof.position.set(0, 0.25, 0);
+ for (const [px, pz] of [[-1.08, -1.15], [1.08, -1.15], [-1.08, 1.15], [1.08, 1.15]]) {
+ const post = new THREE.Mesh(new THREE.CylinderGeometry(0.05, 0.05, 1.5, 5), steelWhiteMat);
+ post.position.set(px, -0.6, pz);
+ cabinPivot.add(post);
+ }
+ const seatAnchor = new THREE.Group();
+ seatAnchor.position.set(0, -1.55, 0);
+ cabinPivot.add(hanger, gondolaFloor, gondolaRoof, seatAnchor);
+ ferrisWheelSpinner.add(cabinPivot);
+ ferrisCabins.push({ pivot: cabinPivot, seatAnchor, baseAngle });
+ }
+ // 4. Malha Viária Real: Avenidas, Ruas, Pontes Estaiadas Intermunicipais e Rodovias Curvas (`SCENIC_ROADS`)!
+ const roadTex = createRoadTexture();
+ const roadMatNS = new THREE.MeshStandardMaterial({ map: roadTex, color: '#ffffff', roughness: 0.82 });
const roadTexEW = createRoadTexture();
if (roadTexEW) {
roadTexEW.rotation = Math.PI / 2;
roadTexEW.center.set(0.5, 0.5);
}
- const roadMatEW = new THREE.MeshStandardMaterial({
- map: roadTexEW,
- color: '#ffffff',
- roughness: 0.82
- });
+ const roadMatEW = new THREE.MeshStandardMaterial({ map: roadTexEW, color: '#ffffff', roughness: 0.82 });
+ const asphaltDarkMat = new THREE.MeshStandardMaterial({ color: '#262936', roughness: 0.82 });
+
+ // 4. MALHA VIÁRIA COM 3 LARGURAS: Avenidas AMPLAS (28m, canteiro central), NORMAIS (18m) e RUAS ESTREITAS (9m)!
+ const medianMat = new THREE.MeshStandardMaterial({ color: '#3b6e52', roughness: 0.9 });
+ const medianCurbMat = new THREE.MeshStandardMaterial({ color: '#ced4da', roughness: 0.7 });
+ const medianStripeMat = new THREE.MeshBasicMaterial({ color: '#ffd166' });
for (const ax of AVENUES_X) {
+ const axWidth = getAvenueWidth(ax);
+ const isWide = axWidth >= 24;
const sidewalk = new THREE.Mesh(
- new THREE.BoxGeometry(ROAD_WIDTH + SIDEWALK_WIDTH * 2, 0.14, 950),
+ new THREE.BoxGeometry(axWidth + SIDEWALK_WIDTH * 2, 0.14, 950),
concreteMat
);
sidewalk.position.set(ax, 0.04, 0);
- sidewalk.receiveShadow = shadows;
root.add(sidewalk);
- const road = new THREE.Mesh(new THREE.PlaneGeometry(ROAD_WIDTH, 945), roadMatNS);
- road.rotation.x = -Math.PI / 2;
- road.position.set(ax, 0.125, 0);
- road.receiveShadow = shadows;
- root.add(road);
+ if (isWide) {
+ // Avenida AMPLA: duas pistas separadas por CANTEIRO CENTRAL ajardinado com meio-fio e faixas amarelas!
+ const laneW = (axWidth - 3.6) * 0.5;
+ for (const side of [-1, 1]) {
+ const lane = new THREE.Mesh(new THREE.PlaneGeometry(laneW, 945), roadMatNS);
+ lane.rotation.x = -Math.PI / 2;
+ lane.position.set(ax + side * (3.6 * 0.5 + laneW * 0.5), 0.125, 0);
+ root.add(lane);
+ }
+ const median = new THREE.Mesh(new THREE.BoxGeometry(3.6, 0.3, 945), medianMat);
+ median.position.set(ax, 0.15, 0);
+ root.add(median);
+ for (const side of [-1, 1]) {
+ const curb = new THREE.Mesh(new THREE.BoxGeometry(0.42, 0.34, 945), medianCurbMat);
+ curb.position.set(ax + side * 1.85, 0.16, 0);
+ const yellowLine = new THREE.Mesh(new THREE.PlaneGeometry(0.28, 945), medianStripeMat);
+ yellowLine.rotation.x = -Math.PI / 2;
+ yellowLine.position.set(ax + side * 2.35, 0.132, 0);
+ root.add(curb, yellowLine);
+ }
+ } else {
+ const road = new THREE.Mesh(new THREE.PlaneGeometry(axWidth, 945), roadMatNS);
+ road.rotation.x = -Math.PI / 2;
+ road.position.set(ax, 0.125, 0);
+ root.add(road);
+ }
}
for (const sz of STREETS_Z) {
+ const szWidth = getStreetWidth(sz);
const hasBridge = BRIDGE_ZS.includes(sz);
if (hasBridge) {
- // Rua inteira de -455 até +335 cruzando o canal com ponte iluminada
const len = 335 - (-455);
const cx = (-455 + 335) * 0.5;
- const road = new THREE.Mesh(new THREE.PlaneGeometry(len, ROAD_WIDTH), roadMatEW);
+ const road = new THREE.Mesh(new THREE.PlaneGeometry(len, szWidth), roadMatEW);
road.rotation.x = -Math.PI / 2;
road.position.set(cx, 0.135, sz);
- road.receiveShadow = shadows;
root.add(road);
- // Estrutura da ponte sobre o Canal de Biscayne
- const bridgeLen = CANAL_MAX_X - CANAL_MIN_X + 14;
+ const bridgeLen = CANAL_MAX_X - CANAL_MIN_X + 16;
const bridgeCx = (CANAL_MIN_X + CANAL_MAX_X) * 0.5;
- const bridgeDeck = new THREE.Mesh(
- new THREE.BoxGeometry(bridgeLen, 0.7, ROAD_WIDTH + 6),
- concreteMat
- );
- bridgeDeck.position.set(bridgeCx, -0.2, sz);
+ const bridgeDeck = new THREE.Mesh(new THREE.BoxGeometry(bridgeLen, 0.8, szWidth + 6), concreteMat);
+ bridgeDeck.position.set(bridgeCx, -0.18, sz);
root.add(bridgeDeck);
- // Arcos neon ciano/magenta nas laterais da ponte
const railMat = new THREE.MeshBasicMaterial({ color: sz === 0 ? '#ff2a85' : '#00f5d4' });
for (const side of [-1, 1]) {
- const rail = new THREE.Mesh(new THREE.BoxGeometry(bridgeLen, 1.3, 0.6), railMat);
- rail.position.set(bridgeCx, 0.8, sz + side * (ROAD_WIDTH * 0.5 + 2.2));
+ const rail = new THREE.Mesh(new THREE.BoxGeometry(bridgeLen, 1.35, 0.6), railMat);
+ rail.position.set(bridgeCx, 0.82, sz + side * (szWidth * 0.5 + 2.2));
root.add(rail);
}
+ } else if (szWidth >= 24) {
+ // Rua Leste-Oeste AMPLA (eixo monumental): canteiro central ajardinado também!
+ const eastLen = 335 - (-116);
+ const westLen = -190 - (-455);
+ const laneW = (szWidth - 3.6) * 0.5;
+ for (const seg of [[-116, 335], [-455, -190]]) {
+ const segLen = seg[1] - seg[0];
+ const segCx = (seg[0] + seg[1]) * 0.5;
+ for (const side of [-1, 1]) {
+ const lane = new THREE.Mesh(new THREE.PlaneGeometry(segLen, laneW), roadMatEW);
+ lane.rotation.x = -Math.PI / 2;
+ lane.position.set(segCx, 0.128, sz + side * (3.6 * 0.5 + laneW * 0.5));
+ root.add(lane);
+ }
+ const medianEW = new THREE.Mesh(new THREE.BoxGeometry(segLen, 0.28, 3.6), medianMat);
+ medianEW.position.set(segCx, 0.155, sz);
+ root.add(medianEW);
+ for (const side of [-1, 1]) {
+ const guardLine = new THREE.Mesh(new THREE.PlaneGeometry(segLen, 0.26), medianStripeMat);
+ guardLine.rotation.x = -Math.PI / 2;
+ guardLine.position.set(segCx, 0.135, sz + side * 2.32);
+ root.add(guardLine);
+ }
+ }
} else {
- // Dois trechos separados pelo canal
const eastLen = 335 - (-116);
- const eastRoad = new THREE.Mesh(new THREE.PlaneGeometry(eastLen, ROAD_WIDTH), roadMatEW);
+ const eastRoad = new THREE.Mesh(new THREE.PlaneGeometry(eastLen, szWidth), roadMatEW);
eastRoad.rotation.x = -Math.PI / 2;
eastRoad.position.set((-116 + 335) * 0.5, 0.13, sz);
root.add(eastRoad);
const westLen = -190 - (-455);
- const westRoad = new THREE.Mesh(new THREE.PlaneGeometry(westLen, ROAD_WIDTH), roadMatEW);
+ const westRoad = new THREE.Mesh(new THREE.PlaneGeometry(westLen, szWidth), roadMatEW);
westRoad.rotation.x = -Math.PI / 2;
westRoad.position.set((-455 + -190) * 0.5, 0.13, sz);
root.add(westRoad);
}
}
- // 4. Cruzamentos asfaltados limpos
- const interMat = new THREE.MeshStandardMaterial({ color: '#272a36', roughness: 0.82 });
+ // RUAS ESTREITAS E BECOS URBANOS (9m — asfalto escuro sem calçada, atalhos de fuga!)
+ const narrowRoadMat = new THREE.MeshStandardMaterial({ color: '#1e212b', roughness: 0.88 });
+ const narrowLineMat = new THREE.MeshBasicMaterial({ color: '#e9ecef' });
+ for (const nr of NARROW_ROADS) {
+ if (nr.axis === 'z') {
+ const len = nr.zMax - nr.zMin;
+ const alley = new THREE.Mesh(new THREE.PlaneGeometry(nr.width, len), narrowRoadMat);
+ alley.rotation.x = -Math.PI / 2;
+ alley.position.set(nr.x, 0.118, (nr.zMin + nr.zMax) * 0.5);
+ root.add(alley);
+ const dashCount = Math.floor(len / 9);
+ for (let d = 0; d < dashCount; d += 1) {
+ const dash = new THREE.Mesh(new THREE.PlaneGeometry(0.24, 2.6), narrowLineMat);
+ dash.rotation.x = -Math.PI / 2;
+ dash.position.set(nr.x, 0.126, nr.zMin + 6 + d * 9);
+ root.add(dash);
+ }
+ } else {
+ const len = nr.xMax - nr.xMin;
+ const alley = new THREE.Mesh(new THREE.PlaneGeometry(len, nr.width), narrowRoadMat);
+ alley.rotation.x = -Math.PI / 2;
+ alley.position.set((nr.xMin + nr.xMax) * 0.5, 0.118, nr.z);
+ root.add(alley);
+ const dashCount = Math.floor(len / 9);
+ for (let d = 0; d < dashCount; d += 1) {
+ const dash = new THREE.Mesh(new THREE.PlaneGeometry(2.6, 0.24), narrowLineMat);
+ dash.rotation.x = -Math.PI / 2;
+ dash.position.set(nr.xMin + 6 + d * 9, 0.126, nr.z);
+ root.add(dash);
+ }
+ }
+ }
+
+ // GRANDES PONTES ESTAIADAS MONUMENTAIS INTERLIGANDO AS 3 CIDADES
+ // Torres H-frame altíssimas + estais em leque, vigas de concreto, guarda-neon e iluminação de ponte!
+ const pylonMat = new THREE.MeshStandardMaterial({ color: '#eef1f5', roughness: 0.42, metalness: 0.22 });
+ const trussMat = new THREE.MeshStandardMaterial({ color: '#495057', roughness: 0.5, metalness: 0.6 });
+
+ for (const br of INTERCITY_BRIDGES) {
+ const horiz = !!br.isEastWest; // Ponte Leste-Oeste (Viaduto do Aeroporto)
+ const bLen = horiz ? (br.xMax - br.xMin + 14) : (br.zMax - br.zMin + 14);
+ const bCz = horiz ? br.z : (br.zMin + br.zMax) * 0.5;
+ const bCx = horiz ? (br.xMin + br.xMax) * 0.5 : br.x;
+ const pylonH = br.pylonHeight || 42;
+ const cableMat = new THREE.MeshBasicMaterial({ color: br.color });
+ const acrossSigns = [-1, 1];
+
+ // Tabuleiro + pista + longarinas laterais metálicas
+ const deckGeo = horiz ? new THREE.BoxGeometry(bLen, 1.15, br.width + 6) : new THREE.BoxGeometry(br.width + 6, 1.15, bLen);
+ const deck = new THREE.Mesh(deckGeo, concreteMat);
+ deck.position.set(bCx, -0.18, bCz);
+ const roadSurface = new THREE.Mesh(
+ horiz ? new THREE.PlaneGeometry(bLen, br.width) : new THREE.PlaneGeometry(br.width, bLen),
+ horiz ? roadMatEW : roadMatNS
+ );
+ roadSurface.rotation.x = -Math.PI / 2;
+ roadSurface.position.set(bCx, 0.43, bCz);
+ root.add(deck, roadSurface);
+
+ // Longarinas + guarda-corpos em neon cor da ponte
+ for (const side of acrossSigns) {
+ const truss = new THREE.Mesh(
+ horiz ? new THREE.BoxGeometry(bLen, 1.5, 0.55) : new THREE.BoxGeometry(0.55, 1.5, bLen),
+ trussMat
+ );
+ truss.position.set(
+ horiz ? bCx : bCx + side * (br.width * 0.5 + 0.4),
+ 1.05,
+ horiz ? bCz + side * (br.width * 0.5 + 0.4) : bCz
+ );
+ const guard = new THREE.Mesh(
+ horiz ? new THREE.BoxGeometry(bLen, 0.5, 0.42) : new THREE.BoxGeometry(0.42, 0.5, bLen),
+ cableMat
+ );
+ guard.position.set(
+ horiz ? bCx : bCx + side * (br.width * 0.5 + 2.6),
+ 1.95,
+ horiz ? bCz + side * (br.width * 0.5 + 2.6) : bCz
+ );
+ const guardNeon = new THREE.Mesh(
+ horiz ? new THREE.BoxGeometry(bLen, 0.16, 0.2) : new THREE.BoxGeometry(0.2, 0.16, bLen),
+ cableMat
+ );
+ guardNeon.position.set(
+ horiz ? bCx : bCx + side * (br.width * 0.5 + 2.6),
+ 2.28,
+ horiz ? bCz + side * (br.width * 0.5 + 2.6) : bCz
+ );
+ root.add(truss, guard, guardNeon);
+ }
+
+ // Duas TORRES H-FRAME gigantes com vigas de contraventamento e neon no topo!
+ const towerOffsets = [-bLen * 0.24, bLen * 0.24];
+ const stays = []; // {ax,ay,az, bx,by,bz} para InstancedMesh
+ for (const towerAlong of towerOffsets) {
+ const tAlong = towerAlong; // relativo ao centro do vão
+ const tWorld = (off, across) => horiz
+ ? [bCx + tAlong + off, across] : [bCx + across, bCz + tAlong + off];
+
+ for (const side of acrossSigns) {
+ const acrossOff = side * (br.width * 0.5 + 2.45);
+ const [colX, colZ] = tWorld(0, acrossOff);
+ const column = new THREE.Mesh(new THREE.BoxGeometry(2.5, pylonH, 3.1), pylonMat);
+ column.position.set(colX, pylonH * 0.5 + 0.4, colZ);
+ root.add(column);
+ // Capitel neon no topo da coluna
+ const cap = new THREE.Mesh(new THREE.BoxGeometry(3.0, 0.7, 3.6), cableMat);
+ cap.position.set(colX, pylonH + 0.75, colZ);
+ root.add(cap);
+ // Colisor da coluna para Rafael não atravessar
+ colliders.push(horiz
+ ? { minX: colX - 1.4, maxX: colX + 1.4, minZ: colZ - 1.7, maxZ: colZ + 1.7, height: pylonH }
+ : { minX: colX - 1.4, maxX: colX + 1.4, minZ: colZ - 1.7, maxZ: colZ + 1.7, height: pylonH });
+ }
+ // Vigas de contraventamento (H-frame): uma acima do tabuleiro, uma no topo!
+ const [midBeamX, midBeamZ] = tWorld(0, 0);
+ const midBeam = new THREE.Mesh(
+ horiz ? new THREE.BoxGeometry(3.1, 2.1, br.width + 9.4) : new THREE.BoxGeometry(br.width + 9.4, 2.1, 3.1),
+ pylonMat
+ );
+ midBeam.position.set(midBeamX, pylonH * 0.52, midBeamZ);
+ const topBeam = new THREE.Mesh(
+ horiz ? new THREE.BoxGeometry(2.6, 2.6, br.width + 10.2) : new THREE.BoxGeometry(br.width + 10.2, 2.6, 2.6),
+ cableMat
+ );
+ topBeam.position.set(midBeamX, pylonH * 0.88, midBeamZ);
+ root.add(midBeam, topBeam);
+
+ // ESTAIS EM LEQUE: do topo da torre até o tabuleiro dos dois lados (cada lado do vão!)
+ for (const side of acrossSigns) {
+ const acrossOff = side * (br.width * 0.5 + 2.45);
+ const [topX, topZ] = tWorld(0, acrossOff);
+ const topY = pylonH - 0.4;
+ const fanStep = (bLen * 0.5 - 5) / 5;
+ for (const dir of [-1, 1]) {
+ for (let k = 1; k <= 5; k += 1) {
+ const attach = 4 + k * fanStep;
+ const [ax2, az2] = tWorld(dir * attach, acrossOff * 0.62);
+ stays.push({ ax: topX, ay: topY, az: topZ, bx: ax2, by: 1.35, bz: az2 });
+ }
+ }
+ }
+ }
+
+ // Estalhos como InstancedMesh (uma única draw call por ponte!)
+ const stayGeo = new THREE.CylinderGeometry(0.09, 0.09, 1, 5);
+ const stayInst = new THREE.InstancedMesh(stayGeo, cableMat, stays.length);
+ const dummyStay = new THREE.Object3D();
+ const upVec = new THREE.Vector3(0, 1, 0);
+ const stayA = new THREE.Vector3();
+ const stayB = new THREE.Vector3();
+ stays.forEach((s, i) => {
+ stayA.set(s.ax, s.ay, s.az);
+ stayB.set(s.bx, s.by, s.bz);
+ const dirVec = new THREE.Vector3().subVectors(stayB, stayA);
+ const len = dirVec.length();
+ dummyStay.position.copy(stayA).addScaledVector(dirVec, 0.5);
+ dummyStay.quaternion.setFromUnitVectors(upVec, dirVec.normalize());
+ dummyStay.scale.set(1, len, 1);
+ dummyStay.updateMatrix();
+ stayInst.setMatrixAt(i, dummyStay.matrix);
+ });
+ root.add(stayInst);
+
+ // Luzes de iluminação do tabuleiro (bico de luz a cada 12m nos dois lados)
+ const lightEvery = 12;
+ const lightCount = Math.floor(bLen / lightEvery) * 2;
+ const lampGeo = new THREE.SphereGeometry(0.32, 6, 5);
+ const lampInst = new THREE.InstancedMesh(lampGeo, new THREE.MeshBasicMaterial({ color: '#fff3c4' }), lightCount);
+ let lampIdx = 0;
+ for (let li = 0; li < Math.floor(bLen / lightEvery); li += 1) {
+ const alongPos = -bLen * 0.5 + 6 + li * lightEvery;
+ for (const side of acrossSigns) {
+ const acrossOff = side * (br.width * 0.5 + 0.4);
+ if (horiz) dummyStay.position.set(bCx + alongPos, 1.9, bCz + acrossOff);
+ else dummyStay.position.set(bCx + acrossOff, 1.9, bCz + alongPos);
+ dummyStay.rotation.set(0, 0, 0);
+ dummyStay.scale.set(1, 1, 1);
+ dummyStay.updateMatrix();
+ lampInst.setMatrixAt(lampIdx, dummyStay.matrix);
+ lampIdx += 1;
+ }
+ }
+ root.add(lampInst);
+
+ // Faróis vermelhos de aviação no topo das torres
+ for (const towerAlong of towerOffsets) {
+ const [topX, topZ] = horiz ? [bCx + towerAlong, bCz] : [bCx, bCz + towerAlong];
+ const beacon = new THREE.Mesh(new THREE.SphereGeometry(0.42, 8, 6), new THREE.MeshBasicMaterial({ color: '#ff3b3b' }));
+ beacon.position.set(topX, pylonH + 1.6, topZ);
+ root.add(beacon);
+ }
+ }
+
+ // Estradas Curvas e Diagonais (`SCENIC_ROADS`) com faixa dupla amarela central e juntas suaves!
+ const stripeMat = new THREE.MeshBasicMaterial({ color: '#ffd166' });
+ const jointGeo = new THREE.CircleGeometry(1, 14);
+ jointGeo.rotateX(-Math.PI / 2);
+
+ for (const sr of SCENIC_ROADS) {
+ const pts = sr.points;
+ for (let i = 0; i < pts.length; i += 1) {
+ const [jx, jz] = pts[i];
+ const joint = new THREE.Mesh(jointGeo, asphaltDarkMat);
+ joint.scale.set(sr.width * 0.54, 1, sr.width * 0.54);
+ joint.position.set(jx, 0.138, jz);
+ root.add(joint);
+
+ if (i < pts.length - 1) {
+ const [x2, z2] = pts[i + 1];
+ const segLen = Math.hypot(x2 - jx, z2 - jz);
+ const yaw = Math.atan2(x2 - jx, z2 - jz);
+ const mx = (jx + x2) * 0.5;
+ const mz = (jz + z2) * 0.5;
+
+ const segMesh = new THREE.Mesh(new THREE.PlaneGeometry(sr.width, segLen + 2), asphaltDarkMat);
+ segMesh.rotation.order = 'YXZ';
+ segMesh.rotation.y = yaw;
+ segMesh.rotation.x = -Math.PI / 2;
+ segMesh.position.set(mx, 0.14, mz);
+ root.add(segMesh);
+
+ const centerLine = new THREE.Mesh(new THREE.PlaneGeometry(0.45, segLen), stripeMat);
+ centerLine.rotation.order = 'YXZ';
+ centerLine.rotation.y = yaw;
+ centerLine.rotation.x = -Math.PI / 2;
+ centerLine.position.set(mx, 0.15, mz);
+ root.add(centerLine);
+ }
+ }
+ }
+
+ // Cruzamentos urbanos limpos
const interGeo = new THREE.PlaneGeometry(ROAD_WIDTH + 0.6, ROAD_WIDTH + 0.6);
+ interGeo.rotateX(-Math.PI / 2);
+ const interInst = new THREE.InstancedMesh(interGeo, asphaltDarkMat, AVENUES_X.length * STREETS_Z.length);
+ const dummy = new THREE.Object3D();
+ let idxInter = 0;
for (const ax of AVENUES_X) {
for (const sz of STREETS_Z) {
- const patch = new THREE.Mesh(interGeo, interMat);
- patch.rotation.x = -Math.PI / 2;
- patch.position.set(ax, 0.14, sz);
- root.add(patch);
+ dummy.position.set(ax, 0.145, sz);
+ dummy.rotation.set(0, 0, 0);
+ dummy.scale.set(1, 1, 1);
+ dummy.updateMatrix();
+ interInst.setMatrixAt(idxInter++, dummy.matrix);
+ }
+ }
+ root.add(interInst);
+
+ // Cruzamentos com placas de logradouro VERDE-FLORIDA (padrão Miami: avenidas N–S × ruas enumeradas E–O)
+ const AVENUE_NAMES = Object.freeze({
+ '-420': 'DIXIE HWY',
+ '-240': 'BISCAYNE BLVD',
+ '-90': 'ALTON RD',
+ '40': 'WASHINGTON AVE',
+ '170': 'COLLINS AVE',
+ '300': 'OCEAN DR'
+ });
+ const STREET_NAMES = Object.freeze({
+ '-440': '15TH ST',
+ '-280': '13TH ST',
+ '-140': '11TH ST',
+ '0': '9TH ST',
+ '140': '7TH ST',
+ '280': '5TH ST',
+ '430': '1ST ST'
+ });
+ const signMatCache = new Map();
+ const signMaterial = text => {
+ let mat = signMatCache.get(text);
+ if (!mat) {
+ const tex = makeCanvasTexture(512, 72, (ctx, cw, ch) => {
+ ctx.fillStyle = '#0d5c3f'; // verde institucional Florida DOT
+ ctx.fillRect(0, 0, cw, ch);
+ ctx.strokeStyle = '#f2f6f2';
+ ctx.lineWidth = 4;
+ ctx.strokeRect(6, 6, cw - 12, ch - 12);
+ ctx.fillStyle = '#ffffff';
+ ctx.font = '800 37px "Arial Black", Arial, sans-serif';
+ ctx.textAlign = 'center';
+ ctx.textBaseline = 'middle';
+ ctx.fillText(text, cw * 0.5, ch * 0.54);
+ });
+ mat = new THREE.MeshBasicMaterial({ map: tex, side: THREE.DoubleSide, toneMapped: false });
+ signMatCache.set(text, mat);
+ }
+ return mat;
+ };
+ const signBladeGeo = new THREE.PlaneGeometry(3.15, 0.44);
+ const signPoleGeo = new THREE.CylinderGeometry(0.07, 0.09, 3.5, 6);
+ const signPoleMat = new THREE.MeshStandardMaterial({ color: '#6b7280', roughness: 0.45, metalness: 0.7 });
+ const signSlots = [];
+ for (const ax of AVENUES_X) {
+ for (const sz of STREETS_Z) {
+ signSlots.push({
+ x: ax + getAvenueWidth(ax) * 0.5 + 1.15,
+ z: sz + getStreetWidth(sz) * 0.5 + 1.15,
+ avenue: AVENUE_NAMES[String(ax)] || 'VICE AVE',
+ street: STREET_NAMES[String(sz)] || 'VICE ST'
+ });
+ }
+ }
+ const signPoleInst = new THREE.InstancedMesh(signPoleGeo, signPoleMat, signSlots.length);
+ signSlots.forEach((slot, i) => {
+ dummy.position.set(slot.x, 1.75, slot.z);
+ dummy.rotation.set(0, 0, 0);
+ dummy.scale.set(1, 1, 1);
+ dummy.updateMatrix();
+ signPoleInst.setMatrixAt(i, dummy.matrix);
+ });
+ root.add(signPoleInst);
+ // Lâminas: 1 InstancedMesh por texto único (13 desenhos no total — zero desperdício)
+ const bladeMatrix = (slot, y, faceStreet) => {
+ dummy.position.set(slot.x, y, slot.z);
+ dummy.rotation.set(0, faceStreet ? Math.PI / 2 : 0, 0);
+ dummy.scale.set(1, 1, 1);
+ dummy.updateMatrix();
+ return dummy.matrix.clone();
+ };
+ const avenueGroups = new Map();
+ const streetGroups = new Map();
+ for (const slot of signSlots) {
+ if (!avenueGroups.has(slot.avenue)) avenueGroups.set(slot.avenue, []);
+ avenueGroups.get(slot.avenue).push(bladeMatrix(slot, 3.12, false));
+ if (!streetGroups.has(slot.street)) streetGroups.set(slot.street, []);
+ streetGroups.get(slot.street).push(bladeMatrix(slot, 2.62, true));
+ }
+ const addBladeSet = groups => {
+ for (const [text, matrices] of groups) {
+ const inst = new THREE.InstancedMesh(signBladeGeo, signMaterial(text), matrices.length);
+ matrices.forEach((m, i) => inst.setMatrixAt(i, m));
+ root.add(inst);
+ }
+ };
+ addBladeSet(avenueGroups);
+ addBladeSet(streetGroups);
+
+ // 5. BANCO NACIONAL DE LEONIDA MONUMENTAL (pedra neoclássica texturizada, colunas, frontão e TORRE de vidro espelhada!)
+ const bankGroup = new THREE.Group();
+ const bankStoneTex = createBankStoneTexture();
+ const marbleFloorTex = createMarbleFloorTexture();
+ const marbleMat = new THREE.MeshStandardMaterial({ map: bankStoneTex || null, color: '#ffffff', roughness: 0.5, metalness: 0.14 });
+ const marbleFloorMat = new THREE.MeshStandardMaterial({ map: marbleFloorTex || null, color: '#ffffff', roughness: 0.18, metalness: 0.42, envMapIntensity: 1.4 });
+ const goldVaultMat = new THREE.MeshStandardMaterial({ color: '#ffd166', roughness: 0.22, metalness: 0.85 });
+ const steelVaultMat = new THREE.MeshStandardMaterial({ color: '#495057', roughness: 0.32, metalness: 0.82 });
+ const cashGreenMat = new THREE.MeshStandardMaterial({ color: '#2b9348', roughness: 0.7 });
+
+ const bxMin = BANK_INTERIOR.centerX - BANK_INTERIOR.width * 0.5; // -296
+ const bxMax = BANK_INTERIOR.centerX + BANK_INTERIOR.width * 0.5; // -252 (frente voltada para X = -240!)
+ const bzMin = BANK_INTERIOR.centerZ - BANK_INTERIOR.depth * 0.5; // -81
+ const bzMax = BANK_INTERIOR.centerZ + BANK_INTERIOR.depth * 0.5; // -49
+ const bh = BANK_INTERIOR.height;
+
+ // Piso de mármore e teto iluminado
+ const bankFloor = new THREE.Mesh(new THREE.BoxGeometry(BANK_INTERIOR.width, 0.24, BANK_INTERIOR.depth), marbleFloorMat);
+ bankFloor.position.set(BANK_INTERIOR.centerX, 0.08, BANK_INTERIOR.centerZ);
+ const bankRoof = new THREE.Mesh(new THREE.BoxGeometry(BANK_INTERIOR.width + 2, 1.2, BANK_INTERIOR.depth + 2), marbleMat);
+ bankRoof.position.set(BANK_INTERIOR.centerX, bh + 0.6, BANK_INTERIOR.centerZ);
+ bankGroup.add(bankFloor, bankRoof);
+
+ // Paredes externas com colisão real, deixando uma porta dupla bem larga de 9 metros aberta na fachada leste (`bxMax`)!
+ const wallThick = 1.4;
+ // Parede Norte (`bzMin`)
+ const wallNorth = new THREE.Mesh(new THREE.BoxGeometry(BANK_INTERIOR.width, bh, wallThick), marbleMat);
+ wallNorth.position.set(BANK_INTERIOR.centerX, bh * 0.5, bzMin);
+ colliders.push({ minX: bxMin, maxX: bxMax, minZ: bzMin - 0.8, maxZ: bzMin + 0.8, height: bh });
+ // Parede Sul (`bzMax`)
+ const wallSouth = new THREE.Mesh(new THREE.BoxGeometry(BANK_INTERIOR.width, bh, wallThick), marbleMat);
+ wallSouth.position.set(BANK_INTERIOR.centerX, bh * 0.5, bzMax);
+ colliders.push({ minX: bxMin, maxX: bxMax, minZ: bzMax - 0.8, maxZ: bzMax + 0.8, height: bh });
+ // Parede Fundo Oeste (`bxMin`, atrás do cofre)
+ const wallWest = new THREE.Mesh(new THREE.BoxGeometry(wallThick, bh, BANK_INTERIOR.depth), marbleMat);
+ wallWest.position.set(bxMin, bh * 0.5, BANK_INTERIOR.centerZ);
+ colliders.push({ minX: bxMin - 0.8, maxX: bxMin + 0.8, minZ: bzMin, maxZ: bzMax, height: bh });
+
+ // Fachada Leste (`bxMax`): dois blocos laterais deixando vão central aberto de Z = -70 a Z = -60!
+ const frontWingLen = (BANK_INTERIOR.depth - 10) * 0.5; // 11m cada lado
+ const frontLeft = new THREE.Mesh(new THREE.BoxGeometry(wallThick, bh, frontWingLen), marbleMat);
+ frontLeft.position.set(bxMax, bh * 0.5, bzMin + frontWingLen * 0.5);
+ colliders.push({ minX: bxMax - 0.8, maxX: bxMax + 0.8, minZ: bzMin, maxZ: bzMin + frontWingLen, height: bh });
+
+ const frontRight = new THREE.Mesh(new THREE.BoxGeometry(wallThick, bh, frontWingLen), marbleMat);
+ frontRight.position.set(bxMax, bh * 0.5, bzMax - frontWingLen * 0.5);
+ colliders.push({ minX: bxMax - 0.8, maxX: bxMax + 0.8, minZ: bzMax - frontWingLen, maxZ: bzMax, height: bh });
+
+ // Verga superior + FRIEZE DOURADO "BANCO NACIONAL DE LEONIDA" + escadaria e tapete vermelho!
+ const lintel = new THREE.Mesh(new THREE.BoxGeometry(wallThick * 1.3, 3.2, 10.6), marbleMat);
+ lintel.position.set(bxMax, bh - 1.6, BANK_INTERIOR.centerZ);
+ const friezeTex = makeSignTexture('BANCO NACIONAL DE LEONIDA', { w: 1024, h: 96, fg: '#ffd166', bg: '#141109', font: '900 52px Georgia, serif' });
+ const frieze = friezeTex
+ ? new THREE.Mesh(new THREE.PlaneGeometry(24, 2.3), new THREE.MeshBasicMaterial({ map: friezeTex }))
+ : new THREE.Mesh(new THREE.BoxGeometry(0.4, 1.4, 18), new THREE.MeshBasicMaterial({ color: '#ffd166' }));
+ frieze.position.set(bxMax + 0.95, bh - 1.55, BANK_INTERIOR.centerZ);
+ if (friezeTex) frieze.rotation.y = Math.PI / 2;
+ bankGroup.add(wallNorth, wallSouth, wallWest, frontLeft, frontRight, lintel, frieze);
+
+ // Escadaria monumental na frente + tapete vermelho até a porta!
+ const stairSteps = [
+ { offset: 1.1, width: 16, height: 0.42 },
+ { offset: 2.5, width: 13, height: 0.26 },
+ { offset: 3.8, width: 10, height: 0.13 }
+ ];
+ for (const step of stairSteps) {
+ const stepMesh = new THREE.Mesh(new THREE.BoxGeometry(2.1, step.height, step.width), marbleMat);
+ stepMesh.position.set(bxMax + step.offset, step.height * 0.5, BANK_INTERIOR.centerZ);
+ bankGroup.add(stepMesh);
+ }
+ const redCarpet = new THREE.Mesh(new THREE.PlaneGeometry(9.5, 5.4), new THREE.MeshStandardMaterial({ color: '#8d0801', roughness: 0.85 }));
+ redCarpet.rotation.x = -Math.PI / 2;
+ redCarpet.position.set(bxMax + 8.1, 0.02, BANK_INTERIOR.centerZ);
+ bankGroup.add(redCarpet);
+
+ // 6 COLUNAS CORÍNTIAS colossais (fuste estriado + capitel duplo + base) flanqueando a porta!
+ const colGeo = new THREE.CylinderGeometry(0.6, 0.74, bh * 0.9, 14);
+ const capGeo = new THREE.BoxGeometry(1.75, 0.62, 1.75);
+ const baseGeo = new THREE.BoxGeometry(1.7, 0.5, 1.7);
+ for (const czCol of [-77.6, -72.4, -57.6, -52.4]) {
+ const col = new THREE.Mesh(colGeo, marbleMat);
+ col.position.set(bxMax + 2.1, bh * 0.45, czCol);
+ const capital = new THREE.Mesh(capGeo, marbleMat);
+ capital.position.set(bxMax + 2.1, bh * 0.9 + 0.3, czCol);
+ const colBase = new THREE.Mesh(baseGeo, marbleMat);
+ colBase.position.set(bxMax + 2.1, 0.25, czCol);
+ bankGroup.add(col, capital, colBase);
+ }
+
+ // FRONTÃO TRIANGULAR clássico acima da entrada (extrusão do triângulo neoclássico)!
+ const pedimentShape = new THREE.Shape();
+ pedimentShape.moveTo(-19, 0);
+ pedimentShape.lineTo(19, 0);
+ pedimentShape.lineTo(0, 5.6);
+ pedimentShape.closePath();
+ const pedimentGeo = new THREE.ExtrudeGeometry(pedimentShape, { depth: 2.3, bevelEnabled: false });
+ pedimentGeo.rotateY(Math.PI / 2);
+ const pediment = new THREE.Mesh(pedimentGeo, marbleMat);
+ pediment.position.set(bxMax + 1.05, bh + 1.15, BANK_INTERIOR.centerZ);
+ bankGroup.add(pediment);
+ // Disco solar dourado no centro do frontão
+ const sunDisc = new THREE.Mesh(new THREE.CylinderGeometry(1.55, 1.55, 0.35, 18), goldVaultMat);
+ sunDisc.rotation.z = Math.PI / 2;
+ sunDisc.position.set(bxMax + 2.35, bh + 2.6, BANK_INTERIOR.centerZ);
+ bankGroup.add(sunDisc);
+
+ // TORRE CORPORATIVA DE VIDRO ESPELHADO erguendo-se acima do pódio de granito (skyline de Leônida!)
+ const towerHeight = BANK_INTERIOR.towerHeight || 42;
+ const bankTowerTex = buildingFacadeTexture({ wall: '#121c2e', accent: '#24344f', neon: '#ffd166', style: 'skyscraper' });
+ const bankTowerMat = new THREE.MeshStandardMaterial({ map: bankTowerTex || null, color: '#9db8d6', roughness: 0.16, metalness: 0.78, envMapIntensity: 1.7 });
+ const towerBody = new THREE.Mesh(new THREE.BoxGeometry(30, towerHeight, 22), bankTowerMat);
+ towerBody.position.set(BANK_INTERIOR.centerX, bh + 1.2 + towerHeight * 0.5, BANK_INTERIOR.centerZ);
+ bankGroup.add(towerBody);
+ const towerSetback = new THREE.Mesh(new THREE.BoxGeometry(21, 9, 15), bankTowerMat);
+ towerSetback.position.set(BANK_INTERIOR.centerX, bh + 1.2 + towerHeight + 4.5, BANK_INTERIOR.centerZ);
+ bankGroup.add(towerSetback);
+ // Antena dourada + farol de aviação no topo (blink na tickCity!)
+ const antenna = new THREE.Mesh(new THREE.CylinderGeometry(0.32, 0.55, 10.5, 8), goldVaultMat);
+ antenna.position.set(BANK_INTERIOR.centerX, bh + 1.2 + towerHeight + 9 + 4.5, BANK_INTERIOR.centerZ);
+ const bankBeacon = new THREE.Mesh(new THREE.SphereGeometry(0.55, 10, 8), new THREE.MeshBasicMaterial({ color: '#ff3b3b' }));
+ bankBeacon.position.set(BANK_INTERIOR.centerX, bh + 1.2 + towerHeight + 9 + 9.9, BANK_INTERIOR.centerZ);
+ bankGroup.add(antenna, bankBeacon);
+
+ // Lustres de cristal no saguão do banco (brilho quente sobre o mármore!)
+ const chandelierMat = new THREE.MeshStandardMaterial({ color: '#fff3c4', emissive: '#ffd166', emissiveIntensity: 1.6, roughness: 0.3 });
+ for (const chandZ of [BANK_INTERIOR.centerZ - 9, BANK_INTERIOR.centerZ + 9]) {
+ const chandelier = new THREE.Mesh(new THREE.IcosahedronGeometry(0.85, 0), chandelierMat);
+ chandelier.position.set(BANK_INTERIOR.centerX, bh - 1.5, chandZ);
+ bankGroup.add(chandelier);
+ }
+
+ // Balcões de atendimento internos (nas laterais para deixar corredor livre até o cofre!)
+ for (const zSide of [-75, -55]) {
+ const desk = new THREE.Mesh(new THREE.BoxGeometry(18, 1.25, 2.2), pierWoodMat);
+ desk.position.set(BANK_INTERIOR.centerX + 4, 0.65, zSide);
+ bankGroup.add(desk);
+ }
+
+ // COFRE FORTE GIGANTE nos fundos (`vaultX = -290, vaultZ = -65`) com porta circular entreaberta, barras de ouro e notas!
+ const vaultRoomFrame = new THREE.Mesh(new THREE.BoxGeometry(2.2, 6.2, 10.5), steelVaultMat);
+ vaultRoomFrame.position.set(BANK_INTERIOR.vaultX - 3.2, 3.1, BANK_INTERIOR.vaultZ);
+ const vaultDoorPivot = new THREE.Group();
+ vaultDoorPivot.position.set(BANK_INTERIOR.vaultX - 1.8, 2.6, BANK_INTERIOR.vaultZ - 2.3);
+ const vaultDoorDisc = new THREE.Mesh(new THREE.CylinderGeometry(2.2, 2.2, 0.55, 24), steelVaultMat);
+ vaultDoorDisc.rotation.z = Math.PI / 2;
+ vaultDoorDisc.position.set(0, 0, 2.2);
+ const vaultWheel = new THREE.Mesh(new THREE.TorusGeometry(0.85, 0.12, 8, 18), goldVaultMat);
+ vaultWheel.rotation.y = Math.PI / 2;
+ vaultWheel.position.set(0.35, 0, 2.2);
+ vaultDoorPivot.add(vaultDoorDisc, vaultWheel);
+ vaultDoorPivot.rotation.y = 0.85; // Porta pesada do cofre escancarada!
+
+ // Pilhas de barras de ouro e maços de dólares brilhando no cofre
+ const lootGroup = new THREE.Group();
+ lootGroup.position.set(BANK_INTERIOR.vaultX, 0.2, BANK_INTERIOR.vaultZ);
+ const lootTable = new THREE.Mesh(new THREE.BoxGeometry(2.6, 0.9, 4.4), steelVaultMat);
+ lootTable.position.y = 0.45;
+ lootGroup.add(lootTable);
+ for (let gx = -0.6; gx <= 0.6; gx += 0.6) {
+ for (let gz = -1.4; gz <= 1.4; gz += 0.7) {
+ const bar = new THREE.Mesh(
+ new THREE.BoxGeometry(0.42, 0.24, 0.52),
+ (Math.abs(gz) < 0.8) ? goldVaultMat : cashGreenMat
+ );
+ bar.position.set(gx, 1.04, gz);
+ lootGroup.add(bar);
}
}
+ const vaultGlowRing = new THREE.Mesh(
+ new THREE.RingGeometry(2.1, 2.8, 28),
+ new THREE.MeshBasicMaterial({ color: '#ffd166', side: THREE.DoubleSide })
+ );
+ vaultGlowRing.rotation.x = -Math.PI / 2;
+ vaultGlowRing.position.set(1.8, 0.08, 0);
+ lootGroup.add(vaultGlowRing);
+
+ bankGroup.add(vaultRoomFrame, vaultDoorPivot, lootGroup);
+ root.add(bankGroup);
+
+ // 6. CONTAINER MARÍTIMO ESPECIAL NO PORTO (guardando o Corvette Stingray exclusivo!)
+ const containerGroup = new THREE.Group();
+ containerGroup.position.set(CORVETTE_CONTAINER.x, 0, CORVETTE_CONTAINER.z);
+ containerGroup.rotation.y = CORVETTE_CONTAINER.yaw;
+ const contMat = new THREE.MeshStandardMaterial({ color: '#0f4c81', roughness: 0.52, metalness: 0.55 });
+ const contNeon = new THREE.MeshBasicMaterial({ color: '#00f5d4' });
+ const cw = CORVETTE_CONTAINER.width;
+ const cl = CORVETTE_CONTAINER.length;
+ const ch = CORVETTE_CONTAINER.height;
+
+ const contFloor = new THREE.Mesh(new THREE.BoxGeometry(cw, 0.22, cl), steelVaultMat);
+ contFloor.position.y = 0.11;
+ const contRoof = new THREE.Mesh(new THREE.BoxGeometry(cw + 0.2, 0.22, cl), contMat);
+ contRoof.position.y = ch;
+ const contBack = new THREE.Mesh(new THREE.BoxGeometry(cw, ch, 0.24), contMat);
+ contBack.position.set(0, ch * 0.5, -cl * 0.5);
+ const contSideL = new THREE.Mesh(new THREE.BoxGeometry(0.24, ch, cl), contMat);
+ contSideL.position.set(cw * 0.5, ch * 0.5, 0);
+ const contSideR = new THREE.Mesh(new THREE.BoxGeometry(0.24, ch, cl), contMat);
+ contSideR.position.set(-cw * 0.5, ch * 0.5, 0);
+
+ // Portas duplas do container abertas para fora na extremidade +Z + rampa metálica de saída!
+ for (const s of [-1, 1]) {
+ const openDoor = new THREE.Mesh(new THREE.BoxGeometry(cw * 0.48, ch * 0.94, 0.16), contMat);
+ openDoor.position.set(s * (cw * 0.5 + 0.85), ch * 0.48, cl * 0.5 + 0.65);
+ openDoor.rotation.y = s * 1.15;
+ containerGroup.add(openDoor);
+ }
+ const contRamp = new THREE.Mesh(new THREE.BoxGeometry(cw * 0.94, 0.16, 3.2), steelVaultMat);
+ contRamp.position.set(0, 0.06, cl * 0.5 + 1.5);
+ contRamp.rotation.x = 0.05;
+ const contLightStrip = new THREE.Mesh(new THREE.BoxGeometry(cw * 0.7, 0.14, cl * 0.84), contNeon);
+ contLightStrip.position.set(0, ch - 0.16, 0);
- // 5. Prédios Art Déco, Midtown e Arranha-céus de Downtown
+ containerGroup.add(contFloor, contRoof, contBack, contSideL, contSideR, contRamp, contLightStrip);
+ root.add(containerGroup);
+ // Colisores das laterais e fundo do container (deixando a boca +Z aberta para entrar e tirar o Corvette!)
+ colliders.push(
+ { minX: CORVETTE_CONTAINER.x - cw * 0.5 - 0.3, maxX: CORVETTE_CONTAINER.x - cw * 0.5 + 0.3, minZ: CORVETTE_CONTAINER.z - cl * 0.5, maxZ: CORVETTE_CONTAINER.z + cl * 0.5, height: ch },
+ { minX: CORVETTE_CONTAINER.x + cw * 0.5 - 0.3, maxX: CORVETTE_CONTAINER.x + cw * 0.5 + 0.3, minZ: CORVETTE_CONTAINER.z - cl * 0.5, maxZ: CORVETTE_CONTAINER.z + cl * 0.5, height: ch },
+ { minX: CORVETTE_CONTAINER.x - cw * 0.5, maxX: CORVETTE_CONTAINER.x + cw * 0.5, minZ: CORVETTE_CONTAINER.z - cl * 0.5 - 0.3, maxZ: CORVETTE_CONTAINER.z - cl * 0.5 + 0.3, height: ch }
+ );
+
+ // 6.5 TÚNEIS RODOVIÁRIOS ILUMINADOS (portal de concreto + arco, luzes âmbar e morro paisagístico por cima!)
+ const tunnelConcrete = new THREE.MeshStandardMaterial({ color: '#8f96a3', roughness: 0.72 });
+ const tunnelDarkMat = new THREE.MeshStandardMaterial({ color: '#20242e', roughness: 0.95, side: THREE.BackSide });
+ const tunnelLightMat = new THREE.MeshBasicMaterial({ color: '#ffc46b' });
+ const tunnelHillMat = new THREE.MeshStandardMaterial({ color: '#3b6e52', roughness: 0.9 });
+ const tunnelTreeMat = new THREE.MeshStandardMaterial({ color: '#2d936c', roughness: 0.75 });
+
+ for (const tn of ROAD_TUNNELS) {
+ const tLen = tn.zMax - tn.zMin;
+ const tCz = (tn.zMin + tn.zMax) * 0.5;
+ const tTop = tn.height;
+
+ // Interior escuro do túnel (box aberto dos dois lados)
+ const inner = new THREE.Mesh(new THREE.BoxGeometry(tn.width, tTop, tLen), tunnelDarkMat);
+ inner.position.set(tn.x, tTop * 0.5, tCz);
+ root.add(inner);
+
+ // Luzes âmbar do teto a cada 8 metros + fitas laterais guia!
+ const lightCount = Math.floor(tLen / 8);
+ for (let li = 0; li < lightCount; li += 1) {
+ const lz = tn.zMin + 4 + li * 8;
+ const ceilLight = new THREE.Mesh(new THREE.BoxGeometry(3.4, 0.16, 1.15), tunnelLightMat);
+ ceilLight.position.set(tn.x, tTop - 0.32, lz);
+ root.add(ceilLight);
+ for (const side of [-1, 1]) {
+ const wallStrip = new THREE.Mesh(new THREE.BoxGeometry(0.18, 0.3, 5.4), tunnelLightMat);
+ wallStrip.position.set(tn.x + side * (tn.width * 0.5 - 0.35), 1.15, lz);
+ root.add(wallStrip);
+ }
+ }
+
+ // Portais monumentais de concreto nas duas bocas + semicírculo do arco
+ for (const [portalZ, facing] of [[tn.zMin, -1], [tn.zMax, 1]]) {
+ for (const side of [-1, 1]) {
+ const pillar = new THREE.Mesh(new THREE.BoxGeometry(2.5, tTop + 3.6, 2.1), tunnelConcrete);
+ pillar.position.set(tn.x + side * (tn.width * 0.5 + 1.25), (tTop + 3.6) * 0.5, portalZ);
+ root.add(pillar);
+ }
+ const lintel = new THREE.Mesh(new THREE.BoxGeometry(tn.width + 7.2, 2.5, 2.3), tunnelConcrete);
+ lintel.position.set(tn.x, tTop + 1.25, portalZ);
+ root.add(lintel);
+ // Faixa neon âmbar sob a verga (iluminação de bocal do túnel!)
+ const archGlow = new THREE.Mesh(new THREE.BoxGeometry(tn.width + 2.4, 0.42, 0.34), tunnelLightMat);
+ archGlow.position.set(tn.x, tTop - 0.28, portalZ + facing * 0.9);
+ root.add(archGlow);
+ // Placa luminosa do túnel acima do portal (voltada para fora!)
+ const signTex = makeSignTexture(tn.name.toUpperCase(), { w: 640, h: 96, fg: '#ffc46b', bg: '#120d04', font: '900 46px Arial Black, sans-serif' });
+ if (signTex) {
+ const sign = new THREE.Mesh(new THREE.PlaneGeometry(tn.width * 0.88, 1.35), new THREE.MeshBasicMaterial({ map: signTex }));
+ sign.position.set(tn.x, tTop + 1.32, portalZ + facing * 1.22);
+ if (facing < 0) sign.rotation.y = Math.PI;
+ root.add(sign);
+ }
+ }
+
+ // MORRO PAISAGÍSTICO por cima do túnel (gramado + coqueiros e pinheiros!)
+ const mound = new THREE.Mesh(new THREE.SphereGeometry(1, 18, 12, 0, Math.PI * 2, 0, Math.PI * 0.5), tunnelHillMat);
+ mound.scale.set(tn.width * 0.92, tTop * 1.05, tLen * 0.6);
+ mound.position.set(tn.x, 0, tCz);
+ root.add(mound);
+ for (let k = 0; k < 6; k += 1) {
+ const ang = (k / 6) * Math.PI * 2 + 0.4;
+ const tree = new THREE.Mesh(new THREE.ConeGeometry(1.7, 4.6, 6), tunnelTreeMat);
+ tree.position.set(tn.x + Math.cos(ang) * tn.width * 0.55, tTop + 0.9 + (k % 2) * 0.8, tCz + Math.sin(ang) * tLen * 0.3);
+ root.add(tree);
+ }
+
+ // Colisores das paredes laterais (as bocas continuam abertas para carros e o Rafael!)
+ colliders.push(
+ { minX: tn.x - tn.width * 0.5 - 0.6, maxX: tn.x - tn.width * 0.5 + 0.7, minZ: tn.zMin, maxZ: tn.zMax, height: tTop },
+ { minX: tn.x + tn.width * 0.5 - 0.7, maxX: tn.x + tn.width * 0.5 + 0.6, minZ: tn.zMin, maxZ: tn.zMax, height: tTop }
+ );
+ }
+
+ // 6.6 LINHA DE TREM EXPRESSO METRORAIL + 2 ESTAÇÕES CAMINHÁVEIS!
+ const trackLen = TRAIN_LINE.zMax - TRAIN_LINE.zMin;
+ const trackCz = (TRAIN_LINE.zMin + TRAIN_LINE.zMax) * 0.5;
+ const trackX = TRAIN_LINE.trackX;
+
+ // Lastro + dormentes (InstancedMesh) + trilhos de aço gêmeos
+ const ballast = new THREE.Mesh(new THREE.BoxGeometry(7.4, 0.26, trackLen), new THREE.MeshStandardMaterial({ color: '#343a45', roughness: 0.95 }));
+ ballast.position.set(trackX, 0.13, trackCz);
+ root.add(ballast);
+ const sleeperGeo = new THREE.BoxGeometry(2.7, 0.14, 0.62);
+ const sleeperMat = new THREE.MeshStandardMaterial({ color: '#4a3b2a', roughness: 0.9 });
+ const sleeperCount = Math.floor(trackLen / 2.4);
+ const sleeperInst = new THREE.InstancedMesh(sleeperGeo, sleeperMat, sleeperCount);
+ const dummySleeper = new THREE.Object3D();
+ for (let sIdx = 0; sIdx < sleeperCount; sIdx += 1) {
+ dummySleeper.position.set(trackX, 0.3, TRAIN_LINE.zMin + 1.2 + sIdx * 2.4);
+ dummySleeper.rotation.set(0, 0, 0);
+ dummySleeper.scale.set(1, 1, 1);
+ dummySleeper.updateMatrix();
+ sleeperInst.setMatrixAt(sIdx, dummySleeper.matrix);
+ }
+ root.add(sleeperInst);
+ const railMat2 = new THREE.MeshStandardMaterial({ color: '#d5dae2', roughness: 0.25, metalness: 0.92 });
+ for (const railOff of [-1.06, 1.06]) {
+ const rail = new THREE.Mesh(new THREE.BoxGeometry(0.17, 0.16, trackLen), railMat2);
+ rail.position.set(trackX + railOff, 0.42, trackCz);
+ root.add(rail);
+ }
+ // Postes catenária a cada 26m
+ const catenaryMat = new THREE.MeshStandardMaterial({ color: '#2b2d42', roughness: 0.6, metalness: 0.5 });
+ const poleCount = Math.floor(trackLen / 26);
+ const catenaryInst = new THREE.InstancedMesh(new THREE.CylinderGeometry(0.13, 0.18, 6.4, 6), catenaryMat, poleCount);
+ for (let pIdx = 0; pIdx < poleCount; pIdx += 1) {
+ dummySleeper.position.set(trackX + 4.6, 3.2, TRAIN_LINE.zMin + 13 + pIdx * 26);
+ dummySleeper.rotation.set(0, 0, 0);
+ dummySleeper.scale.set(1, 1, 1);
+ dummySleeper.updateMatrix();
+ catenaryInst.setMatrixAt(pIdx, dummySleeper.matrix);
+ }
+ root.add(catenaryInst);
+
+ // ESTAÇÕES: plataformas duplas, cobertura com neon, bancos, letreiro luminoso e escadas!
+ const platformMat = new THREE.MeshStandardMaterial({ color: '#aeb4bf', roughness: 0.6 });
+ const platformEdgeMat = new THREE.MeshBasicMaterial({ color: '#ffd166' });
+ const canopyMat = new THREE.MeshStandardMaterial({ color: '#f2f4f8', roughness: 0.38, metalness: 0.35 });
+ const canopyNeonMat = new THREE.MeshBasicMaterial({ color: '#00f5d4' });
+ const benchMat = new THREE.MeshStandardMaterial({ color: '#5a4632', roughness: 0.8 });
+ const pillarMat = new THREE.MeshStandardMaterial({ color: '#e9ecef', roughness: 0.5 });
+
+ for (const st of TRAIN_LINE.stations) {
+ const stationGroup = new THREE.Group();
+ const halfLen = st.platformLength * 0.5;
+ for (const side of [-1, 1]) {
+ const platX = trackX + side * (2.5 + st.platformWidth * 0.5);
+ const platform = new THREE.Mesh(new THREE.BoxGeometry(st.platformWidth, 0.44, st.platformLength), platformMat);
+ platform.position.set(platX, 0.22, st.z);
+ stationGroup.add(platform);
+ const edge = new THREE.Mesh(new THREE.BoxGeometry(0.5, 0.06, st.platformLength), platformEdgeMat);
+ edge.position.set(trackX + side * 2.5, 0.455, st.z);
+ stationGroup.add(edge);
+
+ // Cobertura (canopy) sobre a plataforma com fileira de pilares e friso neon!
+ const canopy = new THREE.Mesh(new THREE.BoxGeometry(st.platformWidth + 1.6, 0.24, st.platformLength * 0.66), canopyMat);
+ canopy.position.set(platX, 4.35, st.z);
+ stationGroup.add(canopy);
+ const neonTrim = new THREE.Mesh(new THREE.BoxGeometry(st.platformWidth + 1.9, 0.18, st.platformLength * 0.66), canopyNeonMat);
+ neonTrim.position.set(platX, 4.18, st.z);
+ stationGroup.add(neonTrim);
+ for (const pillarAlong of [-halfLen * 0.55, 0, halfLen * 0.55]) {
+ for (const pillarAcross of [-st.platformWidth * 0.32, st.platformWidth * 0.32]) {
+ const pillar = new THREE.Mesh(new THREE.CylinderGeometry(0.2, 0.2, 4.25, 8), pillarMat);
+ pillar.position.set(platX + pillarAcross, 2.12, st.z + pillarAlong);
+ stationGroup.add(pillar);
+ }
+ }
+ // Bancos de espera
+ for (const benchAlong of [-halfLen * 0.3, halfLen * 0.3]) {
+ const bench = new THREE.Mesh(new THREE.BoxGeometry(0.7, 0.42, 3.4), benchMat);
+ bench.position.set(platX + side * st.platformWidth * 0.28, 0.65, st.z + benchAlong);
+ stationGroup.add(bench);
+ }
+ }
+ // Letreiro luminoso da estação (dos dois lados, voltado para os trilhos)
+ const stationTex = makeSignTexture(st.name.toUpperCase(), { w: 900, h: 110, fg: '#00f5d4', bg: '#04141a', font: '900 44px Arial Black, sans-serif' });
+ if (stationTex) {
+ for (const side of [-1, 1]) {
+ const sign = new THREE.Mesh(new THREE.PlaneGeometry(9.5, 1.15), new THREE.MeshBasicMaterial({ map: stationTex, side: THREE.DoubleSide }));
+ sign.position.set(trackX + side * 4.4, 3.15, st.z);
+ sign.rotation.y = side > 0 ? -Math.PI / 2 : Math.PI / 2;
+ stationGroup.add(sign);
+ }
+ }
+ // Escada/rampa de acesso nas duas pontas da plataforma
+ for (const rampEnd of [-1, 1]) {
+ const ramp = new THREE.Mesh(new THREE.BoxGeometry(st.platformWidth * 2 + 5.5, 0.3, 5), platformMat);
+ ramp.position.set(trackX, 0.16, st.z + rampEnd * (halfLen + 2.4));
+ stationGroup.add(ramp);
+ }
+ root.add(stationGroup);
+ }
+
+ // O TREM: locomotiva + 3 carros de passageiros com janelas quentes acesas!
+ const trainGroup = new THREE.Group();
+ const trainBodyMat = new THREE.MeshStandardMaterial({ color: '#eef2f6', roughness: 0.32, metalness: 0.55 });
+ const trainStripeMat = new THREE.MeshBasicMaterial({ color: '#00f5d4' });
+ const trainGlassMat = new THREE.MeshStandardMaterial({ color: '#141a26', roughness: 0.12, metalness: 0.8, emissive: '#ffd88a', emissiveIntensity: 0.85 });
+ const trainDarkMat = new THREE.MeshStandardMaterial({ color: '#1b1e27', roughness: 0.7 });
+ const trainNoseMat = new THREE.MeshStandardMaterial({ color: '#00b4d8', roughness: 0.35, metalness: 0.4 });
+
+ function buildTrainCar(carLen, isLocomotive) {
+ const car = new THREE.Group();
+ const body = new THREE.Mesh(new THREE.BoxGeometry(3.35, 2.55, carLen), trainBodyMat);
+ body.position.y = 1.95;
+ car.add(body);
+ const stripe = new THREE.Mesh(new THREE.BoxGeometry(3.42, 0.42, carLen * 0.96), trainStripeMat);
+ stripe.position.y = 1.52;
+ car.add(stripe);
+ const windowBand = new THREE.Mesh(new THREE.BoxGeometry(3.42, 0.72, carLen * 0.78), trainGlassMat);
+ windowBand.position.y = 2.35;
+ car.add(windowBand);
+ const roofBox = new THREE.Mesh(new THREE.BoxGeometry(2.5, 0.34, carLen * 0.55), trainDarkMat);
+ roofBox.position.y = 3.4;
+ car.add(roofBox);
+ if (isLocomotive) {
+ const nose = new THREE.Mesh(new THREE.BoxGeometry(3.2, 2.1, 2.6), trainNoseMat);
+ nose.position.set(0, 1.75, carLen * 0.5 + 1.05);
+ car.add(nose);
+ const windshield = new THREE.Mesh(new THREE.BoxGeometry(2.7, 0.85, 0.2), trainGlassMat);
+ windshield.position.set(0, 2.35, carLen * 0.5 + 1.62);
+ car.add(windshield);
+ // Faróis do metrô acesos
+ for (const side of [-1, 1]) {
+ const headlight = new THREE.Mesh(new THREE.SphereGeometry(0.22, 8, 6), new THREE.MeshBasicMaterial({ color: '#fffbe0' }));
+ headlight.position.set(side * 1.05, 1.15, carLen * 0.5 + 2.36);
+ car.add(headlight);
+ }
+ }
+ // Bogies escuros
+ for (const bogieAlong of [-carLen * 0.32, carLen * 0.32]) {
+ const bogie = new THREE.Mesh(new THREE.BoxGeometry(2.6, 0.55, 2.4), trainDarkMat);
+ bogie.position.set(0, 0.62, bogieAlong);
+ car.add(bogie);
+ }
+ return car;
+ }
+
+ const locomotive = buildTrainCar(15.5, true);
+ trainGroup.add(locomotive);
+ const carOffsets = [-17.6, -33.2, -48.8];
+ for (const carOff of carOffsets) {
+ const car = buildTrainCar(13.5, false);
+ car.position.z = carOff;
+ trainGroup.add(car);
+ }
+ trainGroup.position.set(trackX, 0, TRAIN_LINE.zMin + 60);
+ root.add(trainGroup);
+ const trainState = {
+ z: TRAIN_LINE.zMin + 60,
+ dir: 1,
+ speed: 0,
+ dwell: 0,
+ halfLength: 33,
+ lastStopId: null,
+ hornCooldown: 0,
+ hornNeeded: false
+ };
+
+ // 6.7 AEROPORTO INTERNACIONAL DE VICE LEONIDA (pista zebrada, jatos, torre e terminal entrável!)
+ const airportGroup = new THREE.Group();
+ const runwayLen = AIRPORT_DATA.runwayZMax - AIRPORT_DATA.runwayZMin;
+ const runwayCz = (AIRPORT_DATA.runwayZMin + AIRPORT_DATA.runwayZMax) * 0.5;
+ const apronMat = new THREE.MeshStandardMaterial({ color: '#434a56', roughness: 0.82 });
+ const taxiwayMat = new THREE.MeshStandardMaterial({ color: '#2b2e38', roughness: 0.85 });
+
+ // Pista de pouso listrada com textura zebrada (repeat longitudinal)
+ const runwayTex = createRunwayTexture();
+ if (runwayTex) {
+ runwayTex.repeat.set(1, 7);
+ }
+ const runway = new THREE.Mesh(
+ new THREE.PlaneGeometry(AIRPORT_DATA.runwayWidth, runwayLen),
+ new THREE.MeshStandardMaterial({ map: runwayTex || null, color: '#ffffff', roughness: 0.78 })
+ );
+ runway.rotation.x = -Math.PI / 2;
+ runway.position.set(AIRPORT_DATA.runwayX, 0.135, runwayCz);
+ airportGroup.add(runway);
+
+ // Taxiway ligando a pista ao pátio do terminal + pátio de aeronaves
+ const taxiway = new THREE.Mesh(new THREE.PlaneGeometry(96, 17), taxiwayMat);
+ taxiway.rotation.x = -Math.PI / 2;
+ taxiway.position.set(-714, 0.13, -140);
+ airportGroup.add(taxiway);
+ const apron = new THREE.Mesh(new THREE.BoxGeometry(150, 0.14, 170), apronMat);
+ apron.position.set(-664, 0.07, -138);
+ airportGroup.add(apron);
+
+ // Luzes de borda da pista (brancas) + luzes de aproximação vermelhas nas cabeceiras!
+ const edgeLightGeo = new THREE.SphereGeometry(0.3, 6, 5);
+ const edgeLightMat = new THREE.MeshBasicMaterial({ color: '#f1f8ff' });
+ const edgeLightCount = Math.floor(runwayLen / 13) * 2;
+ const edgeLightInst = new THREE.InstancedMesh(edgeLightGeo, edgeLightMat, edgeLightCount);
+ let edgeIdx = 0;
+ for (let li = 0; li < Math.floor(runwayLen / 13); li += 1) {
+ const lz = AIRPORT_DATA.runwayZMin + 7 + li * 13;
+ for (const side of [-1, 1]) {
+ dummySleeper.position.set(AIRPORT_DATA.runwayX + side * (AIRPORT_DATA.runwayWidth * 0.5 + 1.6), 0.42, lz);
+ dummySleeper.rotation.set(0, 0, 0);
+ dummySleeper.scale.set(1, 1, 1);
+ dummySleeper.updateMatrix();
+ edgeLightInst.setMatrixAt(edgeIdx, dummySleeper.matrix);
+ edgeIdx += 1;
+ }
+ }
+ airportGroup.add(edgeLightInst);
+ const approachMat = new THREE.MeshBasicMaterial({ color: '#ff4d4d' });
+ for (const endZ of [AIRPORT_DATA.runwayZMin - 3, AIRPORT_DATA.runwayZMax + 3]) {
+ for (let k = -2; k <= 2; k += 1) {
+ const appLight = new THREE.Mesh(new THREE.SphereGeometry(0.42, 8, 6), approachMat);
+ appLight.position.set(AIRPORT_DATA.runwayX + k * 4.2, 0.5, endZ);
+ airportGroup.add(appLight);
+ }
+ }
+
+ // TORRE DE CONTROLE (fuste de concreto texturizado + cabine de vidro + radar giratório!)
+ const towerX = AIRPORT_DATA.towerX;
+ const towerZ = AIRPORT_DATA.towerZ;
+ const towerStoneTex = createBankStoneTexture();
+ const towerShaft = new THREE.Mesh(
+ new THREE.CylinderGeometry(2.5, 3.4, 30, 12),
+ new THREE.MeshStandardMaterial({ map: towerStoneTex || null, color: '#dcd6c8', roughness: 0.65 })
+ );
+ towerShaft.position.set(towerX, 15, towerZ);
+ airportGroup.add(towerShaft);
+ const towerCab = new THREE.Mesh(
+ new THREE.CylinderGeometry(4.3, 3.1, 3.6, 12),
+ new THREE.MeshStandardMaterial({ color: '#bfe9ff', roughness: 0.12, metalness: 0.55, emissive: '#59c2ff', emissiveIntensity: 0.75 })
+ );
+ towerCab.position.set(towerX, 31.8, towerZ);
+ airportGroup.add(towerCab);
+ const towerRoof = new THREE.Mesh(new THREE.CylinderGeometry(1.1, 4.35, 1.7, 12), new THREE.MeshStandardMaterial({ color: '#1b1e27', roughness: 0.55 }));
+ towerRoof.position.set(towerX, 34.4, towerZ);
+ airportGroup.add(towerRoof);
+ const radarBar = new THREE.Mesh(new THREE.BoxGeometry(6.4, 0.38, 0.66), new THREE.MeshStandardMaterial({ color: '#e9ecef', roughness: 0.4 }));
+ radarBar.position.set(towerX, 35.6, towerZ);
+ airportGroup.add(radarBar);
+ const towerBeacon = new THREE.Mesh(new THREE.SphereGeometry(0.4, 8, 6), new THREE.MeshBasicMaterial({ color: '#ff3b3b' }));
+ towerBeacon.position.set(towerX, 37.1, towerZ);
+ airportGroup.add(towerBeacon);
+ colliders.push({ minX: towerX - 3.2, maxX: towerX + 3.2, minZ: towerZ - 3.2, maxZ: towerZ + 3.2, height: 30 });
+
+ // FABRICANTE DE JATOS 3D (fuselagem, asas, estabilizador, motores, janelas quentes e trem de pouso)!
+ function buildJet(scale, livery, tailColor) {
+ const jet = new THREE.Group();
+ const fusMat = new THREE.MeshStandardMaterial({ color: livery, roughness: 0.28, metalness: 0.62 });
+ const tailMat = new THREE.MeshStandardMaterial({ color: tailColor, roughness: 0.34, metalness: 0.45 });
+ const darkMat = new THREE.MeshStandardMaterial({ color: '#10141c', roughness: 0.15, metalness: 0.8 });
+ const hotWindowMat = new THREE.MeshStandardMaterial({ color: '#141a26', emissive: '#ffd88a', emissiveIntensity: 0.7, roughness: 0.2 });
+
+ const fus = new THREE.Mesh(new THREE.CylinderGeometry(1.55 * scale, 1.85 * scale, 13.5 * scale, 14), fusMat);
+ fus.rotation.x = Math.PI / 2;
+ fus.position.y = 2.6 * scale;
+ jet.add(fus);
+ const nose = new THREE.Mesh(new THREE.SphereGeometry(1.55 * scale, 14, 10), fusMat);
+ nose.scale.set(1, 0.94, 1.45);
+ nose.position.set(0, 2.6 * scale, 6.4 * scale);
+ jet.add(nose);
+ const cockpit = new THREE.Mesh(new THREE.BoxGeometry(1.5 * scale, 0.62 * scale, 1.15 * scale), darkMat);
+ cockpit.position.set(0, 3.35 * scale, 5.6 * scale);
+ jet.add(cockpit);
+ const windowStrip = new THREE.Mesh(new THREE.BoxGeometry(3.16 * scale, 0.34 * scale, 8.6 * scale), hotWindowMat);
+ windowStrip.position.set(0, 3.05 * scale, -0.6 * scale);
+ jet.add(windowStrip);
+ // Asas principais enflechadas
+ const wing = new THREE.Mesh(new THREE.BoxGeometry(16.2 * scale, 0.3 * scale, 3.4 * scale), fusMat);
+ wing.position.set(0, 2.35 * scale, 0.4 * scale);
+ wing.rotation.y = 0.06;
+ jet.add(wing);
+ // Estabilizadores horizontais + deriva vertical com a cor da cia!
+ const hStab = new THREE.Mesh(new THREE.BoxGeometry(6.2 * scale, 0.24 * scale, 1.7 * scale), fusMat);
+ hStab.position.set(0, 3.15 * scale, -6.1 * scale);
+ jet.add(hStab);
+ const vStab = new THREE.Mesh(new THREE.BoxGeometry(0.34 * scale, 3.4 * scale, 2.5 * scale), tailMat);
+ vStab.position.set(0, 4.7 * scale, -6.0 * scale);
+ jet.add(vStab);
+ // Motores turbofan sob as asas
+ for (const side of [-1, 1]) {
+ const engine = new THREE.Mesh(new THREE.CylinderGeometry(0.62 * scale, 0.66 * scale, 2.4 * scale, 10), tailMat);
+ engine.rotation.x = Math.PI / 2;
+ engine.position.set(side * 4.6 * scale, 1.62 * scale, 1.1 * scale);
+ jet.add(engine);
+ }
+ // Trem de pouso simples
+ const gearMat = new THREE.MeshStandardMaterial({ color: '#21252d', roughness: 0.5, metalness: 0.6 });
+ for (const [gx, gz] of [[0, 4.6], [-2.2, -1.2], [2.2, -1.2]]) {
+ const gear = new THREE.Mesh(new THREE.CylinderGeometry(0.16 * scale, 0.16 * scale, 1.5 * scale, 6), gearMat);
+ gear.position.set(gx * scale, 0.75 * scale, gz * scale);
+ jet.add(gear);
+ }
+ return jet;
+ }
+
+ const parkedJet1 = buildJet(1.0, '#f4f7fb', '#ff2a85'); // Jato comercial rosa/white
+ parkedJet1.position.set(-700, 0, -196);
+ parkedJet1.rotation.y = 0.42;
+ airportGroup.add(parkedJet1);
+ const parkedJet2 = buildJet(0.92, '#f4f7fb', '#00b4d8'); // Jato comercial ciano/white
+ parkedJet2.position.set(-688, 0, -82);
+ parkedJet2.rotation.y = -0.35;
+ airportGroup.add(parkedJet2);
+ const privateJet = buildJet(0.58, '#fff3d6', '#9b5de5'); // Jato executivo dourado/roxo
+ privateJet.position.set(-652, 0, -158);
+ privateJet.rotation.y = 1.05;
+ airportGroup.add(privateJet);
+ colliders.push(
+ { minX: -710, maxX: -690, minZ: -212, maxZ: -180, height: 6 },
+ { minX: -698, maxX: -678, minZ: -98, maxZ: -66, height: 6 },
+ { minX: -660, maxX: -644, minZ: -167, maxZ: -149, height: 4 }
+ );
+
+ // AVIÃO VOANDO O CIRCUITO DE TRÁFEGO (decola e some no horizonte em loop!)
+ const flyingPlane = buildJet(0.85, '#f4f7fb', '#ffd166');
+ airportGroup.add(flyingPlane);
+
+ // Caminhão de combustível + contêineres de carga no pátio
+ const fuelTruck = new THREE.Group();
+ const truckBody = new THREE.Mesh(new THREE.BoxGeometry(2.3, 1.5, 4.6), new THREE.MeshStandardMaterial({ color: '#ffd166', roughness: 0.5 }));
+ truckBody.position.y = 1.35;
+ const truckCab = new THREE.Mesh(new THREE.BoxGeometry(2.2, 1.25, 1.5), new THREE.MeshStandardMaterial({ color: '#f8f9fa', roughness: 0.5 }));
+ truckCab.position.set(0, 1.05, 3.05);
+ fuelTruck.add(truckBody, truckCab);
+ fuelTruck.position.set(-668, 0, -118);
+ fuelTruck.rotation.y = 0.9;
+ airportGroup.add(fuelTruck);
+ const cargoColors = ['#0f4c81', '#2b9348', '#d62828'];
+ cargoColors.forEach((cc, cIdx) => {
+ const cargo = new THREE.Mesh(new THREE.BoxGeometry(2.5, 2.5, 6.1), new THREE.MeshStandardMaterial({ color: cc, roughness: 0.6, metalness: 0.35 }));
+ cargo.position.set(-626 - (cIdx % 2) * 3.1, 1.25 + cIdx * 0.02, -188 + cIdx * 7.2);
+ airportGroup.add(cargo);
+ });
+ root.add(airportGroup);
+
+ // 6.7.1 TERMINAL DE PASSAGEIROS ENTRÁVEL A PÉ (balcões de check-in, assentos e letreiro VIA!)
+ const terminalGroup = new THREE.Group();
+ const tx = AIRPORT_DATA.terminalX;
+ const tz = AIRPORT_DATA.terminalZ;
+ const tW = AIRPORT_DATA.terminalW; // 36 (X)
+ const tD = AIRPORT_DATA.terminalD; // 74 (Z)
+ const tH = 9.2;
+ const termWallMat = new THREE.MeshStandardMaterial({ color: '#e8e4da', roughness: 0.55, metalness: 0.12 });
+ const termFloorMat = new THREE.MeshStandardMaterial({ color: '#cdd3dd', roughness: 0.18, metalness: 0.4 });
+ const termRoofMat = new THREE.MeshStandardMaterial({ color: '#2b2e38', roughness: 0.6 });
+
+ const termFloor = new THREE.Mesh(new THREE.BoxGeometry(tW, 0.24, tD), termFloorMat);
+ termFloor.position.set(tx, 0.1, tz);
+ const termRoof = new THREE.Mesh(new THREE.BoxGeometry(tW + 2, 0.4, tD + 2), termRoofMat);
+ termRoof.position.set(tx, tH + 0.2, tz);
+ terminalGroup.add(termFloor, termRoof);
+
+ // Parede oeste completa + norte/sul completas
+ const tWest = new THREE.Mesh(new THREE.BoxGeometry(0.7, tH, tD), termWallMat);
+ tWest.position.set(tx - tW * 0.5, tH * 0.5, tz);
+ const tNorth = new THREE.Mesh(new THREE.BoxGeometry(tW, tH, 0.7), termWallMat);
+ tNorth.position.set(tx, tH * 0.5, tz - tD * 0.5);
+ const tSouth = new THREE.Mesh(new THREE.BoxGeometry(tW, tH, 0.7), termWallMat);
+ tSouth.position.set(tx, tH * 0.5, tz + tD * 0.5);
+ terminalGroup.add(tWest, tNorth, tSouth);
+ colliders.push(
+ { minX: tx - tW * 0.5 - 0.6, maxX: tx - tW * 0.5 + 0.6, minZ: tz - tD * 0.5, maxZ: tz + tD * 0.5, height: tH },
+ { minX: tx - tW * 0.5, maxX: tx + tW * 0.5, minZ: tz - tD * 0.5 - 0.6, maxZ: tz - tD * 0.5 + 0.6, height: tH },
+ { minX: tx - tW * 0.5, maxX: tx + tW * 0.5, minZ: tz + tD * 0.5 - 0.6, maxZ: tz + tD * 0.5 + 0.6, height: tH }
+ );
+ // Fachada leste COM PORTAL ABERTO de 7m no centro (entrada do terminal!)
+ const tDoorGap = 7;
+ const tWingLen = (tD - tDoorGap) * 0.5;
+ for (const side of [-1, 1]) {
+ const wing = new THREE.Mesh(new THREE.BoxGeometry(0.7, tH, tWingLen), termWallMat);
+ const wingZ = tz + side * (tDoorGap * 0.5 + tWingLen * 0.5);
+ wing.position.set(tx + tW * 0.5, tH * 0.5, wingZ);
+ terminalGroup.add(wing);
+ colliders.push({ minX: tx + tW * 0.5 - 0.6, maxX: tx + tW * 0.5 + 0.6, minZ: wingZ - tWingLen * 0.5, maxZ: wingZ + tWingLen * 0.5, height: tH });
+ }
+ const tLintel = new THREE.Mesh(new THREE.BoxGeometry(0.9, tH - 5.4, tDoorGap + 0.8), termWallMat);
+ tLintel.position.set(tx + tW * 0.5, 5.4 + (tH - 5.4) * 0.5, tz);
+ terminalGroup.add(tLintel);
+
+ // Letreiro VIA acima do portal + faixa de vidro azul-turquesa na fachada
+ const viaTex = makeSignTexture('VIA · AEROPORTO', { w: 720, h: 110, fg: '#38d6ff', bg: '#04141c', font: '900 52px Arial Black, sans-serif' });
+ if (viaTex) {
+ const viaSign = new THREE.Mesh(new THREE.PlaneGeometry(tDoorGap + 3, 1.7), new THREE.MeshBasicMaterial({ map: viaTex }));
+ viaSign.position.set(tx + tW * 0.5 + 0.42, tH - 1.15, tz);
+ viaSign.rotation.y = Math.PI / 2;
+ terminalGroup.add(viaSign);
+ }
+ const glassBand = new THREE.Mesh(new THREE.BoxGeometry(0.18, 1.5, tD * 0.9), new THREE.MeshStandardMaterial({ color: '#7fd7ff', roughness: 0.08, metalness: 0.65, emissive: '#1c6a8a', emissiveIntensity: 0.5 }));
+ glassBand.position.set(tx + tW * 0.5 + 0.06, 3.6, tz);
+ terminalGroup.add(glassBand);
+
+ // Interior: balcões de check-in em fileira, assentos, painéis de partida acesos!
+ const counterMat = new THREE.MeshStandardMaterial({ color: '#33415c', roughness: 0.4, metalness: 0.4 });
+ for (let cIdx = 0; cIdx < 5; cIdx += 1) {
+ const counter = new THREE.Mesh(new THREE.BoxGeometry(2.4, 1.12, 3.6), counterMat);
+ counter.position.set(tx - tW * 0.22, 0.56, tz - 22 + cIdx * 11);
+ terminalGroup.add(counter);
+ }
+ const seatMat = new THREE.MeshStandardMaterial({ color: '#ff2a85', roughness: 0.5 });
+ for (let sRow = 0; sRow < 3; sRow += 1) {
+ for (let sCol = 0; sCol < 6; sCol += 1) {
+ const seat = new THREE.Mesh(new THREE.BoxGeometry(0.85, 0.5, 0.85), seatMat);
+ seat.position.set(tx + 4 + sCol * 2.1, 0.32, tz - 16 + sRow * 15);
+ terminalGroup.add(seat);
+ }
+ }
+ const departureTex = makeCanvasTexture(512, 256, (ctx, cw, ch) => {
+ ctx.fillStyle = '#04141a';
+ ctx.fillRect(0, 0, cw, ch);
+ ctx.fillStyle = '#38d6ff';
+ ctx.font = '900 40px monospace';
+ ctx.fillText('PARTIDAS · DEPARTURES', 18, 52);
+ ctx.font = '700 30px monospace';
+ ctx.fillStyle = '#a9f0ff';
+ ctx.fillText('VLC → SÃO PAULO 10:25', 18, 112);
+ ctx.fillText('VLC → MIAMI 11:40', 18, 158);
+ ctx.fillText('VLC → TÓQUIO 13:15', 18, 204);
+ });
+ if (departureTex) {
+ const departure = new THREE.Mesh(new THREE.PlaneGeometry(7.6, 3.8), new THREE.MeshBasicMaterial({ map: departureTex }));
+ departure.position.set(tx - tW * 0.5 + 0.42, 5.6, tz);
+ departure.rotation.y = Math.PI / 2;
+ terminalGroup.add(departure);
+ }
+ root.add(terminalGroup);
+
+ // 6.8 LOJAS ENTRÁVEIS A PÉ (portais abertos, interiores completos e balcão de compra!)
+ const shopCounterMat = new THREE.MeshStandardMaterial({ color: '#3a3f4d', roughness: 0.35, metalness: 0.5 });
+ const clerkSkinMat = new THREE.MeshStandardMaterial({ color: '#c98d64', roughness: 0.7 });
+ const clerkDarkMat = new THREE.MeshStandardMaterial({ color: '#22252e', roughness: 0.7 });
+
+ const buildEnterableShop = (shop) => {
+ const sW = shop.width;
+ const sD = shop.depth;
+ const sH = shop.height;
+ const cx = shop.centerX;
+ const cz = shop.centerZ;
+ const doorEast = shop.doorSide === 'east';
+ const shopGroup = new THREE.Group();
+
+ const wallMat = new THREE.MeshStandardMaterial({ color: shop.wallColor, roughness: 0.68, metalness: 0.08 });
+ const roofMat = new THREE.MeshStandardMaterial({ color: '#23262f', roughness: 0.6 });
+ const floorMat = new THREE.MeshStandardMaterial({ color: '#2f3542', roughness: 0.22, metalness: 0.35 });
+ const neonMat = new THREE.MeshBasicMaterial({ color: shop.neonColor });
+
+ const floor = new THREE.Mesh(new THREE.BoxGeometry(sW, 0.22, sD), floorMat);
+ floor.position.set(cx, 0.09, cz);
+ const roof = new THREE.Mesh(new THREE.BoxGeometry(sW + 1.2, 0.32, sD + 1.2), roofMat);
+ roof.position.set(cx, sH + 0.16, cz);
+ shopGroup.add(floor, roof);
+
+ // Parede oposta à porta (completa)
+ const backWall = new THREE.Mesh(
+ doorEast ? new THREE.BoxGeometry(0.7, sH, sD) : new THREE.BoxGeometry(0.7, sH, sD),
+ wallMat
+ );
+ backWall.position.set(doorEast ? cx - sW * 0.5 : cx + sW * 0.5, sH * 0.5, cz);
+ shopGroup.add(backWall);
+ colliders.push({
+ minX: backWall.position.x - 0.5, maxX: backWall.position.x + 0.5,
+ minZ: cz - sD * 0.5, maxZ: cz + sD * 0.5, height: sH
+ });
+
+ // Paredes laterais (completas)
+ for (const side of [-1, 1]) {
+ const sideWall = new THREE.Mesh(new THREE.BoxGeometry(sW, sH, 0.7), wallMat);
+ const sideZ = cz + side * (sD * 0.5);
+ sideWall.position.set(cx, sH * 0.5, sideZ);
+ shopGroup.add(sideWall);
+ colliders.push({ minX: cx - sW * 0.5, maxX: cx + sW * 0.5, minZ: sideZ - 0.5, maxZ: sideZ + 0.5, height: sH });
+ }
+
+ // Parede da porta: dois blocos laterais deixando vão aberto de 4.6m + verga superior!
+ const doorGap = 4.6;
+ const doorWingLen = (sD - doorGap) * 0.5;
+ const doorWallX = doorEast ? cx + sW * 0.5 : cx - sW * 0.5;
+ for (const side of [-1, 1]) {
+ const wingZ = cz + side * (doorGap * 0.5 + doorWingLen * 0.5);
+ const wing = new THREE.Mesh(new THREE.BoxGeometry(0.7, sH, doorWingLen), wallMat);
+ wing.position.set(doorWallX, sH * 0.5, wingZ);
+ shopGroup.add(wing);
+ colliders.push({ minX: doorWallX - 0.5, maxX: doorWallX + 0.5, minZ: wingZ - doorWingLen * 0.5, maxZ: wingZ + doorWingLen * 0.5, height: sH });
+ }
+ const doorLintel = new THREE.Mesh(new THREE.BoxGeometry(0.8, sH - 4.0, doorGap + 0.7), wallMat);
+ doorLintel.position.set(doorWallX, 4.0 + (sH - 4.0) * 0.5, cz);
+ shopGroup.add(doorLintel);
+ // Moldura neon em volta da porta aberta
+ for (const side of [-1, 1]) {
+ const doorTrim = new THREE.Mesh(new THREE.BoxGeometry(0.28, 4.1, 0.3), neonMat);
+ doorTrim.position.set(doorWallX + (doorEast ? 0.42 : -0.42), 2.05, cz + side * (doorGap * 0.5 + 0.1));
+ shopGroup.add(doorTrim);
+ }
+ const doorTrimTop = new THREE.Mesh(new THREE.BoxGeometry(0.28, 0.3, doorGap + 0.6), neonMat);
+ doorTrimTop.position.set(doorWallX + (doorEast ? 0.42 : -0.42), 4.15, cz);
+ shopGroup.add(doorTrimTop);
+
+ // Letreiro neon luminoso com o nome da loja acima da porta!
+ const signTex = makeSignTexture(shop.name.toUpperCase(), { w: 720, h: 120, fg: shop.neonColor, bg: '#05070d', font: '900 44px Arial Black, sans-serif' });
+ if (signTex) {
+ const sign = new THREE.Mesh(new THREE.PlaneGeometry(sD * 0.82, 1.9), new THREE.MeshBasicMaterial({ map: signTex }));
+ sign.position.set(doorWallX + (doorEast ? 0.44 : -0.44), sH - 1.15, cz);
+ sign.rotation.y = doorEast ? Math.PI / 2 : -Math.PI / 2;
+ shopGroup.add(sign);
+ }
+
+ // Painéis de luz do teto (interior aceso e convidativo!)
+ for (const panelZ of [-sD * 0.28, 0, sD * 0.28]) {
+ const panel = new THREE.Mesh(new THREE.PlaneGeometry(sW * 0.42, 1.35), new THREE.MeshBasicMaterial({ color: '#fffbe8' }));
+ panel.rotation.x = Math.PI / 2;
+ panel.position.set(cx, sH - 0.12, cz + panelZ);
+ shopGroup.add(panel);
+ }
+
+ // BALCÃO DE ATENDIMENTO + REGISTRADOR + ATENDENTE (Clérigo de camisa neon!)
+ const counterX = doorEast ? cx - sW * 0.26 : cx + sW * 0.26;
+ const counter = new THREE.Mesh(new THREE.BoxGeometry(2.1, 1.12, 5.2), shopCounterMat);
+ counter.position.set(counterX, 0.66, cz);
+ shopGroup.add(counter);
+ const register = new THREE.Mesh(new THREE.BoxGeometry(0.85, 0.5, 0.7), clerkDarkMat);
+ register.position.set(counterX, 1.5, cz - 1.2);
+ shopGroup.add(register);
+ // Atendente (corpo cápsula + cabeça) atrás do balcão
+ const clerkBody = new THREE.Mesh(new THREE.CylinderGeometry(0.36, 0.46, 1.28, 8), new THREE.MeshStandardMaterial({ color: shop.neonColor, roughness: 0.62 }));
+ clerkBody.position.set(counterX + (doorEast ? -1.15 : 1.15), 1.28, cz + 0.6);
+ const clerkHead = new THREE.Mesh(new THREE.SphereGeometry(0.33, 10, 8), clerkSkinMat);
+ clerkHead.position.set(counterX + (doorEast ? -1.15 : 1.15), 2.2, cz + 0.6);
+ const clerkCap = new THREE.Mesh(new THREE.CylinderGeometry(0.35, 0.35, 0.16, 10), clerkDarkMat);
+ clerkCap.position.set(counterX + (doorEast ? -1.15 : 1.15), 2.47, cz + 0.6);
+ shopGroup.add(clerkBody, clerkHead, clerkCap);
+
+ // INTERIOR POR TIPO DE LOJA
+ if (shop.kind === 'market') {
+ // 3 corredores com prateleiras e produtos COLORIDOS (supermercado real!)
+ const productColors = ['#ff6b6b', '#ffd93d', '#6bcb77', '#4d96ff', '#ff9ff3', '#f368e0', '#48dbfb', '#ff9f43'];
+ for (let aisle = -1; aisle <= 1; aisle += 1) {
+ const aisleZ = cz + aisle * (sD * 0.3);
+ const shelf = new THREE.Mesh(new THREE.BoxGeometry(sW * 0.42, 2.0, 1.15), new THREE.MeshStandardMaterial({ color: '#dee3ea', roughness: 0.5 }));
+ shelf.position.set(cx + (doorEast ? 2.2 : -2.2), 1.1, aisleZ);
+ shopGroup.add(shelf);
+ for (let p = 0; p < 8; p += 1) {
+ const prod = new THREE.Mesh(
+ new THREE.BoxGeometry(0.52, 0.46, 0.4),
+ new THREE.MeshStandardMaterial({ color: productColors[(aisle * 8 + p + 4) % productColors.length], roughness: 0.55 })
+ );
+ prod.position.set(cx + (doorEast ? 2.2 : -2.2) - sW * 0.19 + (p % 4) * (sW * 0.125), 1.05 + Math.floor(p / 4) * 0.82, aisleZ + (p % 2 === 0 ? 0.62 : -0.62));
+ shopGroup.add(prod);
+ }
+ }
+ // Parede de geladeiras/freezers com frente luminosa no fundo
+ const fridgeMat = new THREE.MeshStandardMaterial({ color: '#dfe9f3', roughness: 0.25, metalness: 0.55, emissive: '#bfefff', emissiveIntensity: 0.4 });
+ for (let fIdx = 0; fIdx < 3; fIdx += 1) {
+ const fridge = new THREE.Mesh(new THREE.BoxGeometry(0.85, 2.6, 2.5), fridgeMat);
+ fridge.position.set(doorEast ? cx - sW * 0.5 + 0.65 : cx + sW * 0.5 - 0.65, 1.3, cz - 6 + fIdx * 6);
+ shopGroup.add(fridge);
+ }
+ } else if (shop.kind === 'weapons') {
+ // Painéis de rifles na parede do fundo (silhuetas de armas!)
+ const rackMat = new THREE.MeshStandardMaterial({ color: '#151a24', roughness: 0.55 });
+ const gunMat = new THREE.MeshStandardMaterial({ color: '#5c677d', roughness: 0.3, metalness: 0.85 });
+ for (let rIdx = 0; rIdx < 3; rIdx += 1) {
+ const rackZ = cz - 6.4 + rIdx * 6.4;
+ const rack = new THREE.Mesh(new THREE.BoxGeometry(0.34, 2.5, 4.6), rackMat);
+ rack.position.set(doorEast ? cx - sW * 0.5 + 0.34 : cx + sW * 0.5 - 0.34, 1.6, rackZ);
+ shopGroup.add(rack);
+ for (let g = 0; g < 4; g += 1) {
+ const rifle = new THREE.Mesh(new THREE.BoxGeometry(0.12, 0.22, 1.55), gunMat);
+ rifle.position.set(doorEast ? cx - sW * 0.5 + 0.56 : cx + sW * 0.5 - 0.56, 1.05 + g * 0.44, rackZ - 1.5 + (g % 2) * 3);
+ rifle.rotation.x = (g % 2 === 0 ? 1 : -1) * 0.16;
+ shopGroup.add(rifle);
+ }
+ }
+ // 2 balcões de vidro com armas curtas em exposição
+ const glassMat = new THREE.MeshStandardMaterial({ color: '#cfe8ff', roughness: 0.06, metalness: 0.4, transparent: true, opacity: 0.38 });
+ for (const caseZ of [-2.2, 2.2]) {
+ const display = new THREE.Mesh(new THREE.BoxGeometry(1.25, 1.05, 3.1), glassMat);
+ display.position.set(cx + (doorEast ? 1.6 : -1.6), 1.05, cz + caseZ);
+ shopGroup.add(display);
+ for (let pIdx = 0; pIdx < 3; pIdx += 1) {
+ const pistol = new THREE.Mesh(new THREE.BoxGeometry(0.18, 0.14, 0.62), gunMat);
+ pistol.position.set(cx + (doorEast ? 1.6 : -1.6), 1.62, cz + caseZ - 1 + pIdx);
+ shopGroup.add(pistol);
+ }
+ }
+ // Caixas de munição militares empilhadas
+ const ammoMat = new THREE.MeshStandardMaterial({ color: '#3a4031', roughness: 0.7 });
+ for (const [ax2, az2] of [[-3.1, -3.4], [-2.2, -4.6], [-3.4, 3.6]]) {
+ const ammoBox = new THREE.Mesh(new THREE.BoxGeometry(0.95, 0.65, 0.72), ammoMat);
+ ammoBox.position.set(cx + ax2 * (doorEast ? 1 : -1), 0.56, cz + az2);
+ shopGroup.add(ammoBox);
+ }
+ const ammoSignTex = makeSignTexture('MUNIÇÃO & ARMAS', { w: 560, h: 80, fg: '#ff2a85', bg: '#14040c', font: '900 42px Arial Black, sans-serif' });
+ if (ammoSignTex) {
+ const ammoSign = new THREE.Mesh(new THREE.PlaneGeometry(4.6, 0.68), new THREE.MeshBasicMaterial({ map: ammoSignTex }));
+ ammoSign.position.set(doorEast ? cx - sW * 0.5 + 0.42 : cx + sW * 0.5 - 0.42, 3.4, cz);
+ ammoSign.rotation.y = doorEast ? Math.PI / 2 : -Math.PI / 2;
+ shopGroup.add(ammoSign);
+ }
+ } else if (shop.kind === 'clothing') {
+ // Araras com roupas de neon penduradas (boutique!)
+ const clothColors = ['#ff2a85', '#00f5d4', '#ffd166', '#9b5de5', '#00bbf9', '#f72585'];
+ for (const rackZ of [-sD * 0.22, sD * 0.18]) {
+ const rail = new THREE.Mesh(new THREE.CylinderGeometry(0.07, 0.07, sW * 0.4, 8), new THREE.MeshStandardMaterial({ color: '#e9ecef', metalness: 0.8, roughness: 0.3 }));
+ rail.rotation.z = Math.PI / 2;
+ rail.position.set(cx + (doorEast ? 1.9 : -1.9), 1.62, cz + rackZ);
+ shopGroup.add(rail);
+ for (const postOff of [-sW * 0.19, sW * 0.19]) {
+ const post = new THREE.Mesh(new THREE.CylinderGeometry(0.06, 0.06, 1.7, 6), new THREE.MeshStandardMaterial({ color: '#e9ecef', metalness: 0.8, roughness: 0.3 }));
+ post.position.set(cx + (doorEast ? 1.9 : -1.9) + postOff, 0.85, cz + rackZ);
+ shopGroup.add(post);
+ }
+ for (let cIdx = 0; cIdx < 6; cIdx += 1) {
+ const garment = new THREE.Mesh(
+ new THREE.ConeGeometry(0.34, 1.15, 7),
+ new THREE.MeshStandardMaterial({ color: clothColors[(cIdx * 2 + (rackZ > 0 ? 3 : 0)) % clothColors.length], roughness: 0.62 })
+ );
+ garment.position.set(cx + (doorEast ? 1.9 : -1.9) - sW * 0.17 + cIdx * (sW * 0.068), 1.02, cz + rackZ);
+ shopGroup.add(garment);
+ }
+ }
+ // Manequins de vitrine + espelhos dourados
+ for (const manZ of [-1.6, 0, 1.6]) {
+ const mannequin = new THREE.Group();
+ const base = new THREE.Mesh(new THREE.CylinderGeometry(0.42, 0.5, 0.14, 10), clerkDarkMat);
+ base.position.y = 0.07;
+ const torso = new THREE.Mesh(new THREE.CylinderGeometry(0.3, 0.42, 1.25, 10), new THREE.MeshStandardMaterial({ color: '#f8f9fa', roughness: 0.35 }));
+ torso.position.y = 0.85;
+ const head = new THREE.Mesh(new THREE.SphereGeometry(0.21, 8, 6), new THREE.MeshStandardMaterial({ color: '#f8f9fa', roughness: 0.35 }));
+ head.position.y = 1.62;
+ mannequin.add(base, torso, head);
+ mannequin.position.set(doorEast ? cx + sW * 0.5 - 1.6 : cx - sW * 0.5 + 1.6, 0, cz + manZ + (sD * 0.32));
+ shopGroup.add(mannequin);
+ }
+ const mirrorMat = new THREE.MeshBasicMaterial({ color: '#fdf3d8' });
+ for (const mirZ of [-3.4, 3.4]) {
+ const mirror = new THREE.Mesh(new THREE.PlaneGeometry(1.7, 3.4), mirrorMat);
+ mirror.position.set(doorEast ? cx - sW * 0.5 + 0.42 : cx + sW * 0.5 - 0.42, 1.9, cz + mirZ);
+ mirror.rotation.y = doorEast ? Math.PI / 2 : -Math.PI / 2;
+ shopGroup.add(mirror);
+ }
+ }
+ root.add(shopGroup);
+ };
+ for (const shop of ENTERABLE_SHOPS) {
+ buildEnterableShop(shop);
+ }
+
+ // 7. Prédios Art Déco, Midtown, Arranha-céus e Casas (com cache de materiais para zero lag!)
const neonStrips = [];
const roofMat = new THREE.MeshStandardMaterial({ color: '#2b2d42', roughness: 0.85 });
+ const poolMat = new THREE.MeshBasicMaterial({ color: '#00e5ff' });
+ const sideMatCache = new Map();
+ const crownMatCache = new Map();
+ const houseRoofMatCache = new Map();
+ const unitBoxGeo = new THREE.BoxGeometry(1, 1, 1);
+
+ const porchMat = new THREE.MeshBasicMaterial({ color: '#ffe599' });
+ const buildingMeshes = [];
for (const b of layout.buildings) {
- const facade = buildingFacadeTexture(b);
- const sideMat = new THREE.MeshStandardMaterial({
- map: facade,
- roughness: b.style === 'skyscraper' ? 0.35 : 0.72,
- metalness: b.style === 'skyscraper' ? 0.35 : 0.06
- });
+ const matKey = `${b.wall}|${b.accent}|${b.neon}|${b.style}`;
+ let sideMat = sideMatCache.get(matKey);
+ if (!sideMat) {
+ const facade = buildingFacadeTexture(b);
+ sideMat = new THREE.MeshStandardMaterial({
+ map: facade,
+ roughness: b.style === 'skyscraper' ? 0.35 : 0.72,
+ metalness: b.style === 'skyscraper' ? 0.35 : 0.06
+ });
+ sideMatCache.set(matKey, sideMat);
+ }
const materials = [sideMat, sideMat, roofMat, roofMat, sideMat, sideMat];
- const mesh = new THREE.Mesh(new THREE.BoxGeometry(b.w, b.h, b.d), materials);
+ const mesh = new THREE.Mesh(unitBoxGeo, materials);
+ mesh.scale.set(b.w, b.h, b.d);
mesh.position.set(b.x, b.h * 0.5, b.z);
mesh.castShadow = shadows;
mesh.receiveShadow = shadows;
root.add(mesh);
+ if (b.style !== 'house' && b.style !== 'lifeguard') {
+ buildingMeshes.push({ mesh, data: b });
+ }
+
+ if (b.style === 'house') {
+ // ESTILOS DE CASA DA FLORIDA (pesquisado: Miami Beach + Florida Keys):
+ // 'mediterranean' — Revival Mediterrâneo 1920s (stucco creme, telhado de barril terracota,
+ // arcos, ferro e ladrilhos) — maioria dos chalés e vilas;
+ // 'streamline' — Streamline Moderne / MiMo (plano, pastel, marquee horizontal e louvers);
+ // 'conch' — Casas Conch de Key West (elevadas em palafita, frontão íngreme e varanda).
+ const houseHash = Math.abs(Math.sin(b.x * 12.9898 + b.z * 78.233) * 43758.5453) % 1;
+ const houseStyle = houseHash < 0.42 ? 'mediterranean' : houseHash < 0.74 ? 'streamline' : 'conch';
+
+ const archDarkMat = new THREE.MeshStandardMaterial({ color: '#241a12', roughness: 0.9 });
+ const ironMat = new THREE.MeshStandardMaterial({ color: '#1f2430', roughness: 0.4, metalness: 0.72 });
+ const whiteTrimMat = new THREE.MeshStandardMaterial({ color: '#f8f6ef', roughness: 0.6 });
+
+ if (houseStyle === 'mediterranean') {
+ // Telhado de barril terracota: cone de 4 águas com crista + frisos de cupim
+ const rHex = ['#c1440e', '#a63a12', '#b5501e'][Math.floor(houseHash * 97) % 3];
+ let tileMat = houseRoofMatCache.get(rHex);
+ if (!tileMat) {
+ tileMat = new THREE.MeshStandardMaterial({ color: rHex, roughness: 0.72 });
+ houseRoofMatCache.set(rHex, tileMat);
+ }
+ const roofRadius = Math.hypot(b.w, b.d) * 0.60;
+ const pitchedRoof = new THREE.Mesh(new THREE.ConeGeometry(1, 2.55, 4), tileMat);
+ pitchedRoof.scale.set(roofRadius, 1, roofRadius);
+ pitchedRoof.rotation.y = Math.PI / 4;
+ pitchedRoof.position.set(b.x, b.h + 1.26, b.z);
+ // Beiral de telha (eave) branco
+ const eave = new THREE.Mesh(new THREE.BoxGeometry(b.w + 1.6, 0.3, b.d + 1.6), whiteTrimMat);
+ eave.position.set(b.x, b.h + 0.14, b.z);
+ // Porta em ARCO (escuro) na fachada sul/norte + varanda de ferro
+ const arch = new THREE.Mesh(new THREE.CylinderGeometry(1.05, 1.05, 0.5, 12, 1, false, 0, Math.PI), archDarkMat);
+ arch.rotation.z = Math.PI / 2;
+ arch.rotation.y = Math.PI / 2;
+ arch.position.set(b.x, 1.5, b.z + b.d * 0.5 + 0.06);
+ const doorLower = new THREE.Mesh(new THREE.BoxGeometry(2.1, 1.6, 0.34), archDarkMat);
+ doorLower.position.set(b.x, 0.78, b.z + b.d * 0.5 + 0.02);
+ const railY = 1.05;
+ for (const railOff of [-b.w * 0.32, 0, b.w * 0.32]) {
+ const baluster = new THREE.Mesh(new THREE.CylinderGeometry(0.045, 0.045, 0.82, 5), ironMat);
+ baluster.position.set(b.x + railOff, railY, b.z + b.d * 0.5 + 1.15);
+ root.add(baluster);
+ }
+ const rail = new THREE.Mesh(new THREE.BoxGeometry(b.w * 0.82, 0.07, 0.07), ironMat);
+ rail.position.set(b.x, railY + 0.44, b.z + b.d * 0.5 + 1.15);
+ // Ladrilho/plaqueta cerâmica azul acima do arco
+ const tile = new THREE.Mesh(new THREE.BoxGeometry(1.35, 0.42, 0.1), new THREE.MeshBasicMaterial({ color: '#2a6fdb' }));
+ tile.position.set(b.x, 2.75, b.z + b.d * 0.5 + 0.12);
+ root.add(pitchedRoof, eave, arch, doorLower, rail, tile);
+ } else if (houseStyle === 'streamline') {
+ // Streamline Moderne: laje plana com marquee/olho-de-sobrado e friso neon
+ const pastel = b.wall || '#f6eaff';
+ const slabMat = houseRoofMatCache.get(`${pastel}-slab`) || new THREE.MeshStandardMaterial({ color: '#2b2d42', roughness: 0.6 });
+ if (!houseRoofMatCache.get(`${pastel}-slab`)) houseRoofMatCache.set(`${pastel}-slab`, slabMat);
+ const overhang = new THREE.Mesh(new THREE.BoxGeometry(b.w + 2.1, 0.34, b.d + 2.1), whiteTrimMat);
+ overhang.position.set(b.x, b.h + 0.16, b.z);
+ // "Eyebrow" — friso de sombra sobre a janela central (marca registrada Moderne)
+ const eyebrow = new THREE.Mesh(new THREE.BoxGeometry(b.w * 0.62, 0.34, 0.3), whiteTrimMat);
+ eyebrow.position.set(b.x, b.h * 0.62, b.z + b.d * 0.5 + 0.16);
+ const glassBand = new THREE.Mesh(
+ new THREE.BoxGeometry(b.w * 0.52, 0.2, 0.1),
+ new THREE.MeshStandardMaterial({ color: '#141a26', emissive: '#ffd88a', emissiveIntensity: 0.9, roughness: 0.2 })
+ );
+ glassBand.position.set(b.x, b.h * 0.62 - 0.26, b.z + b.d * 0.5 + 0.18);
+ // Friso neon horizontal de canto (dot lit)
+ let neonCornerMat = crownMatCache.get(b.neon);
+ if (!neonCornerMat) {
+ neonCornerMat = new THREE.MeshBasicMaterial({ color: b.neon });
+ crownMatCache.set(b.neon, neonCornerMat);
+ }
+ const neonCorner = new THREE.Mesh(new THREE.BoxGeometry(0.22, b.h * 0.72, 0.22), neonCornerMat);
+ neonCorner.position.set(b.x + b.w * 0.5 + 0.06, b.h * 0.4, b.z + b.d * 0.5 + 0.06);
+ neonStrips.push(neonCorner);
+ root.add(overhang, eyebrow, glassBand, neonCorner);
+ } else {
+ // Casa Conch de Key West: CORPO ELEVADO em palafita, frontão íngreme e varanda frontal!
+ mesh.position.y = b.h * 0.5 + 1.35;
+ const stiltMat = new THREE.MeshStandardMaterial({ color: '#4a3b2a', roughness: 0.85 });
+ for (const [sx2, sz2] of [[-1, -1], [1, -1], [-1, 1], [1, 1]]) {
+ const stilt = new THREE.Mesh(new THREE.CylinderGeometry(0.22, 0.26, 1.35, 6), stiltMat);
+ stilt.position.set(b.x + sx2 * (b.w * 0.36), 0.67, b.z + sz2 * (b.d * 0.36));
+ root.add(stilt);
+ }
+ const conchRoofKey = b.roof || '#9b2226';
+ let conchPitchedRoofMat = houseRoofMatCache.get(conchRoofKey);
+ if (!conchPitchedRoofMat) {
+ conchPitchedRoofMat = new THREE.MeshStandardMaterial({ color: conchRoofKey, roughness: 0.8 });
+ houseRoofMatCache.set(conchRoofKey, conchPitchedRoofMat);
+ }
+ const steepRoof = new THREE.Mesh(new THREE.ConeGeometry(1, 3.6, 4), conchPitchedRoofMat);
+ const steepRadius = Math.hypot(b.w, b.d) * 0.62;
+ steepRoof.scale.set(steepRadius, 1, steepRadius);
+ steepRoof.rotation.y = Math.PI / 4;
+ steepRoof.position.set(b.x, b.h + 1.35 + 1.72, b.z);
+ // Varanda com telhadinho + 2 colunas brancas
+ const porchRoof = new THREE.Mesh(new THREE.BoxGeometry(b.w * 0.72, 0.16, 2.5), whiteTrimMat);
+ porchRoof.position.set(b.x, 2.62, b.z + b.d * 0.5 + 1.15);
+ for (const colOff of [-b.w * 0.3, b.w * 0.3]) {
+ const porchCol = new THREE.Mesh(new THREE.CylinderGeometry(0.11, 0.13, 2.3, 6), whiteTrimMat);
+ porchCol.position.set(b.x + colOff, 1.35, b.z + b.d * 0.5 + 2.1);
+ root.add(porchCol);
+ }
+ root.add(steepRoof, porchRoof);
+ }
+
+ const porchLight = new THREE.Mesh(unitBoxGeo, porchMat);
+ porchLight.scale.set(b.w * 0.42, 0.28, 1.8);
+ porchLight.position.set(b.x, 2.9, b.z + b.d * 0.5 + 0.6);
+ root.add(porchLight);
+ neonStrips.push(porchLight);
- // Topo escalonado Art Déco + tubo neon que acende forte ao entardecer/noite
- const crownMat = new THREE.MeshBasicMaterial({ color: b.neon });
- const crown = new THREE.Mesh(new THREE.BoxGeometry(b.w * 0.82, 0.65, b.d * 0.82), crownMat);
- crown.position.set(b.x, b.h + 0.32, b.z);
- root.add(crown);
- neonStrips.push(crown);
+ if (b.hasPool) {
+ const pool = new THREE.Mesh(new THREE.PlaneGeometry(5.2, 8.4), poolMat);
+ pool.rotation.x = -Math.PI / 2;
+ pool.position.set(b.x - b.w * 0.5 - 3.6, 0.08, b.z);
+ // Borda de concreto da piscina (MiMo kidney-ish para as MiMo)!
+ const poolRim = new THREE.Mesh(new THREE.PlaneGeometry(6.3, 9.5), new THREE.MeshStandardMaterial({ color: '#e8e4da', roughness: 0.7 }));
+ poolRim.rotation.x = -Math.PI / 2;
+ poolRim.position.set(b.x - b.w * 0.5 - 3.6, 0.055, b.z);
+ root.add(poolRim, pool);
+ }
+ } else {
+ let crownMat = crownMatCache.get(b.neon);
+ if (!crownMat) {
+ crownMat = new THREE.MeshBasicMaterial({ color: b.neon });
+ crownMatCache.set(b.neon, crownMat);
+ }
+ const crown = new THREE.Mesh(unitBoxGeo, crownMat);
+ crown.scale.set(b.w * 0.82, 0.65, b.d * 0.82);
+ crown.position.set(b.x, b.h + 0.32, b.z);
+ root.add(crown);
+ neonStrips.push(crown);
+ }
colliders.push({
minX: b.x - b.w * 0.5,
@@ -208,7 +2070,7 @@ export function buildCityScene(scene, { shadows = true } = {}) {
});
}
- // 6. Oficinas Pay & Spray (arcos neon verdes nos pontos 'garage')
+ // 8. Oficinas Pay & Spray (arcos neon verdes)
for (const poi of POINTS_OF_INTEREST.filter(p => p.kind === 'garage')) {
const bayMat = new THREE.MeshStandardMaterial({ color: '#1b263b', roughness: 0.6 });
const neonGreen = new THREE.MeshBasicMaterial({ color: '#2ee59d' });
@@ -224,58 +2086,281 @@ export function buildCityScene(scene, { shadows = true } = {}) {
const sign = new THREE.Mesh(new THREE.BoxGeometry(10.6, 0.55, 8.9), neonGreen);
sign.position.set(0, 6.15, 0);
- // Anel luminoso no chão indicando reparo + perda de estrelas
const pad = new THREE.Mesh(
new THREE.RingGeometry(3.4, 4.4, 28),
new THREE.MeshBasicMaterial({ color: '#2ee59d', side: THREE.DoubleSide })
);
pad.rotation.x = -Math.PI / 2;
- pad.position.set(-15, 0.18, 0); // direto na faixa lateral da rua para entrar fácil de carro
+ pad.position.set(-15, 0.18, 0);
archGroup.add(leftPillar, rightPillar, roof, sign, pad);
root.add(archGroup);
}
- // 7. Palmeiras tropicais de Leonida (InstancedMesh ou grupos leves)
+ // 9. Palmeiras e Árvores Copadas Otimizadas (`InstancedMesh` -> apenas 4 draw calls no total!)
+ // + Upgrade automático caso o usuário tenha enviado `palm.glb`, `tree.glb` ou `building.glb`!
+ const vegGroup = new THREE.Group();
+ root.add(vegGroup);
+
const trunkMat = new THREE.MeshStandardMaterial({ color: '#7f5539', roughness: 0.9 });
- const leafMat = new THREE.MeshStandardMaterial({ color: '#2d936c', roughness: 0.72, side: THREE.DoubleSide });
- const trunkGeo = new THREE.CylinderGeometry(0.22, 0.38, 7.5, 6);
- const frondGeo = new THREE.ConeGeometry(2.6, 1.5, 6);
-
- for (const p of layout.palms) {
- const g = new THREE.Group();
- g.position.set(p.x, 0, p.z);
- g.scale.setScalar(p.scale);
-
- const trunk = new THREE.Mesh(trunkGeo, trunkMat);
- trunk.position.y = 3.75;
- trunk.rotation.z = 0.06;
- g.add(trunk);
-
- const canopy = new THREE.Mesh(frondGeo, leafMat);
- canopy.position.set(-0.22, 7.6, 0);
- g.add(canopy);
- root.add(g);
- }
-
- // 8. Guarda-sóis coloridos em Vice Beach
- const poleGeo = new THREE.CylinderGeometry(0.06, 0.06, 2.4, 5);
- const poleMat = new THREE.MeshStandardMaterial({ color: '#f8f9fa' });
- const topGeo = new THREE.ConeGeometry(2.1, 0.85, 8);
- for (const u of layout.props) {
- if (u.kind !== 'umbrella') continue;
+ const palmLeafMat = new THREE.MeshStandardMaterial({ color: '#2d936c', roughness: 0.68, side: THREE.DoubleSide });
+ const treeLeafMat = new THREE.MeshStandardMaterial({ color: '#38b000', roughness: 0.78 });
+
+ const palmTrunks = new THREE.InstancedMesh(new THREE.CylinderGeometry(0.20, 0.36, 7.6, 6), trunkMat, layout.palms.length);
+ const palmCrowns = new THREE.InstancedMesh(new THREE.ConeGeometry(2.7, 1.55, 7), palmLeafMat, layout.palms.length);
+ layout.palms.forEach((p, idx) => {
+ dummy.position.set(p.x, 3.8 * p.scale, p.z);
+ dummy.rotation.set(0, (idx * 1.1) % 6.28, 0.06);
+ dummy.scale.setScalar(p.scale);
+ dummy.updateMatrix();
+ palmTrunks.setMatrixAt(idx, dummy.matrix);
+
+ dummy.position.set(p.x - 0.22 * p.scale, 7.65 * p.scale, p.z);
+ dummy.rotation.set(0, (idx * 0.7) % 6.28, 0);
+ dummy.scale.setScalar(p.scale);
+ dummy.updateMatrix();
+ palmCrowns.setMatrixAt(idx, dummy.matrix);
+ });
+ vegGroup.add(palmTrunks, palmCrowns);
+
+ const treeTrunks = new THREE.InstancedMesh(new THREE.CylinderGeometry(0.24, 0.38, 3.4, 6), trunkMat, layout.trees.length);
+ const treeCanopies = new THREE.InstancedMesh(new THREE.DodecahedronGeometry(2.35, 1), treeLeafMat, layout.trees.length);
+ layout.trees.forEach((t, idx) => {
+ dummy.position.set(t.x, 1.7 * t.scale, t.z);
+ dummy.rotation.set(0, 0, 0);
+ dummy.scale.setScalar(t.scale);
+ dummy.updateMatrix();
+ treeTrunks.setMatrixAt(idx, dummy.matrix);
+
+ dummy.position.set(t.x, 4.35 * t.scale, t.z);
+ dummy.rotation.set(0.2, idx * 0.8, 0);
+ dummy.scale.set(t.scale * 1.08, t.scale * 0.92, t.scale * 1.08);
+ dummy.updateMatrix();
+ treeCanopies.setMatrixAt(idx, dummy.matrix);
+ });
+ vegGroup.add(treeTrunks, treeCanopies);
+
+ // Se o usuário enviou modelos `.glb` de palmeira, árvore ou prédio no Estúdio / Git, aplica automaticamente!
+ resolveEnvironmentPropGlbs().then(async envGlbs => {
+ if (envGlbs.palm) {
+ const gltf = await loadGlbOnce(envGlbs.palm);
+ if (gltf?.scene) {
+ palmTrunks.visible = false;
+ palmCrowns.visible = false;
+ const box = new THREE.Box3().setFromObject(gltf.scene);
+ const sz = new THREE.Vector3();
+ box.getSize(sz);
+ const baseScale = 8.2 / Math.max(0.5, sz.y);
+ for (let i = 0; i < layout.palms.length; i += 2) {
+ const p = layout.palms[i];
+ const clone = gltf.scene.clone(true);
+ clone.scale.setScalar(baseScale * p.scale);
+ clone.position.set(p.x, -box.min.y * baseScale * p.scale, p.z);
+ vegGroup.add(clone);
+ }
+ }
+ }
+ if (envGlbs.tree) {
+ const gltf = await loadGlbOnce(envGlbs.tree);
+ if (gltf?.scene) {
+ treeTrunks.visible = false;
+ treeCanopies.visible = false;
+ const box = new THREE.Box3().setFromObject(gltf.scene);
+ const sz = new THREE.Vector3();
+ box.getSize(sz);
+ const baseScale = 6.2 / Math.max(0.5, sz.y);
+ for (const t of layout.trees) {
+ const clone = gltf.scene.clone(true);
+ clone.scale.setScalar(baseScale * t.scale);
+ clone.position.set(t.x, -box.min.y * baseScale * t.scale, t.z);
+ vegGroup.add(clone);
+ }
+ }
+ }
+ if (envGlbs.buildings.length > 0) {
+ const gltf = await loadGlbOnce(envGlbs.buildings[0]);
+ if (gltf?.scene) {
+ const box = new THREE.Box3().setFromObject(gltf.scene);
+ const sz = new THREE.Vector3();
+ const ctr = new THREE.Vector3();
+ box.getSize(sz);
+ box.getCenter(ctr);
+ for (let i = 0; i < Math.min(10, buildingMeshes.length); i += 1) {
+ const target = buildingMeshes[i * 3 % buildingMeshes.length];
+ if (!target) continue;
+ target.mesh.visible = false;
+ const clone = gltf.scene.clone(true);
+ const scX = target.data.w / Math.max(1, sz.x);
+ const scY = target.data.h / Math.max(1, sz.y);
+ const scZ = target.data.d / Math.max(1, sz.z);
+ clone.scale.set(scX, scY, scZ);
+ clone.position.set(target.data.x - ctr.x * scX, -box.min.y * scY, target.data.z - ctr.z * scZ);
+ root.add(clone);
+ }
+ }
+ }
+ });
+
+ // 10. POSTES DE LUZ NAS CALÇADAS (`InstancedMesh`) QUE ACENDEM À NOITE E ILUMINAM O CHÃO!
+ const lampPostMetal = new THREE.MeshStandardMaterial({ color: '#2b2d42', metalness: 0.7, roughness: 0.4 });
+ const lampBulbMat = new THREE.MeshBasicMaterial({ color: '#3a3f54' });
+ const lampHaloMat = new THREE.MeshBasicMaterial({
+ color: '#ffd88a',
+ transparent: true,
+ opacity: 0.0,
+ side: THREE.DoubleSide,
+ depthWrite: false
+ });
+
+ const slCount = layout.streetlights.length;
+ const poleInst = new THREE.InstancedMesh(new THREE.CylinderGeometry(0.09, 0.14, 6.2, 6), lampPostMetal, slCount);
+ const armInst = new THREE.InstancedMesh(new THREE.BoxGeometry(1.8, 0.10, 0.12), lampPostMetal, slCount);
+ const bulbInst = new THREE.InstancedMesh(new THREE.SphereGeometry(0.24, 8, 6), lampBulbMat, slCount);
+ const poolLightGeo = new THREE.CircleGeometry(5.6, 14);
+ poolLightGeo.rotateX(-Math.PI / 2);
+ const groundGlowInst = new THREE.InstancedMesh(poolLightGeo, lampHaloMat, slCount);
+
+ layout.streetlights.forEach((sl, idx) => {
+ dummy.position.set(sl.x, 3.1, sl.z);
+ dummy.rotation.set(0, sl.yaw, 0);
+ dummy.scale.set(1, 1, 1);
+ dummy.updateMatrix();
+ poleInst.setMatrixAt(idx, dummy.matrix);
+
+ const outX = Math.cos(sl.yaw) * 0.85;
+ const outZ = -Math.sin(sl.yaw) * 0.85;
+ dummy.position.set(sl.x + outX, 6.12, sl.z + outZ);
+ dummy.rotation.set(0, sl.yaw, 0);
+ dummy.updateMatrix();
+ armInst.setMatrixAt(idx, dummy.matrix);
+
+ dummy.position.set(sl.x + outX * 1.85, 5.98, sl.z + outZ * 1.85);
+ dummy.rotation.set(0, 0, 0);
+ dummy.updateMatrix();
+ bulbInst.setMatrixAt(idx, dummy.matrix);
+
+ dummy.position.set(sl.x + outX * 1.85, 0.16, sl.z + outZ * 1.85);
+ dummy.rotation.set(0, 0, 0);
+ dummy.updateMatrix();
+ groundGlowInst.setMatrixAt(idx, dummy.matrix);
+ });
+ root.add(poleInst, armInst, bulbInst, groundGlowInst);
+
+ // Pool de 2 PointLights reais que acompanham os postes mais próximos do jogador à noite (ilumina carros e Rafael sem pesar no FPS!)
+ const activeStreetPointLights = [
+ new THREE.PointLight('#ffcf75', 0, 32, 1.6),
+ new THREE.PointLight('#ffcf75', 0, 32, 1.6)
+ ];
+ for (const pl of activeStreetPointLights) scene.add(pl);
+
+ // 11. Vida na Praia: Guarda-sóis, Cadeiras de Sol, Redes de Vôlei com Bola Animada e Altinha!
+ const poleGeo = new THREE.CylinderGeometry(0.06, 0.06, 2.5, 5);
+ const poleWhiteMat = new THREE.MeshStandardMaterial({ color: '#f8f9fa' });
+ const topGeo = new THREE.ConeGeometry(2.15, 0.88, 8);
+ const loungeFrameMat = new THREE.MeshStandardMaterial({ color: '#ffffff', roughness: 0.5 });
+ const loungeCushionMat = new THREE.MeshStandardMaterial({ color: '#00bbf9', roughness: 0.75 });
+
+ for (const bs of layout.beachSets) {
const ug = new THREE.Group();
- ug.position.set(u.x, 0, u.z);
- const pole = new THREE.Mesh(poleGeo, poleMat);
- pole.position.y = 1.2;
- const top = new THREE.Mesh(topGeo, new THREE.MeshStandardMaterial({ color: u.color, roughness: 0.65 }));
- top.position.y = 2.45;
+ ug.position.set(bs.x, 0, bs.z);
+ const pole = new THREE.Mesh(poleGeo, poleWhiteMat);
+ pole.position.y = 1.25;
+ const top = new THREE.Mesh(topGeo, new THREE.MeshStandardMaterial({ color: bs.color, roughness: 0.65 }));
+ top.position.y = 2.52;
ug.add(pole, top);
+
+ // Duas cadeiras espreguiçadeiras voltadas para o mar (+X) ao lado do guarda-sol!
+ for (const zOff of [-1.45, 1.45]) {
+ const chair = new THREE.Group();
+ chair.position.set(0.35, 0.22, zOff);
+ const seat = new THREE.Mesh(new THREE.BoxGeometry(1.55, 0.10, 0.68), loungeFrameMat);
+ const pad = new THREE.Mesh(new THREE.BoxGeometry(1.45, 0.06, 0.60), loungeCushionMat);
+ pad.position.y = 0.06;
+ const backrest = new THREE.Mesh(new THREE.BoxGeometry(0.62, 0.09, 0.66), loungeFrameMat);
+ backrest.position.set(-0.62, 0.22, 0);
+ backrest.rotation.z = -0.58;
+ chair.add(seat, pad, backrest);
+ ug.add(chair);
+ }
root.add(ug);
}
- // 9. Cilindro holográfico de objetivo / missão ativa
- const beaconGeo = new THREE.CylinderGeometry(3.8, 3.8, 14, 24, 1, true);
+ // Quadras de Vôlei de Praia (postes + rede branca + linhas na areia) e Bolas Voando em Tempo Real!
+ const animatedBeachBalls = [];
+ const ballGeo = new THREE.SphereGeometry(0.24, 12, 10);
+ const ballVolleyMat = new THREE.MeshStandardMaterial({ color: '#ffd166', roughness: 0.4 });
+ const ballAltinhaMat = new THREE.MeshStandardMaterial({ color: '#ffffff', roughness: 0.45 });
+ const netMat = new THREE.MeshBasicMaterial({ color: '#f8f9fa', wireframe: true });
+
+ for (const court of layout.beachCourts) {
+ if (court.kind === 'volleyball') {
+ const cg = new THREE.Group();
+ cg.position.set(court.x, 0, court.z);
+ for (const zPost of [-4.2, 4.2]) {
+ const post = new THREE.Mesh(new THREE.CylinderGeometry(0.07, 0.07, 2.55, 6), steelWhiteMat);
+ post.position.set(0, 1.25, zPost);
+ cg.add(post);
+ }
+ const net = new THREE.Mesh(new THREE.PlaneGeometry(8.2, 0.95, 14, 4), netMat);
+ net.rotation.y = Math.PI / 2;
+ net.position.set(0, 1.95, 0);
+ cg.add(net);
+ root.add(cg);
+
+ const ball = new THREE.Mesh(ballGeo, ballVolleyMat);
+ root.add(ball);
+ animatedBeachBalls.push({ mesh: ball, cx: court.x, cz: court.z, kind: 'volleyball', spanX: 3.6, phase: Math.random() * 6 });
+ } else {
+ const ball = new THREE.Mesh(ballGeo, ballAltinhaMat);
+ root.add(ball);
+ animatedBeachBalls.push({ mesh: ball, cx: court.x, cz: court.z, kind: 'altinha', radius: 2.3, phase: Math.random() * 6 });
+ }
+ }
+
+ // 12. SISTEMA DE PEGADAS DE PÉ NA AREIA (`InstancedMesh` circular de 180 pegadas — zero GC / zero travamento!)
+ const MAX_FOOTPRINTS = 180;
+ const footprintGeo = new THREE.PlaneGeometry(0.20, 0.40);
+ footprintGeo.rotateX(-Math.PI / 2);
+ const footprintMat = new THREE.MeshStandardMaterial({
+ color: '#b89460',
+ roughness: 0.95,
+ transparent: true,
+ opacity: 0.62,
+ polygonOffset: true,
+ polygonOffsetFactor: -2
+ });
+ const footprintInst = new THREE.InstancedMesh(footprintGeo, footprintMat, MAX_FOOTPRINTS);
+ footprintInst.instanceMatrix.setUsage(THREE.DynamicDrawUsage);
+ footprintInst.frustumCulled = false;
+
+ // Inicializa todas ocultas sob o solo
+ for (let i = 0; i < MAX_FOOTPRINTS; i += 1) {
+ dummy.position.set(0, -10, 0);
+ dummy.scale.setScalar(0.001);
+ dummy.updateMatrix();
+ footprintInst.setMatrixAt(i, dummy.matrix);
+ }
+ root.add(footprintInst);
+
+ let footprintCursor = 0;
+ let footprintTotalAdded = 0;
+
+ function addSandFootprint(x, z, yaw, isLeftFoot = true) {
+ const sideOffset = isLeftFoot ? 0.13 : -0.13;
+ const fx = x + Math.cos(yaw) * sideOffset;
+ const fz = z - Math.sin(yaw) * sideOffset;
+ dummy.position.set(fx, 0.024, fz);
+ dummy.rotation.set(0, yaw + (isLeftFoot ? 0.06 : -0.06), 0);
+ dummy.scale.set(1, 1, 1);
+ dummy.updateMatrix();
+ footprintInst.setMatrixAt(footprintCursor, dummy.matrix);
+ footprintInst.instanceMatrix.needsUpdate = true;
+ footprintCursor = (footprintCursor + 1) % MAX_FOOTPRINTS;
+ footprintTotalAdded += 1;
+ }
+
+ // 13. Cilindro holográfico de objetivo / missão ativa
+ const beaconGeo = new THREE.CylinderGeometry(3.8, 3.8, 14, 20, 1, true);
const beaconMat = new THREE.MeshBasicMaterial({
color: '#ff2a85',
transparent: true,
@@ -286,7 +2371,7 @@ export function buildCityScene(scene, { shadows = true } = {}) {
const missionBeacon = new THREE.Mesh(beaconGeo, beaconMat);
missionBeacon.position.set(274, 7, 22);
- const ringGeo = new THREE.RingGeometry(3.2, 4.3, 32);
+ const ringGeo = new THREE.RingGeometry(3.2, 4.3, 28);
const ringMat = new THREE.MeshBasicMaterial({ color: '#ffd166', side: THREE.DoubleSide });
const missionRing = new THREE.Mesh(ringGeo, ringMat);
missionRing.rotation.x = -Math.PI / 2;
@@ -304,8 +2389,195 @@ export function buildCityScene(scene, { shadows = true } = {}) {
beaconMat.color.set(color);
}
- function tickCity(elapsed) {
- foam.position.x = OCEAN_WATER_X - 1.5 + Math.sin(elapsed * 1.8) * 1.3;
+ let ferrisWheelAngle = 0;
+
+ let lastTickElapsed = 0;
+
+ function tickCity(elapsed, { nightFactor = 0, focusX = 300, focusZ = 28 } = {}) {
+ const tickDt = Math.min(0.05, Math.max(0.001, elapsed - lastTickElapsed));
+ lastTickElapsed = elapsed;
+
+ // 0. ONDAS OCEÂNICAS VÉRTICE A VÉRTICE (maré viva com swell longo + ondulação cruzada!)
+ const wPos = waterGeo.attributes.position;
+ const wArr = wPos.array;
+ const wTime = elapsed * 1.32;
+ for (let i = 0; i < wPos.count; i += 1) {
+ const bx = waterBasePositions[i * 3];
+ const by = waterBasePositions[i * 3 + 1];
+ wArr[i * 3 + 2] =
+ Math.sin(bx * 0.016 + wTime * 1.18) * 0.19
+ + Math.sin(by * 0.023 - wTime * 0.9) * 0.15
+ + Math.sin((bx + by) * 0.011 + wTime * 0.66) * 0.17
+ + Math.sin(Math.hypot(bx * 0.8, by) * 0.019 - wTime * 1.55) * 0.09;
+ }
+ wPos.needsUpdate = true;
+ waterGeo.computeVertexNormals();
+
+ // 1. Movimento da textura cáustica do mar + ondas quebrando na areia de Vice Beach!
+ if (waterTex) {
+ waterTex.offset.x = (elapsed * 0.018) % 1;
+ waterTex.offset.y = Math.sin(elapsed * 0.35) * 0.04;
+ }
+ if (farWaterTex) {
+ farWaterTex.offset.x = (elapsed * 0.006) % 1;
+ farWaterTex.offset.y = (elapsed * 0.0025) % 1;
+ }
+ for (const wc of waveCrests) {
+ const cycle = ((elapsed * 0.34 + wc.phaseOffset / (Math.PI * 2)) % 1);
+ // A onda nasce lá fora (+26m), ganha altura ao se aproximar e arrebenta na arrebentação (-3m)!
+ const distFromShore = 26 * (1 - cycle) - 3;
+ const shoaling = Math.pow(cycle, 1.35); // steepening antes de quebrar!
+ const crestH = Math.sin(Math.min(1, cycle * 1.06) * Math.PI) * (0.42 + shoaling * 0.5);
+ wc.group.position.x = OCEAN_WATER_X + distFromShore;
+ wc.group.position.y = -0.18 + crestH * 0.5;
+ // Inclinação frontal progressiva da face da onda
+ wc.group.rotation.z = -shoaling * 0.24;
+ const foamPeak = Math.sin(cycle * Math.PI);
+ wc.foam.material.opacity = Math.pow(foamPeak, 1.6) * 0.95;
+ wc.spray.material.opacity = Math.pow(foamPeak, 2.6) * 0.8;
+ wc.spray.scale.y = 1;
+ wc.spray.position.y = 0.34 + foamPeak * 0.22;
+ }
+
+ // 1.5 ARQUIPÉLAGO: faróis girando + veleiros balançando suavemente nas ondas!
+ for (const beam of lighthouseBeams) {
+ beam.rotation.y = elapsed * 0.85;
+ }
+ for (const boat of sailboats) {
+ boat.group.position.y = Math.sin(elapsed * 1.6 + boat.phase) * 0.16 - 0.05;
+ boat.group.rotation.x = Math.sin(elapsed * 1.35 + boat.phase * 1.7) * 0.055;
+ boat.group.rotation.z = Math.cos(elapsed * 1.1 + boat.phase) * 0.07;
+ boat.group.rotation.y = boat.baseYaw + Math.sin(elapsed * 0.4 + boat.phase) * 0.14;
+ }
+
+ // 1.6 TREM EXPRESSO METRORAIL em movimento com paradas nas estações!
+ const T = trainState;
+ if (T.hornCooldown > 0) T.hornCooldown = Math.max(0, T.hornCooldown - tickDt);
+ if (T.dwell > 0) {
+ T.dwell -= tickDt;
+ T.speed = 0;
+ } else {
+ // Desacelera ao se aproximar da próxima estação ou do fim da linha
+ let targetSpeed = 23;
+ let distToStop = Infinity;
+ let stopStation = null;
+ for (const st of TRAIN_LINE.stations) {
+ const ahead = (st.z - T.z) * T.dir;
+ if (ahead > 0 && ahead < distToStop) {
+ distToStop = ahead;
+ stopStation = st;
+ }
+ }
+ const endZ = T.dir > 0 ? TRAIN_LINE.zMax : TRAIN_LINE.zMin;
+ const distToEnd = (endZ - T.z) * T.dir;
+ if (stopStation && distToStop < 110) {
+ targetSpeed = Math.max(0, (distToStop - 2.5) * 0.30);
+ }
+ if (distToEnd < 80) {
+ targetSpeed = Math.min(targetSpeed, Math.max(0, distToEnd * 0.35));
+ }
+ const accel = targetSpeed >= T.speed ? 9.5 : 17;
+ T.speed += Math.sign(targetSpeed - T.speed) * Math.min(Math.abs(targetSpeed - T.speed), accel * tickDt);
+ T.z += T.dir * T.speed * tickDt;
+
+ // Chegou na estação: para 3.4s (embarque/desembarque!)
+ if (stopStation && distToStop <= 3.2 && T.speed < 1.6 && T.lastStopId !== stopStation.id) {
+ T.dwell = 3.4;
+ T.speed = 0;
+ T.lastStopId = stopStation.id;
+ }
+ // Fim da linha: inverte a direção com uma paradinha
+ if (distToEnd <= 2.5) {
+ T.dir *= -1;
+ T.dwell = 2.4;
+ T.lastStopId = null;
+ }
+ // Apita ao cruzar perto do jogador!
+ const distToPlayer = Math.hypot(focusX - trackX, focusZ - T.z);
+ if (distToPlayer < 42 && T.hornCooldown <= 0 && T.speed > 4) {
+ T.hornNeeded = true;
+ T.hornCooldown = 6.5;
+ }
+ }
+ trainGroup.position.z = T.z;
+ trainGroup.rotation.y = T.dir > 0 ? 0 : Math.PI;
+
+ // 1.7 Radar do aeroporto girando + faróis de aviação piscando!
+ radarBar.rotation.y = elapsed * 1.5;
+ const beaconBlink = (elapsed % 1.15) < 0.62;
+ towerBeacon.visible = beaconBlink;
+ bankBeacon.visible = beaconBlink;
+
+ // 1.8 Avião comercial no circuito de tráfego (decola, sobe e arrodeia a cidade!)
+ const planeAngle = elapsed * 0.085 + 2.1;
+ const planeRadius = 430 + Math.sin(elapsed * 0.05) * 90;
+ const planeAlt = 120 + Math.sin(elapsed * 0.11 + 1.3) * 42;
+ flyingPlane.position.set(Math.cos(planeAngle) * planeRadius, planeAlt, Math.sin(planeAngle) * planeRadius * 1.25 - 60);
+ flyingPlane.rotation.y = -planeAngle - Math.PI / 2 + Math.PI;
+ flyingPlane.rotation.z = 0.16;
+
+ // 2. Rotação contínua da Roda-Gigante e nivelamento gravimétrico das 10 cabines!
+ ferrisWheelAngle = (elapsed * 0.24) % (Math.PI * 2);
+ ferrisWheelSpinner.rotation.z = ferrisWheelAngle;
+ for (const cab of ferrisCabins) {
+ cab.pivot.rotation.z = -ferrisWheelAngle;
+ }
+
+ // 3. Trajetória parabólica das bolas de vôlei de praia e de altinha!
+ for (const b of animatedBeachBalls) {
+ const t = elapsed * 1.65 + b.phase;
+ if (b.kind === 'volleyball') {
+ const pingPong = Math.sin(t);
+ const arc = Math.abs(Math.cos(t));
+ b.mesh.position.set(b.cx + pingPong * b.spanX, 1.35 + arc * 2.55, b.cz + Math.sin(t * 0.5) * 0.8);
+ } else {
+ const ang = t * 1.25;
+ const arc = Math.abs(Math.sin(t * 2.2));
+ b.mesh.position.set(b.cx + Math.cos(ang) * b.radius, 0.95 + arc * 1.95, b.cz + Math.sin(ang) * b.radius);
+ }
+ }
+
+ // 4. Postes de Luz nas Calçadas: acendem ao anoitecer (`nightFactor > 0.25`) e iluminam os arredores!
+ const lampOn = Math.max(0, Math.min(1, (nightFactor - 0.22) / 0.45));
+ if (lampOn > 0.02) {
+ lampBulbMat.color.setRGB(0.25 + 0.75 * lampOn, 0.25 + 0.65 * lampOn, 0.32 + 0.35 * lampOn);
+ lampHaloMat.opacity = lampOn * 0.36;
+ groundGlowInst.visible = true;
+
+ // Posiciona as 2 PointLights reais nos 2 postes mais próximos do jogador!
+ let best1 = null;
+ let best2 = null;
+ let d1 = Infinity;
+ let d2 = Infinity;
+ for (const sl of layout.streetlights) {
+ const dSq = (sl.x - focusX) * (sl.x - focusX) + (sl.z - focusZ) * (sl.z - focusZ);
+ if (dSq < d1) {
+ d2 = d1; best2 = best1;
+ d1 = dSq; best1 = sl;
+ } else if (dSq < d2) {
+ d2 = dSq; best2 = sl;
+ }
+ }
+ const chosen = [best1, best2];
+ for (let i = 0; i < 2; i += 1) {
+ const sl = chosen[i];
+ if (sl) {
+ activeStreetPointLights[i].position.set(sl.x, 5.8, sl.z);
+ activeStreetPointLights[i].intensity = lampOn * 2.6;
+ } else {
+ activeStreetPointLights[i].intensity = 0;
+ }
+ }
+ } else {
+ lampBulbMat.color.set('#3a3f54');
+ lampHaloMat.opacity = 0;
+ groundGlowInst.visible = false;
+ activeStreetPointLights[0].intensity = 0;
+ activeStreetPointLights[1].intensity = 0;
+ }
+
+ // 5. Brilho pulsante do cofre do banco e do marcador de missão
+ vaultGlowRing.scale.setScalar(1 + Math.sin(elapsed * 5) * 0.08);
missionRing.scale.setScalar(1 + Math.sin(elapsed * 4.2) * 0.08);
beaconMat.opacity = 0.26 + Math.sin(elapsed * 3.5) * 0.1;
}
@@ -314,7 +2586,27 @@ export function buildCityScene(scene, { shadows = true } = {}) {
root,
colliders,
layout,
+ ferrisCabins,
+ lootGroup,
+ addSandFootprint,
+ getFootprintCount: () => footprintTotalAdded,
setBeaconTarget,
+ train: {
+ trackX: TRAIN_LINE.trackX,
+ zMin: TRAIN_LINE.zMin,
+ zMax: TRAIN_LINE.zMax,
+ halfLength: trainState.halfLength,
+ stations: TRAIN_LINE.stations,
+ getZ: () => trainState.z,
+ getSpeed: () => trainState.speed,
+ consumeHorn: () => {
+ if (trainState.hornNeeded) {
+ trainState.hornNeeded = false;
+ return true;
+ }
+ return false;
+ }
+ },
tickCity
};
}
diff --git a/vice-game/src/world/controls.js b/vice-game/src/world/controls.js
index fdb09334..6cd8a5e5 100644
--- a/vice-game/src/world/controls.js
+++ b/vice-game/src/world/controls.js
@@ -201,8 +201,9 @@ export function createTouchAndKeyControls({
else if (code === 'KeyQ' || code === 'Tab') {
e.preventDefault();
onAction?.('cycle-weapon');
- } else if (code === 'KeyC') onAction?.('switch-character');
+ } else if (code === 'KeyX') onAction?.('surrender');
else if (code === 'KeyH') onAction?.('horn');
+ else if (code === 'KeyG') onAction?.('open-garage');
else if (code === 'KeyM') onAction?.('open-map');
else if (code === 'Escape' || code === 'KeyP') onAction?.('pause');
else if (code === 'Space' && !state.drivingMode) onAction?.('jump');
diff --git a/vice-game/src/world/engine.js b/vice-game/src/world/engine.js
index 82af6347..0f8727c0 100644
--- a/vice-game/src/world/engine.js
+++ b/vice-game/src/world/engine.js
@@ -1,43 +1,50 @@
// Motor 3D de Vice Leonida (three.js local): texturas procedurais de asfalto,
-// fachadas Art Déco iluminadas, água do oceano/baía, céu com ciclo dia/pôr do sol/noite neon.
+// fachadas Art Déco, arranha-céus e casas tropicais, água do oceano/baía e
+// Abóbada Celeste 3D dinâmica (Dia: céu azul celeste, Sol radiante e nuvens volumétricas;
+// Noite: céu preto profundo, constelações estreladas e Lua brilhante!).
import * as THREE from '../../vendor/three.module.min.js';
export { THREE };
+// Velocidade oficial do ciclo Dia <-> Noite:
+// 12 horas do jogo (ex.: 12:00 meio-dia -> 00:00 meia-noite ou 00:00 -> 12:00) em exatos 10 minutos (600 s).
+export const DAY_TO_NIGHT_SECONDS = 600;
+export const GAME_HOURS_PER_SECOND = 12 / DAY_TO_NIGHT_SECONDS; // 0.02 h/s (ciclo completo 24h = 20 min)
+
export const QUALITY_PRESETS = Object.freeze({
low: {
id: 'low',
- label: 'Leve (60 FPS Mobile)',
- pixelRatio: 1.0,
+ label: 'Leve (Zero Travamento Mobile)',
+ pixelRatio: 0.9,
antialias: false,
shadows: false,
shadowSize: 512,
- trafficCount: 14,
- pedCount: 16,
- drawDistance: 270
+ trafficCount: 10,
+ pedCount: 12,
+ drawDistance: 320
},
medium: {
id: 'medium',
- label: 'Médio (Equilibrado)',
- pixelRatio: 1.25,
+ label: 'Equilibrado (60 FPS Recomendado)',
+ pixelRatio: 1.15,
antialias: false,
- shadows: true,
- shadowSize: 1024,
- trafficCount: 22,
- pedCount: 24,
- drawDistance: 360
+ shadows: false,
+ shadowSize: 512,
+ trafficCount: 16,
+ pedCount: 18,
+ drawDistance: 430
},
high: {
id: 'high',
label: 'Ultra Vice Neon',
- pixelRatio: 1.5,
+ pixelRatio: 1.35,
antialias: true,
shadows: true,
shadowSize: 1024,
- trafficCount: 30,
- pedCount: 32,
- drawDistance: 460
+ trafficCount: 22,
+ pedCount: 24,
+ drawDistance: 540
}
});
@@ -72,6 +79,36 @@ export function buildingFacadeTexture({ wall = '#fff1e6', accent = '#ff4fa3', ne
ctx.fillStyle = wall;
ctx.fillRect(0, 0, w, h);
+ if (style === 'house') {
+ // Fachada residencial de casa/mansão em Leonida: varanda, janelas grandes com venezianas e porta dupla
+ ctx.fillStyle = accent;
+ ctx.fillRect(0, h - 18, w, 18);
+ ctx.fillRect(0, 0, w, 10);
+
+ const cols = 3;
+ const rows = 2;
+ const padX = 14;
+ const padY = 34;
+ const cellW = (w - padX * 2) / cols;
+ const cellH = 66;
+ for (let r = 0; r < rows; r += 1) {
+ for (let c = 0; c < cols; c += 1) {
+ if (r === 1 && c === 1) continue; // espaço para porta principal
+ ctx.fillStyle = '#243046';
+ ctx.fillRect(padX + c * cellW + 4, padY + r * cellH, cellW - 8, 42);
+ ctx.fillStyle = 'rgba(255, 240, 185, 0.9)';
+ ctx.fillRect(padX + c * cellW + 7, padY + r * cellH + 3, cellW - 14, 36);
+ }
+ }
+
+ // Porta residencial e porta de garagem lateral
+ ctx.fillStyle = '#5c3a21';
+ ctx.fillRect(w * 0.41, h - 54, w * 0.18, 54);
+ ctx.fillStyle = '#dfe7fd';
+ ctx.fillRect(10, h - 46, 28, 46);
+ return;
+ }
+
// Faixas verticais Art Déco ou arranha-céu corporativo
ctx.fillStyle = accent;
if (style === 'art-deco' || style === 'strip') {
@@ -80,11 +117,10 @@ export function buildingFacadeTexture({ wall = '#fff1e6', accent = '#ff4fa3', ne
ctx.fillRect(0, 0, w, 14);
ctx.fillRect(0, h - 28, w, 8);
} else if (style === 'skyscraper') {
- ctx.fillStyle = 'rgba(255,255,255,0.06)';
+ ctx.fillStyle = 'rgba(255,255,255,0.08)';
for (let x = 8; x < w; x += 16) ctx.fillRect(x, 0, 2, h);
}
- // Grade de janelas iluminadas
const rows = style === 'skyscraper' ? 16 : 9;
const cols = 4;
const padX = 16;
@@ -96,9 +132,9 @@ export function buildingFacadeTexture({ wall = '#fff1e6', accent = '#ff4fa3', ne
for (let c = 0; c < cols; c += 1) {
const lit = ((r * 7 + c * 13) % 5) !== 0;
if (style === 'skyscraper') {
- ctx.fillStyle = lit ? 'rgba(130, 232, 255, 0.78)' : 'rgba(15, 25, 42, 0.85)';
+ ctx.fillStyle = lit ? 'rgba(130, 232, 255, 0.82)' : 'rgba(15, 25, 42, 0.88)';
} else {
- ctx.fillStyle = lit ? 'rgba(255, 235, 175, 0.88)' : 'rgba(34, 42, 68, 0.68)';
+ ctx.fillStyle = lit ? 'rgba(255, 235, 175, 0.9)' : 'rgba(34, 42, 68, 0.72)';
}
ctx.fillRect(
padX + c * cellW + 3,
@@ -109,12 +145,10 @@ export function buildingFacadeTexture({ wall = '#fff1e6', accent = '#ff4fa3', ne
}
}
- // Faixa neon luminosa no térreo / topo para dar clima de Vice City / GTA 6
ctx.fillStyle = neon;
ctx.fillRect(8, 14, w - 16, 4);
ctx.fillRect(12, h - 34, w - 24, 5);
- // Porta do lobby no térreo
ctx.fillStyle = '#141a29';
ctx.fillRect(w * 0.36, h - 24, w * 0.28, 24);
});
@@ -127,16 +161,13 @@ export function createRoadTexture() {
return makeCanvasTexture(128, 128, (ctx, w, h) => {
ctx.fillStyle = '#252834';
ctx.fillRect(0, 0, w, h);
- // Granulado leve de asfalto
for (let i = 0; i < 240; i += 1) {
ctx.fillStyle = i % 2 ? 'rgba(255,255,255,0.035)' : 'rgba(0,0,0,0.08)';
ctx.fillRect((i * 37) % w, (i * 53) % h, 2, 2);
}
- // Linhas laterais contínuas
ctx.fillStyle = 'rgba(255,255,255,0.5)';
ctx.fillRect(5, 0, 3, h);
ctx.fillRect(w - 8, 0, 3, h);
- // Faixa dupla amarela / tracejada central
ctx.fillStyle = '#ffd166';
for (let y = 8; y < h; y += 32) {
ctx.fillRect(w * 0.5 - 2, y, 4, 18);
@@ -144,6 +175,366 @@ export function createRoadTexture() {
}, { repeatX: 1, repeatY: 42 });
}
+export function createSandTexture() {
+ return makeCanvasTexture(256, 256, (ctx, w, h) => {
+ const grad = ctx.createLinearGradient(0, 0, w, h);
+ grad.addColorStop(0, '#f7e5be');
+ grad.addColorStop(0.5, '#f2d9a2');
+ grad.addColorStop(1, '#edd193');
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, w, h);
+ // Ondulações sutis do vento na areia + grãos de quartzo e conchas claras
+ for (let y = 0; y < h; y += 8) {
+ ctx.fillStyle = 'rgba(255, 250, 235, 0.24)';
+ ctx.fillRect(0, y, w, 3);
+ ctx.fillStyle = 'rgba(180, 145, 92, 0.14)';
+ ctx.fillRect(0, y + 4, w, 2);
+ }
+ let s = 4242;
+ for (let i = 0; i < 700; i += 1) {
+ s = (s * 1664525 + 1013904223) >>> 0;
+ const gx = (s % w);
+ const gy = ((s >>> 8) % h);
+ ctx.fillStyle = (i % 3 === 0) ? 'rgba(255,255,255,0.45)' : 'rgba(150,115,68,0.22)';
+ ctx.fillRect(gx, gy, 2, 2);
+ }
+ }, { repeatX: 6, repeatY: 48 });
+}
+
+export function createOceanWaterTexture() {
+ return makeCanvasTexture(256, 256, (ctx, w, h) => {
+ const grad = ctx.createLinearGradient(0, 0, w, h);
+ grad.addColorStop(0, '#005f87');
+ grad.addColorStop(0.5, '#0077a8');
+ grad.addColorStop(1, '#005b82');
+ ctx.fillStyle = grad;
+ ctx.fillRect(0, 0, w, h);
+
+ // Cristas direcionais de ondas oceânicas + malha cáustica turquesa/branca realista
+ for (let y = 4; y < h; y += 16) {
+ ctx.strokeStyle = 'rgba(144, 224, 239, 0.28)';
+ ctx.lineWidth = 2.2;
+ ctx.beginPath();
+ for (let x = 0; x <= w; x += 16) {
+ const wy = y + Math.sin((x / w) * Math.PI * 4 + y * 0.1) * 3.5;
+ if (x === 0) ctx.moveTo(x, wy);
+ else ctx.lineTo(x, wy);
+ }
+ ctx.stroke();
+ }
+ for (let i = 0; i < 72; i += 1) {
+ const cx = (i * 53) % w;
+ const cy = (i * 89) % h;
+ ctx.strokeStyle = i % 3 === 0 ? 'rgba(255, 255, 255, 0.22)' : 'rgba(72, 202, 228, 0.28)';
+ ctx.lineWidth = 1.8;
+ ctx.beginPath();
+ ctx.ellipse(cx, cy, 20, 7, (i % 4) * 0.35, 0, Math.PI * 2);
+ ctx.stroke();
+ }
+ }, { repeatX: 44, repeatY: 44 });
+}
+
+export function createBankStoneTexture() {
+ return makeCanvasTexture(256, 256, (ctx, w, h) => {
+ // Cantaria neoclássica de granito/calcário com juntas de blocos, frisos dourados e janelas espelhadas!
+ ctx.fillStyle = '#e7e2d8';
+ ctx.fillRect(0, 0, w, h);
+ const rowH = 32;
+ for (let y = 0; y < h; y += rowH) {
+ ctx.fillStyle = (y / rowH) % 2 === 0 ? 'rgba(255,255,255,0.22)' : 'rgba(190,180,164,0.20)';
+ ctx.fillRect(0, y, w, rowH - 2);
+ ctx.fillStyle = 'rgba(115, 105, 92, 0.45)';
+ ctx.fillRect(0, y + rowH - 2, w, 2);
+ const offset = ((y / rowH) % 2) * 32;
+ for (let x = offset; x < w; x += 64) {
+ ctx.fillRect(x, y, 2, rowH);
+ }
+ }
+ // Friso imperial dourado e janelas verticais blindadas do edifício bancário
+ ctx.fillStyle = '#c9a227';
+ ctx.fillRect(0, 12, w, 6);
+ ctx.fillRect(0, h - 18, w, 6);
+ for (let wx = 20; wx < w - 24; wx += 56) {
+ ctx.fillStyle = '#1b263b';
+ ctx.fillRect(wx, 38, 30, h - 74);
+ ctx.fillStyle = '#415a77';
+ ctx.fillRect(wx + 3, 42, 24, h - 82);
+ ctx.strokeStyle = '#c9a227';
+ ctx.lineWidth = 2;
+ ctx.strokeRect(wx, 38, 30, h - 74);
+ }
+ }, { repeatX: 2, repeatY: 2 });
+}
+
+export function createMarbleFloorTexture() {
+ return makeCanvasTexture(256, 256, (ctx, w, h) => {
+ ctx.fillStyle = '#f1efe9';
+ ctx.fillRect(0, 0, w, h);
+ const tile = 64;
+ for (let y = 0; y < h; y += tile) {
+ for (let x = 0; x < w; x += tile) {
+ const dark = ((x / tile + y / tile) % 2 === 0);
+ ctx.fillStyle = dark ? '#dcd8ce' : '#f6f4ef';
+ ctx.fillRect(x + 1, y + 1, tile - 2, tile - 2);
+ // Veios sutis de mármore Carrara
+ ctx.strokeStyle = 'rgba(140, 135, 125, 0.28)';
+ ctx.lineWidth = 1.4;
+ ctx.beginPath();
+ ctx.moveTo(x + 6, y + 12);
+ ctx.bezierCurveTo(x + 26, y + 28, x + 38, y + 20, x + tile - 8, y + tile - 10);
+ ctx.stroke();
+ }
+ }
+ }, { repeatX: 6, repeatY: 6 });
+}
+
+export function createRunwayTexture() {
+ return makeCanvasTexture(256, 256, (ctx, w, h) => {
+ ctx.fillStyle = '#22252e';
+ ctx.fillRect(0, 0, w, h);
+ // Marcas de pneu de pouso no centro e cabeceira zebrada da pista de aeroporto!
+ ctx.fillStyle = 'rgba(0,0,0,0.28)';
+ ctx.fillRect(w * 0.34, 0, w * 0.32, h);
+ ctx.fillStyle = '#f8f9fa';
+ ctx.fillRect(10, 0, 5, h);
+ ctx.fillRect(w - 15, 0, 5, h);
+ for (let y = 12; y < h; y += 48) {
+ ctx.fillRect(w * 0.5 - 4, y, 8, 28);
+ }
+ }, { repeatX: 1, repeatY: 18 });
+}
+
+export function createLeonidaEnvironmentMap(renderer) {
+ if (!renderer || typeof THREE.PMREMGenerator !== 'function') return null;
+ const envScene = new THREE.Scene();
+ envScene.background = new THREE.Color('#2a3d66');
+
+ const skyDome = new THREE.Mesh(
+ new THREE.SphereGeometry(28, 24, 16),
+ new THREE.MeshBasicMaterial({ color: '#56b4f5', side: THREE.BackSide })
+ );
+ envScene.add(skyDome);
+
+ const horizonBand = new THREE.Mesh(
+ new THREE.CylinderGeometry(26, 26, 9, 24, 1, true),
+ new THREE.MeshBasicMaterial({ color: '#ffd6a5', side: THREE.BackSide })
+ );
+ horizonBand.position.y = 3.5;
+ envScene.add(horizonBand);
+
+ const groundDisc = new THREE.Mesh(
+ new THREE.CircleGeometry(27, 24),
+ new THREE.MeshBasicMaterial({ color: '#1b2236', side: THREE.DoubleSide })
+ );
+ groundDisc.rotation.x = -Math.PI / 2;
+ groundDisc.position.y = -4;
+ envScene.add(groundDisc);
+
+ const studioPanels = [
+ { pos: [0, 16, 8], rot: [Math.PI / 2.3, 0, 0], size: [18, 9], color: '#ffffff' },
+ { pos: [-14, 7, 6], rot: [0, Math.PI / 2.4, 0], size: [12, 5], color: '#00f5d4' },
+ { pos: [14, 7, -4], rot: [0, -Math.PI / 2.4, 0], size: [12, 5], color: '#ff2a85' },
+ { pos: [0, 9, -15], rot: [0, 0, 0], size: [16, 6], color: '#ffd166' }
+ ];
+ for (const p of studioPanels) {
+ const panel = new THREE.Mesh(
+ new THREE.PlaneGeometry(p.size[0], p.size[1]),
+ new THREE.MeshBasicMaterial({ color: p.color, side: THREE.DoubleSide })
+ );
+ panel.position.set(p.pos[0], p.pos[1], p.pos[2]);
+ panel.rotation.set(p.rot[0], p.rot[1], p.rot[2]);
+ envScene.add(panel);
+ }
+
+ const pmrem = new THREE.PMREMGenerator(renderer);
+ pmrem.compileCubemapShader();
+ const envRT = pmrem.fromScene(envScene, 0.035);
+ pmrem.dispose();
+ return envRT;
+}
+
+/**
+ * Constrói o Domo Celeste 3D que acompanha a câmera:
+ * - Estrelas cintilantes no céu preto à noite (`Points`);
+ * - Lua cheia com halo prateado e crateras sutis à noite;
+ * - Sol dourado radiante com corona durante o dia;
+ * - Nuvens 3D fofas brancas navegando pelo céu azul durante o dia!
+ */
+export function createCelestialRig(drawDistance = 460) {
+ const skyRadius = Math.max(220, drawDistance * 0.78); // chamado com ~6100 => domo ~4760m (além do oceano até o horizonte)
+ const rig = new THREE.Group();
+ rig.name = 'vice-celestial-sky';
+
+ // 1. Campo de estrelas (850 estrelas distribuídas no hemisfério superior)
+ const starCount = 850;
+ const starPositions = new Float32Array(starCount * 3);
+ const starColors = new Float32Array(starCount * 3);
+ let seed = 90210;
+ const rnd = () => {
+ seed = (seed * 1664525 + 1013904223) >>> 0;
+ return seed / 4294967296;
+ };
+
+ for (let i = 0; i < starCount; i += 1) {
+ const theta = rnd() * Math.PI * 2;
+ const phi = Math.acos(0.06 + rnd() * 0.94); // apenas acima do horizonte
+ const r = skyRadius * (0.92 + rnd() * 0.05);
+ starPositions[i * 3] = r * Math.sin(phi) * Math.cos(theta);
+ starPositions[i * 3 + 1] = r * Math.cos(phi);
+ starPositions[i * 3 + 2] = r * Math.sin(phi) * Math.sin(theta);
+
+ const tint = rnd();
+ const c = tint < 0.2 ? [0.75, 0.88, 1.0] : tint < 0.35 ? [1.0, 0.94, 0.78] : [1.0, 1.0, 1.0];
+ starColors[i * 3] = c[0];
+ starColors[i * 3 + 1] = c[1];
+ starColors[i * 3 + 2] = c[2];
+ }
+
+ const starGeo = new THREE.BufferGeometry();
+ starGeo.setAttribute('position', new THREE.BufferAttribute(starPositions, 3));
+ starGeo.setAttribute('color', new THREE.BufferAttribute(starColors, 3));
+ const starMat = new THREE.PointsMaterial({
+ size: 2.3,
+ sizeAttenuation: false,
+ vertexColors: true,
+ transparent: true,
+ opacity: 0,
+ fog: false,
+ depthWrite: false
+ });
+ const stars = new THREE.Points(starGeo, starMat);
+ rig.add(stars);
+
+ // 2. Sol 3D + halo luminoso (fog: false para brilhar sempre nítido no horizonte e no zênite)
+ const sunGroup = new THREE.Group();
+ const sunCoreMat = new THREE.MeshBasicMaterial({ color: '#fff8d6', fog: false, depthWrite: false });
+ const sunHaloMat = new THREE.MeshBasicMaterial({
+ color: '#ffd166',
+ transparent: true,
+ opacity: 0.42,
+ fog: false,
+ depthWrite: false,
+ side: THREE.DoubleSide
+ });
+ const sunCore = new THREE.Mesh(new THREE.SphereGeometry(skyRadius * 0.052, 20, 20), sunCoreMat);
+ const sunHalo = new THREE.Mesh(new THREE.SphereGeometry(skyRadius * 0.095, 20, 20), sunHaloMat);
+ sunGroup.add(sunCore, sunHalo);
+ rig.add(sunGroup);
+
+ // 3. Lua 3D prateada + halo noturno azulado
+ const moonGroup = new THREE.Group();
+ const moonTex = makeCanvasTexture(128, 128, (ctx, w, h) => {
+ ctx.fillStyle = '#f4f6fb';
+ ctx.fillRect(0, 0, w, h);
+ // Crateras lunares suaves
+ const craters = [[38, 44, 14], [84, 52, 18], [58, 86, 12], [30, 88, 9], [92, 92, 10], [66, 28, 8]];
+ for (const [cx, cy, cr] of craters) {
+ ctx.fillStyle = 'rgba(175, 186, 210, 0.55)';
+ ctx.beginPath();
+ ctx.arc(cx, cy, cr, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ });
+ const moonCoreMat = new THREE.MeshBasicMaterial({
+ map: moonTex || null,
+ color: '#f8f9ff',
+ fog: false,
+ depthWrite: false
+ });
+ const moonHaloMat = new THREE.MeshBasicMaterial({
+ color: '#a8dadc',
+ transparent: true,
+ opacity: 0.3,
+ fog: false,
+ depthWrite: false
+ });
+ const moonCore = new THREE.Mesh(new THREE.SphereGeometry(skyRadius * 0.044, 20, 20), moonCoreMat);
+ const moonHalo = new THREE.Mesh(new THREE.SphereGeometry(skyRadius * 0.082, 20, 20), moonHaloMat);
+ moonGroup.add(moonCore, moonHalo);
+ rig.add(moonGroup);
+
+ // 4. Anel de Nuvens 3D fofas no céu diurno
+ const cloudsGroup = new THREE.Group();
+ const cloudMat = new THREE.MeshBasicMaterial({
+ color: '#ffffff',
+ transparent: true,
+ opacity: 0.9,
+ fog: false,
+ depthWrite: false
+ });
+ const puffGeo = new THREE.SphereGeometry(1, 10, 8);
+
+ const cloudCount = 22;
+ for (let i = 0; i < cloudCount; i += 1) {
+ const cluster = new THREE.Group();
+ const ang = (i / cloudCount) * Math.PI * 2 + rnd() * 0.22;
+ const dist = skyRadius * (0.48 + rnd() * 0.36);
+ const height = skyRadius * (0.22 + rnd() * 0.28);
+
+ const puffs = 4 + (i % 3);
+ for (let p = 0; p < puffs; p += 1) {
+ const puff = new THREE.Mesh(puffGeo, cloudMat);
+ const w = 13 + rnd() * 14;
+ const h = 5.5 + rnd() * 4.5;
+ puff.scale.set(w, h, w * 0.72);
+ puff.position.set((p - (puffs - 1) * 0.5) * 11, (p % 2 === 0 ? 1.5 : -0.5), (rnd() - 0.5) * 6);
+ cluster.add(puff);
+ }
+ cluster.position.set(Math.cos(ang) * dist, height, Math.sin(ang) * dist);
+ cluster.lookAt(0, height * 0.85, 0);
+ cloudsGroup.add(cluster);
+ }
+ rig.add(cloudsGroup);
+
+ function update(hour, focusX, focusZ, nightFactor, dt = 0.016) {
+ rig.position.set(focusX, 0, focusZ);
+
+ // Orbita solar/lunar (6h nasce a leste +X, 12h topo +Y, 18h põe-se a oeste -X, 0h Lua no topo!)
+ const sunAngle = ((hour - 6) / 24) * Math.PI * 2;
+ const orbitR = skyRadius * 0.86;
+ const sx = Math.cos(sunAngle) * orbitR;
+ const sy = Math.sin(sunAngle) * orbitR;
+ const sz = -orbitR * 0.28;
+
+ sunGroup.position.set(sx, sy, sz);
+ sunGroup.visible = sy > -18;
+ if (sy < 35) {
+ sunCoreMat.color.set('#ffb703');
+ sunHaloMat.color.set('#ff4fa3');
+ } else {
+ sunCoreMat.color.set('#fffbe6');
+ sunHaloMat.color.set('#ffd166');
+ }
+
+ // Lua exatamente oposta ao Sol (brilha alta das 18h às 6h!)
+ const mx = -sx;
+ const my = -sy;
+ const mz = -sz;
+ moonGroup.position.set(mx, my, mz);
+ moonGroup.visible = my > -12;
+ moonHaloMat.opacity = 0.16 + nightFactor * 0.24;
+
+ // Estrelas aparecem nítidas no céu preto noturno e somem de dia
+ starMat.opacity = Math.max(0, Math.min(1, (nightFactor - 0.18) / 0.65));
+ stars.visible = starMat.opacity > 0.02;
+ stars.rotation.y += dt * 0.004;
+
+ // Nuvens brancas de dia -> ficam tênues/azuladas no crepúsculo e discretas à noite
+ cloudsGroup.rotation.y += dt * 0.012;
+ const dayVisibility = 1 - nightFactor;
+ cloudMat.opacity = 0.14 + dayVisibility * 0.78;
+ if (nightFactor > 0.65) {
+ cloudMat.color.set('#1b263b');
+ } else if (nightFactor > 0.2) {
+ cloudMat.color.set('#ffc8dd');
+ } else {
+ cloudMat.color.set('#ffffff');
+ }
+ }
+
+ return { rig, stars, sunGroup, moonGroup, cloudsGroup, update };
+}
+
export function createEngine(canvas, qualityId = 'high') {
const preset = getQualityPreset(qualityId);
const renderer = new THREE.WebGLRenderer({
@@ -157,25 +548,30 @@ export function createEngine(canvas, qualityId = 'high') {
renderer.setSize(window.innerWidth || 1280, window.innerHeight || 720, false);
renderer.outputColorSpace = THREE.SRGBColorSpace;
renderer.toneMapping = THREE.ACESFilmicToneMapping;
- renderer.toneMappingExposure = 1.08;
+ renderer.toneMappingExposure = 1.15;
renderer.shadowMap.enabled = preset.shadows;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
const scene = new THREE.Scene();
- scene.background = new THREE.Color('#ff8566');
- scene.fog = new THREE.FogExp2('#ff8566', 0.0022);
+ scene.background = new THREE.Color('#38a3f1');
+ scene.fog = new THREE.FogExp2('#38a3f1', 0.00045); // névoa atmosférica leve: água visível até o horizonte!
+
+ const envRT = createLeonidaEnvironmentMap(renderer);
+ if (envRT) {
+ scene.environment = envRT.texture;
+ }
const camera = new THREE.PerspectiveCamera(
60,
(window.innerWidth || 1280) / Math.max(1, window.innerHeight || 720),
0.4,
- preset.drawDistance
+ Math.max(5200, preset.drawDistance * 8) // Horizonte completo: o mar se estende até onde a vista alcança!
);
- const hemi = new THREE.HemisphereLight('#ffd6e8', '#28364a', 1.05);
+ const hemi = new THREE.HemisphereLight('#dff6ff', '#2b3a4a', 1.15);
scene.add(hemi);
- const sun = new THREE.DirectionalLight('#ffb482', 1.55);
+ const sun = new THREE.DirectionalLight('#fff6df', 1.65);
sun.position.set(140, 165, -90);
if (preset.shadows) {
sun.castShadow = true;
@@ -191,6 +587,9 @@ export function createEngine(canvas, qualityId = 'high') {
scene.add(sun);
scene.add(sun.target);
+ const celestial = createCelestialRig(Math.max(6100, preset.drawDistance * 10)); // Domo celeste gigante p/ horizonte do oceano
+ scene.add(celestial.rig);
+
function resize() {
const w = window.innerWidth || 1280;
const h = Math.max(1, window.innerHeight || 720);
@@ -199,64 +598,98 @@ export function createEngine(canvas, qualityId = 'high') {
renderer.setSize(w, h, false);
}
- // Atualiza cores do céu/luz conforme horário (0..24h) em Leonida
- const cDaySky = new THREE.Color('#56cfe1');
- const cSunsetSky = new THREE.Color('#ff6b8b');
- const cNightSky = new THREE.Color('#0b1026');
- const cSunDay = new THREE.Color('#fff3d6');
- const cSunSet = new THREE.Color('#ff7b54');
- const cSunNight = new THREE.Color('#5e60ce');
+ // Paleta Dia Azul / Fim de Tarde Meio Rosa de Leonida / Noite Preta Estrelada
+ const cDaySky = new THREE.Color('#2ea8ff');
+ const cSunsetSky = new THREE.Color('#e85d99'); // Céu meio rosa/coral icônico de fim de tarde em Vice!
+ const cNightSky = new THREE.Color('#02030a'); // Céu preto real à noite!
+ const cSunDay = new THREE.Color('#fff8e6');
+ const cSunSet = new THREE.Color('#ff8c69');
+ const cMoonNight = new THREE.Color('#8ecae6');
const workSky = new THREE.Color();
- const workSun = new THREE.Color();
+ const workLight = new THREE.Color();
- function updateAtmosphere(hour, focusX, focusZ) {
- // 6h-16h: dia ensolarado tropical; 16h-20h: pôr do sol rosa/laranja GTA 6; 20h-6h: noite neon
+ function updateAtmosphere(hour, focusX, focusZ, dt = 0.016) {
+ // 6h30–17h00: Dia azul celeste com Sol e nuvens brancas
+ // 17h00–19h30: Pôr do sol tropical
+ // 19h30–05h00: Noite de céu preto (#02030a), estrelas e Lua brilhante
+ // 05h00–06h30: Amanhecer dourado
let nightFactor = 0;
- if (hour >= 6 && hour < 16) {
- const t = (hour - 6) / 10;
- workSky.copy(cDaySky).lerp(cSunsetSky, Math.max(0, t - 0.75) * 2.2);
- workSun.copy(cSunDay);
- sun.intensity = 1.65;
- hemi.intensity = 1.15;
- } else if (hour >= 16 && hour < 20.5) {
- const t = (hour - 16) / 4.5;
- if (t < 0.55) {
- workSky.copy(cDaySky).lerp(cSunsetSky, t / 0.55);
- workSun.copy(cSunDay).lerp(cSunSet, t / 0.55);
+
+ if (hour >= 6.5 && hour < 17.0) {
+ const late = Math.max(0, (hour - 15.5) / 1.5);
+ workSky.copy(cDaySky).lerp(cSunsetSky, late * 0.35);
+ workLight.copy(cSunDay);
+ sun.intensity = 1.72;
+ hemi.intensity = 1.18;
+ hemi.color.set('#e0f4ff');
+ scene.environmentIntensity = 1.15;
+ } else if (hour >= 17.0 && hour < 19.5) {
+ const t = (hour - 17.0) / 2.5;
+ if (t < 0.5) {
+ const k = t / 0.5;
+ workSky.copy(cDaySky).lerp(cSunsetSky, 0.35 + k * 0.65);
+ workLight.copy(cSunDay).lerp(cSunSet, k);
+ nightFactor = k * 0.25;
} else {
- const k = (t - 0.55) / 0.45;
+ const k = (t - 0.5) / 0.5;
workSky.copy(cSunsetSky).lerp(cNightSky, k);
- workSun.copy(cSunSet).lerp(cSunNight, k);
- nightFactor = k;
+ workLight.copy(cSunSet).lerp(cMoonNight, k);
+ nightFactor = 0.25 + k * 0.75;
}
- sun.intensity = 1.55 - t * 0.9;
- hemi.intensity = 1.05 - t * 0.35;
+ sun.intensity = 1.65 - t * 1.05;
+ hemi.intensity = 1.12 - t * 0.48;
+ hemi.color.set('#ffd6e8');
+ scene.environmentIntensity = 1.05 - nightFactor * 0.45;
+ } else if (hour >= 5.0 && hour < 6.5) {
+ const t = (hour - 5.0) / 1.5;
+ if (t < 0.5) {
+ const k = t / 0.5;
+ workSky.copy(cNightSky).lerp(cSunsetSky, k);
+ workLight.copy(cMoonNight).lerp(cSunSet, k);
+ nightFactor = 1 - k * 0.65;
+ } else {
+ const k = (t - 0.5) / 0.5;
+ workSky.copy(cSunsetSky).lerp(cDaySky, k);
+ workLight.copy(cSunSet).lerp(cSunDay, k);
+ nightFactor = 0.35 * (1 - k);
+ }
+ sun.intensity = 0.6 + t * 1.1;
+ hemi.intensity = 0.64 + t * 0.52;
+ hemi.color.set('#ffe5ec');
+ scene.environmentIntensity = 0.65 + (1 - nightFactor) * 0.5;
} else {
+ // Noite profunda: céu preto estrelado + luz da Lua
nightFactor = 1;
- const dawn = hour >= 4.5 && hour < 6 ? (hour - 4.5) / 1.5 : 0;
- workSky.copy(cNightSky).lerp(cSunsetSky, dawn * 0.7);
- workSun.copy(cSunNight).lerp(cSunSet, dawn);
- sun.intensity = 0.58 + dawn * 0.5;
- hemi.intensity = 0.72 + dawn * 0.25;
+ workSky.copy(cNightSky);
+ workLight.copy(cMoonNight);
+ sun.intensity = 0.62;
+ hemi.intensity = 0.62;
+ hemi.color.set('#485680');
+ scene.environmentIntensity = 0.58;
}
scene.background.copy(workSky);
scene.fog.color.copy(workSky);
- sun.color.copy(workSun);
+ sun.color.copy(workLight);
- const angle = ((hour - 6) / 24) * Math.PI * 2;
+ const orbitAngle = ((hour - 6) / 24) * Math.PI * 2;
+ const isNightLight = nightFactor > 0.65;
+ const lightAngle = isNightLight ? orbitAngle + Math.PI : orbitAngle;
sun.position.set(
- focusX + Math.cos(angle) * 140,
- Math.max(48, Math.sin(angle) * 150 + 65),
+ focusX + Math.cos(lightAngle) * 140,
+ Math.max(52, Math.sin(lightAngle) * 150 + 60),
focusZ - 85
);
sun.target.position.set(focusX, 0, focusZ);
+
+ celestial.update(hour, focusX, focusZ, nightFactor, dt);
return nightFactor;
}
function dispose() {
+ envRT?.dispose?.();
renderer.dispose();
}
- return { renderer, scene, camera, sun, hemi, preset, resize, updateAtmosphere, dispose };
+ return { renderer, scene, camera, sun, hemi, celestial, preset, resize, updateAtmosphere, dispose };
}
diff --git a/vice-game/src/world/entities.js b/vice-game/src/world/entities.js
index 571a7f58..13062b89 100644
--- a/vice-game/src/world/entities.js
+++ b/vice-game/src/world/entities.js
@@ -2,6 +2,8 @@
// - Carrega automaticamente os arquivos .GLB reais enviados em `assets/brand/` (Corvette, Fiesta,
// Pontiac GTO, Cruze Police, Moto 004, Motorhome Triple E Commander, Standing Man e Citizen NPC Pack),
// exibindo um proxy leve instantâneo no 1º frame e trocando para o .GLB real assim que decodificado!
+// - Todos os carros/motos giram as rodas proporcionalmente à velocidade, esterçam as dianteiras e possuem porta articulada!
+// - Todos os NPCs do Citizen Pack têm braços relaxados junto ao corpo (sem A-pose!) e animação completa de braços e pernas!
import { THREE } from './engine.js';
import { getVehicleModel } from '../data/vehicles.js';
@@ -9,13 +11,146 @@ import {
GLB_ASSETS,
loadGlbOnce,
loadCitizenTemplates,
+ instantiateArticulatedCitizen,
instantiateNormalizedVehicle,
- instantiateRiggedProtagonist
+ instantiateRiggedProtagonist,
+ resolveVehicleGlbUrl,
+ resolveCharacterGlbUrl
} from './glb-loader.js';
let citizenVariantCursor = 0;
+/**
+ * Constrói modelos 3D detalhados e realistas de armas (substituindo o antigo bloco preto!):
+ * - `pistol`: ferrolho metálico prateado/grafite, cabo anatômico inclinado, guarda-mato, massa de mira e cano;
+ * - `smg`: submetralhadora compacta com carregador alongado vertical, silenciador/compensador e mira;
+ * - `shotgun`: escopeta 12GA com cano longo duplo/tubo de munição, telha de madeira/polímero e coronha;
+ * - `rifle`: fuzil de assalto M4-AR completo com coronha tática, carregador curvo 5.56, guarda-mão trilho, mira holográfica e cano longo!
+ */
+export function buildRealisticWeaponRig() {
+ const holder = new THREE.Group();
+ holder.name = 'realistic-weapon-rig';
+
+ const steelMat = new THREE.MeshStandardMaterial({ color: '#2b303a', metalness: 0.78, roughness: 0.28 });
+ const chromeMat = new THREE.MeshStandardMaterial({ color: '#8d99ae', metalness: 0.85, roughness: 0.22 });
+ const gripMat = new THREE.MeshStandardMaterial({ color: '#14161c', roughness: 0.85, metalness: 0.12 });
+ const woodMat = new THREE.MeshStandardMaterial({ color: '#6f4518', roughness: 0.72, metalness: 0.08 });
+ const opticMat = new THREE.MeshBasicMaterial({ color: '#ff2a85' });
+
+ const variants = {};
+
+ // 1. PISTOLA 9MM TÁTICA
+ const pistol = new THREE.Group();
+ const pSlide = new THREE.Mesh(new THREE.BoxGeometry(0.042, 0.052, 0.24), chromeMat);
+ pSlide.position.set(0, 0.04, 0.06);
+ const pFrame = new THREE.Mesh(new THREE.BoxGeometry(0.038, 0.032, 0.21), steelMat);
+ pFrame.position.set(0, 0.01, 0.05);
+ const pBarrel = new THREE.CylinderGeometry(0.012, 0.012, 0.06, 8);
+ pBarrel.rotateX(Math.PI / 2);
+ const pBarrelMesh = new THREE.Mesh(pBarrel, steelMat);
+ pBarrelMesh.position.set(0, 0.042, 0.19);
+ const pGrip = new THREE.Mesh(new THREE.BoxGeometry(0.036, 0.115, 0.052), gripMat);
+ pGrip.position.set(0, -0.05, -0.025);
+ pGrip.rotation.x = 0.24;
+ const pGuard = new THREE.Mesh(new THREE.BoxGeometry(0.016, 0.035, 0.055), steelMat);
+ pGuard.position.set(0, -0.018, 0.032);
+ const pSight = new THREE.Mesh(new THREE.BoxGeometry(0.01, 0.012, 0.012), opticMat);
+ pSight.position.set(0, 0.07, -0.04);
+ pistol.add(pSlide, pFrame, pBarrelMesh, pGrip, pGuard, pSight);
+ variants.pistol = pistol;
+ holder.add(pistol);
+
+ // 2. SUBMETRALHADORA MP-VICE
+ const smg = new THREE.Group();
+ const sBody = new THREE.Mesh(new THREE.BoxGeometry(0.055, 0.075, 0.34), steelMat);
+ sBody.position.set(0, 0.03, 0.08);
+ const sBarrel = new THREE.Mesh(pBarrel, chromeMat);
+ sBarrel.scale.set(1.2, 1.2, 2.2);
+ sBarrel.position.set(0, 0.03, 0.29);
+ const sGrip = new THREE.Mesh(new THREE.BoxGeometry(0.04, 0.11, 0.05), gripMat);
+ sGrip.position.set(0, -0.05, -0.02);
+ sGrip.rotation.x = 0.2;
+ const sMag = new THREE.Mesh(new THREE.BoxGeometry(0.03, 0.17, 0.042), chromeMat);
+ sMag.position.set(0, -0.08, 0.12);
+ sMag.rotation.x = -0.12;
+ const sHolo = new THREE.Mesh(new THREE.BoxGeometry(0.034, 0.032, 0.055), gripMat);
+ sHolo.position.set(0, 0.082, 0.06);
+ smg.add(sBody, sBarrel, sGrip, sMag, sHolo);
+ smg.visible = false;
+ variants.smg = smg;
+ holder.add(smg);
+
+ // 3. ESCOPETA 12GA
+ const shotgun = new THREE.Group();
+ const sgReceiver = new THREE.Mesh(new THREE.BoxGeometry(0.054, 0.072, 0.28), steelMat);
+ sgReceiver.position.set(0, 0.02, 0.05);
+ const sgStock = new THREE.Mesh(new THREE.BoxGeometry(0.046, 0.095, 0.28), woodMat);
+ sgStock.position.set(0, -0.015, -0.20);
+ sgStock.rotation.x = 0.12;
+ const barrelLongGeo = new THREE.CylinderGeometry(0.015, 0.015, 0.56, 8);
+ barrelLongGeo.rotateX(Math.PI / 2);
+ const sgBarrel = new THREE.Mesh(barrelLongGeo, chromeMat);
+ sgBarrel.position.set(0, 0.042, 0.44);
+ const sgTube = new THREE.Mesh(barrelLongGeo, steelMat);
+ sgTube.scale.set(0.85, 0.85, 0.82);
+ sgTube.position.set(0, 0.014, 0.39);
+ const sgPump = new THREE.Mesh(new THREE.BoxGeometry(0.056, 0.048, 0.20), woodMat);
+ sgPump.position.set(0, 0.008, 0.36);
+ shotgun.add(sgReceiver, sgStock, sgBarrel, sgTube, sgPump);
+ shotgun.visible = false;
+ variants.shotgun = shotgun;
+ holder.add(shotgun);
+
+ // 4. FUZIL DE ASSALTO M4-AR
+ const rifle = new THREE.Group();
+ const rReceiver = new THREE.Mesh(new THREE.BoxGeometry(0.056, 0.082, 0.30), steelMat);
+ rReceiver.position.set(0, 0.025, 0.05);
+ const rHandguard = new THREE.Mesh(new THREE.BoxGeometry(0.052, 0.068, 0.28), gripMat);
+ rHandguard.position.set(0, 0.03, 0.33);
+ const rBarrel = new THREE.Mesh(barrelLongGeo, steelMat);
+ rBarrel.scale.set(0.85, 0.85, 0.55);
+ rBarrel.position.set(0, 0.034, 0.55);
+ const rStock = new THREE.Mesh(new THREE.BoxGeometry(0.048, 0.105, 0.25), gripMat);
+ rStock.position.set(0, 0.008, -0.19);
+ const rGrip = new THREE.Mesh(new THREE.BoxGeometry(0.038, 0.11, 0.048), gripMat);
+ rGrip.position.set(0, -0.055, -0.02);
+ rGrip.rotation.x = 0.26;
+ const rMag = new THREE.Mesh(new THREE.BoxGeometry(0.032, 0.18, 0.062), chromeMat);
+ rMag.position.set(0, -0.09, 0.12);
+ rMag.rotation.x = -0.22;
+ const rScope = new THREE.Mesh(new THREE.BoxGeometry(0.036, 0.038, 0.09), chromeMat);
+ rScope.position.set(0, 0.084, 0.06);
+ const rDot = new THREE.Mesh(new THREE.BoxGeometry(0.014, 0.014, 0.01), opticMat);
+ rDot.position.set(0, 0.088, 0.015);
+ rifle.add(rReceiver, rHandguard, rBarrel, rStock, rGrip, rMag, rScope, rDot);
+ rifle.visible = false;
+ variants.rifle = rifle;
+ holder.add(rifle);
+
+ // Flash luminoso na boca do cano ao atirar!
+ const muzzleFlash = new THREE.Mesh(
+ new THREE.ConeGeometry(0.055, 0.18, 6),
+ new THREE.MeshBasicMaterial({ color: '#ffd166', transparent: true, opacity: 0.9 })
+ );
+ muzzleFlash.rotation.x = Math.PI / 2;
+ muzzleFlash.visible = false;
+ holder.add(muzzleFlash);
+
+ function setActiveWeapon(weaponId = 'pistol', showFlash = false) {
+ const key = variants[weaponId] ? weaponId : 'pistol';
+ for (const [k, grp] of Object.entries(variants)) {
+ grp.visible = (k === key);
+ }
+ muzzleFlash.visible = Boolean(showFlash);
+ const zTip = (key === 'rifle' || key === 'shotgun') ? 0.74 : (key === 'smg' ? 0.42 : 0.28);
+ muzzleFlash.position.set(0, 0.038, zTip);
+ }
+
+ return { holder, setActiveWeapon };
+}
+
export function createCharacterMesh({
+ characterId = 'rafael',
topColor = '#ff2a85',
bottomColor = '#2b4570',
skinColor = '#c98a63',
@@ -69,12 +204,9 @@ export function createCharacterMesh({
rightArmPivot.add(rightArm);
fallbackGroup.add(rightArmPivot);
- // Arma visível tanto no fallback quanto acoplada à mão/altura do personagem GLB
- const gunMesh = new THREE.Mesh(
- new THREE.BoxGeometry(0.08, 0.13, 0.36),
- new THREE.MeshStandardMaterial({ color: '#222630', metalness: 0.65, roughness: 0.35 })
- );
- gunMesh.position.set(0.28, 1.18, 0.32);
+ const weaponRig = buildRealisticWeaponRig();
+ const gunMesh = weaponRig.holder;
+ gunMesh.position.set(-0.20, 1.18, 0.32);
gunMesh.visible = Boolean(hasWeapon || isPolice);
root.add(gunMesh);
@@ -98,10 +230,10 @@ export function createCharacterMesh({
let walkPhase = 0;
let riggedInstance = null;
- let citizenNode = null;
+ let citizenInstance = null;
if (isProtagonist) {
- loadGlbOnce(GLB_ASSETS.protagonist).then(gltf => {
+ resolveCharacterGlbUrl(characterId, GLB_ASSETS.protagonist).then(url => loadGlbOnce(url)).then(gltf => {
if (!gltf) return;
const inst = instantiateRiggedProtagonist(gltf, { outfitTint: topColor });
if (!inst) return;
@@ -110,48 +242,109 @@ export function createCharacterMesh({
root.add(inst.node);
root.userData.glbLoaded = 'standing_man.glb';
});
- } else if (!isPolice) {
+ } else if (isPolice) {
+ loadGlbOnce(GLB_ASSETS.protagonist).then(gltf => {
+ if (!gltf) return;
+ const inst = instantiateRiggedProtagonist(gltf, { outfitTint: '#1d3557' });
+ if (!inst) return;
+ riggedInstance = inst;
+ fallbackGroup.visible = false;
+ root.add(inst.node);
+ root.userData.glbLoaded = 'standing_man.glb';
+ });
+ } else {
const variantIdx = citizenVariantCursor++;
loadCitizenTemplates().then(templates => {
if (!templates || !templates.length) return;
- const chosen = templates[variantIdx % templates.length].clone(true);
- citizenNode = chosen;
+ const chosenTemplate = templates[variantIdx % templates.length];
+ const inst = instantiateArticulatedCitizen(chosenTemplate);
+ if (!inst) return;
+ citizenInstance = inst;
fallbackGroup.visible = false;
- root.add(chosen);
+ root.add(inst.node);
root.userData.glbLoaded = 'citizen_npc_pack';
});
}
- function animate(dt, speed, aiming = false, showGun = false) {
- gunMesh.visible = Boolean(showGun);
- gunMesh.position.set(0.26, aiming ? 1.34 : 1.02, aiming ? 0.44 : 0.18);
+ function animate(dt, speed, aiming = false, showGun = false, poseOpts = {}) {
+ const mode = poseOpts.mode || 'foot';
+ const weaponId = poseOpts.weaponId || (isPolice ? 'pistol' : 'pistol');
+ const weaponGrip = showGun
+ ? (poseOpts.weaponGrip || ((weaponId === 'rifle' || weaponId === 'shotgun') ? 'rifle' : 'pistol'))
+ : 'none';
+
+ gunMesh.visible = Boolean(showGun && (mode === 'foot' || mode === 'jump'));
+ if (gunMesh.visible) {
+ weaponRig.setActiveWeapon(weaponId, Boolean(poseOpts.muzzleFlash));
+ // No esqueleto Mixamo (standing_man.glb), a mão direita fica em X ≈ -0.18!
+ if (weaponGrip === 'rifle') {
+ if (aiming) {
+ gunMesh.position.set(-0.14, 1.33, 0.28);
+ gunMesh.rotation.set(0, 0, 0);
+ } else {
+ // Fuzil cruzado junto ao peito em patrulha!
+ gunMesh.position.set(-0.06, 1.13, 0.26);
+ gunMesh.rotation.set(0.24, 0.58, 0.14);
+ }
+ } else {
+ if (aiming) {
+ gunMesh.position.set(-0.08, 1.36, 0.42);
+ gunMesh.rotation.set(0, 0, 0);
+ } else {
+ gunMesh.position.set(-0.22, 1.06, 0.24);
+ gunMesh.rotation.set(0.28, 0, 0);
+ }
+ }
+ }
if (riggedInstance) {
- riggedInstance.animateRig(dt, speed, aiming);
+ riggedInstance.animateRig(dt, speed, aiming, { ...poseOpts, weaponGrip });
return;
}
- if (citizenNode) {
- // Balanço leve de caminhada low-poly mobile nos cidadãos do pacote GLB
- if (speed > 0.2) {
- walkPhase += dt * (5.2 + speed * 1.1);
- citizenNode.position.y = Math.abs(Math.sin(walkPhase)) * 0.055;
- citizenNode.rotation.z = Math.sin(walkPhase) * 0.045;
- } else {
- citizenNode.position.y = 0;
- citizenNode.rotation.z = 0;
- }
+ if (citizenInstance) {
+ citizenInstance.animateCitizen(dt, speed, poseOpts.activity || 'walk');
+ return;
+ }
+
+ if (mode === 'ragdoll') {
+ const t = Math.min(1, (poseOpts.ragdollTime || 0) * 2.8);
+ fallbackGroup.rotation.x = -t * (Math.PI * 0.48);
+ fallbackGroup.position.y = 0.2;
+ return;
+ }
+ if (mode === 'enterCar' || mode === 'exitCar') {
+ const p = mode === 'exitCar' ? (1 - (poseOpts.doorProgress || 0)) : (poseOpts.doorProgress || 0);
+ const sitT = Math.max(0, Math.min(1, (p - 0.3) / 0.5));
+ fallbackGroup.position.set(0, -sitT * 0.42, 0);
+ leftLegPivot.rotation.x = -sitT * 1.25;
+ rightLegPivot.rotation.x = -sitT * 1.25;
+ leftArmPivot.rotation.x = -0.95;
+ rightArmPivot.rotation.x = -sitT * 0.95;
+ return;
+ }
+ if (mode === 'bike') {
+ fallbackGroup.rotation.x = 0.35;
+ fallbackGroup.rotation.z = (poseOpts.steer || 0) * 0.24;
+ fallbackGroup.position.set(0, -0.18, -0.14);
+ leftLegPivot.rotation.x = -0.95;
+ rightLegPivot.rotation.x = -0.95;
+ leftArmPivot.rotation.x = -1.1;
+ rightArmPivot.rotation.x = -1.1;
return;
}
+ fallbackGroup.rotation.set(0, 0, 0);
+ fallbackGroup.position.set(0, 0, 0);
+
if (speed > 0.2) {
- walkPhase += dt * (4.5 + speed * 1.15);
- const swing = Math.sin(walkPhase) * Math.min(0.85, 0.22 + speed * 0.075);
+ walkPhase += dt * (4.8 + speed * 1.15);
+ const swing = Math.sin(walkPhase) * Math.min(0.85, 0.24 + speed * 0.075);
leftLegPivot.rotation.x = swing;
rightLegPivot.rotation.x = -swing;
leftArmPivot.rotation.x = -swing * 0.85;
rightArmPivot.rotation.x = aiming ? -1.42 : swing * 0.85;
- torso.position.y = 1.08 + Math.abs(Math.cos(walkPhase * 2)) * 0.035;
+ torso.position.y = 1.08 + Math.abs(Math.cos(walkPhase * 2)) * 0.038;
} else {
leftLegPivot.rotation.x *= 0.82;
rightLegPivot.rotation.x *= 0.82;
@@ -197,9 +390,11 @@ export function createVehicleMesh(modelId, customColor = null) {
const headLightMat = new THREE.MeshBasicMaterial({ color: '#fff8d6' });
const tailLightMat = new THREE.MeshBasicMaterial({ color: '#ff1e56' });
- const wheels = [];
+ const fallbackWheels = [];
+ let fallbackDoorHinge = null;
let sirenRed = null;
let sirenBlue = null;
+ let currentDoorAngle = 0;
if (spec.isBike) {
const frame = new THREE.Mesh(new THREE.BoxGeometry(0.42, 0.52, 1.65), bodyMat);
@@ -210,10 +405,12 @@ export function createVehicleMesh(modelId, customColor = null) {
const wheelGeo = new THREE.CylinderGeometry(0.36, 0.36, 0.22, 14);
wheelGeo.rotateZ(Math.PI / 2);
for (const wz of [-0.72, 0.74]) {
+ const steerPivot = new THREE.Group();
+ steerPivot.position.set(0, 0.36, wz);
const w = new THREE.Mesh(wheelGeo, darkMat);
- w.position.set(0, 0.36, wz);
- fallbackGroup.add(w);
- wheels.push(w);
+ steerPivot.add(w);
+ fallbackGroup.add(steerPivot);
+ fallbackWheels.push({ steerPivot, spinMesh: w, isFront: wz > 0, radius: 0.36 });
}
} else {
const w = spec.width;
@@ -229,6 +426,15 @@ export function createVehicleMesh(modelId, customColor = null) {
cabin.position.set(0, 1.02, -0.15);
fallbackGroup.add(cabin);
+ // Porta articulada esquerda (+X) no fallback também!
+ fallbackDoorHinge = new THREE.Group();
+ fallbackDoorHinge.position.set(w * 0.5 + 0.01, 0.58, l * 0.16);
+ const doorMesh = new THREE.Mesh(new THREE.BoxGeometry(0.05, 0.48, 0.95), bodyMat);
+ doorMesh.position.set(0, 0, -0.475);
+ fallbackDoorHinge.add(doorMesh);
+ fallbackDoorHinge.visible = false;
+ fallbackGroup.add(fallbackDoorHinge);
+
for (const sx of [-w * 0.34, w * 0.34]) {
const hl = new THREE.Mesh(new THREE.BoxGeometry(0.32, 0.16, 0.08), headLightMat);
hl.position.set(sx, 0.58, l * 0.5 + 0.02);
@@ -242,14 +448,15 @@ export function createVehicleMesh(modelId, customColor = null) {
const wx = w * 0.48;
const wz = l * 0.32;
for (const [px, pz] of [[-wx, wz], [wx, wz], [-wx, -wz], [wx, -wz]]) {
+ const steerPivot = new THREE.Group();
+ steerPivot.position.set(px, 0.36, pz);
const wheel = new THREE.Mesh(wheelGeo, darkMat);
- wheel.position.set(px, 0.36, pz);
- fallbackGroup.add(wheel);
- wheels.push(wheel);
+ steerPivot.add(wheel);
+ fallbackGroup.add(steerPivot);
+ fallbackWheels.push({ steerPivot, spinMesh: wheel, isFront: pz > 0, radius: 0.36 });
}
}
- // Luzes de giroflex policiais e letreiro de táxi permanecem no root para brilhar também sobre o GLB!
if (spec.isTaxi) {
const taxiSign = new THREE.Mesh(
new THREE.BoxGeometry(0.62, 0.2, 0.26),
@@ -297,18 +504,22 @@ export function createVehicleMesh(modelId, customColor = null) {
let glbVehicle = null;
if (spec.glbUrl) {
- loadGlbOnce(spec.glbUrl).then(gltf => {
+ resolveVehicleGlbUrl(spec.id, spec.glbUrl).then(url => loadGlbOnce(url)).then(gltf => {
if (!gltf) return;
const inst = instantiateNormalizedVehicle(gltf, {
targetLength: spec.length,
yawOffset: spec.glbYaw || 0,
- tintColor: spec.tintGlb ? color : null
+ tintColor: spec.tintGlb ? color : null,
+ isBike: Boolean(spec.isBike),
+ bodyColor: color
});
if (!inst) return;
glbVehicle = inst;
+ glbVehicle.setDoorAngle(currentDoorAngle);
fallbackGroup.visible = false;
root.add(inst.node);
root.userData.glbLoaded = spec.glbUrl;
+ root.userData.wheelCount = inst.wheelCount;
});
}
@@ -317,9 +528,30 @@ export function createVehicleMesh(modelId, customColor = null) {
glbVehicle?.setColor(hex);
}
- function updateVisuals(dt, speed, elapsed, sirenActive = false, hpRatio = 1) {
- const spin = speed * dt * 2.4;
- for (const w of wheels) w.rotation.x += spin;
+ function setDoorAngle(rad) {
+ currentDoorAngle = Math.max(0, Math.min(1.25, rad));
+ glbVehicle?.setDoorAngle(currentDoorAngle);
+ if (fallbackDoorHinge) {
+ fallbackDoorHinge.visible = currentDoorAngle > 0.012;
+ fallbackDoorHinge.rotation.y = -currentDoorAngle;
+ }
+ }
+
+ function updateVisuals(dt, speed, elapsed, sirenActive = false, hpRatio = 1, steer = 0) {
+ // 1. Giro das rodas e esterçamento das dianteiras (tanto no proxy quanto no .GLB real!)
+ if (glbVehicle) {
+ glbVehicle.updateWheels(dt, speed, steer);
+ } else {
+ const steerAngle = -steer * (spec.isBike ? 0.28 : 0.44);
+ for (const fw of fallbackWheels) {
+ fw.spinMesh.rotation.x += (speed * dt) / fw.radius;
+ if (fw.isFront) fw.steerPivot.rotation.y = steerAngle;
+ }
+ }
+
+ if (spec.isBike) {
+ root.rotation.z = steer * Math.min(1, Math.abs(speed) / 8) * 0.28;
+ }
if (sirenRed && sirenBlue) {
if (sirenActive) {
@@ -341,5 +573,5 @@ export function createVehicleMesh(modelId, customColor = null) {
}
}
- return { root, spec, setBodyColor, updateVisuals };
+ return { root, spec, setBodyColor, setDoorAngle, updateVisuals };
}
diff --git a/vice-game/src/world/game.js b/vice-game/src/world/game.js
index 99aac21b..2310d0d0 100644
--- a/vice-game/src/world/game.js
+++ b/vice-game/src/world/game.js
@@ -7,18 +7,28 @@
// - Sistema de Missões de Campanha + entregas rápidas e corridas
// - Exposição em `window.__viceGame` para inspeção e suíte de testes automatizados
-import { THREE, createEngine } from './engine.js';
+import { THREE, createEngine, GAME_HOURS_PER_SECOND } from './engine.js';
import { buildCityScene } from './city-mesh.js';
import { createCharacterMesh, createVehicleMesh } from './entities.js';
import { preloadAllViceModels } from './glb-loader.js';
import { createTouchAndKeyControls } from './controls.js';
-import { drawRadarMinimap, drawFullCityMap } from './minimap.js';
+import { renderMinimap, renderFullCityMap } from './minimap.js';
import {
+ MAP_HALF,
AVENUES_X,
STREETS_Z,
+ ROAD_WIDTH,
+ BEACH_SAND_X,
+ OCEAN_WATER_X,
+ BANK_INTERIOR,
+ CORVETTE_CONTAINER,
+ FERRIS_WHEEL,
+ ENTERABLE_SHOPS,
+ TRAIN_LINE,
POINTS_OF_INTEREST,
districtAt,
- isWaterAt
+ isWaterAt,
+ isRoadAt
} from '../data/city.js';
import { VEHICLE_MODELS, RADIO_STATIONS, getVehicleModel } from '../data/vehicles.js';
import { CHARACTERS, WEAPONS, MISSIONS, getCharacter, getWeapon, nextAvailableMission } from '../data/missions.js';
@@ -50,19 +60,21 @@ export function mountViceWorld({
host,
profile,
initialMissionId = null,
+ initialVehicleId = null,
+ initialVehicleColor = null,
onExitToMenu,
toast
}) {
// ---------------- DOM & HUD ----------------
const canvas = el('canvas', { class: 'vc-canvas' });
- const radarCanvas = el('canvas', { class: 'vc-radar__canvas', width: 170, height: 170 });
+ const radarCanvas = el('canvas', { class: 'vc-radar__canvas', width: 264, height: 264 });
- const districtBadge = el('div', { class: 'vc-district', text: 'Ocean Drive · Vice Beach' });
- const wantedStarsNodes = Array.from({ length: 5 }, () => el('span', { class: 'vc-star', text: '★' }));
+ // 6 estrelas máximas de procurado (o assalto ao Cofre do Banco dispara 6 estrelas na hora!)
+ const wantedStarsNodes = Array.from({ length: 6 }, () => el('span', { class: 'vc-star', text: '★' }));
const wantedRow = el('div', { class: 'vc-wanted', 'aria-label': 'Nível de procurado' }, ...wantedStarsNodes);
const moneyLabel = el('div', { class: 'vc-money', text: `$${profile.money.toLocaleString('pt-BR')}` });
- const clockLabel = el('div', { class: 'vc-clock', text: '17:30' });
+ const clockLabel = el('div', { class: 'vc-clock', text: '17:36' });
const hpFill = el('div', { class: 'vc-bar__fill vc-bar__fill--hp' });
const armorFill = el('div', { class: 'vc-bar__fill vc-bar__fill--armor' });
@@ -71,32 +83,29 @@ export function mountViceWorld({
);
const carHpFill = carHpWrap.firstChild;
- const weaponBtn = el('button', {
+ // Botão contextual na tela para embarcar na Roda-Gigante ($70) ou Roubar o Cofre do Banco!
+ // (Estilo GTA: prompt de interação único, só aparece quando dá para agir)
+ const contextActionBtn = el('button', {
type: 'button',
- class: 'vc-pill vc-pill--weapon',
- title: 'Trocar arma (Q)'
+ class: 'vc-context-btn',
+ hidden: 'hidden',
+ text: ''
});
- const charBtn = el('button', {
+ // Botão de render única e contextual (só aparece quando a VCPD cerca o jogador)
+ const surrenderBtn = el('button', {
type: 'button',
- class: 'vc-pill vc-pill--char',
- title: 'Alternar Lucia / Jason (C)'
+ class: 'vc-surrender-btn',
+ hidden: 'hidden',
+ text: '🙌 SE RENDER',
+ title: 'Levantar as mãos e se render à Polícia VCPD (X)'
});
- const radioBtn = el('button', {
+ // Botão de Menu ÚNICO e discreto (estilo minimalismo GTA): abre mapa/missões/garagem/sistema
+ const menuBtn = el('button', {
type: 'button',
- class: 'vc-pill vc-pill--radio',
- title: 'Estação de Rádio FM (R)'
- });
- const mapBtn = el('button', {
- type: 'button',
- class: 'vc-pill vc-pill--map',
- text: 'MAPA GPS',
- title: 'Abrir Mapa de Vice Leonida (M)'
- });
- const pauseBtn = el('button', {
- type: 'button',
- class: 'vc-pill vc-pill--pause',
- text: 'PAUSA',
- title: 'Menu de Pausa (Esc)'
+ class: 'vc-menu-btn',
+ text: '☰',
+ title: 'Menu (Esc): Mapa, Missões, Carros 3D, Ammu-Nation e Sistema',
+ 'aria-label': 'Menu'
});
const speedoBox = el('div', { class: 'vc-speedo', hidden: 'hidden' },
@@ -117,8 +126,13 @@ export function mountViceWorld({
el('div', { class: 'vc-splash__sub', text: '' })
);
- // Mira central discreta quando armado a pé
- const crosshair = el('div', { class: 'vc-crosshair' });
+ // Mira "Complex" do GTA VI (padrão): seta superior + duas diagonais + ponto central
+ const crosshair = el('div', { class: 'vc-crosshair' },
+ el('div', { class: 'vc-crosshair__line vc-crosshair__line--top' }),
+ el('div', { class: 'vc-crosshair__line vc-crosshair__line--left' }),
+ el('div', { class: 'vc-crosshair__line vc-crosshair__line--right' }),
+ el('div', { class: 'vc-crosshair__dot' })
+ );
// Modal de Mapa / Pausa / Concessionária Rápida
const modalBackdrop = el('div', { class: 'vc-modal', hidden: 'hidden' });
@@ -134,13 +148,11 @@ export function mountViceWorld({
radarWrap.addEventListener('click', () => openOverlay('map'));
const topRightHud = el('div', { class: 'vc-hud-tr' },
- el('div', { class: 'vc-hud-tr__row' }, clockLabel, moneyLabel),
- wantedRow,
- el('div', { class: 'vc-hud-tr__pills' }, charBtn, weaponBtn, radioBtn, mapBtn, pauseBtn)
+ el('div', { class: 'vc-hud-tr__row' }, menuBtn, clockLabel, moneyLabel),
+ wantedRow
);
const topLeftHud = el('div', { class: 'vc-hud-tl' },
- districtBadge,
missionBanner
);
@@ -151,6 +163,8 @@ export function mountViceWorld({
topRightHud,
radarWrap,
speedoBox,
+ contextActionBtn,
+ surrenderBtn,
splashOverlay,
modalBackdrop
);
@@ -165,6 +179,7 @@ export function mountViceWorld({
// ---------------- Estado Vivo da Sessão ----------------
let protagonist = getCharacter(profile.characterId);
const playerMesh = createCharacterMesh({
+ characterId: protagonist.id,
topColor: protagonist.outfitTop,
bottomColor: protagonist.outfitBottom,
skinColor: protagonist.skin,
@@ -185,16 +200,28 @@ export function mountViceWorld({
maxArmor: protagonist.maxArmor,
weaponIndex: 1, // Pistola por padrão
fireCooldown: 0,
+ muzzleFlashTimer: 0,
inVehicle: null,
- onGround: true
+ doorTransition: null,
+ ferrisRide: null, // { cabinIdx, timer, duration } — volta panorâmica 3D real na cabine da Roda-Gigante!
+ surrenderTimer: 0,
+ footprintDistAcc: 0,
+ lastFootLeft: false,
+ onGround: true,
+ ragdollTimer: 0,
+ ragdollDuration: 0,
+ ragdollVx: 0,
+ ragdollVz: 0
};
- let gameHour = profile.settings.timeMode === 'night' ? 22.0
- : profile.settings.timeMode === 'day' ? 12.5
- : 17.35; // Pôr do sol icônico de Leonida
+ let gameHour = profile.settings.timeMode === 'night' ? 23.0
+ : profile.settings.timeMode === 'day' ? 11.5
+ : 17.65; // Céu meio rosa de fim de tarde de Vice por padrão!
let wanted = 0;
let wantedDecayTimer = 0;
+ let bankVaultCooldown = 0;
+ let trainHitCooldown = 0;
let paused = false;
let elapsed = 0;
let garageCooldown = 0;
@@ -205,14 +232,89 @@ export function mountViceWorld({
let camY = 4;
let camZ = player.z - 8;
- // ---------------- Veículos Estacionados + Tráfego ----------------
+ // ---------------- Colisão com Prédios e Casas ----------------
+ function resolveBuildingCollisions(x, z, radius = 0.65) {
+ let nx = x;
+ let nz = z;
+ let collided = false;
+ for (const c of city.colliders) {
+ if (nx + radius > c.minX && nx - radius < c.maxX && nz + radius > c.minZ && nz - radius < c.maxZ) {
+ collided = true;
+ const penLeft = (nx + radius) - c.minX;
+ const penRight = c.maxX - (nx - radius);
+ const penTop = (nz + radius) - c.minZ;
+ const penBot = c.maxZ - (nz - radius);
+ const minPen = Math.min(penLeft, penRight, penTop, penBot);
+ if (minPen === penLeft) nx = c.minX - radius;
+ else if (minPen === penRight) nx = c.maxX + radius;
+ else if (minPen === penTop) nz = c.minZ - radius;
+ else nz = c.maxZ + radius;
+ }
+ }
+ return { x: nx, z: nz, collided };
+ }
+
+ // ---------------- Veículos Estacionados + Tráfego (zero carros grudados!) ----------------
const vehicles = [];
+ /**
+ * Garante espaçamento mínimo real entre qualquer veículo novo e todos os já existentes
+ * (levando em conta o comprimento real de ônibus/motorhomes de 8.2m vs carros de 4.5m).
+ */
+ function findClearVehicleSpot(rawX, rawZ, spec, {
+ aiTraffic = false,
+ yaw = 0,
+ ignoreHidden = true
+ } = {}) {
+ let x = rawX;
+ let z = rawZ;
+
+ const myRadius = Math.max(spec.length * 0.56, spec.width * 0.7) + 1.4;
+ const stepDirZ = Math.cos(yaw) >= 0 ? -1 : 1;
+
+ for (let attempt = 0; attempt < 18; attempt += 1) {
+ let conflict = null;
+ for (const other of vehicles) {
+ if (ignoreHidden && !other.mesh.root.visible) continue;
+ const otherRadius = Math.max(other.spec.length * 0.56, other.spec.width * 0.7) + 1.4;
+ const minGap = myRadius + otherRadius + (aiTraffic && other.aiTraffic ? 6.5 : 1.2);
+ const dx = x - other.x;
+ const dz = z - other.z;
+ const dist = Math.hypot(dx, dz);
+ if (dist < minGap) {
+ conflict = { other, minGap, dist, dx, dz };
+ break;
+ }
+ }
+ if (!conflict) break;
+
+ if (aiTraffic) {
+ // Desloca o veículo de tráfego ao longo da própria faixa sem encostar em ninguém
+ z += stepDirZ * (conflict.minGap + 4.0);
+ if (z > 435) z -= 870;
+ if (z < -435) z += 870;
+ } else {
+ const ang = conflict.dist > 0.1 ? Math.atan2(conflict.dx, conflict.dz) : (attempt * 1.1);
+ x += Math.sin(ang) * (conflict.minGap - conflict.dist + 1.2);
+ z += Math.cos(ang) * (conflict.minGap - conflict.dist + 1.2);
+ const col = resolveBuildingCollisions(x, z, Math.max(1.1, spec.width * 0.6));
+ x = col.x;
+ z = col.z;
+ }
+ }
+
+ return { x, z };
+ }
+
function spawnVehicle({ modelId, x, z, yaw = 0, color = null, aiTraffic = false, isCopUnit = false }) {
const spec = getVehicleModel(modelId);
+ const clearSpot = isCopUnit ? { x, z } : findClearVehicleSpot(x, z, spec, { aiTraffic, yaw });
+ const fx = clearSpot.x;
+ const fz = clearSpot.z;
+
const chosenColor = color || spec.colors[Math.floor(Math.random() * spec.colors.length)];
const meshObj = createVehicleMesh(modelId, chosenColor);
- meshObj.root.position.set(x, 0, z);
+ meshObj.root.position.set(fx, 0, fz);
meshObj.root.rotation.y = yaw;
engine.scene.add(meshObj.root);
@@ -222,8 +324,8 @@ export function mountViceWorld({
spec,
color: chosenColor,
mesh: meshObj,
- x,
- z,
+ x: fx,
+ z: fz,
yaw,
speed: 0,
steer: 0,
@@ -237,21 +339,42 @@ export function mountViceWorld({
return v;
}
- // Carros icônicos estacionados na Ocean Drive, Hotel, Clube e Concessionária
- spawnVehicle({ modelId: 'cheetah-vice', x: 294, z: 20, yaw: 0, color: '#ff2a85' });
- spawnVehicle({ modelId: 'banshee-cabrio', x: 294, z: 42, yaw: 0, color: '#00e5ff' });
- spawnVehicle({ modelId: 'pcj-moto', x: 287, z: 30, yaw: 0.35, color: '#ffbe0b' });
- spawnVehicle({ modelId: 'sabre-muscle', x: 164, z: -185, yaw: Math.PI, color: '#ff5400' });
- spawnVehicle({ modelId: 'cavalcade-suv', x: -234, z: -58, yaw: 0, color: '#1d2d44' });
- spawnVehicle({ modelId: 'cheetah-vice', x: -414, z: 205, yaw: Math.PI * 0.5, color: '#00f5d4' });
-
- // Tráfego civil circulando pelas avenidas
- const trafficPool = ['banshee-cabrio', 'sabre-muscle', 'cavalcade-suv', 'vice-taxi', 'pcj-moto', 'cheetah-vice'];
+ // Showroom de carros comuns na Ocean Drive + CORVETTE STINGRAY EXCLUSIVO ESCONDIDO NO CONTAINER DO PORTO!
+ const containerCorvette = spawnVehicle({
+ modelId: 'cheetah-vice',
+ x: CORVETTE_CONTAINER.x,
+ z: CORVETTE_CONTAINER.z,
+ yaw: CORVETTE_CONTAINER.yaw,
+ color: '#ff2a85',
+ isCopUnit: true // preserva coordenada exata dentro do container sem deslocar!
+ });
+ containerCorvette.isCopUnit = false;
+ containerCorvette.isSpecialContainerCar = true;
+
+ const showroomVehicles = [
+ spawnVehicle({ modelId: 'leonida-gt-custom', x: 291.2, z: 26, yaw: 0, color: '#00bbf9' }),
+ spawnVehicle({ modelId: 'pcj-moto', x: 286.2, z: 30, yaw: 0.28, color: '#ff2a85' }),
+ spawnVehicle({ modelId: 'banshee-cabrio', x: 291.2, z: 40, yaw: 0, color: '#00e5ff' }),
+ spawnVehicle({ modelId: 'sabre-muscle', x: 291.2, z: 54, yaw: 0, color: '#ff5400' }),
+ spawnVehicle({ modelId: 'vcpd-cruiser', x: 291.2, z: 12, yaw: 0, color: '#1b4332' }),
+ spawnVehicle({ modelId: 'vice-taxi', x: 308.8, z: 12, yaw: Math.PI, color: '#ffd166' }),
+ spawnVehicle({ modelId: 'cavalcade-suv', x: 311.5, z: 34, yaw: Math.PI, color: '#f1faee' }),
+ containerCorvette
+ ];
+
+ // Carros estacionados em Palm Bay City (Norte), Banco Nacional e Ilha de Vice Keys (Sul)
+ spawnVehicle({ modelId: 'sabre-muscle', x: 161.2, z: -185, yaw: Math.PI, color: '#ff5400' });
+ spawnVehicle({ modelId: 'leonida-gt-custom', x: -238.5, z: -58, yaw: 0, color: '#ff2a85' }); // Carro de fuga na porta do Banco!
+ spawnVehicle({ modelId: 'banshee-cabrio', x: 40, z: -690, yaw: 0, color: '#06d6a0' }); // Palm Bay City (Norte)
+ spawnVehicle({ modelId: 'pcj-moto', x: 235, z: 685, yaw: -0.6, color: '#ffd166' }); // Ilha de Vice Keys (Sul)
+
+ // Tráfego civil circulando pelas avenidas (SEM o Corvette `cheetah-vice`, que agora é raridade exclusiva do Container!)
+ const trafficPool = ['banshee-cabrio', 'sabre-muscle', 'vice-taxi', 'leonida-gt-custom', 'vcpd-cruiser', 'cavalcade-suv'];
for (let i = 0; i < engine.preset.trafficCount; i += 1) {
const av = AVENUES_X[i % AVENUES_X.length];
const dir = i % 2 === 0 ? 1 : -1;
const laneOffset = dir > 0 ? 4.2 : -4.2;
- const zPos = -400 + ((i * 67) % 800);
+ const zPos = -390 + ((i * 83) % 780);
const modelId = trafficPool[i % trafficPool.length];
spawnVehicle({
modelId,
@@ -268,7 +391,28 @@ export function mountViceWorld({
const pedBotColors = ['#1d3557', '#2b2d42', '#e9c46a', '#457b9d', '#343a40'];
const skinPalette = ['#f1c27d', '#e0ac69', '#c68642', '#8d5524', '#ffdbac'];
- function spawnNpc({ x, z, isPolice = false }) {
+ // Garante que todo pedestre spawne e caminhe na calçada ou no calçadão da praia (nunca no meio do asfalto!)
+ function snapToSidewalk(rawX, rawZ) {
+ let sx = rawX;
+ let sz = rawZ;
+ const roadHalf = ROAD_WIDTH * 0.5 + 2.4;
+ for (const ax of AVENUES_X) {
+ if (Math.abs(sx - ax) < roadHalf) {
+ sx = sx >= ax ? ax + roadHalf : ax - roadHalf;
+ }
+ }
+ for (const stz of STREETS_Z) {
+ if (Math.abs(sz - stz) < roadHalf) {
+ sz = sz >= stz ? stz + roadHalf : stz - roadHalf;
+ }
+ }
+ const col = resolveBuildingCollisions(sx, sz, 0.7);
+ return { x: col.x, z: col.z };
+ }
+
+ function spawnNpc({ x, z, isPolice = false, activity = 'walk', fixedYaw = null, parentCar = null }) {
+ const isStaticBeach = activity === 'sunbathe' || activity === 'volleyball' || activity === 'altinha';
+ const safePos = (isPolice || isStaticBeach || x > BEACH_SAND_X) ? { x, z } : snapToSidewalk(x, z);
const charMesh = createCharacterMesh({
topColor: pedTopColors[npcs.length % pedTopColors.length],
bottomColor: pedBotColors[npcs.length % pedBotColors.length],
@@ -276,35 +420,75 @@ export function mountViceWorld({
isPolice,
hasWeapon: isPolice
});
- charMesh.root.position.set(x, 0, z);
+ charMesh.root.position.set(safePos.x, activity === 'sunbathe' ? 0.24 : 0, safePos.z);
engine.scene.add(charMesh.root);
+ const sidewalkYaw = fixedYaw !== null
+ ? fixedYaw
+ : isPolice ? (Math.random() * Math.PI * 2) : (npcs.length % 2 === 0 ? 0 : Math.PI);
+
const npc = {
mesh: charMesh,
- x,
- z,
- yaw: Math.random() * Math.PI * 2,
- hp: isPolice ? 90 : 50,
+ x: safePos.x,
+ z: safePos.z,
+ sidewalkX: safePos.x,
+ yaw: sidewalkYaw,
+ hp: isPolice ? 105 : 50,
alive: true,
isPolice,
+ activity,
+ parentCar,
+ weaponId: isPolice ? (wanted >= 4 ? 'rifle' : 'pistol') : 'pistol',
panicTimer: 0,
- shootTimer: 0.8 + Math.random() * 0.8,
+ shootTimer: 0.7 + Math.random() * 0.7,
+ muzzleTimer: 0,
respawnTimer: 0
};
npcs.push(npc);
return npc;
}
+ // Pedestres .GLB (Citizen Pack) caminhando nas calçadas laterais de Ocean Drive + caminhantes na beira da areia!
+ const oceanPromenadeSpots = [
+ [280, 18], [283, 38], [313, 22], [315, 34],
+ [438, -25], [442, 45], [436, 115], [440, -95] // Pessoas caminhando descalças na beira do mar!
+ ];
+ for (const [px, pz] of oceanPromenadeSpots) {
+ spawnNpc({ x: px, z: pz, isPolice: false });
+ }
+
+ // Vida na Praia: Banhistas deitados nas cadeiras de sol, Jogadores de Vôlei de Praia e Roda de Altinha!
+ for (let i = 0; i < Math.min(8, city.layout.beachSets.length); i += 1) {
+ const bs = city.layout.beachSets[i * 2 % city.layout.beachSets.length];
+ spawnNpc({ x: bs.x + 0.35, z: bs.z - 1.45, activity: 'sunbathe', fixedYaw: Math.PI * 0.5 });
+ }
+ for (const court of city.layout.beachCourts) {
+ if (court.kind === 'volleyball') {
+ spawnNpc({ x: court.x - 3.6, z: court.z - 1.2, activity: 'volleyball', fixedYaw: Math.PI * 0.5 });
+ spawnNpc({ x: court.x + 3.6, z: court.z + 1.2, activity: 'volleyball', fixedYaw: -Math.PI * 0.5 });
+ } else {
+ for (let a = 0; a < 3; a += 1) {
+ const ang = (a / 3) * Math.PI * 2;
+ spawnNpc({
+ x: court.x + Math.cos(ang) * 2.4,
+ z: court.z + Math.sin(ang) * 2.4,
+ activity: 'altinha',
+ fixedYaw: wrapAngle(ang + Math.PI)
+ });
+ }
+ }
+ }
+
for (let i = 0; i < engine.preset.pedCount; i += 1) {
const onBoardwalk = i % 3 === 0;
- const x = onBoardwalk ? (322 + (i % 5) * 3.5) : (AVENUES_X[i % AVENUES_X.length] + (i % 2 ? 11.2 : -11.2));
+ const x = onBoardwalk ? (324 + (i % 4) * 3.5) : (AVENUES_X[i % AVENUES_X.length] + (i % 2 ? 11.8 : -11.8));
const z = -380 + ((i * 53) % 760);
spawnNpc({ x, z, isPolice: false });
}
- // Unidades policiais dedicadas (ativadas conforme estrelas de procurado)
+ // 5 Unidades policiais VCPD dedicadas (suportam até 6 estrelas + policiais que saem da viatura para trocar tiro a pé!)
const copCars = [];
- for (let i = 0; i < 4; i += 1) {
+ for (let i = 0; i < 5; i += 1) {
const cv = spawnVehicle({
modelId: 'vcpd-cruiser',
x: -90 + i * 6,
@@ -312,6 +496,8 @@ export function mountViceWorld({
yaw: 0,
isCopUnit: true
});
+ cv.hasDeployedOfficer = false;
+ cv.ramCooldown = 0;
cv.mesh.root.visible = false;
copCars.push(cv);
}
@@ -415,7 +601,7 @@ export function mountViceWorld({
function setWantedLevel(level) {
const prev = wanted;
- wanted = clamp(Math.round(level), 0, 5);
+ wanted = clamp(Math.round(level), 0, 6);
wantedDecayTimer = 0;
if (wanted > profile.stats.maxWantedSurvived) {
profile.stats.maxWantedSurvived = wanted;
@@ -423,29 +609,209 @@ export function mountViceWorld({
wantedStarsNodes.forEach((node, idx) => {
node.classList.toggle('is-active', idx < wanted);
});
- if (wanted > 0 && prev === 0) {
- toast?.('Polícia VCPD alertada! Fuja ou entre numa Oficina Neon Customs.');
+ if (wanted > 0) {
+ surrenderBtn.removeAttribute('hidden');
+ if (prev === 0) {
+ toast?.('Polícia VCPD em perseguição! Meta fuga, enfrente ou toque em SE RENDER.');
+ }
+ } else {
+ surrenderBtn.setAttribute('hidden', 'hidden');
+ // Recolhe policiais desembarcados quando a perseguição termina
+ for (let i = npcs.length - 1; i >= 0; i -= 1) {
+ if (npcs[i].isPolice) {
+ engine.scene.remove(npcs[i].mesh.root);
+ npcs.splice(i, 1);
+ }
+ }
}
- // Posiciona viaturas ativas nas redondezas quando estrelas sobem
+
const activeUnits = Math.min(copCars.length, wanted);
for (let i = 0; i < copCars.length; i += 1) {
const cc = copCars[i];
if (i < activeUnits) {
if (!cc.mesh.root.visible) {
- const angle = Math.random() * Math.PI * 2;
- cc.x = clamp(player.x + Math.cos(angle) * 78, -440, 320);
- cc.z = clamp(player.z + Math.sin(angle) * 78, -430, 420);
+ const angle = (i / Math.max(1, activeUnits)) * Math.PI * 2 + Math.random() * 0.5;
+ cc.x = clamp(player.x + Math.cos(angle) * 72, -520, 330);
+ cc.z = clamp(player.z + Math.sin(angle) * 72, -760, 760);
cc.hp = cc.maxHp;
cc.speed = 18;
+ cc.hasDeployedOfficer = false;
+ cc.mesh.setDoorAngle?.(0);
cc.mesh.root.visible = true;
}
} else if (!cc.isPlayerDriving) {
+ cc.hasDeployedOfficer = false;
+ cc.mesh.setDoorAngle?.(0);
cc.mesh.root.visible = false;
}
}
}
- // ---------------- Armas, Personagens e Rádio ----------------
+ // ---------------- Rendição Voluntária (`SE RENDER`) ----------------
+ function surrenderToPolice() {
+ if (wanted <= 0 || player.surrenderTimer > 0 || player.ferrisRide) return;
+ if (player.inVehicle) {
+ toggleVehicle({ instant: true });
+ }
+ player.surrenderTimer = 2.1;
+ uiClick();
+ toast?.('🙌 Rafael levantou as mãos e se rendeu à Polícia VCPD...');
+ }
+
+ // ---------------- Roubo do Cofre do Banco Nacional -> 6 ESTRELAS IMEDIATAS! ----------------
+ function robBankVault() {
+ if (bankVaultCooldown > 0) {
+ toast?.(`Cofre em bloqueio térmico! Aguarde ${Math.ceil(bankVaultCooldown)}s.`);
+ return false;
+ }
+ bankVaultCooldown = 75;
+ const lootAmount = 50000;
+ profile.money += lootAmount;
+ profile.stats.banksRobbed = (profile.stats.banksRobbed || 0) + 1;
+ saveProfile(profile);
+ city.lootGroup.visible = false;
+ playMissionFanfare();
+ setWantedLevel(6); // 6 ESTRELAS MÁXIMAS NA HORA!
+ updateHudPills();
+ showSplash(
+ '★★★★★★ COFRE ARROMBADO!',
+ `+$${lootAmount.toLocaleString('pt-BR')} roubados! Alerta Máximo 6 Estrelas VCPD — META FUGA!`,
+ '#ffd166',
+ 4200
+ );
+ return true;
+ }
+
+ // ---------------- Roda-Gigante 3D Real ($70 — embarca na cabine e gira de verdade sem tela preta!) ----------------
+ function boardFerrisWheel() {
+ if (player.ferrisRide) {
+ // Permite desembarcar de volta no píer quando quiser
+ if (playerMesh.root.parent !== engine.scene) engine.scene.add(playerMesh.root);
+ player.ferrisRide = null;
+ player.x = FERRIS_WHEEL.boardX;
+ player.y = FERRIS_WHEEL.baseY;
+ player.z = FERRIS_WHEEL.boardZ;
+ playerMesh.root.position.set(player.x, player.y, player.z);
+ playerMesh.root.rotation.set(0, Math.PI, 0);
+ crosshair.style.display = '';
+ toast?.('Você desembarcou no Píer de Vice Beach!');
+ return true;
+ }
+ if (player.inVehicle) {
+ toast?.('Saia do veículo antes de embarcar na Roda-Gigante!');
+ return false;
+ }
+ if (profile.money < FERRIS_WHEEL.ticketPrice) {
+ toast?.(`Você precisa de $${FERRIS_WHEEL.ticketPrice} para o ingresso da Roda-Gigante!`);
+ return false;
+ }
+
+ profile.money -= FERRIS_WHEEL.ticketPrice;
+ profile.stats.ferrisRides = (profile.stats.ferrisRides || 0) + 1;
+ saveProfile(profile);
+ updateHudPills();
+ uiClick();
+
+ // Escolhe a cabine que está mais baixa (próxima à plataforma de embarque no Píer!)
+ let bestIdx = 0;
+ let lowestY = Infinity;
+ const tmpWorld = new THREE.Vector3();
+ city.ferrisCabins.forEach((cab, idx) => {
+ cab.seatAnchor.getWorldPosition(tmpWorld);
+ if (tmpWorld.y < lowestY) {
+ lowestY = tmpWorld.y;
+ bestIdx = idx;
+ }
+ });
+
+ const chosenCabin = city.ferrisCabins[bestIdx];
+ chosenCabin.seatAnchor.add(playerMesh.root);
+ playerMesh.root.position.set(0, 0.05, 0);
+ playerMesh.root.rotation.set(0, 0, 0);
+ playerMesh.root.visible = true;
+ crosshair.style.display = 'none';
+
+ player.ferrisRide = {
+ cabinIdx: bestIdx,
+ timer: 0,
+ duration: 26.5 // Uma volta panorâmica completa real de ~26s (arraste a tela para olhar 360°!)
+ };
+ toast?.(`🎡 Ingresso pago (-$${FERRIS_WHEEL.ticketPrice})! Rafael embarcou na cabine — gire a câmera para curtir a vista!`);
+ return true;
+ }
+
+ // ---------------- Compras nas LOJAS ENTRÁVEIS (a pé, dentro do interior 3D!) ----------------
+ function purchaseInsideShop(shop) {
+ if (profile.money < shop.itemPrice) {
+ toast?.(`Dinheiro insuficiente! ${shop.name} custa $${shop.itemPrice}.`);
+ return false;
+ }
+ profile.money -= shop.itemPrice;
+
+ if (shop.rewardType === 'heal') {
+ player.health = player.maxHealth;
+ player.armor = player.maxArmor;
+ profile.stats.medKitsBought = (profile.stats.medKitsBought || 0) + 1;
+ toast?.('💊 Kit Completo do Vice Mart! Vida e Colete 100% restaurados!');
+ } else if (shop.rewardType === 'arsenal') {
+ for (const weaponId of ['smg', 'shotgun', 'rifle']) {
+ if (!profile.ownedWeapons.includes(weaponId)) profile.ownedWeapons.push(weaponId);
+ const weapon = WEAPONS.find(w => w.id === weaponId);
+ profile.ammo[weaponId] = (profile.ammo[weaponId] || 0) + (weapon?.defaultAmmo || 60);
+ }
+ player.armor = player.maxArmor;
+ profile.stats.arsenalsBought = (profile.stats.arsenalsBought || 0) + 1;
+ toast?.('🔫 Pacote Tático Ammu-Nation: SMG + Espingarda + Fuzil M4-AR + Colete + Munição!');
+ } else if (shop.rewardType === 'outfit') {
+ setWantedLevel(0);
+ profile.stats.outfitsBought = (profile.stats.outfitsBought || 0) + 1;
+ toast?.('👔 Traje de Gala Neon Threads! Rafael está irreconhecível — nível de procurado zerado!');
+ }
+ saveProfile(profile);
+ updateHudPills();
+ uiClick();
+ return true;
+ }
+
+ // Retorna a loja cujo interior contém o ponto (x, z), ou null
+ function shopInteriorAt(x, z) {
+ for (const shop of ENTERABLE_SHOPS) {
+ const hw = shop.width * 0.5;
+ const hd = shop.depth * 0.5;
+ if (x >= shop.centerX - hw && x <= shop.centerX + hw && z >= shop.centerZ - hd && z <= shop.centerZ + hd) {
+ return shop;
+ }
+ }
+ return null;
+ }
+
+ // ---------------- Estações de Trem METRORAIL (embarque rápido!) ----------------
+ function stationAt(x, z) {
+ for (const st of TRAIN_LINE.stations) {
+ if (Math.abs(x - st.x) <= 13.5 && Math.abs(z - st.z) <= st.platformLength * 0.5 + 6) return st;
+ }
+ return null;
+ }
+
+ function rideMetrorail() {
+ const current = stationAt(player.x, player.z);
+ if (!current) return false;
+ const other = TRAIN_LINE.stations.find(st => st.id !== current.id);
+ if (!other) return false;
+ player.x = other.x + 6.5;
+ player.z = other.z;
+ player.y = 0;
+ player.vy = 0;
+ player.onGround = true;
+ camX = player.x - Math.sin(player.yaw) * 7;
+ camZ = player.z - Math.cos(player.yaw) * 7;
+ camY = 4;
+ playMissionFanfare();
+ toast?.(`🚆 Rafael embarcou no Metrorail e desceu na ${other.name}! (viagem grátis)`);
+ return true;
+ }
+
+ // ---------------- Armas, Protagonista Rafael e Rádio ----------------
function ownedWeaponList() {
return WEAPONS.filter(w => profile.ownedWeapons.includes(w.id));
}
@@ -456,13 +822,7 @@ export function mountViceWorld({
}
function updateHudPills() {
- const w = currentWeapon();
- const ammoTxt = w.ammoCost ? ` · ${profile.ammo[w.id] ?? 0}` : '';
- weaponBtn.textContent = `${w.name}${ammoTxt}`;
- charBtn.textContent = protagonist.name.split(' ')[0].toUpperCase();
-
- const st = RADIO_STATIONS.find(r => r.id === profile.radioStation) || RADIO_STATIONS[0];
- radioBtn.textContent = player.inVehicle ? `📻 ${st.name.split(' ')[0]}` : '📻 RÁDIO';
+ // HUD minimalista: só o dinheiro fica fixo no topo (o resto virou toast/menu — igual GTA VI!)
moneyLabel.textContent = `$${profile.money.toLocaleString('pt-BR')}`;
}
@@ -470,24 +830,9 @@ export function mountViceWorld({
const list = ownedWeaponList();
player.weaponIndex = (player.weaponIndex + 1) % list.length;
uiClick();
- updateHudPills();
- }
-
- function switchProtagonist() {
- const nextId = protagonist.id === 'lucia' ? 'jason' : 'lucia';
- protagonist = getCharacter(nextId);
- profile.characterId = nextId;
- player.maxHealth = protagonist.maxHealth;
- player.health = Math.min(player.maxHealth, player.health + 20);
- playerMesh.setColors({
- top: protagonist.outfitTop,
- bottom: protagonist.outfitBottom,
- skin: protagonist.skin,
- hair: protagonist.hair
- });
- saveProfile(profile);
- uiClick();
- toast?.(`Protagonista ativo: ${protagonist.name}`);
+ const w = currentWeapon();
+ const ammoTxt = w.ammoCost ? ` · ${profile.ammo[w.id] ?? 0} tiros` : '';
+ toast?.(`${w.name}${ammoTxt}`);
updateHudPills();
}
@@ -502,7 +847,29 @@ export function mountViceWorld({
updateHudPills();
}
- // ---------------- Entrar / Sair de Veículos ----------------
+ // ---------------- Entrar / Sair de Veículos (com animação de abrir/fechar porta!) ----------------
+ function computeVehicleDoorGeometry(v) {
+ // Em Three.js, com o veículo olhando para +Z em yaw=0:
+ // fwd = (sin(yaw), cos(yaw)), lado esquerdo do motorista (+X local) = (cos(yaw), -sin(yaw))
+ const fwdX = Math.sin(v.yaw);
+ const fwdZ = Math.cos(v.yaw);
+ const leftX = Math.cos(v.yaw);
+ const leftZ = -Math.sin(v.yaw);
+
+ const doorOutDist = v.spec.width * 0.56 + 0.52;
+ const seatLatDist = Math.min(0.45, v.spec.width * 0.22);
+ const zOffset = v.spec.category === 'suv' ? (v.spec.length * 0.24) : 0.12;
+
+ const doorX = v.x + leftX * doorOutDist + fwdX * zOffset;
+ const doorZ = v.z + leftZ * doorOutDist + fwdZ * zOffset;
+ const seatX = v.x + leftX * seatLatDist + fwdX * zOffset;
+ const seatZ = v.z + leftZ * seatLatDist + fwdZ * zOffset;
+ // Olhando em direção à porta do motorista (-X local do carro) -> yaw - PI/2
+ const faceCarYaw = wrapAngle(v.yaw - Math.PI * 0.5);
+
+ return { doorX, doorZ, seatX, seatZ, faceCarYaw };
+ }
+
function nearestEnterableVehicle(maxDist = 6.2) {
let best = null;
let bestD = maxDist;
@@ -517,20 +884,54 @@ export function mountViceWorld({
return best;
}
- function toggleVehicle() {
- if (paused) return;
+ function startVehicleDoorTransition(v, type = 'enter') {
+ if (!v) return;
+ v.speed = 0;
+ const geom = computeVehicleDoorGeometry(v);
+ if (playerMesh.root.parent !== engine.scene) {
+ engine.scene.add(playerMesh.root);
+ }
+ playerMesh.root.visible = true;
+
+ player.doorTransition = {
+ type,
+ vehicle: v,
+ timer: 0,
+ duration: type === 'enter' ? 1.18 : 0.92,
+ startX: type === 'enter' ? geom.doorX : geom.seatX,
+ startZ: type === 'enter' ? geom.doorZ : geom.seatZ,
+ doorX: geom.doorX,
+ doorZ: geom.doorZ,
+ seatX: geom.seatX,
+ seatZ: geom.seatZ,
+ faceCarYaw: geom.faceCarYaw,
+ carYaw: v.yaw
+ };
+
+ if (type === 'enter') {
+ player.x = geom.doorX;
+ player.z = geom.doorZ;
+ player.y = 0;
+ player.yaw = geom.faceCarYaw;
+ } else {
+ player.x = geom.seatX;
+ player.z = geom.seatZ;
+ player.y = 0;
+ player.yaw = v.yaw;
+ }
+ }
+
+ function toggleVehicle({ instant = false } = {}) {
+ if (paused || player.ragdollTimer > 0 || player.doorTransition) return;
if (player.inVehicle) {
const v = player.inVehicle;
v.isPlayerDriving = false;
- // Sai ao lado da porta do motorista
- const sideX = v.x + Math.cos(v.yaw) * (v.spec.width * 0.9 + 0.9);
- const sideZ = v.z - Math.sin(v.yaw) * (v.spec.width * 0.9 + 0.9);
- player.x = sideX;
- player.z = sideZ;
- player.y = 0;
- player.yaw = v.yaw;
+ v.mesh.setDoorAngle?.(0);
+ if (v.spec.isBike && playerMesh.root.parent === v.mesh.root) {
+ engine.scene.add(playerMesh.root);
+ }
+
player.inVehicle = null;
- playerMesh.root.visible = true;
controls.setDrivingMode(false);
speedoBox.setAttribute('hidden', 'hidden');
carHpWrap.setAttribute('hidden', 'hidden');
@@ -538,6 +939,20 @@ export function mountViceWorld({
setRadioStation('off');
uiClick();
updateHudPills();
+
+ if (!instant && !v.spec.isBike) {
+ startVehicleDoorTransition(v, 'exit');
+ return;
+ }
+
+ const geom = computeVehicleDoorGeometry(v);
+ const safeExit = resolveBuildingCollisions(geom.doorX, geom.doorZ, 0.55);
+ player.x = safeExit.x;
+ player.z = safeExit.z;
+ player.y = 0;
+ player.yaw = v.yaw;
+ playerMesh.root.visible = true;
+ playerMesh.root.rotation.set(0, player.yaw, 0);
return;
}
@@ -547,7 +962,6 @@ export function mountViceWorld({
return;
}
- // Se roubou viatura da polícia ou carro em movimento, pode atrair atenção da VCPD
if (candidate.isCopUnit && wanted < 2) {
setWantedLevel(2);
} else if (candidate.aiTraffic) {
@@ -556,18 +970,54 @@ export function mountViceWorld({
if (Math.random() < 0.35 && wanted === 0) setWantedLevel(1);
}
- player.inVehicle = candidate;
- candidate.isPlayerDriving = true;
- playerMesh.root.visible = false;
- camYaw = candidate.yaw;
- controls.setDrivingMode(true);
- speedoBox.removeAttribute('hidden');
- carHpWrap.removeAttribute('hidden');
- speedoBox.querySelector('.vc-speedo__car').textContent = candidate.spec.name;
- crosshair.style.display = 'none';
- setRadioStation(profile.radioStation);
uiClick();
- toast?.(`Dirigindo: ${candidate.spec.name}`);
+ if (!instant && !candidate.spec.isBike) {
+ startVehicleDoorTransition(candidate, 'enter');
+ } else {
+ enterSpecificVehicle(candidate);
+ toast?.(`Dirigindo: ${candidate.spec.name}`);
+ }
+ }
+
+ // Arremessa o personagem da moto quando bate forte num prédio, casa ou carro!
+ function ejectFromBikeCrash(bike, impactSpeed, dirX, dirZ) {
+ if (!bike) return;
+ bike.isPlayerDriving = false;
+ bike.speed *= -0.18;
+ bike.mesh.root.rotation.z = 0.68; // moto tombada no asfalto após o impacto
+ if (playerMesh.root.parent !== engine.scene) {
+ engine.scene.add(playerMesh.root);
+ }
+
+ player.inVehicle = null;
+ playerMesh.root.visible = true;
+ controls.setDrivingMode(false);
+ speedoBox.setAttribute('hidden', 'hidden');
+ carHpWrap.setAttribute('hidden', 'hidden');
+ crosshair.style.display = '';
+ setRadioStation('off');
+
+ const launchSpeed = clamp(impactSpeed * 0.55, 6.5, 16.5);
+ player.x = bike.x + dirX * 1.1;
+ player.z = bike.z + dirZ * 1.1;
+ player.y = 0.55;
+ player.vy = 5.4;
+ player.onGround = false;
+ player.ragdollVx = dirX * launchSpeed;
+ player.ragdollVz = dirZ * launchSpeed;
+ player.ragdollDuration = 1.65;
+ player.ragdollTimer = 1.65;
+
+ const dmg = Math.round(clamp(impactSpeed * 1.1, 10, 38));
+ if (player.armor > 0) {
+ const absorbed = Math.min(player.armor, dmg * 0.7);
+ player.armor -= absorbed;
+ player.health -= (dmg - absorbed);
+ } else {
+ player.health -= dmg;
+ }
+
+ toast?.('💥 Acidente de moto! Você foi arremessado no asfalto!');
updateHudPills();
}
@@ -587,6 +1037,7 @@ export function mountViceWorld({
}
player.fireCooldown = w.fireRate;
+ player.muzzleFlashTimer = 0.065;
playGunshot(w.id);
updateHudPills();
@@ -675,28 +1126,6 @@ export function mountViceWorld({
}
}
- // ---------------- Colisão com Prédios ----------------
- function resolveBuildingCollisions(x, z, radius = 0.65) {
- let nx = x;
- let nz = z;
- let collided = false;
- for (const c of city.colliders) {
- if (nx + radius > c.minX && nx - radius < c.maxX && nz + radius > c.minZ && nz - radius < c.maxZ) {
- collided = true;
- const penLeft = (nx + radius) - c.minX;
- const penRight = c.maxX - (nx - radius);
- const penTop = (nz + radius) - c.minZ;
- const penBot = c.maxZ - (nz - radius);
- const minPen = Math.min(penLeft, penRight, penTop, penBot);
- if (minPen === penLeft) nx = c.minX - radius;
- else if (minPen === penRight) nx = c.maxX + radius;
- else if (minPen === penTop) nz = c.minZ - radius;
- else nz = c.maxZ + radius;
- }
- }
- return { x: nx, z: nz, collided };
- }
-
// ---------------- Modal de Mapa GPS, Missões, Loja de Armas e Pausa ----------------
function closeOverlay() {
paused = false;
@@ -725,10 +1154,16 @@ export function mountViceWorld({
text: 'MISSÕES',
onclick: () => openOverlay('missions')
}),
+ el('button', {
+ type: 'button',
+ class: `vc-tab ${tab === 'garage3d' ? 'is-active' : ''}`,
+ text: '🚗 CARROS 3D',
+ onclick: () => openOverlay('garage3d')
+ }),
el('button', {
type: 'button',
class: `vc-tab ${tab === 'shop' ? 'is-active' : ''}`,
- text: 'AMMU & GARAGEM',
+ text: 'AMMU-NATION',
onclick: () => openOverlay('shop')
}),
el('button', {
@@ -742,11 +1177,21 @@ export function mountViceWorld({
const body = el('div', { class: 'vc-modal__body' });
if (tab === 'map') {
- const fullMapCanvas = el('canvas', { class: 'vc-fullmap', width: 460, height: 340 });
+ // Mapa GPS expandido RENDERIZADO EM devicePixelRatio (HiDPI — zero serrilhado em telas Retina/AMOLED!)
+ const viewportW = (typeof window !== 'undefined' && window.innerWidth) || 900;
+ const mapCssSize = Math.max(340, Math.min(680, Math.floor(viewportW * 0.62)));
+ const dpr = Math.min(2, (typeof window !== 'undefined' && window.devicePixelRatio) || 1);
+ const fullMapCanvas = el('canvas', {
+ class: 'vc-fullmap',
+ width: Math.floor(mapCssSize * dpr),
+ height: Math.floor(mapCssSize * dpr)
+ });
+ fullMapCanvas.style.width = `${mapCssSize}px`;
+ fullMapCanvas.style.height = `${mapCssSize}px`;
const legend = el('div', { class: 'vc-map-legend' },
el('h3', { text: 'GPS Vice Leonida' }),
el('p', { text: `Posição atual: ${districtAt(activeX, activeZ).name}` }),
- ...POINTS_OF_INTEREST.slice(0, 6).map(poi => el('button', {
+ ...POINTS_OF_INTEREST.slice(0, 9).map(poi => el('button', {
type: 'button',
class: 'vc-poi-btn',
text: `${poi.icon} ${poi.name}`,
@@ -759,11 +1204,16 @@ export function mountViceWorld({
);
body.append(fullMapCanvas, legend);
requestAnimationFrame(() => {
- drawFullCityMap(fullMapCanvas, {
- playerX: activeX,
- playerZ: activeZ,
- target: currentBeaconTarget()
- });
+ const ctxMap = fullMapCanvas.getContext('2d');
+ if (ctxMap) {
+ renderFullCityMap(ctxMap, {
+ width: fullMapCanvas.width,
+ height: fullMapCanvas.height,
+ playerX: activeX,
+ playerZ: activeZ,
+ target: currentBeaconTarget()
+ });
+ }
});
} else if (tab === 'missions') {
const list = el('div', { class: 'vc-card-grid' },
@@ -790,6 +1240,53 @@ export function mountViceWorld({
})
);
body.appendChild(list);
+ } else if (tab === 'garage3d') {
+ const fleetCards = VEHICLE_MODELS.map(v => {
+ const glbFile = (v.glbUrl || '').split('/').pop();
+ return el('div', { class: 'vc-item-card' },
+ el('div', { class: 'vc-item-card__badge', text: `MODELO 3D · ${glbFile}` }),
+ el('h4', { text: v.name }),
+ el('p', {
+ text: `${v.brand} · ${Math.round(v.maxSpeed * 3.6)} km/h · ${v.maxHp} HP`
+ }),
+ el('div', { class: 'vc-color-dots', style: { marginBottom: '6px' } },
+ ...v.colors.map(c => el('span', { class: 'vc-dot', style: { background: c } }))
+ ),
+ el('div', { class: 'vc-item-card__footer', style: { gap: '8px', flexWrap: 'wrap' } },
+ el('button', {
+ type: 'button',
+ class: 'vc-action-btn',
+ text: 'ENTREGAR AO LADO',
+ onclick: () => {
+ summonVehicle(v.id, { enterImmediately: false });
+ closeOverlay();
+ }
+ }),
+ el('button', {
+ type: 'button',
+ class: 'vc-action-btn is-active',
+ text: '▶ DIRIGIR AGORA',
+ onclick: () => {
+ summonVehicle(v.id, { enterImmediately: true });
+ closeOverlay();
+ }
+ })
+ )
+ );
+ });
+
+ body.append(
+ el('div', { class: 'vc-shop-bar' },
+ el('strong', { text: 'FROTA COMPLETA .GLB — Entrega instantânea gratuita na sua rua' }),
+ el('a', {
+ href: './upload-glb.html',
+ class: 'vc-action-btn',
+ style: { textDecoration: 'none' },
+ text: '📦 ENVIAR NOVO .GLB'
+ })
+ ),
+ el('div', { class: 'vc-card-grid' }, ...fleetCards)
+ );
} else if (tab === 'shop') {
const armorBtn = el('button', {
type: 'button',
@@ -869,14 +1366,19 @@ export function mountViceWorld({
el('button', {
type: 'button',
class: 'vc-big-btn',
- text: `HORÁRIO: ${profile.settings.timeMode.toUpperCase()} (ALTERNAR)`,
+ text: `CLIMA / CÉU: ${{
+ dynamic: 'CICLO 10 MIN (DIA ↔ NOITE)',
+ day: '☀️ DIA AZUL (SOL & NUVENS)',
+ night: '🌙 NOITE PRETA (LUA & ESTRELAS)',
+ sunset: '🌅 PÔR DO SOL TROPICAL'
+ }[profile.settings.timeMode] || 'CICLO 10 MIN'} (TOQUE PARA TROCAR)`,
onclick: () => {
- const modes = ['dynamic', 'sunset', 'night', 'day'];
+ const modes = ['dynamic', 'day', 'night', 'sunset'];
const next = modes[(modes.indexOf(profile.settings.timeMode) + 1) % modes.length];
profile.settings.timeMode = next;
- if (next === 'sunset') gameHour = 17.6;
- else if (next === 'night') gameHour = 22.5;
- else if (next === 'day') gameHour = 12.5;
+ if (next === 'day') gameHour = 12.0;
+ else if (next === 'night') gameHour = 0.0;
+ else if (next === 'sunset') gameHour = 17.8;
saveProfile(profile);
openOverlay('pause');
}
@@ -918,12 +1420,83 @@ export function mountViceWorld({
modalBackdrop.appendChild(panel);
}
- // Liga cliques dos botões de topo do HUD
- weaponBtn.addEventListener('click', cycleWeapon);
- charBtn.addEventListener('click', switchProtagonist);
- radioBtn.addEventListener('click', cycleRadio);
- mapBtn.addEventListener('click', () => openOverlay('map'));
- pauseBtn.addEventListener('click', () => openOverlay('pause'));
+ function enterSpecificVehicle(candidate) {
+ if (!candidate) return;
+ if (player.inVehicle && player.inVehicle !== candidate) {
+ player.inVehicle.isPlayerDriving = false;
+ if (playerMesh.root.parent !== engine.scene) engine.scene.add(playerMesh.root);
+ }
+ player.inVehicle = candidate;
+ candidate.isPlayerDriving = true;
+ candidate.mesh.root.rotation.z = 0; // levanta a moto caso estivesse tombada!
+
+ if (candidate.spec.isBike) {
+ // Na moto, o personagem 3D fica visível montado no selim e segurando o guidão!
+ candidate.mesh.root.add(playerMesh.root);
+ playerMesh.root.position.set(0, 0.04, -0.1);
+ playerMesh.root.rotation.set(0, 0, 0);
+ playerMesh.root.visible = true;
+ playerMesh.animate(0.016, 0, false, false, { mode: 'bike', steer: 0 });
+ } else {
+ if (playerMesh.root.parent !== engine.scene) engine.scene.add(playerMesh.root);
+ playerMesh.root.visible = false;
+ }
+
+ camYaw = candidate.yaw;
+ controls.setDrivingMode(true);
+ speedoBox.removeAttribute('hidden');
+ carHpWrap.removeAttribute('hidden');
+ speedoBox.querySelector('.vc-speedo__car').textContent = candidate.spec.name;
+ crosshair.style.display = 'none';
+ setRadioStation(profile.radioStation);
+ updateHudPills();
+ }
+
+ function summonVehicle(modelId, { color = null, enterImmediately = true } = {}) {
+ const baseYaw = player.inVehicle ? player.inVehicle.yaw : camYaw;
+ const refX = player.inVehicle ? player.inVehicle.x : player.x;
+ const refZ = player.inVehicle ? player.inVehicle.z : player.z;
+ const spawnDist = enterImmediately ? 0.5 : 4.6;
+ const rawX = refX + Math.sin(baseYaw) * spawnDist;
+ const rawZ = refZ + Math.cos(baseYaw) * spawnDist;
+ const safe = resolveBuildingCollisions(rawX, rawZ, 1.4);
+
+ if (enterImmediately && player.inVehicle) {
+ player.inVehicle.isPlayerDriving = false;
+ player.inVehicle = null;
+ }
+
+ const v = spawnVehicle({
+ modelId,
+ x: safe.x,
+ z: safe.z,
+ yaw: baseYaw,
+ color,
+ aiTraffic: false,
+ isCopUnit: false
+ });
+
+ if (enterImmediately) {
+ player.x = v.x;
+ player.z = v.z;
+ enterSpecificVehicle(v);
+ uiClick();
+ toast?.(`Dirigindo modelo 3D: ${v.spec.name}`);
+ } else {
+ uiClick();
+ toast?.(`${v.spec.name} entregue na sua frente!`);
+ }
+ return v;
+ }
+
+ // Liga cliques dos botões de topo e ações contextuais do HUD
+ let activeContextCallback = null;
+ contextActionBtn.addEventListener('click', () => {
+ if (activeContextCallback) activeContextCallback();
+ });
+
+ surrenderBtn.addEventListener('click', surrenderToPolice);
+ menuBtn.addEventListener('click', () => openOverlay('pause'));
updateHudPills();
// ---------------- Controles Touch + Teclado ----------------
@@ -931,10 +1504,14 @@ export function mountViceWorld({
host: worldRoot,
sensitivity: profile.settings.touchSensitivity || 1.0,
onAction: action => {
- if (action === 'toggle-vehicle') toggleVehicle();
- else if (action === 'cycle-radio') cycleRadio();
+ if (action === 'toggle-vehicle') {
+ if (player.ferrisRide) boardFerrisWheel();
+ else if (activeContextCallback && !player.inVehicle && !nearestEnterableVehicle(5.8)) activeContextCallback();
+ else toggleVehicle();
+ } else if (action === 'cycle-radio') cycleRadio();
else if (action === 'cycle-weapon') cycleWeapon();
- else if (action === 'switch-character') switchProtagonist();
+ else if (action === 'surrender') surrenderToPolice();
+ else if (action === 'open-garage') openOverlay('garage3d');
else if (action === 'open-map') openOverlay('map');
else if (action === 'pause') {
if (paused) closeOverlay();
@@ -942,7 +1519,7 @@ export function mountViceWorld({
} else if (action === 'horn') {
if (player.inVehicle) playHorn(player.inVehicle.spec.isPolice);
} else if (action === 'jump') {
- if (!player.inVehicle && player.onGround) {
+ if (!player.inVehicle && !player.ferrisRide && player.onGround) {
player.vy = 6.8;
player.onGround = false;
}
@@ -954,7 +1531,17 @@ export function mountViceWorld({
// ---------------- Respawn no Hospital / Delegacia ----------------
function respawnPlayer(reason = 'WASTED · HOSPITALIZADO') {
- if (player.inVehicle) toggleVehicle();
+ if (player.ferrisRide) {
+ if (playerMesh.root.parent !== engine.scene) engine.scene.add(playerMesh.root);
+ player.ferrisRide = null;
+ crosshair.style.display = '';
+ }
+ player.surrenderTimer = 0;
+ if (player.doorTransition) {
+ player.doorTransition.vehicle?.mesh.setDoorAngle?.(0);
+ player.doorTransition = null;
+ }
+ if (player.inVehicle) toggleVehicle({ instant: true });
const poi = reason.includes('DETIDO')
? POINTS_OF_INTEREST.find(p => p.kind === 'police')
: POINTS_OF_INTEREST.find(p => p.kind === 'hospital');
@@ -964,7 +1551,7 @@ export function mountViceWorld({
player.y = 0;
player.health = player.maxHealth;
player.armor = Math.max(25, player.armor);
- const fee = Math.min(profile.money, 250);
+ const fee = Math.min(profile.money, reason.includes('RENDIÇÃO') ? 150 : 250);
profile.money -= fee;
setWantedLevel(0);
if (missionStageIndex >= 0) {
@@ -977,6 +1564,7 @@ export function mountViceWorld({
// ---------------- Loop Físico Principal (`tick`) ----------------
let lastDistrictId = '';
+ const ferrisSeatWorldPos = new THREE.Vector3();
function tick(dt) {
if (paused) return;
@@ -984,19 +1572,28 @@ export function mountViceWorld({
elapsed += step;
if (garageCooldown > 0) garageCooldown -= step;
if (player.fireCooldown > 0) player.fireCooldown -= step;
+ if (player.muzzleFlashTimer > 0) player.muzzleFlashTimer = Math.max(0, player.muzzleFlashTimer - step);
+ if (bankVaultCooldown > 0) {
+ bankVaultCooldown = Math.max(0, bankVaultCooldown - step);
+ if (bankVaultCooldown <= 0) city.lootGroup.visible = true;
+ }
+ if (trainHitCooldown > 0) {
+ trainHitCooldown = Math.max(0, trainHitCooldown - step);
+ }
- // Relógio de Vice Leonida
+ // Relógio de Vice Leonida: Dia -> Noite em exatos 10 minutos (600s) e Noite -> Dia em 10 minutos!
if (profile.settings.timeMode === 'dynamic') {
- gameHour = (gameHour + step * 0.14) % 24;
+ gameHour = (gameHour + step * GAME_HOURS_PER_SECOND) % 24;
}
const hh = String(Math.floor(gameHour)).padStart(2, '0');
const mm = String(Math.floor((gameHour % 1) * 60)).padStart(2, '0');
- clockLabel.textContent = `${hh}:${mm}`;
+ const isNightClock = gameHour >= 19.0 || gameHour < 6.0;
+ clockLabel.textContent = `${isNightClock ? '🌙' : '☀️'} ${hh}:${mm}`;
const input = controls.sampleInput();
camYaw = wrapAngle(camYaw + input.yawDelta);
- // 1. Movimento do Jogador (A Pé ou Dirigindo)
+ // 1. Movimento do Jogador (A Pé, Queda/Ragdoll ou Dirigindo Carro/Moto)
if (player.inVehicle) {
const v = player.inVehicle;
const spec = v.spec;
@@ -1020,72 +1617,239 @@ export function mountViceWorld({
const speedFactor = Math.min(1, Math.abs(v.speed) / 6.5);
const revSign = v.speed >= -0.2 ? 1 : -1;
const driftBoost = input.handbrake ? 1.48 : 1.0;
+ v.steer = input.moveX;
v.yaw = wrapAngle(v.yaw - input.moveX * spec.turnRate * driftBoost * speedFactor * revSign * step);
+ const preImpactSpeed = Math.abs(v.speed);
+ const fwdX = Math.sin(v.yaw);
+ const fwdZ = Math.cos(v.yaw);
const moveDist = v.speed * step;
- const nextX = v.x + Math.sin(v.yaw) * moveDist;
- const nextZ = v.z + Math.cos(v.yaw) * moveDist;
+ const nextX = v.x + fwdX * moveDist;
+ const nextZ = v.z + fwdZ * moveDist;
- const col = resolveBuildingCollisions(nextX, nextZ, spec.width * 0.58);
+ const col = resolveBuildingCollisions(nextX, nextZ, Math.max(0.72, spec.width * 0.58));
+ let crashedBike = false;
if (col.collided) {
- const impact = Math.abs(v.speed);
- if (impact > 11) v.hp = Math.max(0, v.hp - impact * 0.85);
- v.speed *= -0.28;
+ if (preImpactSpeed > 11) v.hp = Math.max(0, v.hp - preImpactSpeed * 0.85);
+ v.x = clamp(col.x, -MAP_HALF + 20, MAP_HALF - 20);
+ v.z = clamp(col.z, -MAP_HALF + 20, MAP_HALF - 20);
+ v.mesh.root.position.set(v.x, 0, v.z);
+ // Se estiver de moto e bater forte na parede/prédio/casa, o personagem voa e cai no chão!
+ if (spec.isBike && preImpactSpeed >= 10.5) {
+ ejectFromBikeCrash(v, preImpactSpeed, fwdX, fwdZ);
+ crashedBike = true;
+ } else {
+ v.speed *= -0.28;
+ }
+ } else {
+ v.x = clamp(col.x, -MAP_HALF + 20, MAP_HALF - 20);
+ v.z = clamp(col.z, -MAP_HALF + 20, MAP_HALF - 20);
}
- v.x = clamp(col.x, -545, 452);
- v.z = clamp(col.z, -505, 505);
-
- // Evita afundar no mar/canal fora das pontes
- if (isWaterAt(v.x, v.z)) {
- v.speed *= -0.4;
- v.x -= Math.sin(v.yaw) * 2.2;
- v.z -= Math.cos(v.yaw) * 2.2;
+
+ // Colisão contra carros estacionados na rua/calçada (também derruba a moto ou empurra o carro!)
+ if (!crashedBike) {
+ for (const other of vehicles) {
+ if (other === v || !other.mesh.root.visible || other.aiTraffic) continue;
+ const dist = Math.hypot(v.x - other.x, v.z - other.z);
+ const minDist = (spec.width + other.spec.width) * 0.52 + 0.55;
+ if (dist < minDist) {
+ const nx = (v.x - other.x) / Math.max(0.1, dist);
+ const nz = (v.z - other.z) / Math.max(0.1, dist);
+ v.x += nx * (minDist - dist);
+ v.z += nz * (minDist - dist);
+ if (spec.isBike && preImpactSpeed >= 9.5) {
+ v.mesh.root.position.set(v.x, 0, v.z);
+ ejectFromBikeCrash(v, preImpactSpeed, fwdX, fwdZ);
+ crashedBike = true;
+ break;
+ } else {
+ v.speed *= -0.25;
+ other.x -= nx * 0.35;
+ other.z -= nz * 0.35;
+ other.mesh.root.position.set(other.x, 0, other.z);
+ }
+ }
+ }
}
- profile.stats.distanceDrivenMeters += Math.abs(moveDist);
+ if (!crashedBike) {
+ // Evita afundar no mar/canal fora das pontes
+ if (isWaterAt(v.x, v.z)) {
+ v.speed *= -0.4;
+ v.x -= Math.sin(v.yaw) * 2.2;
+ v.z -= Math.cos(v.yaw) * 2.2;
+ }
- v.mesh.root.position.set(v.x, 0, v.z);
- v.mesh.root.rotation.y = v.yaw;
- v.mesh.updateVisuals(step, v.speed, elapsed, spec.isPolice && wanted > 0, v.hp / v.maxHp);
+ profile.stats.distanceDrivenMeters += Math.abs(moveDist);
- player.x = v.x;
- player.z = v.z;
- player.yaw = v.yaw;
+ v.mesh.root.position.set(v.x, 0, v.z);
+ v.mesh.root.rotation.y = v.yaw;
+ v.mesh.updateVisuals(step, v.speed, elapsed, spec.isPolice && wanted > 0, v.hp / v.maxHp, input.moveX);
- // Câmera acompanha traseira do veículo suavemente quando não arrastada
- if (Math.abs(input.yawDelta) < 0.0005 && Math.abs(v.speed) > 2.2) {
- const diff = wrapAngle(v.yaw - camYaw);
- camYaw = wrapAngle(camYaw + diff * Math.min(1, step * 3.4));
- }
+ // Atualiza a pose do piloto montado na moto (segurando o guidão e inclinando nas curvas!)
+ if (spec.isBike) {
+ playerMesh.root.position.set(0, 0.04, -0.1);
+ playerMesh.root.rotation.set(0, 0, 0);
+ playerMesh.animate(step, Math.abs(v.speed), false, false, { mode: 'bike', steer: input.moveX });
+ }
+
+ player.x = v.x;
+ player.z = v.z;
+ player.yaw = v.yaw;
- // Velocímetro e barra de integridade do carro
- const kmh = Math.round(Math.abs(v.speed) * 3.6);
- speedoBox.querySelector('.vc-speedo__val').textContent = String(kmh);
- carHpFill.style.width = `${Math.round((v.hp / v.maxHp) * 100)}%`;
-
- // Oficina Pay & Spray (repara veículo, pinta cor nova e limpa polícia!)
- if (garageCooldown <= 0) {
- for (const poi of POINTS_OF_INTEREST) {
- if (poi.kind !== 'garage') continue;
- if (Math.hypot(v.x - poi.x, v.z - poi.z) < 9.5 && Math.abs(v.speed) < 16) {
- garageCooldown = 7;
- v.hp = v.maxHp;
- const newColor = spec.colors[Math.floor(Math.random() * spec.colors.length)];
- v.mesh.setBodyColor(newColor);
- if (wanted > 0) setWantedLevel(0);
- playSpraySound();
- toast?.('Oficina Neon Customs: Veículo 100% reparado, nova pintura e VCPD despistada!');
+ // Câmera acompanha traseira do veículo suavemente quando não arrastada
+ if (Math.abs(input.yawDelta) < 0.0005 && Math.abs(v.speed) > 2.2) {
+ const diff = wrapAngle(v.yaw - camYaw);
+ camYaw = wrapAngle(camYaw + diff * Math.min(1, step * 3.4));
+ }
+
+ // Velocímetro e barra de integridade do carro
+ const kmh = Math.round(Math.abs(v.speed) * 3.6);
+ speedoBox.querySelector('.vc-speedo__val').textContent = String(kmh);
+ carHpFill.style.width = `${Math.round((v.hp / v.maxHp) * 100)}%`;
+
+ // Oficina Pay & Spray (repara veículo, pinta cor nova e limpa polícia!)
+ if (garageCooldown <= 0) {
+ for (const poi of POINTS_OF_INTEREST) {
+ if (poi.kind !== 'garage') continue;
+ if (Math.hypot(v.x - poi.x, v.z - poi.z) < 9.5 && Math.abs(v.speed) < 16) {
+ garageCooldown = 7;
+ v.hp = v.maxHp;
+ const newColor = spec.colors[Math.floor(Math.random() * spec.colors.length)];
+ v.mesh.setBodyColor(newColor);
+ if (wanted > 0) setWantedLevel(0);
+ playSpraySound();
+ toast?.('Oficina Neon Customs: Veículo 100% reparado, nova pintura e VCPD despistada!');
+ }
}
}
- }
- if (v.hp <= 0) {
- player.health -= 45;
- toggleVehicle();
- toast?.('O motor fundiu! Você saltou do veículo a tempo.');
+ if (v.hp <= 0) {
+ player.health -= 45;
+ toggleVehicle({ instant: true });
+ toast?.('O motor fundiu! Você saltou do veículo a tempo.');
+ }
+ }
+ } else if (player.doorTransition) {
+ // Animação completa de abrir a porta do carro, entrar/sentar e fechar a porta (ou sair!)
+ const dtState = player.doorTransition;
+ const v = dtState.vehicle;
+ dtState.timer += step;
+ const p = Math.min(1, dtState.timer / dtState.duration);
+
+ // Curva de abertura da porta: abre rápido até ~62° (1.08 rad), mantém aberta para passagem e fecha!
+ let doorAngle = 0;
+ if (p < 0.32) {
+ doorAngle = Math.sin((p / 0.32) * (Math.PI * 0.5)) * 1.08;
+ } else if (p < 0.74) {
+ doorAngle = 1.08;
+ } else {
+ doorAngle = Math.cos(((p - 0.74) / 0.26) * (Math.PI * 0.5)) * 1.08;
+ }
+ v.mesh.setDoorAngle?.(doorAngle);
+
+ if (dtState.type === 'enter') {
+ const slideT = Math.max(0, Math.min(1, (p - 0.30) / 0.44));
+ const smoothSlide = slideT * slideT * (3 - 2 * slideT);
+ player.x = dtState.doorX + (dtState.seatX - dtState.doorX) * smoothSlide;
+ player.z = dtState.doorZ + (dtState.seatZ - dtState.doorZ) * smoothSlide;
+ const yawDiff = wrapAngle(dtState.carYaw - dtState.faceCarYaw);
+ player.yaw = wrapAngle(dtState.faceCarYaw + yawDiff * smoothSlide);
+
+ playerMesh.root.position.set(player.x, 0, player.z);
+ playerMesh.root.rotation.set(0, player.yaw, 0);
+ playerMesh.animate(step, 0, false, false, { mode: 'enterCar', doorProgress: p });
+
+ if (p >= 1) {
+ v.mesh.setDoorAngle?.(0);
+ player.doorTransition = null;
+ enterSpecificVehicle(v);
+ toast?.(`Dirigindo: ${v.spec.name}`);
+ }
+ } else {
+ const slideT = Math.max(0, Math.min(1, (p - 0.24) / 0.46));
+ const smoothSlide = slideT * slideT * (3 - 2 * slideT);
+ player.x = dtState.seatX + (dtState.doorX - dtState.seatX) * smoothSlide;
+ player.z = dtState.seatZ + (dtState.doorZ - dtState.seatZ) * smoothSlide;
+ player.yaw = dtState.carYaw;
+
+ playerMesh.root.position.set(player.x, 0, player.z);
+ playerMesh.root.rotation.set(0, player.yaw, 0);
+ playerMesh.animate(step, 0, false, false, { mode: 'exitCar', doorProgress: p });
+
+ if (p >= 1) {
+ v.mesh.setDoorAngle?.(0);
+ const safeExit = resolveBuildingCollisions(dtState.doorX, dtState.doorZ, 0.55);
+ player.x = safeExit.x;
+ player.z = safeExit.z;
+ player.doorTransition = null;
+ }
}
+ } else if (player.surrenderTimer > 0) {
+ // Estado de Rendição Voluntária (`SE RENDER`): Rafael com as mãos levantadas acima da cabeça!
+ player.surrenderTimer -= step;
+ playerMesh.root.position.set(player.x, 0, player.z);
+ playerMesh.root.rotation.y = player.yaw;
+ playerMesh.animate(step, 0, false, false, { mode: 'surrender' });
+ contextActionBtn.setAttribute('hidden', 'hidden');
+ activeContextCallback = null;
+ if (player.surrenderTimer <= 0) {
+ respawnPlayer('DETIDO · RENDIÇÃO À VCPD');
+ }
+ } else if (player.ferrisRide) {
+ // Roda-Gigante 3D Real ($70): Rafael sentado dentro da cabine enquanto ela gira em tempo real lá no alto!
+ player.ferrisRide.timer += step;
+ const cab = city.ferrisCabins[player.ferrisRide.cabinIdx];
+ cab.seatAnchor.getWorldPosition(ferrisSeatWorldPos);
+ player.x = ferrisSeatWorldPos.x;
+ player.y = ferrisSeatWorldPos.y;
+ player.z = ferrisSeatWorldPos.z;
+ playerMesh.root.position.set(0, 0.05, 0);
+ playerMesh.root.rotation.set(0, 0, 0);
+ playerMesh.animate(step, 0, false, false, { mode: 'ferrisSit' });
+
+ contextActionBtn.removeAttribute('hidden');
+ contextActionBtn.textContent = '🎡 SAIR DA RODA-GIGANTE (F)';
+ activeContextCallback = boardFerrisWheel;
+ controls.setCarButtonPrompt('SAIR CABINE');
+
+ if (player.ferrisRide.timer >= player.ferrisRide.duration && ferrisSeatWorldPos.y < FERRIS_WHEEL.baseY + 5.8) {
+ boardFerrisWheel();
+ }
+ } else if (player.ragdollTimer > 0) {
+ // Estado de Queda / Ragdoll após batida de moto ou atropelamento!
+ player.ragdollTimer = Math.max(0, player.ragdollTimer - step);
+ const slideCol = resolveBuildingCollisions(
+ player.x + player.ragdollVx * step,
+ player.z + player.ragdollVz * step,
+ 0.52
+ );
+ if (!isWaterAt(slideCol.x, slideCol.z)) {
+ player.x = clamp(slideCol.x, -MAP_HALF + 20, MAP_HALF - 20);
+ player.z = clamp(slideCol.z, -MAP_HALF + 20, MAP_HALF - 20);
+ }
+ if (slideCol.collided) {
+ player.ragdollVx *= -0.35;
+ player.ragdollVz *= -0.35;
+ }
+ const friction = player.y <= 0.02 ? 4.2 : 1.1;
+ player.ragdollVx *= Math.max(0, 1 - friction * step);
+ player.ragdollVz *= Math.max(0, 1 - friction * step);
+
+ player.y += player.vy * step;
+ player.vy -= 19.5 * step;
+ if (player.y <= 0) {
+ player.y = 0;
+ player.vy = 0;
+ player.onGround = true;
+ }
+
+ const ragElapsed = player.ragdollDuration - player.ragdollTimer;
+ playerMesh.root.position.set(player.x, player.y, player.z);
+ playerMesh.root.rotation.y = player.yaw;
+ playerMesh.animate(step, 0, false, false, { mode: 'ragdoll', ragdollTime: ragElapsed });
} else {
- // A Pé
+ // A Pé (com caminhada/corrida biomecânica + pegadas na areia + armas 3D realistas!)
const mag = Math.min(1, Math.hypot(input.moveX, input.moveY));
const baseSpeed = (input.sprint ? 8.8 : 5.2) * protagonist.speedBonus;
let actualSpeed = 0;
@@ -1095,24 +1859,60 @@ export function mountViceWorld({
const worldAngle = wrapAngle(camYaw + localAngle);
player.yaw = worldAngle;
actualSpeed = baseSpeed * mag;
- const nx = player.x + Math.sin(worldAngle) * actualSpeed * step;
- const nz = player.z + Math.cos(worldAngle) * actualSpeed * step;
+ const prevX = player.x;
+ const prevZ = player.z;
+ let nx = player.x + Math.sin(worldAngle) * actualSpeed * step;
+ let nz = player.z + Math.cos(worldAngle) * actualSpeed * step;
+
+ // Impede atravessar carros estacionados a pé
+ for (const v of vehicles) {
+ if (!v.mesh.root.visible) continue;
+ const d = Math.hypot(nx - v.x, nz - v.z);
+ const minR = v.spec.width * 0.55 + 0.45;
+ if (d < minR) {
+ nx = v.x + ((nx - v.x) / Math.max(0.08, d)) * minR;
+ nz = v.z + ((nz - v.z) / Math.max(0.08, d)) * minR;
+ }
+ }
+
const col = resolveBuildingCollisions(nx, nz, 0.52);
- if (!isWaterAt(col.x, col.z)) {
- player.x = clamp(col.x, -545, 452);
- player.z = clamp(col.z, -505, 505);
+ // No Píer da Roda-Gigante (X = 342..512, |Z - (-140)| < 14), Rafael caminha sobre o deck de madeira acima do mar!
+ const onPierDeck = col.x >= 342 && col.x <= 512 && Math.abs(col.z - FERRIS_WHEEL.z) < 13.5;
+ if (onPierDeck || !isWaterAt(col.x, col.z)) {
+ player.x = clamp(col.x, -MAP_HALF + 20, MAP_HALF - 20);
+ player.z = clamp(col.z, -MAP_HALF + 20, MAP_HALF - 20);
+ }
+
+ // Pegadas na areia quando Rafael caminha/corre na faixa de areia de Vice Beach (fora do Píer)!
+ const movedStep = Math.hypot(player.x - prevX, player.z - prevZ);
+ const onBeachSand = !onPierDeck && player.onGround
+ && player.x >= BEACH_SAND_X + 1.5 && player.x <= OCEAN_WATER_X - 0.5
+ && Math.abs(player.z) < 480;
+ if (onBeachSand && movedStep > 0.01) {
+ player.footprintDistAcc += movedStep;
+ if (player.footprintDistAcc >= 0.85) {
+ player.footprintDistAcc = 0;
+ player.lastFootLeft = !player.lastFootLeft;
+ city.addSandFootprint(player.x, player.z, player.yaw, player.lastFootLeft);
+ }
}
}
+ // Altura do piso (sobe suavemente no deck do Píer da Roda-Gigante!)
+ const onPierNow = player.x >= 342 && player.x <= 512 && Math.abs(player.z - FERRIS_WHEEL.z) < 13.5;
+ const groundLevelY = onPierNow ? FERRIS_WHEEL.baseY : 0;
+
// Gravidade e pulo
- if (!player.onGround || player.y > 0) {
+ if (!player.onGround || player.y > groundLevelY) {
player.y += player.vy * step;
player.vy -= 18.5 * step;
- if (player.y <= 0) {
- player.y = 0;
+ if (player.y <= groundLevelY) {
+ player.y = groundLevelY;
player.vy = 0;
player.onGround = true;
}
+ } else {
+ player.y = groundLevelY;
}
if (input.firing) fireWeapon();
@@ -1120,92 +1920,372 @@ export function mountViceWorld({
const w = currentWeapon();
playerMesh.root.position.set(player.x, player.y, player.z);
playerMesh.root.rotation.y = player.yaw;
- playerMesh.animate(step, actualSpeed, input.firing || player.fireCooldown > 0, w.id !== 'fist');
+ playerMesh.animate(
+ step,
+ actualSpeed,
+ input.firing || player.fireCooldown > 0,
+ w.id !== 'fist',
+ {
+ mode: player.onGround ? 'foot' : 'jump',
+ steer: input.moveX,
+ weaponId: w.id,
+ weaponGrip: w.grip || 'none',
+ muzzleFlash: player.muzzleFlashTimer > 0
+ }
+ );
+
+ // Interações contextuais a pé: LOJAS ENTRÁVEIS (comprare dentro!), ESTAÇÕES DE TREM, Cofre do Banco (6★) e Roda-Gigante!
+ const dVault = Math.hypot(player.x - BANK_INTERIOR.vaultX, player.z - BANK_INTERIOR.vaultZ);
+ const dFerris = Math.hypot(player.x - FERRIS_WHEEL.boardX, player.z - FERRIS_WHEEL.boardZ);
+ const insideShop = shopInteriorAt(player.x, player.z);
+ const nearStation = stationAt(player.x, player.z);
+
+ if (insideShop) {
+ contextActionBtn.removeAttribute('hidden');
+ contextActionBtn.textContent = `🛒 ${insideShop.itemLabel} ($${insideShop.itemPrice}) [F]`;
+ activeContextCallback = () => purchaseInsideShop(insideShop);
+ } else if (nearStation) {
+ const other = TRAIN_LINE.stations.find(st => st.id !== nearStation.id);
+ contextActionBtn.removeAttribute('hidden');
+ contextActionBtn.textContent = `🚆 EMBARCAR NO METRORAIL → ${other ? other.name.split(' Metrorail')[0].toUpperCase() : 'OUTRA ESTAÇÃO'} [F]`;
+ activeContextCallback = rideMetrorail;
+ } else if (dVault < BANK_INTERIOR.vaultRadius + 1.4 && bankVaultCooldown <= 0) {
+ contextActionBtn.removeAttribute('hidden');
+ contextActionBtn.textContent = '💰 ROUBAR COFRE (+$50.000 · 6 ESTRELAS!) [F]';
+ activeContextCallback = robBankVault;
+ } else if (dFerris < 8.5) {
+ contextActionBtn.removeAttribute('hidden');
+ contextActionBtn.textContent = `🎡 ANDAR NA RODA-GIGANTE ($${FERRIS_WHEEL.ticketPrice}) [F]`;
+ activeContextCallback = boardFerrisWheel;
+ } else {
+ contextActionBtn.setAttribute('hidden', 'hidden');
+ activeContextCallback = null;
+ }
const nearCar = nearestEnterableVehicle(6.5);
controls.setCarButtonPrompt(nearCar ? `ENTRAR (${nearCar.spec.name.split(' ')[0].toUpperCase()})` : 'ENTRAR');
}
- // 2. Tráfego Civil Inteligente
+ if (player.inVehicle || player.doorTransition) {
+ contextActionBtn.setAttribute('hidden', 'hidden');
+ activeContextCallback = null;
+ }
+
+ // Metrorail em tempo real: a buzina soa quando o trem passa perto e ATROPELA quem estiver nos trilhos!
+ if (city.train && typeof city.train.consumeHorn === 'function' && city.train.consumeHorn()) {
+ playHorn(false);
+ }
+ if (city.train && trainHitCooldown <= 0) {
+ const tz = city.train.getZ();
+ const onTrack = Math.abs(player.x - city.train.trackX) < 2.45;
+ const trainOverlaps = Math.abs(tz - player.z) < city.train.halfLength + 1.6;
+ if (onTrack && trainOverlaps && city.train.getSpeed() > 3) {
+ trainHitCooldown = 2.5;
+ const pushDir = player.x >= city.train.trackX ? 1 : -1;
+ player.ragdollVx = pushDir * 9.5;
+ player.ragdollVz = (Math.random() - 0.5) * 6;
+ player.y = 0.45;
+ player.vy = 4.6;
+ player.onGround = false;
+ player.ragdollDuration = 1.5;
+ player.ragdollTimer = 1.5;
+ player.health -= 32;
+ toast?.('🚆🚆 ATROPELADO PELO METRORAIL! Saia dos trilhos!');
+ }
+ }
+
+ // 2. Tráfego Civil Inteligente (freia atrás de outros carros/ônibus e NUNCA gruda um no outro!)
for (const v of vehicles) {
if (v.isPlayerDriving || !v.aiTraffic || !v.mesh.root.visible) continue;
- // Reduz velocidade se o jogador estiver bem na frente
- const dx = player.x - v.x;
- const dz = player.z - v.z;
- const forwardDot = dx * Math.sin(v.yaw) + dz * Math.cos(v.yaw);
- const sideDist = Math.abs(dx * Math.cos(v.yaw) - dz * Math.sin(v.yaw));
- const blocked = forwardDot > 0 && forwardDot < 13 && sideDist < 3.5;
-
- const targetSpd = blocked ? 0 : 14.5;
- v.speed += (targetSpd - v.speed) * Math.min(1, step * 3.0);
- v.x += Math.sin(v.yaw) * v.speed * step;
- v.z += Math.cos(v.yaw) * v.speed * step;
-
- // Retorno nos limites das avenidas
- if (v.z > 445) { v.z = -445; }
- else if (v.z < -445) { v.z = 445; }
-
- // Colisão carro-a-carro com o veículo do jogador
+ if (player.doorTransition?.vehicle === v) continue;
+
+ const fwdX = Math.sin(v.yaw);
+ const fwdZ = Math.cos(v.yaw);
+
+ // Reduz velocidade se o jogador a pé estiver na faixa à frente
+ const dxP = player.x - v.x;
+ const dzP = player.z - v.z;
+ const forwardDotP = dxP * fwdX + dzP * fwdZ;
+ const sideDistP = Math.abs(dxP * fwdZ - dzP * fwdX);
+ let blocked = forwardDotP > 0 && forwardDotP < 14 && sideDistP < 3.4;
+
+ // Sensor de distância frontal contra TODOS os outros veículos visíveis (tráfego, estacionados e jogador!)
+ let desiredSpd = v.spec.category === 'suv' ? 12.2 : 14.5;
+ const safeGapBase = (v.spec.length * 0.5) + 5.5;
+
+ for (const other of vehicles) {
+ if (other === v || !other.mesh.root.visible) continue;
+ const odx = other.x - v.x;
+ const odz = other.z - v.z;
+ const fwdDot = odx * fwdX + odz * fwdZ;
+ if (fwdDot <= 0) continue;
+ const reqGap = safeGapBase + other.spec.length * 0.5;
+ if (fwdDot > reqGap + 14) continue;
+ const latDist = Math.abs(odx * fwdZ - odz * fwdX);
+ if (latDist < (v.spec.width + other.spec.width) * 0.55 + 0.9) {
+ if (fwdDot < reqGap) {
+ blocked = true;
+ desiredSpd = 0;
+ break;
+ } else {
+ // Iguala suavemente à velocidade do veículo da frente antes de encostar
+ desiredSpd = Math.min(desiredSpd, Math.max(0, other.speed * 0.9));
+ }
+ }
+ }
+
+ const targetSpd = blocked ? 0 : desiredSpd;
+ const accelRate = targetSpd < v.speed ? 6.5 : 2.8;
+ v.speed += (targetSpd - v.speed) * Math.min(1, step * accelRate);
+ v.x += fwdX * v.speed * step;
+ v.z += fwdZ * v.speed * step;
+
+ // Retorno nos limites das avenidas — verifica se a ponta oposta está livre antes de reposicionar!
+ if (v.z > 445 || v.z < -445) {
+ const wrappedZ = v.z > 445 ? -445 : 445;
+ let wrapBlocked = false;
+ for (const other of vehicles) {
+ if (other === v || !other.mesh.root.visible) continue;
+ if (Math.abs(other.x - v.x) < 3.5 && Math.abs(other.z - wrappedZ) < (v.spec.length + other.spec.length) * 0.6 + 6) {
+ wrapBlocked = true;
+ break;
+ }
+ }
+ if (!wrapBlocked) {
+ v.z = wrappedZ;
+ } else {
+ v.z = clamp(v.z, -445, 445);
+ v.speed = 0;
+ }
+ }
+
+ // Separação física carro-a-carro entre todos os veículos não-controlados para NUNCA ficarem grudados!
+ for (const other of vehicles) {
+ if (other === v || other.isPlayerDriving || !other.mesh.root.visible) continue;
+ const sdx = v.x - other.x;
+ const sdz = v.z - other.z;
+ const dist = Math.hypot(sdx, sdz);
+ const minSep = (v.spec.length + other.spec.length) * 0.46 + 1.2;
+ if (dist < minSep) {
+ const latCheck = Math.abs(sdx * fwdZ - sdz * fwdX);
+ const minLat = (v.spec.width + other.spec.width) * 0.52 + 0.55;
+ if (latCheck < minLat) {
+ // Afasta ao longo do eixo entre os dois veículos sem jamais sobrepor!
+ const nx = dist > 0.05 ? (sdx / dist) : -fwdX;
+ const nz = dist > 0.05 ? (sdz / dist) : -fwdZ;
+ const push = (minSep - dist) * 0.55;
+ v.x += nx * push;
+ v.z += nz * push;
+ v.speed = 0;
+ if (other.aiTraffic) {
+ other.x -= nx * push * 0.45;
+ other.z -= nz * push * 0.45;
+ }
+ }
+ }
+ }
+
+ // Colisão carro-a-carro (ou carro batendo na moto / jogador a pé!)
if (player.inVehicle) {
const pv = player.inVehicle;
const dist = Math.hypot(pv.x - v.x, pv.z - v.z);
- if (dist < 3.6) {
+ const minCarDist = (pv.spec.width + v.spec.width) * 0.54 + 0.85;
+ if (dist < minCarDist) {
const pushX = (pv.x - v.x) / Math.max(0.1, dist);
const pushZ = (pv.z - v.z) / Math.max(0.1, dist);
- pv.x += pushX * 0.65;
- pv.z += pushZ * 0.65;
- v.x -= pushX * 0.65;
- v.z -= pushZ * 0.65;
- pv.speed *= 0.72;
+ const relSpeed = Math.hypot(
+ Math.sin(pv.yaw) * pv.speed - fwdX * v.speed,
+ Math.cos(pv.yaw) * pv.speed - fwdZ * v.speed
+ );
+ if (pv.spec.isBike && relSpeed >= 8.5) {
+ ejectFromBikeCrash(pv, relSpeed, pushX, pushZ);
+ } else {
+ pv.x += pushX * (minCarDist - dist) * 0.65;
+ pv.z += pushZ * (minCarDist - dist) * 0.65;
+ v.x -= pushX * (minCarDist - dist) * 0.55;
+ v.z -= pushZ * (minCarDist - dist) * 0.55;
+ v.speed = 0;
+ pv.speed *= 0.68;
+ }
+ }
+ } else if (!player.doorTransition && player.ragdollTimer <= 0 && Math.abs(v.speed) > 7.5) {
+ const dPed = Math.hypot(player.x - v.x, player.z - v.z);
+ if (dPed < 1.85) {
+ const hitDirX = (player.x - v.x) / Math.max(0.1, dPed);
+ const hitDirZ = (player.z - v.z) / Math.max(0.1, dPed);
+ player.ragdollVx = hitDirX * 8.5;
+ player.ragdollVz = hitDirZ * 8.5;
+ player.y = 0.4;
+ player.vy = 4.2;
+ player.onGround = false;
+ player.ragdollDuration = 1.35;
+ player.ragdollTimer = 1.35;
+ player.health -= 14;
+ toast?.('💥 Cuidado ao atravessar a avenida! Um carro atingiu você.');
}
}
v.mesh.root.position.set(v.x, 0, v.z);
v.mesh.root.rotation.y = v.yaw;
- v.mesh.updateVisuals(step, v.speed, elapsed, false, v.hp / v.maxHp);
+ v.mesh.updateVisuals(step, v.speed, elapsed, false, v.hp / v.maxHp, 0);
}
- // 3. Perseguição Policial VCPD (Viaturas)
+ // 3. Perseguição Policial VCPD Reformulada:
+ // - Distância tática de perseguição (~13m a ~18m, sem empilhar no para-choque!);
+ // - Colisão elástica real sem grudar nunca no carro do jogador (dá para meter fuga livremente!);
+ // - Quando Rafael está a pé, os policiais estacionam a viatura, abrem a porta, descem armados e trocam tiros a pé!
const activeCopsForRadar = [];
+ const activeFootCopsForRadar = [];
if (wanted > 0) {
let seenByCop = false;
- for (const cc of copCars) {
+ for (let cIdx = 0; cIdx < copCars.length; cIdx += 1) {
+ const cc = copCars[cIdx];
if (!cc.mesh.root.visible || cc.isPlayerDriving || cc.hp <= 0) continue;
activeCopsForRadar.push(cc);
+ if (cc.ramCooldown > 0) cc.ramCooldown = Math.max(0, cc.ramCooldown - step);
+
const dx = player.x - cc.x;
const dz = player.z - cc.z;
const dist = Math.hypot(dx, dz);
- if (dist < 95) seenByCop = true;
+ if (dist < 115) seenByCop = true;
- if (dist > 175) {
- // Reposiciona mais perto para manter perseguição emocionante
- const ang = Math.random() * Math.PI * 2;
- cc.x = clamp(player.x + Math.cos(ang) * 90, -430, 320);
- cc.z = clamp(player.z + Math.sin(ang) * 90, -420, 420);
+ if (dist > 210 && !cc.hasDeployedOfficer) {
+ const ang = (cIdx / copCars.length) * Math.PI * 2 + Math.random() * 0.4;
+ cc.x = clamp(player.x + Math.cos(ang) * 95, -520, 330);
+ cc.z = clamp(player.z + Math.sin(ang) * 95, -760, 760);
}
- const desiredYaw = Math.atan2(dx, dz);
- const diff = wrapAngle(desiredYaw - cc.yaw);
- cc.yaw = wrapAngle(cc.yaw + clamp(diff, -2.2 * step, 2.2 * step));
- const targetSpeed = dist > 9 ? (21 + wanted * 3.2) : 6;
- cc.speed += (targetSpeed - cc.speed) * Math.min(1, step * 2.5);
+ // Se o policial desta viatura já desembarcou e Rafael voltou para um carro longe (>32m), reembarca!
+ if (cc.hasDeployedOfficer) {
+ cc.speed *= Math.max(0, 1 - 4.5 * step);
+ if (player.inVehicle && dist > 32) {
+ cc.hasDeployedOfficer = false;
+ cc.mesh.setDoorAngle?.(0);
+ for (let k = npcs.length - 1; k >= 0; k -= 1) {
+ if (npcs[k].parentCar === cc) {
+ engine.scene.remove(npcs[k].mesh.root);
+ npcs.splice(k, 1);
+ }
+ }
+ }
+ cc.mesh.root.position.set(cc.x, 0, cc.z);
+ cc.mesh.root.rotation.y = cc.yaw;
+ cc.mesh.updateVisuals(step, cc.speed, elapsed, true, cc.hp / cc.maxHp);
+ continue;
+ }
+
+ // Se Rafael está A PÉ (ex.: saindo do carro para trocar tiro ou fugindo do Banco!) e a viatura chegou a < 24m:
+ // a viatura freia, abre a porta e os policiais saem armados para trocar tiro!
+ if (!player.inVehicle && !player.ferrisRide && dist < 24 && dist > 7.5) {
+ cc.speed = 0;
+ cc.hasDeployedOfficer = true;
+ cc.mesh.setDoorAngle?.(0.92);
+ const geom = computeVehicleDoorGeometry(cc);
+ const safeDoor = resolveBuildingCollisions(geom.doorX, geom.doorZ, 0.6);
+ spawnNpc({
+ x: safeDoor.x,
+ z: safeDoor.z,
+ isPolice: true,
+ fixedYaw: Math.atan2(dx, dz),
+ parentCar: cc
+ });
+ // Em 5 ou 6 estrelas, sai também o parceiro tático pelo lado direito da viatura!
+ if (wanted >= 5) {
+ const rightX = cc.x - Math.cos(cc.yaw) * 1.9;
+ const rightZ = cc.z + Math.sin(cc.yaw) * 1.9;
+ const safeRight = resolveBuildingCollisions(rightX, rightZ, 0.6);
+ spawnNpc({
+ x: safeRight.x,
+ z: safeRight.z,
+ isPolice: true,
+ fixedYaw: Math.atan2(dx, dz),
+ parentCar: cc
+ });
+ }
+ cc.mesh.root.position.set(cc.x, 0, cc.z);
+ cc.mesh.root.rotation.y = cc.yaw;
+ cc.mesh.updateVisuals(step, 0, elapsed, true, cc.hp / cc.maxHp);
+ continue;
+ }
+
+ // Mirar num ponto de escolta tática desplazado lateralmente por viatura para manter distância e NÃO grudar!
+ const flankSign = (cIdx % 2 === 0 ? 1 : -1);
+ const standoffDist = player.inVehicle ? (13.5 + (cIdx % 3) * 3.5) : 15.0;
+ const pYaw = player.inVehicle ? player.inVehicle.yaw : player.yaw;
+ const targetX = player.x - Math.sin(pYaw) * standoffDist + Math.cos(pYaw) * flankSign * (3.2 + cIdx * 1.1);
+ const targetZ = player.z - Math.cos(pYaw) * standoffDist - Math.sin(pYaw) * flankSign * (3.2 + cIdx * 1.1);
+
+ const tdx = targetX - cc.x;
+ const tdz = targetZ - cc.z;
+ const distToSlot = Math.hypot(tdx, tdz);
+
+ if (cc.ramCooldown <= 0) {
+ const desiredYaw = dist > standoffDist + 4 ? Math.atan2(tdx, tdz) : Math.atan2(dx, dz);
+ const diff = wrapAngle(desiredYaw - cc.yaw);
+ cc.yaw = wrapAngle(cc.yaw + clamp(diff, -2.35 * step, 2.35 * step));
+ }
+
+ const playerSpd = player.inVehicle ? Math.abs(player.inVehicle.speed) : 5.5;
+ let targetSpeed = 0;
+ if (dist < 8.8) {
+ // Muito perto: desacelera / recua levemente para manter distância de perseguição sem colar!
+ targetSpeed = Math.max(0, playerSpd * 0.65 - 4);
+ } else if (distToSlot > 8) {
+ targetSpeed = Math.min(39 + wanted * 1.2, Math.max(20, playerSpd + 6 + wanted * 1.4));
+ } else {
+ targetSpeed = Math.max(8, playerSpd * 0.96);
+ }
+
+ cc.speed += (targetSpeed - cc.speed) * Math.min(1, step * 3.2);
const nx = cc.x + Math.sin(cc.yaw) * cc.speed * step;
const nz = cc.z + Math.cos(cc.yaw) * cc.speed * step;
- const col = resolveBuildingCollisions(nx, nz, 1.2);
- if (col.collided) cc.yaw = wrapAngle(cc.yaw + 0.9);
+ const col = resolveBuildingCollisions(nx, nz, 1.25);
+ if (col.collided) {
+ cc.yaw = wrapAngle(cc.yaw + 0.95);
+ cc.speed *= 0.45;
+ }
cc.x = col.x;
cc.z = col.z;
- // Colisão tática contra o jogador
- if (dist < 3.8) {
- if (player.inVehicle) {
- player.inVehicle.hp = Math.max(0, player.inVehicle.hp - 14 * step);
- player.inVehicle.speed *= 0.92;
- } else {
- const dmg = (8 + wanted * 2.5) * step;
- if (player.armor > 0) player.armor = Math.max(0, player.armor - dmg);
- else player.health -= dmg;
+ // Separação entre as próprias viaturas policiais para nunca empilharem umas nas outras!
+ for (let j = 0; j < copCars.length; j += 1) {
+ if (j === cIdx || !copCars[j].mesh.root.visible) continue;
+ const o = copCars[j];
+ const cdx = cc.x - o.x;
+ const cdz = cc.z - o.z;
+ const cDist = Math.hypot(cdx, cdz);
+ if (cDist < 5.6) {
+ const cnx = cdx / Math.max(0.1, cDist);
+ const cnz = cdz / Math.max(0.1, cDist);
+ cc.x += cnx * (5.6 - cDist) * 0.55;
+ cc.z += cnz * (5.6 - cDist) * 0.55;
+ }
+ }
+
+ // Colisão Física Limpa e Anti-Grude contra o veículo do jogador (permite meter fuga sem travar!)
+ if (player.inVehicle) {
+ const pv = player.inVehicle;
+ const pDist = Math.hypot(pv.x - cc.x, pv.z - cc.z);
+ const minSep = (pv.spec.width + cc.spec.width) * 0.56 + 1.35;
+ if (pDist < minSep) {
+ const pushX = (pv.x - cc.x) / Math.max(0.1, pDist);
+ const pushZ = (pv.z - cc.z) / Math.max(0.1, pDist);
+ const overlap = minSep - pDist + 0.45;
+ // Empurra a viatura para trás com impulso firme e libera o carro do jogador imediatamente!
+ pv.x += pushX * overlap * 0.35;
+ pv.z += pushZ * overlap * 0.35;
+ cc.x -= pushX * overlap * 0.85;
+ cc.z -= pushZ * overlap * 0.85;
+ cc.speed = -5.5;
+ cc.ramCooldown = 1.15; // Impede a viatura de acelerar contra o carro por 1.15s após o toque!
+
+ if (pv.spec.isBike && (Math.abs(cc.speed) > 12 || Math.abs(pv.speed) > 12)) {
+ ejectFromBikeCrash(pv, 13, pushX, pushZ);
+ } else {
+ pv.hp = Math.max(0, pv.hp - 4.5);
+ pv.speed *= 0.94;
+ }
}
}
@@ -1224,46 +2304,137 @@ export function mountViceWorld({
}
}
- // 4. Pedestres Civis
+ // 4. Pedestres Civis, Banhistas/Vôlei na Praia + Policiais VCPD Táticos Trocando Tiros a Pé!
for (const npc of npcs) {
if (!npc.alive) {
npc.respawnTimer -= step;
- if (npc.respawnTimer <= 0) {
+ if (npc.respawnTimer <= 0 && !npc.isPolice) {
npc.alive = true;
npc.hp = 50;
npc.mesh.root.rotation.x = 0;
- npc.mesh.root.position.y = 0;
- npc.z = clamp(player.z + (Math.random() > 0.5 ? 85 : -85), -410, 410);
+ npc.mesh.root.position.y = npc.activity === 'sunbathe' ? 0.24 : 0;
}
continue;
}
- // Atropelamento caso o jogador bata em alta velocidade
+ // Atropelamento caso o jogador suba na calçada/areia ou atinja policial em alta velocidade
if (player.inVehicle && Math.abs(player.inVehicle.speed) > 9) {
const dCar = Math.hypot(npc.x - player.inVehicle.x, npc.z - player.inVehicle.z);
- if (dCar < 2.1) {
+ if (dCar < 2.15) {
npc.alive = false;
- npc.respawnTimer = 14;
+ npc.respawnTimer = 16;
npc.mesh.root.rotation.x = -Math.PI / 2;
npc.mesh.root.position.y = 0.2;
- if (wanted < 1) setWantedLevel(1);
+ if (npc.isPolice && wanted < 3) setWantedLevel(3);
+ else if (wanted < 1) setWantedLevel(1);
+ continue;
+ }
+ }
+
+ // 4a. Policiais VCPD desembarcados a pé: avançam taticamente até distância de tiro e trocam tiros com Rafael!
+ if (npc.isPolice) {
+ activeFootCopsForRadar.push(npc);
+ if (npc.muzzleTimer > 0) npc.muzzleTimer = Math.max(0, npc.muzzleTimer - step);
+
+ const dx = player.x - npc.x;
+ const dz = player.z - npc.z;
+ const dist = Math.hypot(dx, dz);
+ npc.yaw = Math.atan2(dx, dz);
+
+ let moveSpd = 0;
+ if (dist > 14.5) {
+ moveSpd = 4.4;
+ const col = resolveBuildingCollisions(
+ npc.x + Math.sin(npc.yaw) * moveSpd * step,
+ npc.z + Math.cos(npc.yaw) * moveSpd * step,
+ 0.55
+ );
+ if (!isWaterAt(col.x, col.z)) {
+ npc.x = col.x;
+ npc.z = col.z;
+ }
+ } else if (dist < 7.0) {
+ moveSpd = 2.2;
+ const col = resolveBuildingCollisions(
+ npc.x - Math.sin(npc.yaw) * moveSpd * step,
+ npc.z - Math.cos(npc.yaw) * moveSpd * step,
+ 0.55
+ );
+ npc.x = col.x;
+ npc.z = col.z;
+ }
+
+ // Disparo policial real com traçante luminoso contra Rafael ou contra o carro de fuga!
+ npc.shootTimer -= step;
+ if (npc.shootTimer <= 0 && dist < 38 && player.surrenderTimer <= 0 && !player.ferrisRide) {
+ npc.shootTimer = Math.max(0.55, 1.35 - wanted * 0.12) + Math.random() * 0.35;
+ npc.muzzleTimer = 0.07;
+ const spread = (Math.random() - 0.5) * 0.16;
+ const shotYaw = npc.yaw + spread;
+ const sx = Math.sin(shotYaw);
+ const sz = Math.cos(shotYaw);
+ addTracer(
+ npc.x + sx * 0.5,
+ 1.32,
+ npc.z + sz * 0.5,
+ npc.x + sx * Math.min(dist + 2, 34),
+ 1.22,
+ npc.z + sz * Math.min(dist + 2, 34),
+ '#ff9f1c'
+ );
+ playGunshot(npc.weaponId === 'rifle' ? 'rifle' : 'pistol');
+
+ // Probabilidade realista de acerto (permite esquivar correndo/pulando ou meter fuga!)
+ if (Math.random() < 0.48) {
+ const shotDmg = npc.weaponId === 'rifle' ? 7 : 4.5;
+ if (player.inVehicle) {
+ player.inVehicle.hp = Math.max(0, player.inVehicle.hp - shotDmg * 1.4);
+ } else if (player.armor > 0) {
+ player.armor = Math.max(0, player.armor - shotDmg);
+ } else {
+ player.health -= shotDmg;
+ }
+ }
+ }
+
+ npc.mesh.root.position.set(npc.x, 0, npc.z);
+ npc.mesh.root.rotation.y = npc.yaw;
+ npc.mesh.animate(step, moveSpd, true, true, {
+ weaponId: npc.weaponId,
+ weaponGrip: npc.weaponId === 'rifle' ? 'rifle' : 'pistol',
+ muzzleFlash: npc.muzzleTimer > 0
+ });
+ continue;
+ }
+
+ // 4b. Banhistas nas cadeiras de sol, Vôlei de Praia e Roda de Altinha!
+ if (npc.activity === 'sunbathe' || npc.activity === 'volleyball' || npc.activity === 'altinha') {
+ if (npc.panicTimer <= 0) {
+ npc.mesh.root.position.set(npc.x, npc.activity === 'sunbathe' ? 0.24 : 0, npc.z);
+ npc.mesh.root.rotation.y = npc.yaw;
+ npc.mesh.animate(step, 0, false, false, { activity: npc.activity });
continue;
}
+ // Se houver tiroteio perto, levantam e correm!
+ npc.mesh.root.position.y = 0;
}
const spd = npc.panicTimer > 0 ? 5.2 : 1.45;
if (npc.panicTimer > 0) npc.panicTimer -= step;
const nx = npc.x + Math.sin(npc.yaw) * spd * step;
const nz = npc.z + Math.cos(npc.yaw) * spd * step;
- if (isWaterAt(nx, nz) || Math.abs(nz) > 440) {
- npc.yaw = wrapAngle(npc.yaw + Math.PI * 0.85);
+ const col = resolveBuildingCollisions(nx, nz, 0.55);
+
+ const steppedIntoRoad = isRoadAt(col.x, col.z);
+ if (steppedIntoRoad || col.collided || isWaterAt(col.x, col.z) || Math.abs(col.z) > 450) {
+ npc.yaw = wrapAngle(npc.yaw + Math.PI);
} else {
- npc.x = nx;
- npc.z = nz;
+ npc.x = col.x;
+ npc.z = col.z;
}
npc.mesh.root.position.set(npc.x, 0, npc.z);
npc.mesh.root.rotation.y = npc.yaw;
- npc.mesh.animate(step, spd, false, false);
+ npc.mesh.animate(step, spd, false, false, { activity: 'walk' });
}
// 5. Traçantes de tiro
@@ -1301,6 +2472,11 @@ export function mountViceWorld({
let satisfied = false;
if (st.type === 'enter-vehicle') {
satisfied = Boolean(player.inVehicle);
+ } else if (st.type === 'rob-vault') {
+ if (dist < (st.radius || 5.2) && !player.inVehicle) {
+ robBankVault();
+ satisfied = true;
+ }
} else if (st.type === 'escape-wanted') {
satisfied = wanted === 0 || dist < (st.radius || 14);
if (satisfied && wanted > 0) setWantedLevel(0);
@@ -1351,19 +2527,21 @@ export function mountViceWorld({
respawnPlayer(wanted >= 2 ? 'DETIDO · DELEGACIA VCPD' : 'WASTED · HOSPITAL CENTRAL');
}
- // 8. Bairro atual no HUD
+ // 8. Bairro atual: assinatura do GTA VI — o nome do distrito aparece SÓ por alguns segundos
+ // ao cruzar para uma área nova, sem ocupar espaço fixo no HUD!
const district = districtAt(player.x, player.z);
if (district.id !== lastDistrictId) {
lastDistrictId = district.id;
- districtBadge.textContent = district.name;
- districtBadge.style.borderColor = district.color;
+ toast?.(district.name);
}
- // 9. Câmera 3ª pessoa (mais afastada e baixa em alta velocidade no carro)
+ // 9. Câmera 3ª pessoa (com vista panorâmica dedicada quando sentado na cabine da Roda-Gigante!)
const driving = Boolean(player.inVehicle);
+ const inDoorAnim = Boolean(player.doorTransition);
+ const inFerris = Boolean(player.ferrisRide);
const speedBoost = driving ? Math.min(4.2, Math.abs(player.inVehicle.speed) * 0.09) : 0;
- const distBack = (driving ? 8.6 : 5.2) + speedBoost;
- const heightUp = (driving ? 3.2 : 2.35) + input.pitchOffset * 4.2 + speedBoost * 0.2;
+ const distBack = (inFerris ? 7.2 : driving ? 8.6 : inDoorAnim ? 6.4 : 5.2) + speedBoost;
+ const heightUp = (inFerris ? 2.15 : driving ? 3.2 : inDoorAnim ? 2.55 : 2.35) + input.pitchOffset * 4.2 + speedBoost * 0.2;
const desiredCamX = player.x - Math.sin(camYaw) * distBack;
const desiredCamZ = player.z - Math.cos(camYaw) * distBack;
@@ -1376,14 +2554,22 @@ export function mountViceWorld({
engine.camera.position.set(camX, camY, camZ);
engine.camera.lookAt(
- player.x + Math.sin(camYaw) * 3.2,
- (driving ? 1.0 : player.y + 1.35),
- player.z + Math.cos(camYaw) * 3.2
+ player.x + Math.sin(camYaw) * (inFerris ? 4.5 : 3.2),
+ (driving ? 1.0 : player.y + (inFerris ? 1.0 : 1.35)),
+ player.z + Math.cos(camYaw) * (inFerris ? 4.5 : 3.2)
);
- // 10. Atmosfera, Áudio e Minimapa
- engine.updateAtmosphere(gameHour, player.x, player.z);
- city.tickCity(elapsed);
+ // 10. Atmosfera (Céu rosa fim de tarde / Sol / Lua / Postes acesos à noite!) e Minimapa
+ engine.updateAtmosphere(gameHour, player.x, player.z, step);
+ const nightFactor = (gameHour >= 19.2 || gameHour < 5.3)
+ ? 1
+ : (gameHour >= 17.5 && gameHour < 19.2)
+ ? ((gameHour - 17.5) / 1.7)
+ : (gameHour >= 5.3 && gameHour < 6.4)
+ ? (1 - (gameHour - 5.3) / 1.1)
+ : 0;
+ city.tickCity(elapsed, { nightFactor, focusX: player.x, focusZ: player.z });
+
updateVehicleLoop({
inVehicle: driving,
speed: driving ? player.inVehicle.speed : 0,
@@ -1393,19 +2579,40 @@ export function mountViceWorld({
dt: step
});
- drawRadarMinimap(radarCanvas, {
- playerX: player.x,
- playerZ: player.z,
- playerYaw: driving ? player.inVehicle.yaw : camYaw,
- vehicles,
- cops: activeCopsForRadar,
- target: currentBeaconTarget(),
- wanted
- });
+ const radarCtx = radarCanvas.getContext('2d');
+ if (radarCtx) {
+ renderMinimap(radarCtx, {
+ width: radarCanvas.width,
+ height: radarCanvas.height,
+ playerX: player.x,
+ playerZ: player.z,
+ playerYaw: driving ? player.inVehicle.yaw : camYaw,
+ vehicles,
+ cops: activeCopsForRadar,
+ copFootUnits: activeFootCopsForRadar,
+ target: currentBeaconTarget()
+ });
+ }
engine.renderer.render(engine.scene, engine.camera);
}
+ // Se o jogador escolheu "DIRIGIR AGORA" na Garagem 3D do Menu Principal, inicia já ao volante!
+ if (initialVehicleId) {
+ const existing = showroomVehicles.find(v => v.modelId === initialVehicleId);
+ if (existing) {
+ if (initialVehicleColor) {
+ existing.color = initialVehicleColor;
+ existing.mesh.setBodyColor(initialVehicleColor);
+ }
+ player.x = existing.x;
+ player.z = existing.z;
+ enterSpecificVehicle(existing);
+ } else {
+ summonVehicle(initialVehicleId, { color: initialVehicleColor, enterImmediately: true });
+ }
+ }
+
// ---------------- Animation Frame Loop ----------------
let rafId = 0;
let lastNow = performance.now();
@@ -1434,16 +2641,23 @@ export function mountViceWorld({
const api = {
player,
vehicles,
+ containerCorvette,
+ showroomVehicles,
copCars,
npcs,
+ city,
tick,
toggleVehicle,
+ summonVehicle,
fireWeapon,
setWantedLevel,
- switchProtagonist,
+ surrenderToPolice,
+ robBankVault,
+ boardFerrisWheel,
cycleRadio,
cycleWeapon,
getWanted: () => wanted,
+ getFootprintCount: () => city.getFootprintCount(),
getActiveMission: () => activeMission,
getMissionStage: () => missionStageIndex,
setPaused: v => { paused = Boolean(v); },
diff --git a/vice-game/src/world/glb-loader.js b/vice-game/src/world/glb-loader.js
index 30ca2e17..93a76450 100644
--- a/vice-game/src/world/glb-loader.js
+++ b/vice-game/src/world/glb-loader.js
@@ -1,12 +1,13 @@
-// Carregador central e cache dos 8 modelos .GLB reais de VICE VI Mobile:
-// - standing_man.glb (protagonista com esqueleto Mixamo completo)
-// - citizen_npc_pack_1_character_lowpoly_mobile.glb (14 cidadãos variados isolados e centralizados)
-// - harlows_chevrolet_corvette_stingray_nfs_unbound.glb (Supercarro Corvette)
-// - fiesta_2012.glb (Esportivo / Táxi)
-// - pontiac_gto_police_2005.glb (Muscle V8 Interceptor)
-// - 2011_chevrolet_cruze_police.glb (Viatura Policial VCPD)
-// - moto_004.glb (Moto de Rua)
-// - triple_e_commander.glb (Motorhome / Camper RV)
+// Carregador central, higienizador PBR, extrator de rodas/portas e rigging dos modelos .GLB reais de VICE VI Mobile:
+// - standing_man.glb (protagonista com esqueleto Mixamo completo, rotações em espaço global e amortecimento suave)
+// - citizen_npc_pack_1_character_lowpoly_mobile.glb (14 cidadãos articulados: braços relaxados junto ao corpo + membros animados!)
+// - harlows_chevrolet_corvette_stingray_nfs_unbound.glb (Supercarro Corvette Stingray com rodas e porta articuladas)
+// - fiesta_2012.glb (Esportivo / Táxi com 4 rodas extraídas por componentes conexos)
+// - pontiac_gto_police_2005.glb (Muscle V8 Interceptor com 4 rodas extraídas)
+// - 2011_chevrolet_cruze_police.glb (Viatura Policial VCPD com 4 rodas extraídas)
+// - moto_004.glb (Moto de Rua com pneus dianteiro e traseiro girando)
+// - triple_e_commander.glb (Motorhome / Camper RV orientado em +Z com as 4 rodas girando e esterçando)
+// + Suporte automático a overrides customizados enviados pelo Estúdio 3D (`assets/models/.glb`).
import { THREE } from './engine.js';
import { GLTFLoader } from '../../vendor/GLTFLoader.js';
@@ -23,16 +24,169 @@ export const GLB_ASSETS = Object.freeze({
commander: 'assets/brand/triple_e_commander.glb'
});
+// Mapeia slots enviados em /upload-glb.html (`assets/models/*.glb` ou `assets/brand/*.glb`) para veículos, Rafael, árvores, palmeiras e prédios!
+export const CUSTOM_SLOT_OVERRIDES = Object.freeze({
+ rafael: 'assets/models/rafael.glb',
+ lucia: 'assets/models/lucia.glb',
+ jason: 'assets/models/jason.glb',
+ 'cheetah-vice': 'assets/models/supercar.glb',
+ 'banshee-cabrio': 'assets/models/cabrio.glb',
+ 'sabre-muscle': 'assets/models/muscle.glb',
+ 'pcj-moto': 'assets/models/bike.glb',
+ 'vcpd-cruiser': 'assets/models/police.glb',
+ palm: 'assets/models/palm.glb',
+ tree: 'assets/models/tree.glb',
+ building: 'assets/models/building.glb',
+ carExtra: 'assets/models/car-extra.glb'
+});
+
+// Padrões automáticos para detectar novos .GLBs de palmeira, árvore, prédio e carros extras colocados em `assets/brand/` ou `assets/models/`!
+export const PROP_GLB_PATTERNS = Object.freeze({
+ palm: /(palm|palmeira|coconut)/i,
+ tree: /(tree|arvore|oak|pine|bush|foliage)/i,
+ building: /(building|predio|skyscraper|tower|house|hotel|office|shop)/i,
+ carExtra: /(car|carro|sedan|coupe|suv|truck|lambor|ferrari|porsche|mustang|camaro|civic|bmw|audi|supra)/i
+});
+
+// Clipes extras de animação Mixamo (.glb) opcionais detectados automaticamente em `assets/models/` ou `assets/brand/`
+export const MIXAMO_CLIP_PATTERNS = Object.freeze({
+ idle: /(idle|breathing|stand)/i,
+ walk: /(walk|strut|pacing)/i,
+ run: /(run|sprint|jog)/i,
+ jump: /(jump|leap|hop)/i,
+ fall: /(fall|knock|hit|stumble|death|ragdoll|flying)/i,
+ bike: /(bike|moto|ride)/i,
+ enterCar: /(enter|car|door)/i,
+ aim: /(aim|shoot|pistol|rifle|fire)/i
+});
+
const gltfCache = new Map();
const pendingLoads = new Map();
let citizenTemplates = null;
let sharedLoader = null;
+let customOverridesReady = null;
+const availableCustomPaths = new Set();
+let externalMixamoClipsPromise = null;
+const externalMixamoClips = {};
+
+const WORLD_X = new THREE.Vector3(1, 0, 0);
+const WORLD_Y = new THREE.Vector3(0, 1, 0);
+const WORLD_Z = new THREE.Vector3(0, 0, 1);
function loader() {
if (!sharedLoader) sharedLoader = new GLTFLoader();
return sharedLoader;
}
+/**
+ * Corrige materiais PBR exportados do Blender/Substance/Redshift com `metalness: 1, roughness: 1`
+ * (ex.: `triple_e_commander.glb` -> `mat_0001_camper`), que sem ajuste absorvem a luz difusa.
+ */
+export function sanitizePbrMaterial(mat) {
+ if (!mat) return mat;
+
+ if (mat.map && THREE.SRGBColorSpace) {
+ mat.map.colorSpace = THREE.SRGBColorSpace;
+ }
+
+ if (typeof mat.metalness === 'number' && typeof mat.roughness === 'number') {
+ const hasDiffuseMap = Boolean(mat.map);
+ const hasMetalnessMap = Boolean(mat.metalnessMap);
+
+ if (hasDiffuseMap && !hasMetalnessMap && mat.metalness >= 0.85 && mat.roughness >= 0.85) {
+ mat.metalness = 0.22;
+ mat.roughness = 0.42;
+ } else if (mat.metalness >= 0.9 && !hasMetalnessMap && !/chrome|rim|metal|exhaust|mirror/i.test(mat.name || '')) {
+ mat.metalness = Math.min(mat.metalness, 0.55);
+ mat.roughness = Math.min(mat.roughness, 0.48);
+ }
+
+ if (typeof mat.envMapIntensity === 'number') {
+ mat.envMapIntensity = Math.max(mat.envMapIntensity, 1.35);
+ }
+ }
+
+ mat.needsUpdate = true;
+ return mat;
+}
+
+export function sanitizeSceneMaterials(root) {
+ if (!root) return root;
+ root.traverse(obj => {
+ if (!obj.isMesh || !obj.material) return;
+ if (Array.isArray(obj.material)) {
+ obj.material.forEach(sanitizePbrMaterial);
+ } else {
+ sanitizePbrMaterial(obj.material);
+ }
+ });
+ return root;
+}
+
+export function discoverCustomModels() {
+ if (typeof window === 'undefined' || typeof fetch !== 'function') {
+ return Promise.resolve(availableCustomPaths);
+ }
+ if (customOverridesReady) return customOverridesReady;
+
+ customOverridesReady = fetch('./api/models', { cache: 'no-store' })
+ .then(r => (r.ok ? r.json() : null))
+ .then(data => {
+ if (data?.ok && Array.isArray(data.models)) {
+ for (const item of data.models) {
+ if (item?.path) availableCustomPaths.add(item.path);
+ }
+ }
+ return availableCustomPaths;
+ })
+ .catch(() => availableCustomPaths);
+
+ return customOverridesReady;
+}
+
+export async function resolveVehicleGlbUrl(modelId, defaultUrl) {
+ if (modelId === 'leonida-gt-custom') {
+ const envGlbs = await resolveEnvironmentPropGlbs();
+ if (envGlbs.extraCars.length > 0) return envGlbs.extraCars[0];
+ }
+ const override = CUSTOM_SLOT_OVERRIDES[modelId];
+ if (!override) return defaultUrl;
+ const set = await discoverCustomModels();
+ return set.has(override) ? override : defaultUrl;
+}
+
+export async function resolveCharacterGlbUrl(characterId, defaultUrl = GLB_ASSETS.protagonist) {
+ const override = CUSTOM_SLOT_OVERRIDES[characterId];
+ if (!override) return defaultUrl;
+ const set = await discoverCustomModels();
+ return set.has(override) ? override : defaultUrl;
+}
+
+/**
+ * Descobre automaticamente modelos `.glb` extras de árvore, palmeira, prédio e carro
+ * que o usuário tenha enviado em `assets/models/` ou `assets/brand/`.
+ */
+export async function resolveEnvironmentPropGlbs() {
+ const paths = await discoverCustomModels();
+ const baseSet = new Set(Object.values(GLB_ASSETS));
+ const result = { palm: null, tree: null, buildings: [], extraCars: [] };
+
+ for (const p of paths) {
+ if (baseSet.has(p)) continue;
+ const fname = p.split('/').pop() || '';
+ if (p === CUSTOM_SLOT_OVERRIDES.palm || PROP_GLB_PATTERNS.palm.test(fname)) {
+ result.palm = p;
+ } else if (p === CUSTOM_SLOT_OVERRIDES.tree || PROP_GLB_PATTERNS.tree.test(fname)) {
+ result.tree = p;
+ } else if (p === CUSTOM_SLOT_OVERRIDES.building || PROP_GLB_PATTERNS.building.test(fname)) {
+ result.buildings.push(p);
+ } else if (p === CUSTOM_SLOT_OVERRIDES.carExtra || PROP_GLB_PATTERNS.carExtra.test(fname)) {
+ result.extraCars.push(p);
+ }
+ }
+ return result;
+}
+
export function loadGlbOnce(url) {
if (!url || typeof window === 'undefined') return Promise.resolve(null);
if (gltfCache.has(url)) return Promise.resolve(gltfCache.get(url));
@@ -42,6 +196,7 @@ export function loadGlbOnce(url) {
loader().load(
url,
gltf => {
+ if (gltf?.scene) sanitizeSceneMaterials(gltf.scene);
gltfCache.set(url, gltf);
pendingLoads.delete(url);
resolve(gltf);
@@ -59,20 +214,406 @@ export function loadGlbOnce(url) {
return p;
}
+/**
+ * Constrói uma sub-geometria contendo apenas os triângulos indicados de `srcGeo`, preservando UVs, normais e grupos de materiais.
+ */
+function buildSubGeometryFromTriangles(srcGeo, triIndices, toLocalMatrix = null) {
+ if (!triIndices.length) return null;
+ const idx = srcGeo.index;
+ const attrNames = Object.keys(srcGeo.attributes);
+ const remap = new Map();
+ const orderedOldVerts = [];
+ const newIndices = [];
+
+ for (const t of triIndices) {
+ const i0 = idx ? idx.getX(t * 3) : t * 3;
+ const i1 = idx ? idx.getX(t * 3 + 1) : t * 3 + 1;
+ const i2 = idx ? idx.getX(t * 3 + 2) : t * 3 + 2;
+ for (const vi of [i0, i1, i2]) {
+ let ni = remap.get(vi);
+ if (ni === undefined) {
+ ni = orderedOldVerts.length;
+ remap.set(vi, ni);
+ orderedOldVerts.push(vi);
+ }
+ newIndices.push(ni);
+ }
+ }
+
+ const outGeo = new THREE.BufferGeometry();
+ const nVerts = orderedOldVerts.length;
+
+ for (const name of attrNames) {
+ const srcAttr = srcGeo.attributes[name];
+ const itemSize = srcAttr.itemSize;
+ const ArrType = srcAttr.array.constructor;
+ const arr = new ArrType(nVerts * itemSize);
+ for (let ni = 0; ni < nVerts; ni += 1) {
+ const oi = orderedOldVerts[ni];
+ for (let k = 0; k < itemSize; k += 1) {
+ arr[ni * itemSize + k] = srcAttr.array[oi * itemSize + k];
+ }
+ }
+ outGeo.setAttribute(name, new THREE.BufferAttribute(arr, itemSize, srcAttr.normalized));
+ }
+
+ outGeo.setIndex(newIndices);
+ if (toLocalMatrix) {
+ outGeo.applyMatrix4(toLocalMatrix);
+ }
+ return outGeo;
+}
+
+/**
+ * Envolve um nó existente de roda (ex.: `tire_4..7` do Motorhome ou `Calliper_*` do Corvette)
+ * em um par `steerPivot -> spinPivot` alinhado aos eixos do veículo (`+X` = giro, `+Y` = esterço),
+ * independentemente de rotações internas de 180° nos nós originais do GLB!
+ */
+function wrapNamedWheelNode(wheelObj, wrapper, isBike = false) {
+ wrapper.updateMatrixWorld(true);
+ const invWrap = new THREE.Matrix4().copy(wrapper.matrixWorld).invert();
+ const box = new THREE.Box3().setFromObject(wheelObj);
+ const centerWorld = new THREE.Vector3();
+ const sizeWorld = new THREE.Vector3();
+ box.getCenter(centerWorld);
+ box.getSize(sizeWorld);
+
+ const centerLocal = centerWorld.clone().applyMatrix4(invWrap);
+ const radius = Math.max(0.18, Math.max(sizeWorld.y, sizeWorld.z) * 0.5);
+ const isFront = centerLocal.z > 0.15;
+
+ // Matriz local do wheelObj relativa ao `wrapper`
+ const objInWrap = new THREE.Matrix4().multiplyMatrices(invWrap, wheelObj.matrixWorld);
+ const pivotOffset = new THREE.Matrix4().makeTranslation(-centerLocal.x, -centerLocal.y, -centerLocal.z);
+ const relMatrix = new THREE.Matrix4().multiplyMatrices(pivotOffset, objInWrap);
+
+ const steerPivot = new THREE.Group();
+ steerPivot.position.copy(centerLocal);
+ const spinPivot = new THREE.Group();
+ steerPivot.add(spinPivot);
+
+ if (wheelObj.parent) wheelObj.parent.remove(wheelObj);
+ wheelObj.position.set(0, 0, 0);
+ wheelObj.quaternion.identity();
+ wheelObj.scale.set(1, 1, 1);
+ wheelObj.applyMatrix4(relMatrix);
+ spinPivot.add(wheelObj);
+ wrapper.add(steerPivot);
+
+ return {
+ steerPivot,
+ spinPivot,
+ radius,
+ isFront: isBike ? centerLocal.z > 0.25 : isFront
+ };
+}
+
+/**
+ * Extrai automaticamente as rodas de malhas únicas (Fiesta, Pontiac GTO, Cruze VCPD, Moto 004)
+ * via componentes conexos soldados espacialmente, criando pivôs reais que giram e esterçam!
+ */
+function extractDisconnectedWheelMeshes(wrapper, { isBike = false } = {}) {
+ wrapper.updateMatrixWorld(true);
+ const invWrap = new THREE.Matrix4().copy(wrapper.matrixWorld).invert();
+ const meshes = [];
+ wrapper.traverse(obj => {
+ if (obj.isMesh && !obj.isSkinnedMesh && obj.geometry?.attributes?.position) {
+ meshes.push(obj);
+ }
+ });
+
+ const extractedClusters = new Map(); // clusterKey -> { cx, cy, cz, radius, parts: [{ mat, geo }] }
+ const v = new THREE.Vector3();
+
+ for (const mesh of meshes) {
+ const geo = mesh.geometry;
+ // Ignora malhas multi-material complexas com groups para não quebrar índices de sub-materiais
+ if (Array.isArray(mesh.material) && geo.groups && geo.groups.length > 1) continue;
+
+ const pos = geo.attributes.position;
+ const idx = geo.index;
+ const vCount = pos.count;
+ const triCount = Math.floor((idx ? idx.count : vCount) / 3);
+ if (triCount < 16 || triCount > 30000) continue;
+
+ const toWrap = new THREE.Matrix4().multiplyMatrices(invWrap, mesh.matrixWorld);
+ const weldMap = new Map();
+ const vToCluster = new Int32Array(vCount);
+ const wrapPts = new Float32Array(vCount * 3);
+ let nextCluster = 0;
+
+ for (let i = 0; i < vCount; i += 1) {
+ v.fromBufferAttribute(pos, i).applyMatrix4(toWrap);
+ wrapPts[i * 3] = v.x;
+ wrapPts[i * 3 + 1] = v.y;
+ wrapPts[i * 3 + 2] = v.z;
+ const key = `${Math.round(v.x * 500)},${Math.round(v.y * 500)},${Math.round(v.z * 500)}`;
+ let cid = weldMap.get(key);
+ if (cid === undefined) {
+ cid = nextCluster++;
+ weldMap.set(key, cid);
+ }
+ vToCluster[i] = cid;
+ }
+
+ const parent = new Int32Array(nextCluster);
+ for (let i = 0; i < nextCluster; i += 1) parent[i] = i;
+ const find = x => {
+ let cur = x;
+ while (parent[cur] !== cur) {
+ parent[cur] = parent[parent[cur]];
+ cur = parent[cur];
+ }
+ return cur;
+ };
+
+ for (let t = 0; t < triCount; t += 1) {
+ const i0 = idx ? idx.getX(t * 3) : t * 3;
+ const i1 = idx ? idx.getX(t * 3 + 1) : t * 3 + 1;
+ const i2 = idx ? idx.getX(t * 3 + 2) : t * 3 + 2;
+ const r0 = find(vToCluster[i0]);
+ const r1 = find(vToCluster[i1]);
+ const r2 = find(vToCluster[i2]);
+ if (r0 !== r1) parent[r1] = r0;
+ const r0b = find(r0);
+ if (r0b !== r2) parent[r2] = r0b;
+ }
+
+ const comps = new Map();
+ for (let t = 0; t < triCount; t += 1) {
+ const i0 = idx ? idx.getX(t * 3) : t * 3;
+ const root = find(vToCluster[i0]);
+ let info = comps.get(root);
+ if (!info) {
+ info = {
+ tris: [],
+ minX: Infinity, maxX: -Infinity,
+ minY: Infinity, maxY: -Infinity,
+ minZ: Infinity, maxZ: -Infinity
+ };
+ comps.set(root, info);
+ }
+ info.tris.push(t);
+ for (let k = 0; k < 3; k += 1) {
+ const vi = idx ? idx.getX(t * 3 + k) : t * 3 + k;
+ const wx = wrapPts[vi * 3];
+ const wy = wrapPts[vi * 3 + 1];
+ const wz = wrapPts[vi * 3 + 2];
+ if (wx < info.minX) info.minX = wx;
+ if (wx > info.maxX) info.maxX = wx;
+ if (wy < info.minY) info.minY = wy;
+ if (wy > info.maxY) info.maxY = wy;
+ if (wz < info.minZ) info.minZ = wz;
+ if (wz > info.maxZ) info.maxZ = wz;
+ }
+ }
+
+ // Precisa sobrar carroceria na malha ou a malha inteira ser roda (ex.: partes da moto)
+ const wheelTriSet = new Set();
+ const matchedWheelComps = [];
+
+ for (const info of comps.values()) {
+ const sx = info.maxX - info.minX;
+ const sy = info.maxY - info.minY;
+ const sz = info.maxZ - info.minZ;
+ const cx = (info.minX + info.maxX) * 0.5;
+ const cy = (info.minY + info.maxY) * 0.5;
+ const cz = (info.minZ + info.maxZ) * 0.5;
+
+ const isWheel = isBike
+ ? (sy > 0.25 && sz > 0.25 && Math.abs(sy - sz) < 0.14 && sx < 0.38 && cy > 0.2 && cy < 0.54 && Math.abs(cz) > 0.45)
+ : (sy > 0.48 && sz > 0.48 && Math.abs(sy - sz) < 0.14 && sx < 0.48 && cy > 0.18 && cy < 0.54 && Math.abs(cx) > 0.52);
+
+ if (isWheel) {
+ matchedWheelComps.push({ info, cx, cy, cz, radius: Math.max(sy, sz) * 0.5 });
+ for (const t of info.tris) wheelTriSet.add(t);
+ }
+ }
+
+ if (!matchedWheelComps.length) continue;
+
+ // Agrupa aros/discos/pneus concêntricos num mesmo eixo de roda (especialmente na Moto 004)
+ for (const wc of matchedWheelComps) {
+ const axleKey = isBike
+ ? (wc.cz > 0 ? 'bike-front' : 'bike-rear')
+ : `${wc.cx > 0 ? 'L' : 'R'}_${wc.cz > 0 ? 'F' : 'R'}`;
+
+ let entry = extractedClusters.get(axleKey);
+ if (!entry) {
+ entry = {
+ cx: isBike ? 0 : wc.cx,
+ cy: wc.cy,
+ cz: wc.cz,
+ radius: wc.radius,
+ parts: []
+ };
+ extractedClusters.set(axleKey, entry);
+ } else {
+ entry.radius = Math.max(entry.radius, wc.radius);
+ }
+
+ const wheelLocalMat = new THREE.Matrix4()
+ .makeTranslation(-entry.cx, -entry.cy, -entry.cz)
+ .multiply(toWrap);
+ const wheelGeo = buildSubGeometryFromTriangles(geo, wc.info.tris, wheelLocalMat);
+ if (wheelGeo) {
+ entry.parts.push({ geo: wheelGeo, material: mesh.material });
+ }
+ }
+
+ // Reconstrói a malha original sem os triângulos das rodas extraídas
+ const bodyTris = [];
+ for (let t = 0; t < triCount; t += 1) {
+ if (!wheelTriSet.has(t)) bodyTris.push(t);
+ }
+ if (bodyTris.length === 0) {
+ mesh.visible = false;
+ } else {
+ const nextBodyGeo = buildSubGeometryFromTriangles(geo, bodyTris, null);
+ if (nextBodyGeo) mesh.geometry = nextBodyGeo;
+ }
+ }
+
+ const wheelPivots = [];
+ for (const entry of extractedClusters.values()) {
+ const steerPivot = new THREE.Group();
+ steerPivot.position.set(entry.cx, entry.cy, entry.cz);
+ const spinPivot = new THREE.Group();
+ steerPivot.add(spinPivot);
+
+ for (const part of entry.parts) {
+ const wm = new THREE.Mesh(part.geo, part.material);
+ wm.castShadow = true;
+ wm.receiveShadow = true;
+ spinPivot.add(wm);
+ }
+ wrapper.add(steerPivot);
+ wheelPivots.push({
+ steerPivot,
+ spinPivot,
+ radius: Math.max(0.22, entry.radius),
+ isFront: entry.cz > 0.15
+ });
+ }
+
+ return wheelPivots;
+}
+
+/**
+ * Cria a porta articulada do motorista (lado esquerdo `+X` em veículos que apontam para `+Z`),
+ * pintada na cor do veículo + vidro fumê + cavidade escura de cabine (visível ao abrir a porta!).
+ */
+function buildDriverDoorRig(wrapper, { width = 2.0, length = 4.5, height = 1.4, bodyColor = '#ff2a85' } = {}) {
+ wrapper.updateMatrixWorld(true);
+ const v = new THREE.Vector3();
+ const invWrap = new THREE.Matrix4().copy(wrapper.matrixWorld).invert();
+ let doorSideX = width * 0.49;
+
+ wrapper.traverse(obj => {
+ if (!obj.isMesh || !obj.geometry?.attributes?.position) return;
+ const pos = obj.geometry.attributes.position;
+ const toWrap = new THREE.Matrix4().multiplyMatrices(invWrap, obj.matrixWorld);
+ const stride = Math.max(1, Math.floor(pos.count / 600));
+ for (let i = 0; i < pos.count; i += stride) {
+ v.fromBufferAttribute(pos, i).applyMatrix4(toWrap);
+ if (v.x > 0.35 && Math.abs(v.z - 0.15) < 0.45 && v.y > 0.38 && v.y < 1.35) {
+ if (v.x > doorSideX) doorSideX = v.x;
+ }
+ }
+ });
+
+ const doorLen = Math.min(1.18, Math.max(0.86, length * 0.24));
+ const lowerH = Math.min(0.62, Math.max(0.42, height * 0.34));
+ const hingeY = Math.min(0.68, Math.max(0.48, height * 0.36));
+ const hingeZ = Math.min(1.65, length * 0.17);
+
+ const paintMat = new THREE.MeshStandardMaterial({
+ color: bodyColor || '#dce1e9',
+ roughness: 0.28,
+ metalness: 0.38,
+ envMapIntensity: 1.35
+ });
+ const glassMat = new THREE.MeshStandardMaterial({
+ color: '#182232',
+ roughness: 0.12,
+ metalness: 0.75,
+ transparent: true,
+ opacity: 0.72
+ });
+ const interiorMat = new THREE.MeshStandardMaterial({
+ color: '#0b0e15',
+ roughness: 0.92,
+ metalness: 0.05
+ });
+
+ // Cavidade escura do interior da cabine + banco do motorista (visível somente quando a porta abre!)
+ const cabinCavity = new THREE.Mesh(
+ new THREE.BoxGeometry(0.14, lowerH * 1.42, doorLen * 0.92),
+ interiorMat
+ );
+ cabinCavity.position.set(doorSideX - 0.055, hingeY + 0.14, hingeZ - doorLen * 0.48);
+ cabinCavity.visible = false;
+ wrapper.add(cabinCavity);
+
+ // Dobradiça dianteira da porta esquerda (`+X`): `rotation.y = +angle` abre a porta para fora!
+ const doorHinge = new THREE.Group();
+ doorHinge.position.set(doorSideX + 0.006, hingeY, hingeZ);
+ doorHinge.visible = false;
+
+ const panel = new THREE.Mesh(new THREE.BoxGeometry(0.048, lowerH, doorLen), paintMat);
+ panel.position.set(0, 0, -doorLen * 0.5);
+ panel.castShadow = true;
+
+ const innerTrim = new THREE.Mesh(new THREE.BoxGeometry(0.025, lowerH * 0.9, doorLen * 0.92), interiorMat);
+ innerTrim.position.set(-0.024, 0, -doorLen * 0.5);
+
+ const windowPane = new THREE.Mesh(new THREE.BoxGeometry(0.024, lowerH * 0.62, doorLen * 0.82), glassMat);
+ windowPane.position.set(-0.01, lowerH * 0.76, -doorLen * 0.52);
+
+ const handle = new THREE.Mesh(
+ new THREE.BoxGeometry(0.032, 0.036, 0.14),
+ new THREE.MeshStandardMaterial({ color: '#1b1f2a', roughness: 0.4, metalness: 0.6 })
+ );
+ handle.position.set(0.026, lowerH * 0.24, -doorLen * 0.82);
+
+ doorHinge.add(panel, innerTrim, windowPane, handle);
+ wrapper.add(doorHinge);
+
+ return {
+ doorHinge,
+ cabinCavity,
+ paintMat,
+ setAngle(rad) {
+ const clamped = Math.max(0, Math.min(1.25, rad));
+ const open = clamped > 0.012;
+ doorHinge.visible = open;
+ cabinCavity.visible = open;
+ // Na lateral +X com dobradiça em +Z e porta indo para -Z, girar em -Y abre a porta para fora (+X)!
+ doorHinge.rotation.y = -clamped;
+ }
+ };
+}
+
/**
* Normaliza qualquer cena GLB (carro, moto, motorhome) para a escala física exata do jogo:
* - Rotaciona `yawOffset` para que a dianteira do veículo aponte em +Z;
* - Escala pelo comprimento alvo (`targetLength`);
- * - Centraliza X/Z em (0, 0) e apoia os pneus exatamente no chão (`minY = 0`).
+ * - Centraliza X/Z em (0, 0) e apoia os pneus exatamente no chão (`minY = 0`);
+ * - Extrai/envolve todas as rodas para girarem proporcionalmente à velocidade e esterçarem nas curvas;
+ * - Equipa porta do motorista articulada para a animação de entrar/sair do veículo!
*/
export function instantiateNormalizedVehicle(gltf, {
targetLength = 4.5,
yawOffset = 0,
- tintColor = null
+ tintColor = null,
+ isBike = false,
+ bodyColor = '#ff2a85'
} = {}) {
if (!gltf || !gltf.scene) return null;
const cloned = gltf.scene.clone(true);
+ sanitizeSceneMaterials(cloned);
+
const pivot = new THREE.Group();
cloned.rotation.y = yawOffset;
pivot.add(cloned);
@@ -95,8 +636,11 @@ export function instantiateNormalizedVehicle(gltf, {
-center.z * scale
);
wrapper.add(pivot);
+ wrapper.updateMatrixWorld(true);
const tintTargets = [];
+ let sampledBodyHex = bodyColor || tintColor || '#dce1e9';
+
pivot.traverse(obj => {
if (!obj.isMesh) return;
obj.castShadow = true;
@@ -104,33 +648,379 @@ export function instantiateNormalizedVehicle(gltf, {
if (tintColor && obj.material) {
const mats = Array.isArray(obj.material) ? obj.material : [obj.material];
const clonedMats = mats.map(m => {
- const cm = m.clone();
+ const cm = sanitizePbrMaterial(m.clone());
if (cm.color) cm.color.set(tintColor);
tintTargets.push(cm);
return cm;
});
obj.material = Array.isArray(obj.material) ? clonedMats : clonedMats[0];
+ } else if (!bodyColor && obj.material && !Array.isArray(obj.material) && obj.material.color && /paint|body|camper/i.test(obj.material.name || '')) {
+ sampledBodyHex = `#${obj.material.color.getHexString()}`;
}
});
+ // 1. Tenta localizar nós nomeados de roda (Motorhome Triple E Commander e Corvette Stingray)
+ const namedWheelNodes = [];
+ pivot.traverse(obj => {
+ if (/^(tire_4|tire001_5|tire002_6|tire003_7|Calliper_Front_L_02|Calliper_Front_R_03|Calliper_Rear_L_04|Calliper_Rear_R_05)$/.test(obj.name || '')) {
+ namedWheelNodes.push(obj);
+ }
+ });
+
+ let wheelPivots = [];
+ if (namedWheelNodes.length >= 2) {
+ wheelPivots = namedWheelNodes.map(wNode => wrapNamedWheelNode(wNode, wrapper, isBike));
+ } else {
+ wheelPivots = extractDisconnectedWheelMeshes(wrapper, { isBike });
+ }
+
+ // 2. Porta articulada do motorista (para todos os carros/motorhome, exceto motos)
+ const scaledW = size.x * scale;
+ const scaledH = size.y * scale;
+ const scaledL = size.z * scale;
+ const doorRig = isBike ? null : buildDriverDoorRig(wrapper, {
+ width: scaledW,
+ length: scaledL,
+ height: scaledH,
+ bodyColor: tintColor || sampledBodyHex
+ });
+
return {
node: wrapper,
+ wheelCount: wheelPivots.length,
setColor: hex => {
for (const m of tintTargets) {
if (m.color) m.color.set(hex);
}
+ if (doorRig?.paintMat?.color) {
+ doorRig.paintMat.color.set(hex);
+ }
+ },
+ updateWheels(dt, speed, steer = 0) {
+ const steerAngle = -steer * (isBike ? 0.28 : 0.44);
+ for (const wp of wheelPivots) {
+ // Avançar em +Z faz o topo da roda ir para +Z -> rotação positiva em +X (`+speed * dt / radius`)!
+ wp.spinPivot.rotation.x += (speed * dt) / wp.radius;
+ if (wp.isFront) {
+ wp.steerPivot.rotation.y = steerAngle;
+ }
+ }
+ },
+ setDoorAngle(rad) {
+ doorRig?.setAngle(rad);
}
};
}
/**
- * Extrai e centraliza os 14 personagens individuais do pacote `citizen_npc_pack_1_character_lowpoly_mobile.glb`.
+ * Converte cada cidadão estático em A-pose do `citizen_npc_pack_1_character_lowpoly_mobile.glb`
+ * em um personagem `SkinnedMesh` real de 6 ossos (`hips`, `torso`, `head`, `armL`, `armR`, `legL`, `legR`):
+ * - Abaixa os braços que vinham abertos em A-pose para ficarem relaxados naturalmente ao lado do corpo;
+ * - Anima braços, pernas, quadril e cabeça durante caminhada, corrida/fuga e respiração em idle!
+ */
+export function buildArticulatedCitizenTemplate(id, meshes) {
+ const worldBox = new THREE.Box3();
+ for (const m of meshes) worldBox.expandByObject(m);
+
+ const size = new THREE.Vector3();
+ const center = new THREE.Vector3();
+ worldBox.getSize(size);
+ worldBox.getCenter(center);
+
+ const targetHeight = 1.74;
+ const scale = targetHeight / Math.max(0.2, size.y);
+
+ let bodyMeshSrc = null;
+ const headMeshesSrc = [];
+ for (const m of meshes) {
+ if (/BODY/i.test(m.name || '')) bodyMeshSrc = m;
+ else headMeshesSrc.push(m);
+ }
+ if (!bodyMeshSrc) bodyMeshSrc = meshes[0];
+
+ // Normaliza a geometria do corpo para metros reais, centrada em X/Z e pés em Y = 0
+ const bodyGeo = bodyMeshSrc.geometry.clone();
+ bodyGeo.applyMatrix4(bodyMeshSrc.matrixWorld);
+ bodyGeo.translate(-center.x, -worldBox.min.y, -center.z);
+ bodyGeo.scale(scale, scale, scale);
+
+ const pos = bodyGeo.attributes.position;
+ let bodyMinY = Infinity;
+ let bodyMaxY = -Infinity;
+ let maxAdx = 0;
+ let handY = 0;
+
+ for (let i = 0; i < pos.count; i += 1) {
+ const x = pos.getX(i);
+ const y = pos.getY(i);
+ if (y < bodyMinY) bodyMinY = y;
+ if (y > bodyMaxY) bodyMaxY = y;
+ if (Math.abs(x) > maxAdx) {
+ maxAdx = Math.abs(x);
+ handY = y;
+ }
+ }
+
+ const bodyH = Math.max(0.4, bodyMaxY - bodyMinY);
+ const shoulderX = 0.185;
+ const shoulderY = bodyMinY + bodyH * 0.87;
+ const hipX = 0.10;
+ const hipY = bodyMinY + bodyH * 0.47;
+
+ // 1. Dobra os braços abertos da A-pose para baixo (~82° abaixo da horizontal, junto ao corpo!)
+ const curArmAngle = Math.atan2(shoulderY - handY, Math.max(0.05, maxAdx - shoulderX));
+ const desiredArmAngle = 1.43;
+ const adduction = Math.max(0, desiredArmAngle - curArmAngle);
+
+ const skinIndices = new Uint16Array(pos.count * 4);
+ const skinWeights = new Float32Array(pos.count * 4);
+ // Bone indices: 0 = root/hips, 1 = torso, 2 = armL (+X), 3 = armR (-X), 4 = legL (+X), 5 = legR (-X)
+
+ for (let i = 0; i < pos.count; i += 1) {
+ let x = pos.getX(i);
+ let y = pos.getY(i);
+ const z = pos.getZ(i);
+ const ny = (y - bodyMinY) / bodyH;
+ const adx = Math.abs(x);
+
+ // Pesos de skinning antes da rotação (onde o braço A-pose é perfeitamente separável por |x| > 0.175!)
+ if (ny > 0.44 && adx > 0.175) {
+ const armWeight = Math.min(1, (adx - 0.175) / 0.075);
+ const sign = x >= 0 ? 1 : -1;
+ const sx = sign * shoulderX;
+ const rx = x - sx;
+ const ry = y - shoulderY;
+ const theta = -sign * adduction * armWeight;
+ const cosT = Math.cos(theta);
+ const sinT = Math.sin(theta);
+ x = sx + rx * cosT - ry * sinT;
+ y = shoulderY + rx * sinT + ry * cosT;
+ pos.setXYZ(i, x, y, z);
+
+ const armBoneIdx = sign > 0 ? 2 : 3;
+ skinIndices[i * 4] = armBoneIdx;
+ skinIndices[i * 4 + 1] = 1;
+ skinWeights[i * 4] = armWeight;
+ skinWeights[i * 4 + 1] = 1 - armWeight;
+ } else if (ny < 0.49) {
+ const legWeight = Math.min(1, Math.max(0, (0.49 - ny) / 0.08));
+ const legBoneIdx = x >= 0 ? 4 : 5;
+ skinIndices[i * 4] = legBoneIdx;
+ skinIndices[i * 4 + 1] = 0;
+ skinWeights[i * 4] = legWeight;
+ skinWeights[i * 4 + 1] = 1 - legWeight;
+ } else {
+ const torsoWeight = Math.min(1, Math.max(0, (ny - 0.45) / 0.1));
+ skinIndices[i * 4] = 1;
+ skinIndices[i * 4 + 1] = 0;
+ skinWeights[i * 4] = torsoWeight;
+ skinWeights[i * 4 + 1] = 1 - torsoWeight;
+ }
+ }
+
+ bodyGeo.setAttribute('skinIndex', new THREE.BufferAttribute(skinIndices, 4));
+ bodyGeo.setAttribute('skinWeight', new THREE.BufferAttribute(skinWeights, 4));
+ bodyGeo.computeVertexNormals();
+ bodyGeo.computeBoundingSphere();
+
+ const headParts = headMeshesSrc.map(hm => {
+ const hGeo = hm.geometry.clone();
+ hGeo.applyMatrix4(hm.matrixWorld);
+ hGeo.translate(-center.x, -worldBox.min.y, -center.z);
+ hGeo.scale(scale, scale, scale);
+ hGeo.translate(0, -(bodyMaxY - 0.02), 0);
+ hGeo.computeBoundingSphere();
+ return { geo: hGeo, material: hm.material };
+ });
+
+ return {
+ id,
+ bodyGeo,
+ bodyMaterial: bodyMeshSrc.material,
+ headParts,
+ pivots: {
+ hipsY: hipY,
+ torsoRelY: 0.08,
+ neckRelY: (bodyMaxY - 0.02) - (hipY + 0.08),
+ shoulderX,
+ shoulderRelY: shoulderY - (hipY + 0.08),
+ hipX
+ }
+ };
+}
+
+/**
+ * Instancia um cidadão articulado a partir de um template `citizenTemplates[i]`.
+ */
+export function instantiateArticulatedCitizen(template) {
+ if (!template || !template.bodyGeo) return null;
+
+ const root = new THREE.Group();
+ root.name = `citizen-${template.id}`;
+
+ const { hipsY, torsoRelY, neckRelY, shoulderX, shoulderRelY, hipX } = template.pivots;
+
+ const hipsBone = new THREE.Bone();
+ hipsBone.name = 'hips';
+ hipsBone.position.set(0, hipsY, 0);
+
+ const torsoBone = new THREE.Bone();
+ torsoBone.name = 'torso';
+ torsoBone.position.set(0, torsoRelY, 0);
+ hipsBone.add(torsoBone);
+
+ const armLBone = new THREE.Bone();
+ armLBone.name = 'armL';
+ armLBone.position.set(shoulderX, shoulderRelY, 0);
+ torsoBone.add(armLBone);
+
+ const armRBone = new THREE.Bone();
+ armRBone.name = 'armR';
+ armRBone.position.set(-shoulderX, shoulderRelY, 0);
+ torsoBone.add(armRBone);
+
+ const legLBone = new THREE.Bone();
+ legLBone.name = 'legL';
+ legLBone.position.set(hipX, 0, 0);
+ hipsBone.add(legLBone);
+
+ const legRBone = new THREE.Bone();
+ legRBone.name = 'legR';
+ legRBone.position.set(-hipX, 0, 0);
+ hipsBone.add(legRBone);
+
+ const headPivot = new THREE.Group();
+ headPivot.position.set(0, neckRelY, 0);
+ for (const hp of template.headParts) {
+ const hm = new THREE.Mesh(hp.geo, hp.material);
+ hm.castShadow = true;
+ hm.receiveShadow = true;
+ headPivot.add(hm);
+ }
+ torsoBone.add(headPivot);
+
+ const skinnedBody = new THREE.SkinnedMesh(template.bodyGeo, template.bodyMaterial);
+ skinnedBody.castShadow = true;
+ skinnedBody.receiveShadow = true;
+ skinnedBody.frustumCulled = false;
+
+ root.add(hipsBone);
+ root.add(skinnedBody);
+ root.updateMatrixWorld(true);
+
+ const skeleton = new THREE.Skeleton([hipsBone, torsoBone, armLBone, armRBone, legLBone, legRBone]);
+ skinnedBody.bind(skeleton, skinnedBody.matrixWorld);
+
+ let phase = Math.random() * Math.PI * 2;
+ let idleTime = Math.random() * 10;
+ let blendMove = 0;
+
+ function animateCitizen(dt, speed, activity = 'walk') {
+ idleTime += dt;
+
+ // 1. Deitado tomando sol na cadeira espreguiçadeira sob o guarda-sol em Vice Beach!
+ if (activity === 'sunbathe') {
+ const breath = Math.sin(idleTime * 1.6);
+ hipsBone.position.y = 0.42;
+ hipsBone.rotation.set(-1.12, 0, 0);
+ torsoBone.rotation.set(0.18 + breath * 0.02, 0, 0);
+ legLBone.rotation.set(0.28, 0, 0.06);
+ legRBone.rotation.set(0.28, 0, -0.06);
+ armLBone.rotation.set(0.25, 0, -0.18);
+ armRBone.rotation.set(0.25, 0, 0.18);
+ headPivot.rotation.set(0.28, Math.sin(idleTime * 0.5) * 0.15, 0);
+ return;
+ }
+
+ // 2. Jogando Vôlei de Praia / Altinha / Fazendo "Ola" na areia!
+ if (activity === 'volleyball' || activity === 'altinha') {
+ phase += dt * (activity === 'volleyball' ? 3.8 : 4.8);
+ const jump = Math.max(0, Math.sin(phase));
+ hipsBone.position.y = hipsY + jump * (activity === 'volleyball' ? 0.34 : 0.12);
+ torsoBone.rotation.set(-jump * 0.18, Math.sin(phase * 0.5) * 0.15, 0);
+ if (activity === 'volleyball') {
+ // Ergue os dois braços acima da cabeça para cortar/levantar a bola de vôlei!
+ const raise = 0.55 + jump * 2.1;
+ armLBone.rotation.set(-raise, 0, -0.12);
+ armRBone.rotation.set(-raise, 0, 0.12);
+ legLBone.rotation.set(jump * 0.25, 0, 0);
+ legRBone.rotation.set(-jump * 0.15, 0, 0);
+ } else {
+ // Altinha na praia: chuta/levanta a bola alternando os pés com braços abertos de equilíbrio!
+ const kickL = Math.max(0, Math.sin(phase));
+ const kickR = Math.max(0, -Math.sin(phase));
+ legLBone.rotation.set(-kickL * 0.95, 0, 0);
+ legRBone.rotation.set(-kickR * 0.95, 0, 0);
+ armLBone.rotation.set(-0.35 - kickR * 0.4, 0, -0.22);
+ armRBone.rotation.set(-0.35 - kickL * 0.4, 0, 0.22);
+ }
+ headPivot.rotation.set(-0.25, Math.sin(phase) * 0.12, 0);
+ return;
+ }
+
+ const moving = speed > 0.18;
+ const targetBlend = moving ? 1 : 0;
+ blendMove += (targetBlend - blendMove) * Math.min(1, dt * 9);
+
+ if (moving) {
+ const runFactor = Math.max(0, Math.min(1, (speed - 2.4) / 3.2));
+ const freq = 4.2 + speed * 1.45;
+ phase += dt * freq;
+
+ const s = Math.sin(phase);
+ const c = Math.cos(phase);
+ const stride = (0.42 + runFactor * 0.44) * blendMove;
+ const armSwing = (0.36 + runFactor * 0.46) * blendMove;
+ const bounce = Math.abs(Math.cos(phase)) * (0.026 + runFactor * 0.036) * blendMove;
+
+ hipsBone.position.y = hipsY + bounce;
+ hipsBone.rotation.y = s * 0.07 * blendMove;
+ torsoBone.rotation.x = (0.04 + runFactor * 0.16) * blendMove;
+ torsoBone.rotation.y = -s * 0.11 * blendMove;
+ torsoBone.rotation.z = c * 0.025 * blendMove;
+
+ // Em Three.js: rotação negativa em X avança um membro pendente (-Y) para frente (+Z)!
+ legLBone.rotation.x = -s * stride;
+ legRBone.rotation.x = s * stride;
+
+ // Braços balançam em oposição às pernas (perna esquerda à frente -> braço direito à frente!)
+ armLBone.rotation.x = s * armSwing - runFactor * 0.18;
+ armRBone.rotation.x = -s * armSwing - runFactor * 0.18;
+ armLBone.rotation.z = -0.03 - runFactor * 0.05;
+ armRBone.rotation.z = 0.03 + runFactor * 0.05;
+
+ headPivot.rotation.y = -s * 0.05 + Math.sin(idleTime * 0.9) * 0.08;
+ headPivot.rotation.x = -runFactor * 0.08;
+ } else {
+ const breath = Math.sin(idleTime * 2.1);
+ hipsBone.position.y = hipsY + breath * 0.008;
+ hipsBone.rotation.y *= 0.85;
+ torsoBone.rotation.x = breath * 0.018;
+ torsoBone.rotation.y = Math.sin(idleTime * 0.7) * 0.04;
+ torsoBone.rotation.z = 0;
+ legLBone.rotation.x *= 0.84;
+ legRBone.rotation.x *= 0.84;
+ armLBone.rotation.x = armLBone.rotation.x * 0.84 + breath * 0.015;
+ armRBone.rotation.x = armRBone.rotation.x * 0.84 - breath * 0.015;
+ armLBone.rotation.z = -0.025;
+ armRBone.rotation.z = 0.025;
+ headPivot.rotation.y = Math.sin(idleTime * 0.85) * 0.18;
+ headPivot.rotation.x = Math.cos(idleTime * 0.6) * 0.04;
+ }
+ }
+
+ return { node: root, animateCitizen };
+}
+
+/**
+ * Extrai e prepara os 14 cidadãos articulados do pacote `citizen_npc_pack_1_character_lowpoly_mobile.glb`.
*/
export async function loadCitizenTemplates() {
if (citizenTemplates) return citizenTemplates;
const gltf = await loadGlbOnce(GLB_ASSETS.citizenPack);
if (!gltf || !gltf.scene) return [];
+ sanitizeSceneMaterials(gltf.scene);
gltf.scene.updateMatrixWorld(true);
const byId = new Map();
@@ -144,34 +1034,7 @@ export async function loadCitizenTemplates() {
const templates = [];
for (const [id, meshes] of byId.entries()) {
- const group = new THREE.Group();
- group.name = `citizen-${id}`;
-
- const worldBox = new THREE.Box3();
- for (const m of meshes) worldBox.expandByObject(m);
-
- const size = new THREE.Vector3();
- const center = new THREE.Vector3();
- worldBox.getSize(size);
- worldBox.getCenter(center);
-
- const targetHeight = 1.74;
- const scale = targetHeight / Math.max(0.2, size.y);
-
- for (const m of meshes) {
- const mc = m.clone();
- mc.applyMatrix4(m.matrixWorld);
- mc.position.x -= center.x;
- mc.position.y -= worldBox.min.y;
- mc.position.z -= center.z;
- mc.castShadow = true;
- group.add(mc);
- }
-
- const scaledHolder = new THREE.Group();
- group.scale.setScalar(scale);
- scaledHolder.add(group);
- templates.push(scaledHolder);
+ templates.push(buildArticulatedCitizenTemplate(id, meshes));
}
citizenTemplates = templates;
@@ -179,13 +1042,103 @@ export async function loadCitizenTemplates() {
}
/**
- * Instancia o protagonista articulado (`standing_man.glb`, esqueleto Mixamo) com animação
- * de idle embutida + passada procedural nos ossos das pernas/braços ao caminhar, correr e mirar.
+ * Re-mapeia os nomes de ossos de qualquer clipe `.glb` do Mixamo para os nomes exatos dos ossos do modelo alvo.
+ */
+export function retargetMixamoClip(clip, targetModel) {
+ if (!clip || !targetModel) return clip;
+ const boneMap = new Map();
+ targetModel.traverse(obj => {
+ if (!obj.isBone) return;
+ const clean = obj.name.replace(/^.*mixamorig:?/i, '').replace(/_\d+$/, '').toLowerCase();
+ boneMap.set(clean, obj.name);
+ });
+
+ const tracks = [];
+ for (const t of clip.tracks) {
+ const dot = t.name.lastIndexOf('.');
+ if (dot < 0) continue;
+ const rawNode = t.name.slice(0, dot);
+ const prop = t.name.slice(dot + 1);
+ const clean = rawNode.replace(/^.*mixamorig:?/i, '').replace(/_\d+$/, '').toLowerCase();
+ const mappedBone = boneMap.get(clean);
+ if (!mappedBone) continue;
+
+ if (clean === 'hips' && prop === 'position') continue;
+
+ const clonedTrack = t.clone();
+ clonedTrack.name = `${mappedBone}.${prop}`;
+ tracks.push(clonedTrack);
+ }
+
+ if (!tracks.length) return null;
+ return new THREE.AnimationClip(clip.name || 'mixamo-clip', clip.duration, tracks);
+}
+
+export function loadExternalMixamoClips() {
+ if (externalMixamoClipsPromise) return externalMixamoClipsPromise;
+ externalMixamoClipsPromise = discoverCustomModels().then(async paths => {
+ const knownVehicleFiles = new Set(Object.values(GLB_ASSETS));
+ const candidates = [...paths].filter(p => !knownVehicleFiles.has(p));
+ for (const path of candidates) {
+ const fileName = path.split('/').pop() || '';
+ for (const [role, regex] of Object.entries(MIXAMO_CLIP_PATTERNS)) {
+ if (regex.test(fileName)) {
+ const gltf = await loadGlbOnce(path);
+ if (gltf?.animations?.length) {
+ externalMixamoClips[role] = gltf.animations[0];
+ }
+ }
+ }
+ }
+ return externalMixamoClips;
+ }).catch(() => externalMixamoClips);
+ return externalMixamoClipsPromise;
+}
+
+/**
+ * Instancia o protagonista articulado (`standing_man.glb`, esqueleto Mixamo) com:
+ * - Rotações biomecânicas exatas em ESPAÇO GLOBAL (`WORLD_X`, `WORLD_Y`, `WORLD_Z`) convertidas
+ * para o espaço de cada osso + interpolação suave (`slerp`) entre poses (zero movimentos robóticos!);
+ * - Respiração e transferência de peso naturais em idle;
+ * - Ciclo de marcha humana de 2 harmônicos (ataque de calcanhar, passagem de joelho flexionado, impulsão);
+ * - Animação dedicada de abrir a porta do carro, abaixar a cabeça, entrar no banco e fechar a porta (`enterCar` / `exitCar`);
+ * - Pose montado na moto (`bike`) e cambalhota de acidente (`ragdoll`).
*/
export function instantiateRiggedProtagonist(gltf, { outfitTint = null } = {}) {
if (!gltf || !gltf.scene) return null;
const model = cloneSkeleton(gltf.scene);
+ sanitizeSceneMaterials(model);
+
+ let mixer = null;
+ const actions = {};
+ if (gltf.animations && gltf.animations.length > 0) {
+ mixer = new THREE.AnimationMixer(model);
+ actions.idle = mixer.clipAction(gltf.animations[0]);
+ actions.idle.play();
+ mixer.update(0.01);
+
+ for (let i = 1; i < gltf.animations.length; i += 1) {
+ const c = gltf.animations[i];
+ for (const [role, regex] of Object.entries(MIXAMO_CLIP_PATTERNS)) {
+ if (!actions[role] && regex.test(c.name || '')) {
+ actions[role] = mixer.clipAction(c);
+ }
+ }
+ }
+ }
+
+ loadExternalMixamoClips().then(clips => {
+ if (!mixer || !clips) return;
+ for (const [role, rawClip] of Object.entries(clips)) {
+ if (actions[role]) continue;
+ const retargeted = retargetMixamoClip(rawClip, model);
+ if (retargeted) {
+ actions[role] = mixer.clipAction(retargeted);
+ }
+ }
+ });
+
model.updateMatrixWorld(true);
const box = new THREE.Box3().setFromObject(model);
@@ -196,7 +1149,8 @@ export function instantiateRiggedProtagonist(gltf, { outfitTint = null } = {}) {
const scale = 1.78 / Math.max(0.3, size.y);
model.scale.setScalar(scale);
- model.position.set(-center.x * scale, -box.min.y * scale, -center.z * scale);
+ const baseModelPos = new THREE.Vector3(-center.x * scale, -box.min.y * scale, -center.z * scale);
+ model.position.copy(baseModelPos);
const bones = {};
const outfitMaterials = [];
@@ -208,6 +1162,7 @@ export function instantiateRiggedProtagonist(gltf, { outfitTint = null } = {}) {
const mats = Array.isArray(obj.material) ? obj.material : [obj.material];
const nextMats = mats.map(m => {
if (!m) return m;
+ sanitizePbrMaterial(m);
if (/outfit/i.test(m.name || '')) {
const cm = m.clone();
if (outfitTint && cm.color) cm.color.lerp(new THREE.Color(outfitTint), 0.38);
@@ -220,91 +1175,473 @@ export function instantiateRiggedProtagonist(gltf, { outfitTint = null } = {}) {
}
if (obj.isBone) {
const n = obj.name;
- if (n.includes('LeftUpLeg')) bones.leftUpLeg = obj;
+ if (n.includes('Hips')) bones.hips = obj;
+ else if (n.includes('Spine2')) bones.chest = obj;
+ else if (n.includes('Spine1')) bones.spine = obj;
+ else if (n.includes('Neck')) bones.neck = obj;
+ else if (n.includes('Head') && !n.includes('Top')) bones.head = obj;
+ else if (n.includes('LeftUpLeg')) bones.leftUpLeg = obj;
else if (n.includes('RightUpLeg')) bones.rightUpLeg = obj;
else if (n.includes('LeftLeg')) bones.leftLeg = obj;
else if (n.includes('RightLeg')) bones.rightLeg = obj;
+ else if (n.includes('LeftFoot')) bones.leftFoot = obj;
+ else if (n.includes('RightFoot')) bones.rightFoot = obj;
else if (n.includes('LeftArm')) bones.leftArm = obj;
else if (n.includes('RightArm')) bones.rightArm = obj;
+ else if (n.includes('LeftForeArm')) bones.leftForeArm = obj;
else if (n.includes('RightForeArm')) bones.rightForeArm = obj;
- else if (n.includes('Spine1')) bones.spine = obj;
- else if (n.includes('Hips')) bones.hips = obj;
}
});
- // Guarda rotações originais da bind pose / idle para somar passada limpa sem deformar
- const restQuats = {};
+ const holder = new THREE.Group();
+ holder.add(model);
+ holder.updateMatrixWorld(true);
+
+ const idleQuats = {};
+ const smoothedQuats = {};
for (const [k, b] of Object.entries(bones)) {
- restQuats[k] = b.quaternion.clone();
+ idleQuats[k] = b.quaternion.clone();
+ smoothedQuats[k] = b.quaternion.clone();
}
- let mixer = null;
- let idleAction = null;
- if (gltf.animations && gltf.animations.length > 0) {
- mixer = new THREE.AnimationMixer(model);
- idleAction = mixer.clipAction(gltf.animations[0]);
- idleAction.play();
- }
+ const tmpParentWorldQuat = new THREE.Quaternion();
+ const tmpInvParentQuat = new THREE.Quaternion();
+ const tmpWorldDelta = new THREE.Quaternion();
+ const tmpStepQuat = new THREE.Quaternion();
+ const tmpTargetLocal = new THREE.Quaternion();
- const holder = new THREE.Group();
- holder.add(model);
+ /**
+ * Aplica rotações anatômicas definidas nos eixos do personagem (`holder`: +X esquerda, +Y cima, +Z frente)
+ * independentemente de eixos revirados do exportador Mixamo/FBX, com amortecimento temporal suave (`slerp`)!
+ */
+ function applyCharSpaceRotations(boneKey, ops, smoothAlpha = 1) {
+ const bone = bones[boneKey];
+ if (!bone) return;
+ const baseQ = idleQuats[boneKey];
- const qRot = new THREE.Quaternion();
- const xAxis = new THREE.Vector3(1, 0, 0);
- const zAxis = new THREE.Vector3(0, 0, 1);
- let stridePhase = 0;
+ if (!ops || ops.length === 0) {
+ tmpTargetLocal.copy(baseQ);
+ } else {
+ // Garante que a cadeia pai (ex.: coxa antes da canela) esteja atualizada no espaço do `holder`
+ bone.parent.updateWorldMatrix(true, false);
+ bone.parent.getWorldQuaternion(tmpParentWorldQuat);
+ // Remove a rotação global do `holder` para trabalhar sempre nos eixos locais do personagem!
+ holder.getWorldQuaternion(tmpStepQuat);
+ tmpStepQuat.invert();
+ tmpParentWorldQuat.premultiply(tmpStepQuat);
- function animateRig(dt, speed, aiming = false) {
- if (mixer) {
- // Quando parado, usa 100% do clipe Mixamo; correndo, reduz peso do clipe e aplica passada atlética
- const movingBlend = Math.min(1, speed / 2.2);
- if (idleAction) idleAction.weight = 1 - movingBlend * 0.82;
- mixer.update(dt);
+ tmpInvParentQuat.copy(tmpParentWorldQuat).invert();
+ tmpWorldDelta.identity();
+ for (let i = 0; i < ops.length; i += 1) {
+ const [axis, angle] = ops[i];
+ tmpStepQuat.setFromAxisAngle(axis, angle);
+ tmpWorldDelta.premultiply(tmpStepQuat);
+ }
+ tmpTargetLocal.copy(tmpInvParentQuat).multiply(tmpWorldDelta).multiply(tmpParentWorldQuat).multiply(baseQ);
}
- if (speed > 0.25) {
- stridePhase += dt * (4.8 + speed * 1.15);
- const amp = Math.min(0.82, 0.24 + speed * 0.068);
- const s = Math.sin(stridePhase);
+ if (smoothAlpha >= 0.999) {
+ smoothedQuats[boneKey].copy(tmpTargetLocal);
+ } else {
+ smoothedQuats[boneKey].slerp(tmpTargetLocal, smoothAlpha);
+ }
+ bone.quaternion.copy(smoothedQuats[boneKey]);
+ }
- if (bones.leftUpLeg) {
- bones.leftUpLeg.quaternion.copy(restQuats.leftUpLeg).multiply(qRot.setFromAxisAngle(xAxis, -s * amp));
- }
- if (bones.rightUpLeg) {
- bones.rightUpLeg.quaternion.copy(restQuats.rightUpLeg).multiply(qRot.setFromAxisAngle(xAxis, s * amp));
- }
- if (bones.leftLeg) {
- const kneeL = Math.max(0, s) * amp * 0.85;
- bones.leftLeg.quaternion.copy(restQuats.leftLeg).multiply(qRot.setFromAxisAngle(xAxis, kneeL));
+ let stridePhase = 0;
+ let breathTime = 0;
+ let activeClipRole = 'idle';
+ let smoothedOffsetY = 0;
+ let smoothedOffsetZ = 0;
+ let smoothedRoll = 0;
+
+ function switchClipAction(desiredRole) {
+ if (!mixer) return false;
+ const targetAction = actions[desiredRole];
+ if (!targetAction) {
+ if (activeClipRole !== 'idle' && actions.idle) {
+ actions[activeClipRole]?.fadeOut(0.18);
+ actions.idle.reset().fadeIn(0.18).play();
+ activeClipRole = 'idle';
}
- if (bones.rightLeg) {
- const kneeR = Math.max(0, -s) * amp * 0.85;
- bones.rightLeg.quaternion.copy(restQuats.rightLeg).multiply(qRot.setFromAxisAngle(xAxis, kneeR));
+ return false;
+ }
+ if (activeClipRole !== desiredRole) {
+ actions[activeClipRole]?.fadeOut(0.18);
+ targetAction.reset().fadeIn(0.18).play();
+ activeClipRole = desiredRole;
+ }
+ return true;
+ }
+
+ function animateRig(dt, speed, aiming = false, {
+ mode = 'foot',
+ steer = 0,
+ ragdollTime = 0,
+ doorProgress = 0,
+ weaponGrip = 'none'
+ } = {}) {
+ const blend = Math.min(1, dt * 15);
+ breathTime += dt;
+
+ // 0. Modo Rendido à Polícia (`surrender` — mãos levantadas acima da cabeça!)
+ if (mode === 'surrender') {
+ switchClipAction('idle');
+ if (mixer) mixer.update(dt * 0.2);
+ model.position.set(baseModelPos.x, baseModelPos.y - 0.12, baseModelPos.z);
+ holder.rotation.set(0, 0, 0);
+ applyCharSpaceRotations('spine', [[WORLD_X, 0.08]], blend);
+ applyCharSpaceRotations('leftUpLeg', [[WORLD_X, -0.35]], blend);
+ applyCharSpaceRotations('rightUpLeg', [[WORLD_X, -0.35]], blend);
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, 0.65]], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, 0.65]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -2.55], [WORLD_Z, 0.22]], blend);
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -2.55], [WORLD_Z, -0.22]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.35]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.35]], blend);
+ return;
+ }
+
+ // 0b. Modo Sentado na Cabine da Roda-Gigante (`ferrisSit`)
+ if (mode === 'ferrisSit') {
+ switchClipAction('idle');
+ if (mixer) mixer.update(dt * 0.2);
+ model.position.set(baseModelPos.x, baseModelPos.y - 0.44, baseModelPos.z);
+ holder.rotation.set(0, 0, 0);
+ applyCharSpaceRotations('spine', [[WORLD_X, -0.05]], blend);
+ applyCharSpaceRotations('neck', [[WORLD_Y, Math.sin(breathTime * 0.7) * 0.32]], blend);
+ applyCharSpaceRotations('leftUpLeg', [[WORLD_X, -1.35], [WORLD_Z, 0.12]], blend);
+ applyCharSpaceRotations('rightUpLeg', [[WORLD_X, -1.35], [WORLD_Z, -0.12]], blend);
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, 1.32]], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, 1.32]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -0.55], [WORLD_Z, 0.18]], blend);
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -0.55], [WORLD_Z, -0.18]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.5]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.5]], blend);
+ return;
+ }
+
+ // 1. Modo Queda / Ragdoll (acidente de moto ou atropelamento)
+ if (mode === 'ragdoll') {
+ const hasFallClip = switchClipAction('fall');
+ if (mixer) mixer.update(dt);
+ if (!hasFallClip) {
+ const tumble = Math.min(1, ragdollTime * 2.8);
+ model.position.set(baseModelPos.x, baseModelPos.y * (1 - tumble * 0.8) + 0.18, baseModelPos.z);
+ holder.rotation.set(-tumble * (Math.PI * 0.48), 0, Math.sin(ragdollTime * 9) * 0.32 * (1 - tumble * 0.6));
+ const flail = Math.sin(ragdollTime * 13) * (1 - tumble * 0.75);
+ applyCharSpaceRotations('spine', [[WORLD_X, 0.25 * (1 - tumble)]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_Z, 0.85], [WORLD_X, -0.45 + flail * 0.4]], blend);
+ applyCharSpaceRotations('rightArm', [[WORLD_Z, -0.85], [WORLD_X, -0.45 - flail * 0.4]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.5]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.5]], blend);
+ applyCharSpaceRotations('leftUpLeg', [[WORLD_X, -0.45 - flail * 0.3], [WORLD_Z, 0.18]], blend);
+ applyCharSpaceRotations('rightUpLeg', [[WORLD_X, -0.2 + flail * 0.3], [WORLD_Z, -0.18]], blend);
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, 0.55]], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, 0.4]], blend);
}
- if (bones.leftArm) {
- // Os braços do rig T-pose baixam levemente em Z e balançam em X
- bones.leftArm.quaternion.copy(restQuats.leftArm)
- .multiply(qRot.setFromAxisAngle(zAxis, 1.15))
- .multiply(new THREE.Quaternion().setFromAxisAngle(xAxis, s * amp * 0.65));
+ return;
+ }
+
+ // 2. Modo Entrando / Saindo do Carro (`enterCar` / `exitCar`):
+ // 0.00..0.34 -> estica a mão na maçaneta e puxa a porta aberta;
+ // 0.34..0.76 -> abaixa a cabeça sob o teto, levanta a perna direita e senta no banco;
+ // 0.76..1.00 -> sentado ao volante puxando a porta para fechar!
+ if (mode === 'enterCar' || mode === 'exitCar') {
+ switchClipAction('idle');
+ if (mixer) mixer.update(dt * 0.2);
+
+ const p = mode === 'exitCar' ? (1 - doorProgress) : doorProgress;
+ const reach = p < 0.36
+ ? Math.sin((p / 0.36) * Math.PI * 0.5)
+ : Math.max(0, 1 - (p - 0.36) / 0.25);
+ const sitT = Math.max(0, Math.min(1, (p - 0.30) / 0.46));
+ const duck = Math.sin(Math.max(0, Math.min(1, (p - 0.24) / 0.52)) * Math.PI);
+ const pullClose = p > 0.72 ? Math.sin(((p - 0.72) / 0.28) * Math.PI) : 0;
+
+ holder.rotation.set(0, 0, 0);
+ model.position.set(
+ baseModelPos.x,
+ baseModelPos.y - sitT * 0.44 - duck * 0.12,
+ baseModelPos.z
+ );
+
+ applyCharSpaceRotations('hips', [[WORLD_Y, (1 - sitT) * 0.08]], blend);
+ applyCharSpaceRotations('spine', [[WORLD_X, duck * 0.38 - sitT * 0.08]], blend);
+ applyCharSpaceRotations('chest', [[WORLD_X, duck * 0.22]], blend);
+ applyCharSpaceRotations('neck', [[WORLD_X, duck * 0.28]], blend);
+
+ // Pernas: passo lateral para dentro da cabine -> posição sentada nos pedais
+ const stepLift = Math.sin(sitT * Math.PI);
+ applyCharSpaceRotations('rightUpLeg', [
+ [WORLD_X, -sitT * 1.32 - stepLift * 0.35],
+ [WORLD_Z, -sitT * 0.1]
+ ], blend);
+ applyCharSpaceRotations('leftUpLeg', [
+ [WORLD_X, -sitT * 1.32],
+ [WORLD_Z, sitT * 0.1 + pullClose * 0.08]
+ ], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, sitT * 1.24 + stepLift * 0.38]], blend);
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, sitT * 1.24]], blend);
+ applyCharSpaceRotations('leftFoot', [[WORLD_X, -sitT * 0.15]], blend);
+ applyCharSpaceRotations('rightFoot', [[WORLD_X, -sitT * 0.15]], blend);
+
+ // Braço esquerdo alcança a maçaneta / puxa a porta ao fechar; braço direito vai ao volante!
+ applyCharSpaceRotations('leftArm', [
+ [WORLD_X, -(reach * 0.92 + sitT * 0.88 + pullClose * 0.25)],
+ [WORLD_Z, pullClose * 0.42 - sitT * 0.16]
+ ], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -(0.35 + reach * 0.35 + pullClose * 0.3)]], blend);
+ applyCharSpaceRotations('rightArm', [
+ [WORLD_X, -(reach * 0.45 + sitT * 0.92)],
+ [WORLD_Z, sitT * 0.18]
+ ], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -(0.28 + sitT * 0.38)]], blend);
+ return;
+ }
+
+ // 3. Modo Montado na Moto (`bike`): tronco inclinado à frente, joelhos abraçando o tanque e mãos no guidão!
+ if (mode === 'bike') {
+ const hasBikeClip = switchClipAction('bike');
+ if (mixer) mixer.update(dt);
+ holder.rotation.set(0, 0, steer * 0.22);
+ model.position.set(baseModelPos.x, baseModelPos.y - 0.20, baseModelPos.z - 0.12);
+
+ if (!hasBikeClip) {
+ const speedLean = Math.min(0.18, Math.abs(speed) * 0.005);
+ applyCharSpaceRotations('hips', [], blend);
+ applyCharSpaceRotations('spine', [[WORLD_X, 0.38 + speedLean]], blend);
+ applyCharSpaceRotations('chest', [[WORLD_X, 0.18], [WORLD_Y, -steer * 0.14]], blend);
+ applyCharSpaceRotations('neck', [[WORLD_X, -0.44 - speedLean * 0.5], [WORLD_Y, -steer * 0.1]], blend);
+ applyCharSpaceRotations('leftUpLeg', [[WORLD_X, -0.92], [WORLD_Z, 0.34]], blend);
+ applyCharSpaceRotations('rightUpLeg', [[WORLD_X, -0.92], [WORLD_Z, -0.34]], blend);
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, 1.28]], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, 1.28]], blend);
+ applyCharSpaceRotations('leftFoot', [[WORLD_X, 0.15]], blend);
+ applyCharSpaceRotations('rightFoot', [[WORLD_X, 0.15]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -0.92 + steer * 0.1], [WORLD_Z, -0.12]], blend);
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -0.92 - steer * 0.1], [WORLD_Z, 0.12]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.34]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.34]], blend);
}
- if (bones.rightArm) {
+ return;
+ }
+
+ // 4. Modo A Pé (Idle Natural / Caminhada Fluida / Corrida Atlética / Pulo / Mira)
+ const isRunning = speed > 6.2;
+ const isWalking = speed > 0.22;
+ const desiredClip = mode === 'jump' ? 'jump' : isRunning ? 'run' : isWalking ? 'walk' : aiming ? 'aim' : 'idle';
+ const usingDedicatedClip = desiredClip !== 'idle' && switchClipAction(desiredClip);
+ if (!usingDedicatedClip) switchClipAction('idle');
+
+ // Congela a pose base simétrica enquanto anda/corre para que o clipe de idle assimétrico não entorte a passada!
+ if (mixer) mixer.update(isWalking && !usingDedicatedClip ? 0 : dt);
+ if (usingDedicatedClip) {
+ holder.rotation.set(0, 0, 0);
+ model.position.copy(baseModelPos);
+ return;
+ }
+
+ if (mode === 'jump') {
+ smoothedOffsetY += (0.04 - smoothedOffsetY) * blend;
+ model.position.set(baseModelPos.x, baseModelPos.y + smoothedOffsetY, baseModelPos.z);
+ holder.rotation.set(0, 0, steer * 0.08);
+ applyCharSpaceRotations('spine', [[WORLD_X, 0.14]], blend);
+ applyCharSpaceRotations('chest', [[WORLD_X, 0.08]], blend);
+ applyCharSpaceRotations('neck', [[WORLD_X, -0.12]], blend);
+ applyCharSpaceRotations('leftUpLeg', [[WORLD_X, -0.68]], blend);
+ applyCharSpaceRotations('rightUpLeg', [[WORLD_X, 0.24]], blend);
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, 0.92]], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, 0.58]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -0.48], [WORLD_Z, 0.22]], blend);
+ applyCharSpaceRotations('rightArm', aiming ? [[WORLD_X, -1.42]] : [[WORLD_X, 0.25], [WORLD_Z, -0.22]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.62]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, aiming ? -0.12 : -0.52]], blend);
+ return;
+ }
+
+ if (isWalking) {
+ const runFactor = Math.max(0, Math.min(1, (speed - 4.4) / 4.2));
+ // Frequência angular calibrada para não deslizar os pés no chão (1 ciclo completo = 2 passos)
+ const freq = 3.9 + speed * 0.92;
+ stridePhase += dt * freq;
+
+ const s = Math.sin(stridePhase);
+ const c = Math.cos(stridePhase);
+ const s2 = Math.sin(stridePhase * 2);
+ const c2 = Math.cos(stridePhase * 2);
+
+ // Oscilação vertical de marcha real: mais alto na meia-passada, mais baixo na dupla-apoio + fase aérea na corrida
+ const verticalBob = (-c2 * (0.019 + runFactor * 0.028)) + (runFactor * 0.014);
+ const lateralSway = c * (0.016 * (1 - runFactor * 0.5));
+ smoothedOffsetY += (verticalBob - smoothedOffsetY) * blend;
+ smoothedOffsetZ += (0 - smoothedOffsetZ) * blend;
+ smoothedRoll += ((steer * 0.10) - smoothedRoll) * Math.min(1, dt * 8);
+
+ model.position.set(baseModelPos.x + lateralSway, baseModelPos.y + smoothedOffsetY, baseModelPos.z);
+ holder.rotation.set(0, 0, smoothedRoll);
+
+ // Pélvis: rotação axial + leve queda pélvica de Trendelenburg (`WORLD_Z`) para naturalidade orgânica!
+ const pelvicYaw = s * (0.075 + runFactor * 0.065);
+ const pelvicTilt = s * (0.032 + runFactor * 0.02);
+ applyCharSpaceRotations('hips', [[WORLD_Y, pelvicYaw], [WORLD_Z, pelvicTilt]], blend);
+
+ // Tronco: inclinação progressiva à frente na corrida + contra-torção de ombros oposta à pélvis
+ const forwardLean = 0.035 + runFactor * 0.17;
+ applyCharSpaceRotations('spine', [
+ [WORLD_X, forwardLean * 0.6 + s2 * 0.014],
+ [WORLD_Y, -pelvicYaw * 0.85]
+ ], blend);
+ applyCharSpaceRotations('chest', [
+ [WORLD_X, forwardLean * 0.45],
+ [WORLD_Y, -pelvicYaw * 0.75],
+ [WORLD_Z, -pelvicTilt * 0.6]
+ ], blend);
+ applyCharSpaceRotations('neck', [
+ [WORLD_X, -forwardLean * 0.72],
+ [WORLD_Y, pelvicYaw * 0.45]
+ ], blend);
+
+ // Ciclo assimétrico de coxas e joelhos (2 harmônicos):
+ // - Quando `sL > 0` (perna à frente), coxa gira `-WORLD_X`;
+ // - Joelho flexiona forte na passagem para frente (`c > 0`, tirando o pé do chão) e estende no toque do calcanhar!
+ const thighFwdAmp = 0.36 + runFactor * 0.42;
+ const thighBackAmp = 0.28 + runFactor * 0.36;
+ const swingL = s >= 0 ? s * thighFwdAmp : s * thighBackAmp;
+ const swingR = -s >= 0 ? -s * thighFwdAmp : -s * thighBackAmp;
+
+ // Corrige a leve assimetria da pose estática da perna direita em `standing_man.glb`
+ applyCharSpaceRotations('leftUpLeg', [[WORLD_X, -swingL - 0.03]], blend);
+ applyCharSpaceRotations('rightUpLeg', [[WORLD_X, -swingR + 0.05], [WORLD_Z, 0.035]], blend);
+
+ const passL = Math.max(0, c * 0.82 - s * 0.22);
+ const impactL = Math.max(0, s * 0.28) * (1 - Math.max(0, c));
+ const kneeL = 0.06 + (passL * (0.68 + runFactor * 0.62)) + impactL * 0.18;
+
+ const passR = Math.max(0, -c * 0.82 + s * 0.22);
+ const impactR = Math.max(0, -s * 0.28) * (1 - Math.max(0, -c));
+ const kneeR = 0.06 + (passR * (0.68 + runFactor * 0.62)) + impactR * 0.18;
+
+ applyCharSpaceRotations('leftLeg', [[WORLD_X, kneeL]], blend);
+ applyCharSpaceRotations('rightLeg', [[WORLD_X, kneeR]], blend);
+
+ // Tornozelos: dorsiflexão no calcanhar à frente (`-WORLD_X`) e impulsão na ponta do pé atrás (`+WORLD_X`)
+ const ankleL = -s * 0.18 + Math.max(0, -s) * (0.18 + runFactor * 0.16);
+ const ankleR = s * 0.18 + Math.max(0, s) * (0.18 + runFactor * 0.16);
+ applyCharSpaceRotations('leftFoot', [[WORLD_X, ankleL]], blend);
+ applyCharSpaceRotations('rightFoot', [[WORLD_X, ankleR]], blend);
+
+ // Braços: postura tática dedicada para Pistola e Fuzil (ou balanço sagital natural desarmado!)
+ const armFwd = 0.26 + runFactor * 0.44;
+ const armBack = 0.20 + runFactor * 0.30;
+ const armSwingL = -s >= 0 ? -s * armFwd : -s * armBack;
+ const armSwingR = s >= 0 ? s * armFwd : s * armBack;
+
+ if (weaponGrip === 'rifle') {
if (aiming) {
- bones.rightArm.quaternion.copy(restQuats.rightArm)
- .multiply(qRot.setFromAxisAngle(zAxis, -1.05))
- .multiply(new THREE.Quaternion().setFromAxisAngle(xAxis, -1.35));
+ // Fuzil na visada de ombro: coronha firme no ombro direito e mão esquerda sustentando o guarda-mão!
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -1.24], [WORLD_Z, 0.16]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.58], [WORLD_Y, 0.22]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -1.28], [WORLD_Y, -0.44], [WORLD_Z, -0.18]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.48]], blend);
} else {
- bones.rightArm.quaternion.copy(restQuats.rightArm)
- .multiply(qRot.setFromAxisAngle(zAxis, -1.15))
- .multiply(new THREE.Quaternion().setFromAxisAngle(xAxis, -s * amp * 0.65));
+ // Patrulha tática (low-ready): fuzil cruzado junto ao peito com as duas mãos!
+ const sway = s * 0.05;
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -0.62 + sway], [WORLD_Z, 0.22]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.82], [WORLD_Y, 0.32]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -0.78 - sway], [WORLD_Y, -0.48], [WORLD_Z, -0.22]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.58]], blend);
}
+ } else if (weaponGrip === 'pistol') {
+ if (aiming) {
+ // Pistola Weaver/Isósceles: duas mãos alinhadas à frente na altura dos olhos!
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -1.44], [WORLD_Y, 0.12]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.10]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -1.40], [WORLD_Y, -0.28]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.18]], blend);
+ } else {
+ // Correndo/andando com pistola pronta na mão direita
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -armSwingL - runFactor * 0.14], [WORLD_Z, -0.03]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -(0.18 + runFactor * 0.72 + Math.max(0, armSwingL) * 0.32)]], blend);
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -0.42 - armSwingR * 0.25], [WORLD_Z, 0.08]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.65]], blend);
+ }
+ } else {
+ applyCharSpaceRotations('leftArm', [
+ [WORLD_X, -armSwingL - runFactor * 0.14],
+ [WORLD_Z, -0.03]
+ ], blend);
+ const elbowL = 0.18 + runFactor * 0.72 + Math.max(0, armSwingL) * 0.32;
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -elbowL]], blend);
+
+ if (aiming) {
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -1.42], [WORLD_Y, 0.08]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.14]], blend);
+ } else {
+ applyCharSpaceRotations('rightArm', [
+ [WORLD_X, -armSwingR - runFactor * 0.14],
+ [WORLD_Z, 0.03]
+ ], blend);
+ const elbowR = 0.18 + runFactor * 0.72 + Math.max(0, armSwingR) * 0.32;
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -elbowR]], blend);
+ }
+ }
+ return;
+ }
+
+ // Idle respirando com micro-transferência natural de peso + empunhadura realista de Pistola e Fuzil!
+ const breath = Math.sin(breathTime * 1.9);
+ const weightShift = Math.sin(breathTime * 0.65);
+ smoothedOffsetY += ((breath * 0.006) - smoothedOffsetY) * blend;
+ smoothedRoll += (0 - smoothedRoll) * blend;
+ model.position.set(baseModelPos.x + weightShift * 0.008, baseModelPos.y + smoothedOffsetY, baseModelPos.z);
+ holder.rotation.set(0, 0, smoothedRoll);
+
+ applyCharSpaceRotations('hips', [[WORLD_Z, weightShift * 0.015]], blend);
+ applyCharSpaceRotations('spine', [[WORLD_X, breath * 0.014]], blend);
+ applyCharSpaceRotations('chest', [[WORLD_X, breath * 0.016], [WORLD_Y, weightShift * 0.025]], blend);
+ applyCharSpaceRotations('neck', [[WORLD_Y, -weightShift * 0.035]], blend);
+ applyCharSpaceRotations('leftUpLeg', [], blend);
+ applyCharSpaceRotations('rightUpLeg', [], blend);
+ applyCharSpaceRotations('leftLeg', [], blend);
+ applyCharSpaceRotations('rightLeg', [], blend);
+ applyCharSpaceRotations('leftFoot', [], blend);
+ applyCharSpaceRotations('rightFoot', [], blend);
+
+ if (weaponGrip === 'rifle') {
+ if (aiming) {
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -1.25], [WORLD_Z, 0.16]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.58], [WORLD_Y, 0.22]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -1.28], [WORLD_Y, -0.44], [WORLD_Z, -0.18]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.48]], blend);
+ } else {
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -0.56 + breath * 0.015], [WORLD_Z, 0.20]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.82], [WORLD_Y, 0.30]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -0.74 + breath * 0.015], [WORLD_Y, -0.46], [WORLD_Z, -0.20]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.56]], blend);
+ }
+ } else if (weaponGrip === 'pistol') {
+ if (aiming) {
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -1.45], [WORLD_Y, 0.12]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.10]], blend);
+ applyCharSpaceRotations('leftArm', [[WORLD_X, -1.40], [WORLD_Y, -0.28]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.18]], blend);
+ } else {
+ applyCharSpaceRotations('leftArm', [[WORLD_X, breath * 0.015]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.10]], blend);
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -0.36 + breath * 0.015], [WORLD_Z, 0.08]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.62]], blend);
}
- if (bones.spine) {
- bones.spine.quaternion.copy(restQuats.spine).multiply(qRot.setFromAxisAngle(xAxis, Math.min(0.18, speed * 0.018)));
+ } else {
+ applyCharSpaceRotations('leftArm', [[WORLD_X, breath * 0.015]], blend);
+ applyCharSpaceRotations('leftForeArm', [[WORLD_X, -0.10]], blend);
+ if (aiming) {
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -1.45], [WORLD_Y, 0.06]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.12]], blend);
+ } else {
+ applyCharSpaceRotations('rightArm', [[WORLD_X, -breath * 0.015]], blend);
+ applyCharSpaceRotations('rightForeArm', [[WORLD_X, -0.10]], blend);
}
- } else if (aiming && bones.rightArm) {
- bones.rightArm.quaternion.copy(restQuats.rightArm)
- .multiply(qRot.setFromAxisAngle(zAxis, -1.05))
- .multiply(new THREE.Quaternion().setFromAxisAngle(xAxis, -1.38));
}
}
@@ -320,9 +1657,10 @@ export function instantiateRiggedProtagonist(gltf, { outfitTint = null } = {}) {
}
/**
- * Dispara o pré-carregamento em paralelo dos pacotes GLB principais.
+ * Dispara o pré-carregamento em paralelo de todos os 8 pacotes GLB principais + eventuais customizados.
*/
export function preloadAllViceModels() {
+ discoverCustomModels();
return Promise.all([
loadGlbOnce(GLB_ASSETS.protagonist),
loadCitizenTemplates(),
diff --git a/vice-game/src/world/minimap.js b/vice-game/src/world/minimap.js
index 51be4d74..77faa907 100644
--- a/vice-game/src/world/minimap.js
+++ b/vice-game/src/world/minimap.js
@@ -1,273 +1,660 @@
-// Minimapa circular/retangular estilo GTA VI no canto inferior esquerdo (acima do analógico)
-// e mapa completo interativo de Vice Leonida com GPS até o objetivo da missão.
+// Radar estilo GTA VI (circular com rotação pelo olhar do jogador) + Mapa GPS completo (Palm Bay, Vice Leonida e Vice Keys!)
import {
AVENUES_X,
STREETS_Z,
- BEACH_SAND_X,
- OCEAN_WATER_X,
+ ROAD_WIDTH,
CANAL_MIN_X,
CANAL_MAX_X,
+ BEACH_SAND_X,
+ OCEAN_WATER_X,
BRIDGE_ZS,
+ INTERCITY_BRIDGES,
+ SCENIC_ROADS,
+ NARROW_ROADS,
+ OFFSHORE_ISLANDS,
+ ROAD_TUNNELS,
+ AIRPORT_DATA,
+ TRAIN_LINE,
POINTS_OF_INTEREST,
- generateCityLayout
+ getAvenueWidth,
+ getStreetWidth
} from '../data/city.js';
-export function drawRadarMinimap(canvas, {
+export function renderMinimap(ctx, {
+ width = 160,
+ height = 160,
playerX = 0,
playerZ = 0,
playerYaw = 0,
vehicles = [],
cops = [],
- target = null,
- wanted = 0
+ copFootUnits = [],
+ target = null
} = {}) {
- if (!canvas) return;
- const ctx = canvas.getContext('2d');
- const w = canvas.width;
- const h = canvas.height;
- const cx = w * 0.5;
- const cy = h * 0.5;
- const scale = 0.52; // 1 metro = 0.52 px no radar
+ const cx = width * 0.5;
+ const cy = height * 0.5;
+ const radius = Math.min(cx, cy) - 4;
+ const scale = 0.52; // px por metro no mundo
+ ctx.clearRect(0, 0, width, height);
ctx.save();
- ctx.clearRect(0, 0, w, h);
- // Fundo escuro da terra/água
- ctx.fillStyle = '#14213d';
- ctx.fillRect(0, 0, w, h);
+ ctx.beginPath();
+ ctx.arc(cx, cy, radius, 0, Math.PI * 2);
+ ctx.clip();
- // Rotaciona o mapa de acordo com a orientação do jogador (frente sempre aponta para o topo)
+ // Fundo oceano
+ ctx.fillStyle = '#073b5c';
+ ctx.fillRect(0, 0, width, height);
+
+ ctx.save();
ctx.translate(cx, cy);
ctx.rotate(playerYaw - Math.PI);
+ ctx.scale(scale, scale);
+ ctx.translate(-playerX, -playerZ);
- const toScreen = (wx, wz) => [
- (wx - playerX) * scale,
- (wz - playerZ) * scale
- ];
-
- // Areia e Oceano a Leste
- const [sandSx] = toScreen(BEACH_SAND_X, playerZ);
- const [oceanSx] = toScreen(OCEAN_WATER_X, playerZ);
- ctx.fillStyle = '#244b3c';
- ctx.fillRect(-600, -600, 1200, 1200);
+ // Terra: Leste + Oeste + Palm Bay (Norte) + Vice Keys (Sul)
+ ctx.fillStyle = '#1f2d3d';
+ ctx.fillRect(-128, -485, 474, 970);
+ ctx.fillRect(-556, -485, 378, 970);
+ ctx.fillRect(-330, -795, 565, 214);
+ ctx.fillRect(25, 582, 290, 214);
+ // Areia de Vice Beach e Vice Keys
ctx.fillStyle = '#e9c46a';
- ctx.fillRect(sandSx, -600, oceanSx - sandSx, 1200);
+ ctx.fillRect(BEACH_SAND_X, -485, OCEAN_WATER_X - BEACH_SAND_X, 970);
- ctx.fillStyle = '#0077b6';
- ctx.fillRect(oceanSx, -600, 900, 1200);
+ // Pontes do Canal e Pontes Intermunicipais
+ ctx.fillStyle = '#6c757d';
+ for (const bz of BRIDGE_ZS) {
+ ctx.fillRect(CANAL_MIN_X - 6, bz - ROAD_WIDTH * 0.6, CANAL_MAX_X - CANAL_MIN_X + 12, ROAD_WIDTH * 1.2);
+ }
+ for (const br of INTERCITY_BRIDGES) {
+ ctx.fillRect(br.x - br.width * 0.6, br.zMin - 4, br.width * 1.2, br.zMax - br.zMin + 8);
+ }
- // Canal de Biscayne
- const [cMinX] = toScreen(CANAL_MIN_X, playerZ);
- const [cMaxX] = toScreen(CANAL_MAX_X, playerZ);
- ctx.fillStyle = '#0096c7';
- ctx.fillRect(cMinX, -600, cMaxX - cMinX, 1200);
+ // Rodovias Curvas (`SCENIC_ROADS`)
+ ctx.strokeStyle = '#6c7a89';
+ ctx.lineWidth = 16;
+ ctx.lineJoin = 'round';
+ ctx.lineCap = 'round';
+ for (const sr of SCENIC_ROADS) {
+ ctx.beginPath();
+ sr.points.forEach(([px, pz], idx) => {
+ if (idx === 0) ctx.moveTo(px, pz);
+ else ctx.lineTo(px, pz);
+ });
+ ctx.stroke();
+ }
- // Avenidas e Ruas
+ // Avenidas e Ruas (com larguras reais do mundo!)
ctx.fillStyle = '#5c677d';
for (const ax of AVENUES_X) {
- const [rx, rz] = toScreen(ax, 0);
- ctx.fillRect(rx - 5, rz - 480 * scale, 10, 960 * scale);
+ const w = getAvenueWidth(ax);
+ ctx.fillRect(ax - w * 0.5, -472, w, 944);
}
for (const sz of STREETS_Z) {
- const [, rz] = toScreen(0, sz);
- const [x0] = toScreen(-455, sz);
- const [x1] = toScreen(335, sz);
- ctx.fillRect(x0, rz - 5, x1 - x0, 10);
+ const w = getStreetWidth(sz);
+ if (BRIDGE_ZS.includes(sz)) {
+ ctx.fillRect(-455, sz - w * 0.5, 790, w);
+ } else {
+ ctx.fillRect(-116, sz - w * 0.5, 451, w);
+ ctx.fillRect(-455, sz - w * 0.5, 265, w);
+ }
+ }
+ // Becos e ruas estreitas
+ ctx.fillStyle = '#49536a';
+ for (const nr of NARROW_ROADS) {
+ if (nr.axis === 'z') ctx.fillRect(nr.x - nr.width * 0.5, nr.zMin, nr.width, nr.zMax - nr.zMin);
+ else ctx.fillRect(nr.xMin, nr.z - nr.width * 0.5, nr.xMax - nr.xMin, nr.width);
+ }
+ // Linha do Metrorail + estações
+ ctx.strokeStyle = '#e9ecef';
+ ctx.lineWidth = 2.4;
+ ctx.beginPath();
+ ctx.moveTo(TRAIN_LINE.trackX, TRAIN_LINE.zMin);
+ ctx.lineTo(TRAIN_LINE.trackX, TRAIN_LINE.zMax);
+ ctx.stroke();
+ ctx.fillStyle = '#00f5d4';
+ for (const st of TRAIN_LINE.stations) {
+ ctx.beginPath();
+ ctx.arc(st.x, st.z, 4.6, 0, Math.PI * 2);
+ ctx.fill();
}
+ // Pista do aeroporto VIA
+ ctx.fillStyle = '#8f96a3';
+ ctx.fillRect(AIRPORT_DATA.runwayX - 9, AIRPORT_DATA.runwayZMin, 18, AIRPORT_DATA.runwayZMax - AIRPORT_DATA.runwayZMin);
- // Prédios próximos
- const { buildings } = generateCityLayout();
- ctx.fillStyle = 'rgba(255, 255, 255, 0.2)';
- for (const b of buildings) {
- if (Math.abs(b.x - playerX) > 220 || Math.abs(b.z - playerZ) > 220) continue;
- const [bx, bz] = toScreen(b.x - b.w * 0.5, b.z - b.d * 0.5);
- ctx.fillRect(bx, bz, b.w * scale, b.d * scale);
+ // Pontos de interesse
+ for (const poi of POINTS_OF_INTEREST) {
+ ctx.fillStyle = poi.color || '#00f5d4';
+ ctx.beginPath();
+ ctx.arc(poi.x, poi.z, 7.5, 0, Math.PI * 2);
+ ctx.fill();
}
- // Linha de rota GPS estilo GTA até o objetivo ativo
+ // Rota GPS rosa até o objetivo ativo
if (target) {
- const [tx, tz] = toScreen(target.x, target.z);
- ctx.strokeStyle = target.color || '#ff2a85';
- ctx.lineWidth = 3;
- ctx.setLineDash([5, 4]);
+ ctx.strokeStyle = '#ff2a85';
+ ctx.lineWidth = 5.5;
ctx.beginPath();
- ctx.moveTo(0, 0);
- ctx.lineTo(tx, tz);
+ ctx.moveTo(playerX, playerZ);
+ ctx.lineTo(target.x, playerZ);
+ ctx.lineTo(target.x, target.z);
ctx.stroke();
- ctx.setLineDash([]);
- // Ponto do objetivo (limitado à borda se estiver longe)
- const dist = Math.hypot(tx, tz);
- const maxR = Math.min(cx, cy) - 10;
- const px = dist > maxR ? (tx / dist) * maxR : tx;
- const pz = dist > maxR ? (tz / dist) * maxR : tz;
ctx.fillStyle = '#ffd166';
+ ctx.strokeStyle = '#11131a';
+ ctx.lineWidth = 2.5;
ctx.beginPath();
- ctx.arc(px, pz, 5.5, 0, Math.PI * 2);
+ ctx.arc(target.x, target.z, 10, 0, Math.PI * 2);
ctx.fill();
- ctx.strokeStyle = '#111';
- ctx.lineWidth = 1.5;
ctx.stroke();
}
- // Ícones de Oficinas Customs próximas
- for (const poi of POINTS_OF_INTEREST) {
- if (poi.kind !== 'garage') continue;
- const [gx, gz] = toScreen(poi.x, poi.z);
- if (Math.hypot(gx, gz) < w * 0.46) {
- ctx.fillStyle = '#2ee59d';
- ctx.fillRect(gx - 3.5, gz - 3.5, 7, 7);
- }
- }
-
// Veículos civis próximos
- ctx.fillStyle = 'rgba(255,255,255,0.6)';
+ ctx.fillStyle = 'rgba(255,255,255,0.68)';
for (const v of vehicles) {
- if (v.isPlayerDriving) continue;
- const [vx, vz] = toScreen(v.x, v.z);
- if (Math.hypot(vx, vz) < w * 0.45) {
- ctx.fillRect(vx - 2, vz - 2, 4, 4);
- }
+ if (v.isPolice) continue;
+ ctx.fillRect(v.x - 2.2, v.z - 2.2, 4.4, 4.4);
}
- // Viaturas / policiais perseguindo (piscam vermelho/azul)
- const flashBlue = Math.floor(Date.now() / 180) % 2 === 0;
- for (const cop of cops) {
- const [px, pz] = toScreen(cop.x, cop.z);
- if (Math.hypot(px, pz) < w * 0.47) {
- ctx.fillStyle = flashBlue ? '#00bbf9' : '#ff1e56';
- ctx.beginPath();
- ctx.arc(px, pz, 4.2, 0, Math.PI * 2);
- ctx.fill();
- }
+ // Viaturas policiais + Policiais a pé piscando vermelho/azul
+ const blinkRed = (Date.now() % 420) < 210;
+ for (const c of cops) {
+ ctx.fillStyle = blinkRed ? '#ff2a55' : '#2ea8ff';
+ ctx.beginPath();
+ ctx.arc(c.x, c.z, 6.2, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ for (const cf of copFootUnits) {
+ if (cf.dead) continue;
+ ctx.fillStyle = blinkRed ? '#2ea8ff' : '#ff2a55';
+ ctx.beginPath();
+ ctx.arc(cf.x, cf.z, 4.8, 0, Math.PI * 2);
+ ctx.fill();
}
ctx.restore();
- // Seta central do jogador
- ctx.save();
- ctx.translate(cx, cy);
+ // Seta central do jogador (Rafael)
ctx.fillStyle = '#ffffff';
ctx.strokeStyle = '#ff2a85';
ctx.lineWidth = 2;
ctx.beginPath();
- ctx.moveTo(0, -7);
- ctx.lineTo(5.5, 6);
- ctx.lineTo(0, 3.2);
- ctx.lineTo(-5.5, 6);
+ ctx.moveTo(cx, cy - 8);
+ ctx.lineTo(cx + 6, cy + 7);
+ ctx.lineTo(cx, cy + 4);
+ ctx.lineTo(cx - 6, cy + 7);
ctx.closePath();
ctx.fill();
ctx.stroke();
- ctx.restore();
- // Moldura piscante policial quando há estrelas de procurado
- if (wanted > 0) {
- ctx.strokeStyle = flashBlue ? 'rgba(0,187,249,0.85)' : 'rgba(255,30,86,0.85)';
- ctx.lineWidth = 3;
- ctx.strokeRect(1.5, 1.5, w - 3, h - 3);
- }
-}
+ ctx.strokeStyle = 'rgba(255, 42, 133, 0.72)';
+ ctx.lineWidth = 3;
+ ctx.beginPath();
+ ctx.arc(cx, cy, radius - 1.5, 0, Math.PI * 2);
+ ctx.stroke();
-export function drawFullCityMap(canvas, { playerX = 0, playerZ = 0, target = null } = {}) {
- if (!canvas) return;
- const ctx = canvas.getContext('2d');
- const w = canvas.width;
- const h = canvas.height;
- ctx.clearRect(0, 0, w, h);
+ ctx.restore();
+}
- // Mundo de -560..+520 mapeado no canvas
- const mapSpan = 1120;
+// ============================================================================
+// MAPA GPS EXPANDIDO DE LEONIDA — renderização vetorial HiDPI nível GTA V/VI:
+// oceano com gradiente profundo + contornos batimétricos, terra em tons
+// modernos, hierarquia viária (avenidas amplas âmbar / normais / becos),
+// pontes com torres, túneis tracejados, metrorail com estações, pista do
+// aeroporto, ilhas do arquipélago, rosa dos ventos, escala e moldura premium!
+// O canvas é renderizado em devicePixelRatio (nítido em telas Retina/AMOLED).
+// ============================================================================
+export function renderFullCityMap(ctx, {
+ width = 640,
+ height = 640,
+ playerX = 0,
+ playerZ = 0,
+ target = null
+} = {}) {
+ const u = width / 640; // unidade de escala global (HiDPI-aware)
+ const px = v => v * u;
+
+ // ---------- Ocean: deep gradient + bathymetry contour lines ----------
+ const oceanGrad = ctx.createRadialGradient(width * 0.62, height * 0.45, width * 0.1, width * 0.5, height * 0.5, width * 0.78);
+ oceanGrad.addColorStop(0, '#0e3a55');
+ oceanGrad.addColorStop(0.45, '#0a2c44');
+ oceanGrad.addColorStop(1, '#051d2f');
+ ctx.fillStyle = oceanGrad;
+ ctx.fillRect(0, 0, width, height);
+
+ const worldMin = -880;
+ const worldSpan = 1760;
const toMap = (wx, wz) => [
- ((wx + 560) / mapSpan) * w,
- ((wz + 560) / mapSpan) * h
+ ((wx - worldMin) / worldSpan) * width,
+ ((wz - worldMin) / worldSpan) * height
];
+ const wScale = width / worldSpan; // px por metro
+ const rectW = (x0, z0, x1, z1, color) => {
+ const [ax, ay] = toMap(x0, z0);
+ const [bx, by] = toMap(x1, z1);
+ ctx.fillStyle = color;
+ ctx.fillRect(ax, ay, bx - ax, by - ay);
+ };
+
+ // Contornos batimétricos suaves (curvas de profundidade)
+ ctx.save();
+ ctx.strokeStyle = 'rgba(120, 200, 235, 0.10)';
+ ctx.lineWidth = px(1.4);
+ for (let r = 0.16; r <= 0.72; r += 0.11) {
+ ctx.beginPath();
+ ctx.ellipse(width * 0.88, height * 0.45, width * r, height * r * 0.94, 0, 0, Math.PI * 2);
+ ctx.stroke();
+ }
+ ctx.restore();
+
+ // ---------- Landmasses with modern satellite-vector tones ----------
+ // Ilhas do arquipélago atlântico (com anel de areia por baixo)
+ for (const isl of OFFSHORE_ISLANDS) {
+ const [ix, iy] = toMap(isl.x, isl.z);
+ ctx.fillStyle = '#d9b26a';
+ ctx.beginPath();
+ ctx.ellipse(ix, iy, isl.rx * wScale, isl.rz * wScale, 0, 0, Math.PI * 2);
+ ctx.fill();
+ ctx.fillStyle = '#234936';
+ ctx.beginPath();
+ ctx.ellipse(ix, iy, isl.rx * wScale * 0.78, isl.rz * wScale * 0.78, 0, 0, Math.PI * 2);
+ ctx.fill();
+ }
+ // Montanhas do horizonte
+ ctx.fillStyle = '#1a2f42';
+ const horizonMountains = [[1420, -760], [1550, -180], [1380, 330], [1520, 830]];
+ for (const [mx, mz] of horizonMountains) {
+ const [px2, py2] = toMap(mx, mz);
+ ctx.beginPath();
+ ctx.moveTo(px2, py2);
+ ctx.lineTo(px2 + px(46), py2);
+ ctx.lineTo(px2 + px(23), py2 - px(34));
+ ctx.closePath();
+ ctx.fill();
+ }
- ctx.fillStyle = '#073b4c';
- ctx.fillRect(0, 0, w, h);
+ // Vice Leonida (Leste)
+ rectW(-128, -492, 346, 492, '#1d2c3d');
+ // Downtown + Porto (Oeste)
+ rectW(-556, -492, CANAL_MIN_X, 492, '#1b2836');
+ // Distritos levemente mais claros para hierarquia visual
+ rectW(-90, -492, 210, 492, '#202f42'); // Strip + Midtown
+ rectW(-420, -240, -185, 120, '#232f44'); // Downtown Financial
+ // Palm Bay City (Norte)
+ rectW(-330, -845, 245, -628, '#1f3040');
+ // Vice Keys (Sul)
+ rectW(25, 628, 315, 845, '#20313a');
+ // Península do aeroporto
+ rectW(AIRPORT_DATA.landXMin, AIRPORT_DATA.landZMin, AIRPORT_DATA.landXMax, AIRPORT_DATA.landZMax, '#1c2a39');
+ // Areia de Vice Beach e Vice Keys
+ rectW(BEACH_SAND_X, -492, OCEAN_WATER_X, 492, '#cdb277');
+ rectW(58, 640, 302, 838, '#cdb277');
+
+ // Grade sutil de coordenadas (graticule)
+ ctx.save();
+ ctx.strokeStyle = 'rgba(148, 197, 255, 0.055)';
+ ctx.lineWidth = px(1);
+ for (let gx = -800; gx <= 800; gx += 200) {
+ const [x0] = toMap(gx, 0);
+ ctx.beginPath();
+ ctx.moveTo(x0, 0);
+ ctx.lineTo(x0, height);
+ ctx.stroke();
+ }
+ for (let gz = -800; gz <= 800; gz += 200) {
+ const [, y0] = toMap(0, gz);
+ ctx.beginPath();
+ ctx.moveTo(0, y0);
+ ctx.lineTo(width, y0);
+ ctx.stroke();
+ }
+ ctx.restore();
- // Terra Oeste & Leste
- const [w0, zTop] = toMap(-540, -510);
- const [w1, zBot] = toMap(CANAL_MIN_X, 510);
- ctx.fillStyle = '#264653';
- ctx.fillRect(w0, zTop, w1 - w0, zBot - zTop);
+ // Canal de Biscayne (água turquesa entre os continentes)
+ rectW(CANAL_MIN_X, -492, CANAL_MAX_X, 492, '#0c3850');
+
+ // ---------- Roads: hierarchy (wide amber / normal light / alleys thin) ----------
+ const roadLine = (x0, z0, x1, z1, widthM, color, glow = 0) => {
+ const [ax, ay] = toMap(x0, z0);
+ const [bx, by] = toMap(x1, z1);
+ ctx.strokeStyle = color;
+ ctx.lineWidth = Math.max(px(1.6), widthM * wScale * 0.92);
+ ctx.lineCap = 'round';
+ if (glow > 0) {
+ ctx.shadowColor = color;
+ ctx.shadowBlur = px(glow);
+ }
+ ctx.beginPath();
+ ctx.moveTo(ax, ay);
+ ctx.lineTo(bx, by);
+ ctx.stroke();
+ ctx.shadowBlur = 0;
+ };
- const [e0] = toMap(CANAL_MAX_X, -510);
- const [e1] = toMap(BEACH_SAND_X, 510);
- ctx.fillStyle = '#2a6f57';
- ctx.fillRect(e0, zTop, e1 - e0, zBot - zTop);
+ // Becos estreitos (finos, discretos)
+ for (const nr of NARROW_ROADS) {
+ if (nr.axis === 'z') roadLine(nr.x, nr.zMin, nr.x, nr.zMax, nr.width, '#3d4a5f');
+ else roadLine(nr.xMin, nr.z, nr.xMax, nr.z, nr.width, '#3d4a5f');
+ }
+ // Rodovias cênicas/curvas (slate médio)
+ ctx.save();
+ ctx.strokeStyle = '#54637c';
+ ctx.lineWidth = px(3.4);
+ ctx.lineJoin = 'round';
+ ctx.lineCap = 'round';
+ for (const sr of SCENIC_ROADS) {
+ ctx.beginPath();
+ sr.points.forEach(([wx, wz], idx) => {
+ const [mx, my] = toMap(wx, wz);
+ if (idx === 0) ctx.moveTo(mx, my);
+ else ctx.lineTo(mx, my);
+ });
+ ctx.stroke();
+ }
+ ctx.restore();
+ // Ruas Leste-Oeste (normais = claro, amplas = âmbar)
+ for (const sz of STREETS_Z) {
+ const w = getStreetWidth(sz);
+ const wide = w >= 22;
+ const col = wide ? '#ffcf5c' : '#c3cbd8';
+ if (BRIDGE_ZS.includes(sz)) {
+ roadLine(-455, sz, 335, sz, w, col, wide ? 6 : 0);
+ } else {
+ roadLine(-455, sz, CANAL_MIN_X, sz, w, col, wide ? 6 : 0);
+ roadLine(CANAL_MAX_X, sz, 335, sz, w, col, wide ? 6 : 0);
+ }
+ }
+ // Avenidas Norte-Sul (amplas = âmbar com glow, normais = claro)
+ for (const ax of AVENUES_X) {
+ const w = getAvenueWidth(ax);
+ const wide = w >= 24;
+ roadLine(ax, -475, ax, 465, w, wide ? '#ffcf5c' : '#c3cbd8', wide ? 6 : 0);
+ }
- const [s1] = toMap(OCEAN_WATER_X, 510);
- ctx.fillStyle = '#e9c46a';
- ctx.fillRect(e1, zTop, s1 - e1, zBot - zTop);
+ // ---------- Metrorail (linha férrea com dormentes) ----------
+ const [railTopX, railTopY] = toMap(TRAIN_LINE.trackX, TRAIN_LINE.zMin);
+ const [railBotX, railBotY] = toMap(TRAIN_LINE.trackX, TRAIN_LINE.zMax);
+ ctx.save();
+ ctx.strokeStyle = '#101820';
+ ctx.lineWidth = px(4.2);
+ ctx.beginPath();
+ ctx.moveTo(railTopX, railTopY);
+ ctx.lineTo(railBotX, railBotY);
+ ctx.stroke();
+ ctx.strokeStyle = '#e8ecf2';
+ ctx.lineWidth = px(1.6);
+ ctx.setLineDash([px(5), px(5)]);
+ ctx.beginPath();
+ ctx.moveTo(railTopX, railTopY);
+ ctx.lineTo(railBotX, railBotY);
+ ctx.stroke();
+ ctx.setLineDash([]);
+ ctx.restore();
+ // Estações de trem
+ for (const st of TRAIN_LINE.stations) {
+ const [sx, sy] = toMap(st.x, st.z);
+ ctx.fillStyle = '#00f5d4';
+ ctx.strokeStyle = '#04141a';
+ ctx.lineWidth = px(1.6);
+ const rx = sx - px(5.5);
+ const ry = sy - px(4);
+ const rw = px(11);
+ const rh = px(8);
+ const rr = Math.min(px(2), rh * 0.5);
+ ctx.beginPath();
+ ctx.moveTo(rx + rr, ry);
+ ctx.lineTo(rx + rw - rr, ry);
+ ctx.quadraticCurveTo(rx + rw, ry, rx + rw, ry + rr);
+ ctx.lineTo(rx + rw, ry + rh - rr);
+ ctx.quadraticCurveTo(rx + rw, ry + rh, rx + rw - rr, ry + rh);
+ ctx.lineTo(rx + rr, ry + rh);
+ ctx.quadraticCurveTo(rx, ry + rh, rx, ry + rh - rr);
+ ctx.lineTo(rx, ry + rr);
+ ctx.quadraticCurveTo(rx, ry, rx + rr, ry);
+ ctx.closePath();
+ ctx.fill();
+ ctx.stroke();
+ }
- // Pontes
- ctx.fillStyle = '#adb5bd';
+ // ---------- Pontes (tabuleiro colorido + torres) ----------
for (const bz of BRIDGE_ZS) {
- const [bx0, by] = toMap(CANAL_MIN_X - 6, bz - 10);
- const [bx1, by1] = toMap(CANAL_MAX_X + 6, bz + 10);
- ctx.fillRect(bx0, by, bx1 - bx0, by1 - by);
+ const [bx0, by0] = toMap(CANAL_MIN_X - 5, bz);
+ const [bx1, by1] = toMap(CANAL_MAX_X + 5, bz);
+ ctx.strokeStyle = '#8d99a8';
+ ctx.lineWidth = px(3.4);
+ ctx.beginPath();
+ ctx.moveTo(bx0, by0);
+ ctx.lineTo(bx1, by1);
+ ctx.stroke();
}
-
- // Vias
- ctx.strokeStyle = '#ced4da';
- ctx.lineWidth = 4;
- for (const ax of AVENUES_X) {
- const [rx, ry0] = toMap(ax, -460);
- const [, ry1] = toMap(ax, 460);
+ for (const br of INTERCITY_BRIDGES) {
+ ctx.save();
+ ctx.strokeStyle = br.color;
+ ctx.shadowColor = br.color;
+ ctx.shadowBlur = px(8);
+ ctx.lineWidth = Math.max(px(3.4), br.width * wScale * 0.55);
+ ctx.lineCap = 'round';
ctx.beginPath();
- ctx.moveTo(rx, ry0);
- ctx.lineTo(rx, ry1);
+ if (br.isEastWest) {
+ const [ax, ay] = toMap(br.xMin, br.z);
+ const [bx, by] = toMap(br.xMax, br.z);
+ ctx.moveTo(ax, ay);
+ ctx.lineTo(bx, by);
+ } else {
+ const [ax, ay] = toMap(br.x, br.zMin);
+ const [bx, by] = toMap(br.x, br.zMax);
+ ctx.moveTo(ax, ay);
+ ctx.lineTo(bx, by);
+ }
ctx.stroke();
+ ctx.shadowBlur = 0;
+ ctx.restore();
+ // Torres da ponte (tick marks perpendiculares)
+ const towerPts = br.isEastWest
+ ? [[(br.xMin + br.xMax) / 2 - (br.xMax - br.xMin) * 0.24, br.z, 'x'], [(br.xMin + br.xMax) / 2 + (br.xMax - br.xMin) * 0.24, br.z, 'x']]
+ : [[br.x, (br.zMin + br.zMax) / 2 - (br.zMax - br.zMin) * 0.24, 'z'], [br.x, (br.zMin + br.zMax) / 2 + (br.zMax - br.zMin) * 0.24, 'z']];
+ ctx.strokeStyle = '#f8f9fa';
+ ctx.lineWidth = px(2.1);
+ for (const [tx2, tz2, axis] of towerPts) {
+ const [txx, tyy] = toMap(tx2, tz2);
+ ctx.beginPath();
+ if (axis === 'z') {
+ ctx.moveTo(txx - px(6), tyy);
+ ctx.lineTo(txx + px(6), tyy);
+ } else {
+ ctx.moveTo(txx, tyy - px(6));
+ ctx.lineTo(txx, tyy + px(6));
+ }
+ ctx.stroke();
+ }
}
- for (const sz of STREETS_Z) {
- const [rx0, ry] = toMap(-455, sz);
- const [rx1] = toMap(335, sz);
+
+ // ---------- Túneis (tracejado violeta por baixo da cidade) ----------
+ ctx.save();
+ ctx.strokeStyle = '#c77dff';
+ ctx.lineWidth = px(3.2);
+ ctx.setLineDash([px(7), px(6)]);
+ for (const tn of ROAD_TUNNELS) {
+ const [ax, ay] = toMap(tn.x, tn.zMin);
+ const [bx, by] = toMap(tn.x, tn.zMax);
ctx.beginPath();
- ctx.moveTo(rx0, ry);
- ctx.lineTo(rx1, ry);
+ ctx.moveTo(ax, ay);
+ ctx.lineTo(bx, by);
ctx.stroke();
}
+ ctx.setLineDash([]);
+ ctx.restore();
- // Pontos de Interesse
- ctx.font = 'bold 11px system-ui, sans-serif';
+ // ---------- Aeroporto VIA (pista listrada + símbolo de avião) ----------
+ const [rwX0, rwY0] = toMap(AIRPORT_DATA.runwayX, AIRPORT_DATA.runwayZMin);
+ const [rwX1, rwY1] = toMap(AIRPORT_DATA.runwayX, AIRPORT_DATA.runwayZMax);
+ ctx.save();
+ ctx.strokeStyle = '#9aa5b4';
+ ctx.lineWidth = px(6.5);
+ ctx.beginPath();
+ ctx.moveTo(rwX0, rwY0);
+ ctx.lineTo(rwX1, rwY1);
+ ctx.stroke();
+ ctx.strokeStyle = '#f1f8ff';
+ ctx.lineWidth = px(1.4);
+ ctx.setLineDash([px(6), px(8)]);
+ ctx.beginPath();
+ ctx.moveTo(rwX0, rwY0);
+ ctx.lineTo(rwX1, rwY1);
+ ctx.stroke();
+ ctx.setLineDash([]);
+ ctx.restore();
+
+ // ---------- Labels (typography moderna com halo) ----------
+ const label = (text, wx, wz, { size = 13, color = 'rgba(240,248,255,0.92)', align = 'center', spacing = 2 } = {}) => {
+ const [lx, ly] = toMap(wx, wz);
+ ctx.save();
+ ctx.font = `800 ${px(size)}px 'Arial Black', Arial, sans-serif`;
+ ctx.textAlign = align;
+ ctx.textBaseline = 'middle';
+ try { ctx.letterSpacing = `${px(spacing)}px`; } catch { /* older engines */ }
+ ctx.lineWidth = px(3.6);
+ ctx.strokeStyle = 'rgba(4, 14, 22, 0.85)';
+ ctx.strokeText(text, lx, ly);
+ ctx.fillStyle = color;
+ ctx.fillText(text, lx, ly);
+ ctx.restore();
+ };
+ label('PALM BAY CITY', -45, -742, { size: 15, color: '#7ff2dd', spacing: 3 });
+ label('VICE KEYS', 170, 800, { size: 13, color: '#ffe08a', spacing: 3 });
+ label('DOWNTOWN', -345, -176, { size: 10, color: '#cdb4ff', spacing: 2 });
+ label('VICE BEACH', 402, 205, { size: 10, color: '#ffd166', spacing: 2 });
+ label('PORTO', -352, 305, { size: 9, color: '#fcbf7f', spacing: 2 });
+ label('AEROPORTO VIA', -722, -278, { size: 10, color: '#8ce3ff', spacing: 2 });
+ label('O C E A N O A T L Â N T I C O', 620, 540, { size: 11, color: 'rgba(126, 200, 230, 0.5)', spacing: 2 });
+ label('ESTAÇÃO CENTRAL', -62, -96, { size: 8, color: '#5eead4', spacing: 1 });
+
+ // ---------- POIs (dots + icon labels) ----------
+ ctx.save();
+ ctx.font = `${px(10.5)}px 'Segoe UI Emoji', 'Apple Color Emoji', sans-serif`;
for (const poi of POINTS_OF_INTEREST) {
- const [px, py] = toMap(poi.x, poi.z);
+ const [poiX, poiY] = toMap(poi.x, poi.z);
+ ctx.save();
+ ctx.shadowColor = poi.color;
+ ctx.shadowBlur = px(6);
ctx.fillStyle = poi.color;
ctx.beginPath();
- ctx.arc(px, py, 6, 0, Math.PI * 2);
+ ctx.arc(poiX, poiY, px(4.6), 0, Math.PI * 2);
ctx.fill();
- ctx.fillStyle = '#ffffff';
- ctx.fillText(poi.name.split('(')[0].trim(), px + 9, py + 4);
+ ctx.restore();
+ ctx.strokeStyle = 'rgba(255,255,255,0.85)';
+ ctx.lineWidth = px(1.1);
+ ctx.beginPath();
+ ctx.arc(poiX, poiY, px(4.6), 0, Math.PI * 2);
+ ctx.stroke();
}
+ ctx.restore();
- // Objetivo
+ // ---------- Route to active objective ----------
if (target) {
const [tx, ty] = toMap(target.x, target.z);
const [ux, uy] = toMap(playerX, playerZ);
+ ctx.save();
ctx.strokeStyle = '#ff2a85';
- ctx.lineWidth = 3;
- ctx.setLineDash([6, 5]);
+ ctx.shadowColor = '#ff2a85';
+ ctx.shadowBlur = px(7);
+ ctx.lineWidth = px(3.1);
+ ctx.setLineDash([px(9), px(7)]);
ctx.beginPath();
ctx.moveTo(ux, uy);
ctx.lineTo(tx, ty);
ctx.stroke();
- ctx.setLineDash([]);
-
+ ctx.restore();
ctx.fillStyle = '#ffd166';
+ ctx.strokeStyle = '#241a02';
+ ctx.lineWidth = px(2);
ctx.beginPath();
- ctx.arc(tx, ty, 8, 0, Math.PI * 2);
+ ctx.arc(tx, ty, px(6.4), 0, Math.PI * 2);
ctx.fill();
+ ctx.stroke();
}
- // Jogador
+ // ---------- Player marker ----------
const [ux, uy] = toMap(playerX, playerZ);
+ ctx.save();
+ ctx.shadowColor = '#ff2a85';
+ ctx.shadowBlur = px(10);
ctx.fillStyle = '#ff2a85';
+ ctx.beginPath();
+ ctx.arc(ux, uy, px(6.2), 0, Math.PI * 2);
+ ctx.fill();
+ ctx.restore();
ctx.strokeStyle = '#ffffff';
- ctx.lineWidth = 2.5;
+ ctx.lineWidth = px(2.1);
+ ctx.beginPath();
+ ctx.arc(ux, uy, px(6.2), 0, Math.PI * 2);
+ ctx.stroke();
+
+ // ---------- Compass rose + title block + scale bar + frame ----------
+ const compassX = width - px(46);
+ const compassY = px(52);
+ ctx.save();
+ ctx.strokeStyle = 'rgba(240,248,255,0.75)';
+ ctx.lineWidth = px(1.6);
ctx.beginPath();
- ctx.arc(ux, uy, 7, 0, Math.PI * 2);
+ ctx.arc(compassX, compassY, px(17), 0, Math.PI * 2);
+ ctx.stroke();
+ ctx.fillStyle = '#ff2a85';
+ ctx.beginPath();
+ ctx.moveTo(compassX, compassY - px(14));
+ ctx.lineTo(compassX - px(5), compassY + px(3));
+ ctx.lineTo(compassX + px(5), compassY + px(3));
+ ctx.closePath();
ctx.fill();
+ ctx.font = `800 ${px(9)}px Arial, sans-serif`;
+ ctx.fillStyle = '#f0f8ff';
+ ctx.textAlign = 'center';
+ ctx.fillText('N', compassX, compassY - px(21));
+ ctx.restore();
+
+ // Título
+ ctx.save();
+ ctx.font = `900 ${px(15)}px 'Arial Black', Arial, sans-serif`;
+ try { ctx.letterSpacing = `${px(2.5)}px`; } catch { /* noop */ }
+ ctx.fillStyle = 'rgba(240,248,255,0.95)';
+ ctx.textAlign = 'left';
+ ctx.textBaseline = 'alphabetic';
+ ctx.fillText('LEONIDA', px(18), px(30));
+ ctx.font = `700 ${px(8)}px Arial, sans-serif`;
+ ctx.fillStyle = 'rgba(94, 234, 212, 0.9)';
+ ctx.fillText('GPS · VICE CITY & REDLINE', px(18), px(44));
+ ctx.restore();
+
+ // Escala (500 m)
+ const scaleM = 500;
+ const scalePx = scaleM * wScale;
+ const scaleX = px(18);
+ const scaleY = height - px(24);
+ ctx.save();
+ ctx.strokeStyle = 'rgba(240,248,255,0.85)';
+ ctx.lineWidth = px(2);
+ ctx.beginPath();
+ ctx.moveTo(scaleX, scaleY);
+ ctx.lineTo(scaleX + scalePx, scaleY);
+ ctx.moveTo(scaleX, scaleY - px(4));
+ ctx.lineTo(scaleX, scaleY + px(4));
+ ctx.moveTo(scaleX + scalePx, scaleY - px(4));
+ ctx.lineTo(scaleX + scalePx, scaleY + px(4));
ctx.stroke();
+ ctx.font = `700 ${px(8.5)}px Arial, sans-serif`;
+ ctx.fillStyle = 'rgba(240,248,255,0.85)';
+ ctx.textAlign = 'left';
+ ctx.fillText('500 m', scaleX + scalePx + px(6), scaleY + px(3));
+ ctx.restore();
+
+ // Moldura premium
+ ctx.save();
+ ctx.strokeStyle = 'rgba(0, 245, 212, 0.35)';
+ ctx.lineWidth = px(2.2);
+ ctx.strokeRect(px(3), px(3), width - px(6), height - px(6));
+ ctx.restore();
}
diff --git a/vice-game/styles/main.css b/vice-game/styles/main.css
index ccc211d6..945ba078 100644
--- a/vice-game/styles/main.css
+++ b/vice-game/styles/main.css
@@ -448,29 +448,57 @@ button {
display: block;
}
+/* Mira "Complex" do GTA VI (padrão): uma seta superior + duas diagonais laterais + ponto central! */
.vc-crosshair {
position: absolute;
left: 50%;
top: 46%;
- width: 14px;
- height: 14px;
+ width: 56px;
+ height: 40px;
transform: translate(-50%, -50%);
- border: 2px solid rgba(255, 255, 255, 0.72);
- border-radius: 50%;
pointer-events: none;
z-index: 4;
}
-.vc-crosshair::after {
- content: '';
+.vc-crosshair__line {
+ position: absolute;
+ width: 3px;
+ height: 12px;
+ background: #ffffff;
+ border-radius: 2px;
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.9), 0 1px 2px rgba(0, 0, 0, 0.8);
+}
+
+.vc-crosshair__line--top {
+ left: 50%;
+ top: 0;
+ transform: translateX(-50%);
+}
+
+.vc-crosshair__line--left {
+ left: 3px;
+ bottom: 0;
+ transform: rotate(45deg);
+ transform-origin: center;
+}
+
+.vc-crosshair__line--right {
+ right: 3px;
+ bottom: 0;
+ transform: rotate(-45deg);
+ transform-origin: center;
+}
+
+.vc-crosshair__dot {
position: absolute;
left: 50%;
top: 50%;
- width: 3px;
- height: 3px;
- background: var(--vc-pink);
+ width: 3.5px;
+ height: 3.5px;
+ background: #ffffff;
border-radius: 50%;
transform: translate(-50%, -50%);
+ box-shadow: 0 0 3px rgba(0, 0, 0, 0.9);
}
/* Topo Esquerdo: Bairro + Missão Ativa */
@@ -482,46 +510,35 @@ button {
display: flex;
flex-direction: column;
gap: 8px;
- max-width: min(370px, 46vw);
+ max-width: min(300px, 40vw);
pointer-events: none;
}
-.vc-district {
- align-self: flex-start;
- padding: 5px 12px;
- border-radius: 999px;
- background: rgba(11, 14, 29, 0.78);
- border-left: 4px solid var(--vc-pink);
- font-size: 12px;
- font-weight: 800;
- letter-spacing: 0.04em;
-}
-
.vc-mission-box {
- padding: 9px 12px;
- border-radius: 14px;
- background: rgba(11, 14, 29, 0.8);
- border: 1px solid rgba(255, 255, 255, 0.14);
- backdrop-filter: blur(8px);
+ padding: 7px 11px;
+ border-radius: 10px;
+ background: rgba(11, 14, 29, 0.55);
+ border-left: 3px solid rgba(255, 209, 102, 0.85);
+ backdrop-filter: blur(6px);
}
.vc-mission-box__tag {
- font-size: 10px;
- font-weight: 900;
- letter-spacing: 0.12em;
- color: var(--vc-gold);
+ font-size: 8.5px;
+ font-weight: 800;
+ letter-spacing: 0.18em;
+ color: rgba(255, 209, 102, 0.85);
}
.vc-mission-box__title {
- font-size: 13.5px;
+ font-size: 12px;
font-weight: 800;
- margin: 2px 0;
+ margin: 1px 0;
}
.vc-mission-box__prompt {
- font-size: 11.5px;
- color: rgba(255, 255, 255, 0.84);
- line-height: 1.3;
+ font-size: 10.5px;
+ color: rgba(255, 255, 255, 0.72);
+ line-height: 1.28;
}
/* Topo Direito: Hora, Dinheiro, Estrelas VCPD e Pílulas Interativas */
@@ -540,10 +557,11 @@ button {
display: flex;
align-items: center;
gap: 12px;
- padding: 5px 12px;
+ padding: 4px 10px;
border-radius: 999px;
- background: rgba(11, 14, 29, 0.8);
- border: 1px solid rgba(255, 255, 255, 0.14);
+ background: rgba(11, 14, 29, 0.55);
+ border: 1px solid rgba(255, 255, 255, 0.12);
+ backdrop-filter: blur(6px);
}
.vc-clock {
@@ -582,60 +600,112 @@ button {
to { color: #6ecbff; text-shadow: 0 0 12px #00bbf9; }
}
-.vc-hud-tr__pills {
- display: flex;
- flex-wrap: wrap;
- justify-content: flex-end;
- gap: 6px;
+.vc-menu-btn {
+ display: grid;
+ place-items: center;
+ width: 30px;
+ height: 30px;
+ padding: 0;
+ border-radius: 50%;
+ border: 1px solid rgba(255, 255, 255, 0.22);
+ background: rgba(14, 18, 38, 0.6);
+ color: rgba(255, 255, 255, 0.9);
+ font-size: 14px;
+ line-height: 1;
+ cursor: pointer;
+ transition: transform 0.12s ease, background 0.12s ease;
}
-.vc-pill {
- padding: 6px 11px;
- border-radius: 10px;
- border: 1px solid rgba(255, 255, 255, 0.2);
- background: rgba(14, 18, 38, 0.84);
+.vc-menu-btn:active {
+ transform: scale(0.9);
+ background: rgba(14, 18, 38, 0.9);
+}
+
+/* Botão de interação contextual — igual ao prompt de GTA (anel fino, escuro, discreto) */
+.vc-context-btn {
+ position: fixed;
+ left: 50%;
+ bottom: 108px;
+ transform: translateX(-50%);
+ z-index: 45;
+ max-width: min(440px, 86vw);
+ padding: 9px 18px;
+ border-radius: 999px;
+ border: 1px solid rgba(255, 255, 255, 0.35);
+ background: rgba(11, 14, 29, 0.72);
+ backdrop-filter: blur(6px);
color: #fff;
- font-size: 11.5px;
+ font-size: 12.5px;
font-weight: 800;
+ letter-spacing: 0.02em;
+ box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
-.vc-pill:active {
- transform: scale(0.95);
+.vc-context-btn:active { transform: translateX(-50%) scale(0.96); }
+
+/* Botão SE RENDER: único elemento vermelho permitido, só quando a VCPD está em cima */
+.vc-surrender-btn {
+ position: fixed;
+ left: 50%;
+ bottom: 158px;
+ transform: translateX(-50%);
+ z-index: 44;
+ padding: 10px 26px;
+ border-radius: 999px;
+ border: 1px solid rgba(255, 255, 255, 0.4);
+ background: rgba(180, 24, 46, 0.88);
+ color: #fff;
+ font-size: 13px;
+ font-weight: 900;
+ letter-spacing: 0.08em;
+ box-shadow: 0 8px 22px rgba(255, 30, 86, 0.35);
+ animation: vcSurrenderPulse 0.9s infinite alternate;
}
+@keyframes vcSurrenderPulse {
+ from { box-shadow: 0 8px 22px rgba(255, 30, 86, 0.3); }
+ to { box-shadow: 0 8px 30px rgba(255, 159, 28, 0.55); }
+}
+
+.vc-surrender-btn:active { transform: translateX(-50%) scale(0.95); }
+
/* Radar / Minimapa (Canto Superior/Médio Esquerdo em Mobile ou Inferior Acima do Stick) */
+/* Radar circular estilo GTA V/VI: anel branco fino, sem moldura pesada */
.vc-radar {
position: absolute;
left: max(14px, env(safe-area-inset-left));
bottom: calc(max(12px, env(safe-area-inset-bottom)) + 158px);
- width: 132px;
+ width: 128px;
z-index: 8;
- border-radius: 14px;
- overflow: hidden;
- background: rgba(11, 14, 29, 0.9);
- border: 2px solid rgba(255, 255, 255, 0.26);
- box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
cursor: pointer;
}
.vc-radar__canvas {
width: 100%;
- height: 112px;
+ aspect-ratio: 1 / 1;
display: block;
+ border-radius: 50%;
+ border: 2px solid rgba(255, 255, 255, 0.38);
+ background: rgba(11, 14, 29, 0.92);
+ box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), inset 0 0 18px rgba(0, 0, 0, 0.6);
}
+/* Barras de vida/colete/carro ultra finas, flutuando abaixo do radar */
.vc-bars {
display: flex;
flex-direction: column;
- gap: 3px;
- padding: 4px;
- background: #0b0e1d;
+ gap: 2px;
+ width: 74%;
+ margin: 4px auto 0;
}
.vc-bar {
- height: 6px;
- background: rgba(255, 255, 255, 0.14);
- border-radius: 3px;
+ height: 3px;
+ background: rgba(0, 0, 0, 0.55);
+ border-radius: 2px;
overflow: hidden;
}
@@ -918,10 +988,17 @@ button {
}
.vc-fullmap {
- border-radius: 14px;
- border: 2px solid rgba(255, 255, 255, 0.2);
+ border-radius: 18px;
+ border: 2px solid rgba(0, 245, 212, 0.4);
+ box-shadow:
+ 0 0 0 1px rgba(6, 20, 30, 0.9),
+ 0 18px 48px rgba(0, 0, 0, 0.55),
+ 0 0 34px rgba(0, 245, 212, 0.22);
max-width: 100%;
height: auto;
+ display: block;
+ background: #051d2f;
+ image-rendering: auto;
}
.vc-map-legend {
@@ -1056,15 +1133,87 @@ button {
transform: translateY(-8px);
}
+/* Showroom 3D giratório (.GLB) na Garagem e Personagens */
+.vc-garage-showcase {
+ display: grid;
+ grid-template-columns: 1.1fr 1fr;
+ gap: 16px;
+ align-items: stretch;
+}
+
+.vc-turntable {
+ position: relative;
+ min-height: 290px;
+ border-radius: 20px;
+ border: 1px solid rgba(0, 245, 212, 0.45);
+ background:
+ radial-gradient(circle at 50% 35%, rgba(255, 42, 133, 0.25) 0%, rgba(11, 14, 29, 0.92) 72%);
+ overflow: hidden;
+ box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
+}
+
+.vc-turntable__canvas {
+ width: 100%;
+ height: 100%;
+ display: block;
+ cursor: grab;
+}
+
+.vc-turntable__canvas:active {
+ cursor: grabbing;
+}
+
+.vc-turntable__hint {
+ position: absolute;
+ left: 12px;
+ bottom: 10px;
+ padding: 5px 10px;
+ border-radius: 999px;
+ background: rgba(9, 12, 26, 0.8);
+ border: 1px solid rgba(255, 255, 255, 0.18);
+ font-size: 11px;
+ font-weight: 700;
+ color: var(--vc-cyan);
+ pointer-events: none;
+}
+
+.vc-garage-detail {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.vc-garage-selector {
+ display: flex;
+ flex-wrap: wrap;
+ gap: 8px;
+}
+
+.vc-garage-pill {
+ padding: 8px 12px;
+ border-radius: 12px;
+ border: 1px solid rgba(255, 255, 255, 0.2);
+ background: rgba(14, 18, 38, 0.85);
+ color: #fff;
+ font-size: 12px;
+ font-weight: 800;
+}
+
+.vc-garage-pill.is-active {
+ background: linear-gradient(90deg, var(--vc-pink), var(--vc-orange));
+ border-color: transparent;
+}
+
@media (max-width: 760px) {
- .vc-home-layout {
+ .vc-home-layout,
+ .vc-garage-showcase {
grid-template-columns: 1fr;
}
+ .vc-turntable {
+ min-height: 220px;
+ }
.vc-radar {
- width: 108px;
+ width: 104px;
bottom: calc(max(10px, env(safe-area-inset-bottom)) + 144px);
}
- .vc-radar__canvas {
- height: 92px;
- }
}
diff --git a/vice-game/upload-glb.html b/vice-game/upload-glb.html
index e164fd85..22ff06b6 100644
--- a/vice-game/upload-glb.html
+++ b/vice-game/upload-glb.html
@@ -185,15 +185,17 @@