map change

This commit is contained in:
2026-11-15 20:05:02 +01:00
parent 319436a5f9
commit 3e565cf8c7
15 changed files with 242 additions and 26 deletions

View File

@@ -661,8 +661,9 @@
out.flashLight = new T.PointLight(0xffaa55, 0, 9); scene.add(out.flashLight);
out.scene = scene; out.group = null; out.id = null;
out.rocketGeo = new T.CylinderGeometry(0.05, 0.05, 0.32, 8); out.rocketGeo.rotateZ(Math.PI / 2);
out.rocketMat = new T.MeshStandardMaterial({ color: 0xdddddd, emissive: 0x331100 });
out.rocketMat = new T.MeshStandardMaterial({ color: 0xe8e8e8, emissive: 0xff5a10, emissiveIntensity: 0.75 });
out.rocketMeshes = [];
out.mineMeshes = [];
buildArenaGeo(out, RC.ARENA);
return out;
}
@@ -758,10 +759,14 @@
}
for (const [px, pz] of [[-1, -1], [1, -1], [-1, 1]]) {
const post = box(0.22, 3.4, 0.22, wallMat); post.position.set(px * (half + 0.35), 1.7, pz * (half + 0.35)); scene.add(post);
const lamp = box(0.5, 0.3, 0.3, m.lamp); lamp.position.set(px * (half + 0.2), 3.5, pz * (half + 0.2)); scene.add(lamp);
const rig = new T.Group(); rig.position.set(px * (half + 0.2), 3.5, pz * (half + 0.2)); scene.add(rig);
const hous = box(0.46, 0.36, 0.34, new T.MeshStandardMaterial({ color: 0x23272e, metalness: 0.6, roughness: 0.5 }));
hous.castShadow = true; rig.add(hous);
const lens = box(0.3, 0.2, 0.3, m.lamp); lens.position.set(-px * 0.13, -0.12, -pz * 0.13); rig.add(lens);
const arm = cyl(0.035, 0.035, 0.36, m.dark, 6); arm.position.set(px * 0.12, 0.26, pz * 0.12); rig.add(arm);
}
// audience stands behind the back walls
const seats = new T.InstancedMesh(new T.BoxGeometry(0.32, 0.5, 0.32), new T.MeshStandardMaterial({ roughness: 0.9 }), 900);
const seats = new T.InstancedMesh(new T.BoxGeometry(0.32, 0.5, 0.32), new T.MeshStandardMaterial({ color: 0x1b1d24, roughness: 0.95 }), 900);
const col = new T.Color(); let ci = 0; let sd = 11;
const rnd = () => { sd = (sd * 16807) % 2147483647; return sd / 2147483647; };
for (const [nx, nz] of [[-1, 0], [0, -1]]) for (let row = 0; row < 5; row++) {
@@ -776,7 +781,10 @@
col.setHSL(rnd(), 0.3, 0.07 + rnd() * 0.08); seats.setColorAt(ci, col); ci++;
}
}
seats.count = ci; dm.scale.set(1, 1, 1); scene.add(seats);
seats.count = ci; dm.scale.set(1, 1, 1);
seats.instanceMatrix.needsUpdate = true;
if (seats.instanceColor) seats.instanceColor.needsUpdate = true;
scene.add(seats);
// floor saws
// --- cover and floor traps (static, built once per arena) ---
@@ -1014,6 +1022,8 @@
showIntro(builds, paints) {
api.showArena(RC.Combat.create({ robots: builds.map(b => RC.stats(b)), seed: 3, arena: 'workshop' }), builds, paints);
mode = 'intro'; introT = 0; pointMode(true);
// compile every shader up front, otherwise the first seconds stutter while they are built
try { renderer.compile(arenaScene, pcam); } catch (e) { /* older three: just carry on */ }
},
skipIntro() { if (mode === 'intro' && introT < INTRO_END) introT = INTRO_END; },
showGarage(build, paint) {
@@ -1068,6 +1078,8 @@
sparks.clear(); smoke.clear(); fire.clear(); clearDebris(); shake = 0;
for (const m of arena.rocketMeshes) arenaScene.remove(m);
arena.rocketMeshes = [];
for (const m of arena.mineMeshes) arenaScene.remove(m);
arena.mineMeshes = [];
},
events(list) {
for (const e of list) {
@@ -1088,6 +1100,7 @@
case 'press': puff(e.x, e.z, 14); burst(e.x, 0.1, e.z, 24, 5, [1, 0.8, 0.4]); shake = Math.max(shake, 0.45); break;
case 'drop': puff(e.x, e.z, 8); shake = Math.max(shake, 0.2); break;
case 'ko': explode(e.x, 0.5, e.z, 1.2); break;
case 'mine_drop': burst(e.x, 0.12, e.z, 6, 2, [1, 0.8, 0.3]); break;
case 'broke':
breakPart(robots[e.who], e.part);
burst(e.x, 0.45, e.z, 22, 5, [1, 0.8, 0.4]); puff(e.x, e.z, 6);
@@ -1165,7 +1178,7 @@
}
// ---- intro: dark arena -> floodlights flicker on -> camera sweeps up -> two robots are lowered in
const INTRO_END = RC.INTRO_END = 7.5;
const INTRO_END = RC.INTRO_END = 5.2;
const ease = u => (u < 0.5 ? 2 * u * u : 1 - Math.pow(-2 * u + 2, 2) / 2);
function lightsOn(k) {
const L = arena.lights;
@@ -1176,12 +1189,12 @@
function introScript(dt) {
const t = introT, s = state;
// floodlights: off, flicker, on
lightsOn(t < 1.2 ? 0 : t < 1.32 ? 1 : t < 1.5 ? 0.08 : t < 1.62 ? 0.8 : t < 1.85 ? 0.25 : 1);
lightsOn(t < 0.25 ? 0.12 : t < 0.4 ? 1 : t < 0.55 ? 0.15 : t < 0.7 ? 0.9 : t < 0.85 ? 0.3 : 1);
// camera path, then a slow orbit
let ang, r, h, lx, lz;
if (t < INTRO_END) {
const e = ease(Math.min(1, t / INTRO_END));
ang = lerp(-2.4, Math.PI / 4, e); r = lerp(5, 20.5, e); h = lerp(0.8, 13.5, Math.pow(e, 1.4));
ang = lerp(-2.4, Math.PI / 4, e); r = lerp(9, 20.5, e); h = lerp(2.4, 13.5, Math.pow(e, 1.4));
lx = lerp(RC.ARENA.pit.x, -0.6, e); lz = lerp(RC.ARENA.pit.z, -0.6, e);
} else {
ang = Math.PI / 4 + (t - INTRO_END) * 0.05; r = 20.5; h = 13.5; lx = lz = 0;
@@ -1191,13 +1204,13 @@
// robots lowered in from above, landing with sparks
s.t = t + 2; // trap timing: flames ignite once the lights are on
s.robots.forEach((rb, i) => {
const k = clamp((t - 2.6 - i * 0.35) / 1.6, 0, 1);
const k = clamp((t - 0.9 - i * 0.3) / 1.3, 0, 1);
const was = rb.y;
rb.y = 7 * Math.pow(1 - k, 2); rb.vx = rb.vz = 0; rb.lifted = rb.y > 0 ? 1 : 0; // lifted: no tumbling
if (was > 0 && rb.y === 0) { burst(rb.x, 0.2, rb.z, Math.round(40 * fxMul), 5, [1, 0.8, 0.4]); puff(rb.x, rb.z, 10); }
rb.spin = t > 5.4 ? Math.min(1, (t - 5.4) * 0.8) : 0; // spinners rev up
rb.sawOn = t > 5.6;
rb.flameOn = t > 5.8 && t < 6.6 || (t > INTRO_END && Math.sin(t * 0.9 + i * 2) > 0.97);
rb.spin = t > 3.1 ? Math.min(1, (t - 3.1) * 1.1) : 0; // spinners rev up
rb.sawOn = t > 3.3;
rb.flameOn = t > 3.5 && t < 4.3 || (t > INTRO_END && Math.sin(t * 0.9 + i * 2) > 0.97);
rb.turretA = rb.a + Math.sin(t * 0.7 + i) * 0.4;
});
}
@@ -1274,6 +1287,16 @@
smoke.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.3, 0.9, (Math.random() - 0.5) * 0.3, 1.6, r.dead ? 0.12 : 0.35, r.dead ? 0.12 : 0.34, r.dead ? 0.12 : 0.33);
if (r.dead || hp < 0.2) fire.spawn(r.x, y, r.z, (Math.random() - 0.5) * 0.4, 0.8, (Math.random() - 0.5) * 0.4, 0.4, 1, 0.5, 0.1);
}
// minigun: glowing tracers flying out of the barrel so you can see where it shoots
if (r.gunOn && R.st.tower && R.st.tower.type === 'minigun') {
const ca = Math.cos(r.turretA), sa = Math.sin(r.turretA), y0 = r.y + R.top + 0.2;
for (let q = 0; q < 2; q++) {
const sp = 46 + Math.random() * 14, sprd = (Math.random() - 0.5) * 0.06;
sparks.spawn(r.x + ca * 0.62, y0, r.z + sa * 0.62,
(ca - sa * sprd) * sp, (Math.random() - 0.5) * 0.6, (sa + ca * sprd) * sp, 0.2, 1, 0.92, 0.55);
}
if (Math.random() < 0.5) smoke.spawn(r.x + ca * 0.6, y0, r.z + sa * 0.6, ca * 0.6, 0.5, sa * 0.6, 0.5, 0.42, 0.42, 0.42);
}
if (r.flameOn && Math.random() < 0.7) {
const a = r.turretA + (Math.random() - 0.5) * 0.5, v = 5 + Math.random() * 2;
fire.spawn(r.x + Math.cos(r.turretA) * 0.6, r.y + R.top + 0.18, r.z + Math.sin(r.turretA) * 0.6, Math.cos(a) * v, 0.3, Math.sin(a) * v, 0.45, 1, 0.55, 0.15);
@@ -1314,6 +1337,28 @@
for (const d of arena.pitDoors) { d.position.x = A.pit.x + d.userData.sx * (A.pit.hw / 2 + o * A.pit.hw * 1.02); d.position.y = 0.025 + o * 0.01; }
for (const l of arena.pitLamps) l.material.emissiveIntensity = s.pitAlarm ? (Math.sin(now / 150) > 0 ? 2.5 : 0.4) : 0;
// rockets
// mines lying on the floor: dark puck, the lamp blinks fast once it is armed
const mines = s.mines || [];
while (arena.mineMeshes.length < mines.length) {
const g = new T.Group();
const puck = new T.Mesh(new T.CylinderGeometry(0.3, 0.34, 0.11, 14), new T.MeshStandardMaterial({ color: 0x23262c, metalness: 0.6, roughness: 0.6 }));
puck.position.y = 0.055; puck.castShadow = true; g.add(puck);
const ring = new T.Mesh(new T.TorusGeometry(0.3, 0.03, 6, 18), new T.MeshStandardMaterial({ color: 0xf2b51c, roughness: 0.6 }));
ring.rotation.x = Math.PI / 2; ring.position.y = 0.1; g.add(ring);
const lamp = new T.Mesh(new T.SphereGeometry(0.06, 8, 6), new T.MeshStandardMaterial({ color: 0x661111, emissive: 0xff2010, emissiveIntensity: 1 }));
lamp.position.y = 0.15; g.add(lamp);
g.userData.lamp = lamp;
arenaScene.add(g); arena.mineMeshes.push(g);
}
arena.mineMeshes.forEach((g, i) => {
const mn = mines[i];
g.visible = !!mn;
if (!mn) return;
g.position.set(mn.x, 0.01, mn.z);
const armed = mn.arm <= 0;
const blink = armed ? (Math.sin(now / 90) > 0 ? 2.4 : 0.15) : 0.5;
g.userData.lamp.material.emissiveIntensity = blink;
});
while (arena.rocketMeshes.length < s.rockets.length) {
const gr = new T.Group();
const body = new T.Mesh(arena.rocketGeo, arena.rocketMat); gr.add(body);