Files
Robot-Clash/tools/partshot.html
Michi 7a69651b6d Online-Lobby, Arenen, Lackiererei, ComfyGen-Grafik, Verschleierung
Grosse Erweiterung ueber die erste spielbare Version hinaus:

- Online (Firebase ueber REST, kein SDK): Konto per E-Mail, globale Lobby
  mit Laender-Raeumen, Herausfordern, Live-PvP (Host rechnet, Gast
  interpoliert, KI-Uebernahme bei Lag). Gast kann anonym beitreten.
  net.js / lobby.js / netfight.js, Regeln in docs/firebase.
- 3 Arenen in verschiedenen Groessen (RC.ARENAS, half 8/12/16), Kamera +
  Licht + Boden skalieren; Liga skaliert die Arena mit, Setting + online
  aus Seed. Harte Rams/Wandtreffer schleudern Roboter auf den Rucken.
- Intro (3D-Kamerafahrt), Titel, Einstellungen (Kamera, Schwierigkeit,
  Steuerung, Grafik, Arena), Lackiererei (painter.js, selbst bemalen).
- Shop mit ComfyGen-Sprites (aus den 3D-Teilen erzeugt), Liga-Gegner sehen
  aus wie ihre Portraits (looks.js), kraeftigere Waffen-Modelle.
- Oekonomie: Startgeld 800, Schadensbonus, Schaukaempfe, Online-Preisgeld.
- Verschleierung: build.ps1 -Obfuscate (terser), tablet-taugliche Touch-UI.
- Tests: tests/sim.test.js, balance.js, online.test.js. Dev-Tools in tools/.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-11-13 15:45:35 +01:00

57 lines
3.1 KiB
HTML

<!doctype html>
<!-- Dev tool (not shipped): renders ONE robot part exactly as the game builds it in 3D, on black,
3/4 view from the front right. Used as reference for the shop images (ComfyGen generate_variants).
partshot.html?id=flipper part id from game/parts.js (chassis, armour, wheels, weapon, tower)
partshot.html?id=flipper&size=768 canvas size in px
Screenshot via Chrome headless: tools/partshots.ps1 -->
<html><head><meta charset="utf-8"><title>partshot</title>
<style>html,body{margin:0;background:#000;overflow:hidden}canvas{display:block}</style></head>
<body>
<canvas id="c"></canvas>
<script src="../game/vendor/three.min.js"></script>
<script src="../game/kit/kit-core.js"></script>
<script src="../game/parts.js"></script>
<script src="../game/robot.js"></script>
<script src="../game/combat.js"></script>
<script src="../game/looks.js"></script>
<script src="../game/render3d.js"></script>
<script>
(function () {
'use strict';
const T = THREE, q = new URLSearchParams(location.search);
const id = q.get('id') || 'flipper', size = +q.get('size') || 768, p = RC.PARTS[id];
const cv = document.getElementById('c');
const renderer = new T.WebGLRenderer({ canvas: cv, antialias: true, preserveDrawingBuffer: true });
renderer.setPixelRatio(1); renderer.setSize(size, size);
renderer.outputEncoding = T.sRGBEncoding; renderer.toneMapping = T.ACESFilmicToneMapping; renderer.toneMappingExposure = 0.85;
const scene = new T.Scene(); scene.background = new T.Color(0x000000);
scene.add(new T.HemisphereLight(0xc8d4ea, 0x2a2018, 0.9));
const key = new T.DirectionalLight(0xfff2e0, 1.9); key.position.set(3, 6, 4); scene.add(key);
const rimA = new T.DirectionalLight(0xff8a3a, 0.9); rimA.position.set(-4, 2, 3); scene.add(rimA);
const rimB = new T.DirectionalLight(0x6aa8ff, 0.8); rimB.position.set(-2, 3, -5); scene.add(rimB);
// neutral steel paint with orange accent - the player paints the body later, parts keep their own colours
const build = Object.assign({}, RC.STARTER, { [p.slot]: id });
if (p.slot === 'weapon' || p.slot === 'tower') build.armour = null;
const R = RC.buildRobotModel(build, { body: 0x8d939c, accent: 0xff7a1a });
scene.add(R.root);
R.tilt.children.forEach(o => { o.visible = o.userData.part === p.slot; });
// frame the visible pieces
// only visible, solid meshes (the hidden flame cone of the flamer would blow up the frame)
R.root.updateMatrixWorld(true);
const bb = new T.Box3();
R.tilt.children.forEach(o => { if (o.visible) o.traverse(m => {
if (m.isMesh && m.visible && !m.material.transparent) { m.geometry.computeBoundingBox(); bb.union(m.geometry.boundingBox.clone().applyMatrix4(m.matrixWorld)); }
}); });
const c = bb.getCenter(new T.Vector3()), s = bb.getSize(new T.Vector3()), r = s.length() / 2;
const cam = new T.PerspectiveCamera(28, 1, 0.05, 100);
const dir = new T.Vector3(1, 0.78, 0.95).normalize();
cam.position.copy(c).addScaledVector(dir, r / Math.sin(T.MathUtils.degToRad(14)) * 1.12);
cam.lookAt(c);
renderer.render(scene, cam);
document.title = 'done';
})();
</script>
</body></html>