@muvtacode/cli 0.1.8 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/loop.js +10 -1
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/prompt.js +101 -0
- package/dist/agent/prompt.js.map +1 -1
- package/dist/cli.js +102 -0
- package/dist/cli.js.map +1 -1
- package/dist/commands/index.js +28 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/pt.js +4 -0
- package/dist/i18n/pt.js.map +1 -1
- package/dist/remote/claudeSessions.js +82 -0
- package/dist/remote/claudeSessions.js.map +1 -0
- package/dist/remote/host.js +530 -0
- package/dist/remote/host.js.map +1 -0
- package/dist/remote/passagem.js +545 -0
- package/dist/remote/passagem.js.map +1 -0
- package/dist/repl.js +94 -22
- package/dist/repl.js.map +1 -1
- package/dist/state/templates.js +43 -10
- package/dist/state/templates.js.map +1 -1
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/AssaultRifle_1.mtl +42 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/AssaultRifle_1.obj +1472 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Grip.mtl +12 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Grip.obj +890 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/LICENCA.txt +25 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_1.mtl +52 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_1.obj +1444 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_4.mtl +32 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Pistol_4.obj +1789 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Revolver_1.mtl +32 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Revolver_1.obj +1273 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Scope_1.mtl +32 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Scope_1.obj +485 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Shotgun_1.mtl +42 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Shotgun_1.obj +1589 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Silencer_1.mtl +12 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/Silencer_1.obj +309 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SniperRifle_1.mtl +52 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SniperRifle_1.obj +1681 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SubmachineGun_1.mtl +42 -0
- package/dist/templates/game/adapt-assets-3d-01/files/public/models/armas/SubmachineGun_1.obj +1275 -0
- package/dist/templates/game/adapt-assets-3d-01/files/src/assets/modelos.ts +270 -0
- package/dist/templates/game/adapt-assets-3d-01/meta.json +30 -0
- package/dist/templates/game/adapt-audio-01/files/src/audio/audio.ts +309 -0
- package/dist/templates/game/adapt-audio-01/meta.json +47 -0
- package/dist/templates/game/adapt-camera-rig-01/files/src/camera/rig.ts +364 -0
- package/dist/templates/game/adapt-camera-rig-01/meta.json +53 -0
- package/dist/templates/game/adapt-controle-teclado-01/files/src/controles/teclado.ts +175 -0
- package/dist/templates/game/adapt-controle-teclado-01/meta.json +36 -0
- package/dist/templates/game/adapt-controle-toque-01/files/src/controles/toque.ts +407 -0
- package/dist/templates/game/adapt-controle-toque-01/meta.json +43 -0
- package/dist/templates/game/adapt-dia-noite-01/files/src/world/dianoite.ts +378 -0
- package/dist/templates/game/adapt-dia-noite-01/meta.json +50 -0
- package/dist/templates/game/adapt-hud-01/files/src/hud/hud.ts +859 -0
- package/dist/templates/game/adapt-hud-01/meta.json +69 -0
- package/dist/templates/game/adapt-menu-01/files/src/ui/menu.ts +427 -0
- package/dist/templates/game/adapt-menu-01/meta.json +41 -0
- package/dist/templates/game/adapt-particulas-01/files/src/vfx/particulas.ts +280 -0
- package/dist/templates/game/adapt-particulas-01/meta.json +50 -0
- package/dist/templates/game/adapt-perf-mobile-01/files/src/engine/performance.ts +220 -0
- package/dist/templates/game/adapt-perf-mobile-01/meta.json +49 -0
- package/dist/templates/game/adapt-primeira-pessoa-01/files/src/camera/primeirapessoa.ts +595 -0
- package/dist/templates/game/adapt-primeira-pessoa-01/meta.json +63 -0
- package/dist/templates/game/adapt-save-01/files/src/save/save.ts +188 -0
- package/dist/templates/game/adapt-save-01/meta.json +34 -0
- package/dist/templates/game/carro-2d-01/files/src/models/carro2d.ts +253 -0
- package/dist/templates/game/carro-2d-01/meta.json +38 -0
- package/dist/templates/game/carro-3d-01/files/src/models/carro3d.ts +266 -0
- package/dist/templates/game/carro-3d-01/meta.json +13 -0
- package/dist/templates/game/estruturas-3d-01/files/src/world/estruturas.ts +490 -0
- package/dist/templates/game/estruturas-3d-01/meta.json +13 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/arena.ts +324 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/armas.ts +398 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/cena.ts +801 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/coletaveis.ts +129 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/fisica.ts +257 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/inimigos.ts +608 -0
- package/dist/templates/game/fps-3d-01/files/src/fps/jogador.ts +224 -0
- package/dist/templates/game/fps-3d-01/files/src/main.ts +21 -0
- package/dist/templates/game/fps-3d-01/meta.json +48 -0
- package/dist/templates/game/game-design-tokens-01/files/src/design/tokens.ts +274 -0
- package/dist/templates/game/game-design-tokens-01/meta.json +13 -0
- package/dist/templates/game/game-engine-base-01/files/index.html +37 -0
- package/dist/templates/game/game-engine-base-01/files/package.json +19 -0
- package/dist/templates/game/game-engine-base-01/files/src/engine/device.ts +57 -0
- package/dist/templates/game/game-engine-base-01/files/src/engine/engine.ts +221 -0
- package/dist/templates/game/game-engine-base-01/files/src/engine/index.ts +68 -0
- package/dist/templates/game/game-engine-base-01/files/src/engine/input.ts +578 -0
- package/dist/templates/game/game-engine-base-01/files/src/engine/layout.ts +192 -0
- package/dist/templates/game/game-engine-base-01/files/tsconfig.json +14 -0
- package/dist/templates/game/game-engine-base-01/files/vite.config.ts +10 -0
- package/dist/templates/game/game-engine-base-01/meta.json +70 -0
- package/dist/templates/game/mundo-25d-01/files/src/world/mundo25d.ts +252 -0
- package/dist/templates/game/mundo-25d-01/meta.json +39 -0
- package/dist/templates/game/mundo-2d-01/files/src/world/mundo2d.ts +273 -0
- package/dist/templates/game/mundo-2d-01/meta.json +38 -0
- package/dist/templates/game/mundo-3d-01/files/src/world/mundo3d.ts +3130 -0
- package/dist/templates/game/mundo-3d-01/meta.json +132 -0
- package/dist/templates/game/npc-3d-01/files/src/ai/npc3d.ts +658 -0
- package/dist/templates/game/npc-3d-01/meta.json +13 -0
- package/dist/templates/game/personagem-2d-01/files/src/models/personagem2d.ts +341 -0
- package/dist/templates/game/personagem-2d-01/meta.json +41 -0
- package/dist/templates/game/personagem-3d-01/files/src/models/personagem3d.ts +614 -0
- package/dist/templates/game/personagem-3d-01/meta.json +67 -0
- package/package.json +2 -1
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Arena procedural de FPS.
|
|
3
|
+
//
|
|
4
|
+
// Layout pensado para TIROTEIO, não para enfeite: um bloco central elevado
|
|
5
|
+
// (com escada dos dois lados) que dá vantagem de altura a quem sobe, pilares
|
|
6
|
+
// que cortam a linha de visada, muros baixos para se agachar atrás e grupos de
|
|
7
|
+
// caixas espalhados — cobertura a cada poucos metros, que é o que torna o
|
|
8
|
+
// combate interessante. Arena vazia vira "quem atira primeiro ganha".
|
|
9
|
+
//
|
|
10
|
+
// Tudo que é sólido entra em `caixas` (colisão, tiro e linha de visada usam a
|
|
11
|
+
// mesma lista — ver fisica.ts). Mesma seed = mesma arena.
|
|
12
|
+
//
|
|
13
|
+
// Cores 100% da paleta (design/tokens): trocar o tema do jogo troca a arena.
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
import * as THREE from 'three';
|
|
17
|
+
import { getPalette, type Palette } from '../design/tokens';
|
|
18
|
+
|
|
19
|
+
export const tuning = {
|
|
20
|
+
/** Meia-largura da arena (m). 22 = 44 x 44 m: dá para correr sem ficar vazio. */
|
|
21
|
+
meiaLargura: 22,
|
|
22
|
+
alturaParede: 5,
|
|
23
|
+
/** Grupos de caixas espalhados pela arena. */
|
|
24
|
+
gruposDeCaixas: 11,
|
|
25
|
+
/** Tamanho do ladrilho do piso (m) — referência de escala para o olho. */
|
|
26
|
+
ladrilho: 2
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export interface Arena {
|
|
30
|
+
/** Adicione na cena. */
|
|
31
|
+
raiz: THREE.Group;
|
|
32
|
+
/** Tudo que é sólido. Colisão, tiro e linha de visada usam esta lista. */
|
|
33
|
+
caixas: THREE.Box3[];
|
|
34
|
+
/** Onde o jogador nasce e para onde olha (ângulo do rig de câmera). */
|
|
35
|
+
spawnJogador: THREE.Vector3;
|
|
36
|
+
anguloInicial: number;
|
|
37
|
+
/** Pontos de nascimento dos inimigos (nas bordas, a meia altura). */
|
|
38
|
+
spawns: THREE.Vector3[];
|
|
39
|
+
/** Meia-largura útil (dentro das paredes). */
|
|
40
|
+
limite: number;
|
|
41
|
+
/** Malhas que fazem sombra — o cena.ts liga/desliga conforme o nível gráfico. */
|
|
42
|
+
sombreaveis: THREE.Mesh[];
|
|
43
|
+
dispose(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Gerador determinístico (mulberry32): mesma seed, mesma arena. */
|
|
47
|
+
function gerador(seed: number): () => number {
|
|
48
|
+
let a = seed >>> 0;
|
|
49
|
+
return () => {
|
|
50
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
51
|
+
let t = a;
|
|
52
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
53
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
54
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const misturar = (a: string, b: string, t: number): THREE.Color =>
|
|
59
|
+
new THREE.Color(a).lerp(new THREE.Color(b), t);
|
|
60
|
+
|
|
61
|
+
/** Piso: ladrilho com junta escura e uma linha fina de cor — escala e direção à vista. */
|
|
62
|
+
function texturaPiso(p: Palette): THREE.CanvasTexture {
|
|
63
|
+
const t = 256;
|
|
64
|
+
const cv = document.createElement('canvas');
|
|
65
|
+
cv.width = cv.height = t;
|
|
66
|
+
const c = cv.getContext('2d')!;
|
|
67
|
+
c.fillStyle = `#${misturar(p.superficie, p.contorno, 0.35).getHexString()}`;
|
|
68
|
+
c.fillRect(0, 0, t, t);
|
|
69
|
+
// Variação sutil por quadrante: chão chapado parece plástico.
|
|
70
|
+
c.fillStyle = 'rgba(255,255,255,0.025)';
|
|
71
|
+
c.fillRect(0, 0, t / 2, t / 2);
|
|
72
|
+
c.fillRect(t / 2, t / 2, t / 2, t / 2);
|
|
73
|
+
c.strokeStyle = `#${misturar(p.fundo, p.superficie, 0.3).getHexString()}`;
|
|
74
|
+
c.lineWidth = 6;
|
|
75
|
+
c.strokeRect(0, 0, t, t);
|
|
76
|
+
c.strokeStyle = p.primaria;
|
|
77
|
+
c.globalAlpha = 0.22;
|
|
78
|
+
c.lineWidth = 2;
|
|
79
|
+
c.strokeRect(5, 5, t - 10, t - 10);
|
|
80
|
+
c.globalAlpha = 1;
|
|
81
|
+
const tex = new THREE.CanvasTexture(cv);
|
|
82
|
+
tex.colorSpace = THREE.SRGBColorSpace;
|
|
83
|
+
tex.wrapS = tex.wrapT = THREE.RepeatWrapping;
|
|
84
|
+
tex.anisotropy = 4;
|
|
85
|
+
return tex;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Caixa de carga: moldura + travessa diagonal, em branco para a cor da instância tingir. */
|
|
89
|
+
function texturaCaixa(): THREE.CanvasTexture {
|
|
90
|
+
const t = 128;
|
|
91
|
+
const cv = document.createElement('canvas');
|
|
92
|
+
cv.width = cv.height = t;
|
|
93
|
+
const c = cv.getContext('2d')!;
|
|
94
|
+
c.fillStyle = '#d8d8d8';
|
|
95
|
+
c.fillRect(0, 0, t, t);
|
|
96
|
+
c.strokeStyle = '#8a8a8a';
|
|
97
|
+
c.lineWidth = 14;
|
|
98
|
+
c.strokeRect(7, 7, t - 14, t - 14);
|
|
99
|
+
c.lineWidth = 10;
|
|
100
|
+
c.beginPath();
|
|
101
|
+
c.moveTo(14, t - 14);
|
|
102
|
+
c.lineTo(t - 14, 14);
|
|
103
|
+
c.stroke();
|
|
104
|
+
const tex = new THREE.CanvasTexture(cv);
|
|
105
|
+
tex.colorSpace = THREE.SRGBColorSpace;
|
|
106
|
+
return tex;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function criarArena(opts: { paleta?: string; seed?: number } = {}): Arena {
|
|
110
|
+
const p = getPalette(opts.paleta);
|
|
111
|
+
const seed = opts.seed ?? Math.floor(Math.random() * 1e9);
|
|
112
|
+
const rnd = gerador(seed);
|
|
113
|
+
const L = tuning.meiaLargura;
|
|
114
|
+
const H = tuning.alturaParede;
|
|
115
|
+
|
|
116
|
+
const raiz = new THREE.Group();
|
|
117
|
+
raiz.name = 'arena';
|
|
118
|
+
const caixas: THREE.Box3[] = [];
|
|
119
|
+
const sombreaveis: THREE.Mesh[] = [];
|
|
120
|
+
const geos: THREE.BufferGeometry[] = [];
|
|
121
|
+
const mats: THREE.Material[] = [];
|
|
122
|
+
const texs: THREE.Texture[] = [];
|
|
123
|
+
|
|
124
|
+
// ------------------------------------------------------------ materiais
|
|
125
|
+
const texPiso = texturaPiso(p);
|
|
126
|
+
texPiso.repeat.set((L * 2) / tuning.ladrilho, (L * 2) / tuning.ladrilho);
|
|
127
|
+
const matPiso = new THREE.MeshStandardMaterial({ map: texPiso, roughness: 0.92, metalness: 0.05 });
|
|
128
|
+
const matParede = new THREE.MeshStandardMaterial({ color: misturar(p.superficie, p.contorno, 0.75), roughness: 0.82, metalness: 0.12 });
|
|
129
|
+
const matBloco = new THREE.MeshStandardMaterial({ color: misturar(p.superficie, p.contorno, 0.5), roughness: 0.7, metalness: 0.2 });
|
|
130
|
+
const matPilar = new THREE.MeshStandardMaterial({ color: misturar(p.contorno, p.textoFraco, 0.25), roughness: 0.6, metalness: 0.35 });
|
|
131
|
+
const matNeon = new THREE.MeshBasicMaterial({ color: p.primaria });
|
|
132
|
+
const matNeonAcento = new THREE.MeshBasicMaterial({ color: p.acento });
|
|
133
|
+
const texCaixa = texturaCaixa();
|
|
134
|
+
const matCaixa = new THREE.MeshStandardMaterial({ map: texCaixa, roughness: 0.75, metalness: 0.1 });
|
|
135
|
+
mats.push(matPiso, matParede, matBloco, matPilar, matNeon, matNeonAcento, matCaixa);
|
|
136
|
+
texs.push(texPiso, texCaixa);
|
|
137
|
+
|
|
138
|
+
// ------------------------------------------------------------- helpers
|
|
139
|
+
/** Caixa sólida: malha + colisor com as MESMAS medidas (nunca divergem). */
|
|
140
|
+
const solido = (
|
|
141
|
+
mat: THREE.Material,
|
|
142
|
+
x0: number, y0: number, z0: number, x1: number, y1: number, z1: number,
|
|
143
|
+
sombra = true
|
|
144
|
+
): THREE.Mesh => {
|
|
145
|
+
const geo = new THREE.BoxGeometry(x1 - x0, y1 - y0, z1 - z0);
|
|
146
|
+
geos.push(geo);
|
|
147
|
+
const m = new THREE.Mesh(geo, mat);
|
|
148
|
+
m.position.set((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2);
|
|
149
|
+
m.castShadow = sombra;
|
|
150
|
+
m.receiveShadow = true;
|
|
151
|
+
if (sombra) sombreaveis.push(m);
|
|
152
|
+
raiz.add(m);
|
|
153
|
+
caixas.push(new THREE.Box3(new THREE.Vector3(x0, y0, z0), new THREE.Vector3(x1, y1, z1)));
|
|
154
|
+
return m;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
/** Faixa de luz decorativa (sem colisão). */
|
|
158
|
+
const faixa = (mat: THREE.Material, x0: number, y0: number, z0: number, x1: number, y1: number, z1: number) => {
|
|
159
|
+
const geo = new THREE.BoxGeometry(x1 - x0, y1 - y0, z1 - z0);
|
|
160
|
+
geos.push(geo);
|
|
161
|
+
const m = new THREE.Mesh(geo, mat);
|
|
162
|
+
m.position.set((x0 + x1) / 2, (y0 + y1) / 2, (z0 + z1) / 2);
|
|
163
|
+
raiz.add(m);
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// ---------------------------------------------------------------- piso
|
|
167
|
+
const geoPiso = new THREE.PlaneGeometry(L * 2, L * 2);
|
|
168
|
+
geos.push(geoPiso);
|
|
169
|
+
const piso = new THREE.Mesh(geoPiso, matPiso);
|
|
170
|
+
piso.rotation.x = -Math.PI / 2;
|
|
171
|
+
piso.receiveShadow = true;
|
|
172
|
+
raiz.add(piso);
|
|
173
|
+
|
|
174
|
+
// ----------------------------------------------------- paredes externas
|
|
175
|
+
solido(matParede, -L - 1, 0, -L - 1, L + 1, H, -L); // norte
|
|
176
|
+
solido(matParede, -L - 1, 0, L, L + 1, H, L + 1); // sul
|
|
177
|
+
solido(matParede, -L - 1, 0, -L, -L, H, L); // oeste
|
|
178
|
+
solido(matParede, L, 0, -L, L + 1, H, L); // leste
|
|
179
|
+
// Faixa de neon no alto e no rodapé: desenha o contorno da arena no escuro.
|
|
180
|
+
const e = 0.06;
|
|
181
|
+
faixa(matNeon, -L, H - 0.6, -L, L, H - 0.5, -L + e);
|
|
182
|
+
faixa(matNeon, -L, H - 0.6, L - e, L, H - 0.5, L);
|
|
183
|
+
faixa(matNeon, -L, H - 0.6, -L, -L + e, H - 0.5, L);
|
|
184
|
+
faixa(matNeon, L - e, H - 0.6, -L, L, H - 0.5, L);
|
|
185
|
+
faixa(matNeonAcento, -L, 0.02, -L, L, 0.1, -L + e);
|
|
186
|
+
faixa(matNeonAcento, -L, 0.02, L - e, L, 0.1, L);
|
|
187
|
+
faixa(matNeonAcento, -L, 0.02, -L, -L + e, 0.1, L);
|
|
188
|
+
faixa(matNeonAcento, L - e, 0.02, -L, L, 0.1, L);
|
|
189
|
+
|
|
190
|
+
// ------------------------------------------- bloco central com escadas
|
|
191
|
+
// 1,6 m de altura em 4 degraus de 0,4 m (o jogador sobe degrau de até 0,45).
|
|
192
|
+
const meioBloco = 3;
|
|
193
|
+
const alturaBloco = 1.6;
|
|
194
|
+
solido(matBloco, -meioBloco, 0, -meioBloco, meioBloco, alturaBloco, meioBloco);
|
|
195
|
+
const profDegrau = 0.7;
|
|
196
|
+
for (let i = 0; i < 3; i++) {
|
|
197
|
+
const alt = (i + 1) * 0.4;
|
|
198
|
+
const zA = meioBloco + (2 - i) * profDegrau;
|
|
199
|
+
const zB = meioBloco + (3 - i) * profDegrau;
|
|
200
|
+
solido(matBloco, -1.6, 0, zA, 1.6, alt, zB); // escada sul
|
|
201
|
+
solido(matBloco, -1.6, 0, -zB, 1.6, alt, -zA); // escada norte
|
|
202
|
+
}
|
|
203
|
+
// Parapeitos nas laterais do topo: cobertura para quem está em cima.
|
|
204
|
+
solido(matParede, -meioBloco, alturaBloco, -1.4, -meioBloco + 0.35, alturaBloco + 0.95, 1.4);
|
|
205
|
+
solido(matParede, meioBloco - 0.35, alturaBloco, -1.4, meioBloco, alturaBloco + 0.95, 1.4);
|
|
206
|
+
faixa(matNeon, -meioBloco - 0.01, alturaBloco - 0.12, -meioBloco - 0.01, meioBloco + 0.01, alturaBloco - 0.05, meioBloco + 0.01);
|
|
207
|
+
|
|
208
|
+
// -------------------------------------------------------------- pilares
|
|
209
|
+
const pilares: Array<[number, number]> = [[11, 11], [-11, 11], [11, -11], [-11, -11]];
|
|
210
|
+
for (const [px, pz] of pilares) {
|
|
211
|
+
solido(matPilar, px - 0.7, 0, pz - 0.7, px + 0.7, H, pz + 0.7);
|
|
212
|
+
faixa(matNeon, px - 0.73, 2.4, pz - 0.73, px + 0.73, 2.5, pz + 0.73);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// ------------------------------------------------------- muros baixos
|
|
216
|
+
// 1,1 m: protege agachado, expõe em pé — o jogador decide o risco.
|
|
217
|
+
const muros: Array<[number, number, boolean]> = [[0, 13, true], [0, -13, true], [13, 0, false], [-13, 0, false]];
|
|
218
|
+
for (const [mx, mz, deitado] of muros) {
|
|
219
|
+
if (deitado) solido(matParede, mx - 2.5, 0, mz - 0.25, mx + 2.5, 1.1, mz + 0.25);
|
|
220
|
+
else solido(matParede, mx - 0.25, 0, mz - 2.5, mx + 0.25, 1.1, mz + 2.5);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// ------------------------------------------------------------- spawns
|
|
224
|
+
// O jogador nasce no meio do lado sul, longe do muro baixo (colado nele, o
|
|
225
|
+
// muro tapava metade da tela no primeiro segundo de jogo). Nenhum spawn de
|
|
226
|
+
// inimigo fica do lado dele.
|
|
227
|
+
const spawnJogador = new THREE.Vector3(0, 0, L * 0.84);
|
|
228
|
+
const spawns: THREE.Vector3[] = [];
|
|
229
|
+
for (const [sx, sz] of [[1, 1], [-1, 1], [1, -1], [-1, -1], [0, -1], [1, 0], [-1, 0]] as const) {
|
|
230
|
+
const k = sx !== 0 && sz !== 0 ? 0.82 : 0.86;
|
|
231
|
+
spawns.push(new THREE.Vector3(sx * L * k, 2.2, sz * L * k));
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// -------------------------------------------------------------- caixas
|
|
235
|
+
// Grupos sorteados num anel, longe do bloco, dos pilares, dos muros e dos
|
|
236
|
+
// pontos de nascimento — caixa em cima do spawn prende quem nasce.
|
|
237
|
+
const ocupados: Array<{ x: number; z: number; r: number }> = [
|
|
238
|
+
{ x: 0, z: 0, r: 7 },
|
|
239
|
+
...pilares.map(([x, z]) => ({ x, z, r: 2.4 })),
|
|
240
|
+
...muros.map(([x, z]) => ({ x, z, r: 3.2 })),
|
|
241
|
+
{ x: spawnJogador.x, z: spawnJogador.z, r: 3.5 },
|
|
242
|
+
...spawns.map((s) => ({ x: s.x, z: s.z, r: 2.8 }))
|
|
243
|
+
];
|
|
244
|
+
const livre = (x: number, z: number, r: number) =>
|
|
245
|
+
Math.abs(x) < L - 1.5 && Math.abs(z) < L - 1.5 &&
|
|
246
|
+
ocupados.every((o) => Math.hypot(o.x - x, o.z - z) > o.r + r);
|
|
247
|
+
|
|
248
|
+
const matrizes: THREE.Matrix4[] = [];
|
|
249
|
+
const cores: THREE.Color[] = [];
|
|
250
|
+
const corBaseCaixa = misturar(p.secundaria, p.superficie, 0.55);
|
|
251
|
+
const tmpQ = new THREE.Quaternion();
|
|
252
|
+
const tmpS = new THREE.Vector3();
|
|
253
|
+
const tmpP = new THREE.Vector3();
|
|
254
|
+
|
|
255
|
+
let tentativas = 0;
|
|
256
|
+
let grupos = 0;
|
|
257
|
+
while (grupos < tuning.gruposDeCaixas && tentativas++ < 400) {
|
|
258
|
+
const ang = rnd() * Math.PI * 2;
|
|
259
|
+
const dist = 8 + rnd() * (L - 10);
|
|
260
|
+
const gx = Math.cos(ang) * dist;
|
|
261
|
+
const gz = Math.sin(ang) * dist;
|
|
262
|
+
if (!livre(gx, gz, 2)) continue;
|
|
263
|
+
ocupados.push({ x: gx, z: gz, r: 2.2 });
|
|
264
|
+
grupos++;
|
|
265
|
+
|
|
266
|
+
const quantas = 1 + Math.floor(rnd() * 3);
|
|
267
|
+
for (let i = 0; i < quantas; i++) {
|
|
268
|
+
const lado = rnd() < 0.3 ? 1.3 : 1;
|
|
269
|
+
const cx = gx + (i === 0 ? 0 : (rnd() - 0.5) * 2.2);
|
|
270
|
+
const cz = gz + (i === 0 ? 0 : (rnd() - 0.5) * 2.2);
|
|
271
|
+
// Caixas do mesmo grupo não se atravessam: a nova encosta se colidir.
|
|
272
|
+
const conflito = caixas.some((b) =>
|
|
273
|
+
cx + lado / 2 > b.min.x && cx - lado / 2 < b.max.x && cz + lado / 2 > b.min.z && cz - lado / 2 < b.max.z && b.min.y < lado);
|
|
274
|
+
const empilhar = conflito || (i > 0 && rnd() < 0.25);
|
|
275
|
+
const base = empilhar ? caixas[caixas.length - 1]! : null;
|
|
276
|
+
const x = base ? (base.min.x + base.max.x) / 2 : cx;
|
|
277
|
+
const z = base ? (base.min.z + base.max.z) / 2 : cz;
|
|
278
|
+
const y0 = base ? base.max.y : 0;
|
|
279
|
+
if (y0 + lado > 2.8) continue; // pilha alta demais vira parede
|
|
280
|
+
caixas.push(new THREE.Box3(
|
|
281
|
+
new THREE.Vector3(x - lado / 2, y0, z - lado / 2),
|
|
282
|
+
new THREE.Vector3(x + lado / 2, y0 + lado, z + lado / 2)
|
|
283
|
+
));
|
|
284
|
+
tmpP.set(x, y0 + lado / 2, z);
|
|
285
|
+
tmpS.set(lado, lado, lado);
|
|
286
|
+
matrizes.push(new THREE.Matrix4().compose(tmpP, tmpQ, tmpS));
|
|
287
|
+
cores.push(corBaseCaixa.clone().offsetHSL((rnd() - 0.5) * 0.04, 0, (rnd() - 0.5) * 0.12));
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Todas as caixas num draw call só.
|
|
292
|
+
const geoCaixa = new THREE.BoxGeometry(1, 1, 1);
|
|
293
|
+
geos.push(geoCaixa);
|
|
294
|
+
const instancias = new THREE.InstancedMesh(geoCaixa, matCaixa, Math.max(1, matrizes.length));
|
|
295
|
+
instancias.count = matrizes.length;
|
|
296
|
+
matrizes.forEach((m, i) => {
|
|
297
|
+
instancias.setMatrixAt(i, m);
|
|
298
|
+
instancias.setColorAt(i, cores[i]!);
|
|
299
|
+
});
|
|
300
|
+
instancias.instanceMatrix.needsUpdate = true;
|
|
301
|
+
if (instancias.instanceColor) instancias.instanceColor.needsUpdate = true;
|
|
302
|
+
instancias.castShadow = true;
|
|
303
|
+
instancias.receiveShadow = true;
|
|
304
|
+
instancias.computeBoundingSphere();
|
|
305
|
+
raiz.add(instancias);
|
|
306
|
+
sombreaveis.push(instancias);
|
|
307
|
+
|
|
308
|
+
return {
|
|
309
|
+
raiz,
|
|
310
|
+
caixas,
|
|
311
|
+
spawnJogador,
|
|
312
|
+
// O rig olha para +Z com ângulo 0; π aponta para -Z, ou seja, para o centro.
|
|
313
|
+
anguloInicial: Math.PI,
|
|
314
|
+
spawns,
|
|
315
|
+
limite: L - 0.5,
|
|
316
|
+
sombreaveis,
|
|
317
|
+
dispose() {
|
|
318
|
+
instancias.dispose();
|
|
319
|
+
geos.forEach((g) => g.dispose());
|
|
320
|
+
mats.forEach((m) => m.dispose());
|
|
321
|
+
texs.forEach((t) => t.dispose());
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
}
|