| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>GHOST HUNTER · DATA SET GYM</title> |
| |
| <link href="https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap" rel="stylesheet"> |
| <style> |
| body { |
| margin: 0; |
| overflow: hidden; |
| font-family: 'Press Start 2P', 'Courier New', monospace; |
| background-color: black; |
| image-rendering: pixelated; |
| image-rendering: crisp-edges; |
| } |
| #info { |
| position: absolute; |
| top: 10px; |
| left: 10px; |
| color: #8af0ff; |
| text-shadow: 2px 2px 0 #004466; |
| font-size: 0.7rem; |
| z-index: 100; |
| background: #001c28; |
| padding: 6px 10px; |
| border: 2px solid #3ecfcf; |
| outline: 2px solid #005f7a; |
| letter-spacing: 0.5px; |
| pointer-events: none; |
| box-shadow: 4px 4px 0 #001018; |
| } |
| #timer-round { |
| position: absolute; |
| top: 10px; |
| left: 50%; |
| transform: translateX(-50%); |
| color: #ffffaa; |
| font-size: 0.9rem; |
| text-shadow: 2px 2px 0 #886600; |
| background: #1a2a1a; |
| padding: 6px 12px; |
| border: 2px solid #aaff55; |
| outline: 2px solid #3f9f3f; |
| z-index: 100; |
| letter-spacing: 0.5px; |
| white-space: nowrap; |
| box-shadow: 4px 4px 0 #0a1f0a; |
| } |
| #ghost-count { |
| position: absolute; |
| top: 10px; |
| right: 10px; |
| color: #ffaa88; |
| font-size: 0.9rem; |
| text-shadow: 2px 2px 0 #882200; |
| background: #2a1010; |
| padding: 6px 12px; |
| border: 2px solid #ff8866; |
| outline: 2px solid #aa4444; |
| z-index: 100; |
| letter-spacing: 0.5px; |
| box-shadow: 4px 4px 0 #200808; |
| } |
| #crosshair { |
| position: absolute; |
| top: 50%; |
| left: 50%; |
| transform: translate(-50%, -50%); |
| width: 18px; |
| height: 18px; |
| border: 3px solid #aaf0ff; |
| box-shadow: 0 0 0 2px #004466, 2px 2px 0 #003344; |
| pointer-events: none; |
| z-index: 200; |
| opacity: 0.9; |
| } |
| #crosshair::after { |
| content: ''; |
| position: absolute; |
| top: 50%; |
| left: 50%; |
| width: 5px; |
| height: 5px; |
| background: #aaf0ff; |
| transform: translate(-50%, -50%); |
| box-shadow: 1px 1px 0 #004466; |
| } |
| #instructions { |
| position: absolute; |
| bottom: 15px; |
| left: 50%; |
| transform: translateX(-50%); |
| color: #b5ffff; |
| font-size: 0.55rem; |
| text-shadow: 2px 2px 0 #006688; |
| background: #0a1c28; |
| padding: 8px 14px; |
| border: 2px solid #3ecfcf; |
| outline: 2px solid #006688; |
| z-index: 100; |
| letter-spacing: 0.5px; |
| white-space: nowrap; |
| box-shadow: 4px 4px 0 #021018; |
| animation: pulse 2s step-end infinite; |
| } |
| @keyframes pulse { |
| 0% { opacity: 1; background: #0a1c28; } |
| 50% { opacity: 0.9; background: #0e2430; border-color: #5fe0e0; } |
| 100% { opacity: 1; background: #0a1c28; } |
| } |
| #victory { |
| position: absolute; |
| top: 50%; |
| left: 50%; |
| transform: translate(-50%, -50%); |
| color: #ffffaa; |
| font-size: 1.8rem; |
| text-shadow: 3px 3px 0 #448800; |
| background: #1a3f1a; |
| padding: 20px 30px; |
| border: 4px solid #aaff55; |
| outline: 3px solid #2f9f2f; |
| z-index: 300; |
| letter-spacing: 2px; |
| display: none; |
| text-align: center; |
| line-height: 1.5; |
| box-shadow: 10px 10px 0 #0a2a0a; |
| } |
| #victory span { |
| font-size: 1.0rem; |
| display: block; |
| margin-top: 15px; |
| color: #aaf0ff; |
| text-shadow: 2px 2px 0 #004466; |
| } |
| .scanline { |
| position: absolute; |
| top: 0; |
| left: 0; |
| width: 100%; |
| height: 100%; |
| background: repeating-linear-gradient(0deg, rgba(0,255,255,0.03) 0px, rgba(0,0,0,0.2) 2px, transparent 3px); |
| pointer-events: none; |
| z-index: 300; |
| opacity: 0.3; |
| } |
| .hit-effect { |
| position: absolute; |
| width: 20px; |
| height: 20px; |
| background: radial-gradient(circle, #ffffaa, #ff8800); |
| border-radius: 50%; |
| pointer-events: none; |
| z-index: 400; |
| transform: translate(-50%, -50%); |
| animation: hitPing 0.2s ease-out forwards; |
| } |
| @keyframes hitPing { |
| 0% { opacity: 1; transform: translate(-50%, -50%) scale(0.5); } |
| 100% { opacity: 0; transform: translate(-50%, -50%) scale(2); } |
| } |
| |
| .kill-flash { |
| position: absolute; |
| top: 0; |
| left: 0; |
| width: 100%; |
| height: 100%; |
| background: rgba(255,220,150,0.1); |
| pointer-events: none; |
| z-index: 500; |
| animation: flashFade 0.1s ease-out; |
| } |
| @keyframes flashFade { |
| 0% { opacity: 0.4; } |
| 100% { opacity: 0; } |
| } |
| #lock-hint { |
| position: absolute; |
| bottom: 70px; |
| left: 50%; |
| transform: translateX(-50%); |
| color: #b0b0ff; |
| font-size: 0.45rem; |
| background: #000c1a; |
| padding: 4px 8px; |
| border: 1px solid #3399ff; |
| z-index: 150; |
| white-space: nowrap; |
| } |
| |
| #dataset-panel { |
| position: absolute; |
| bottom: 120px; |
| right: 10px; |
| background: #0a1a2a; |
| border: 2px solid #ffaa55; |
| outline: 2px solid #aa5500; |
| padding: 8px 12px; |
| color: #ffdd99; |
| font-size: 0.6rem; |
| z-index: 250; |
| box-shadow: 4px 4px 0 #031010; |
| display: flex; |
| flex-direction: column; |
| gap: 6px; |
| min-width: 160px; |
| } |
| #dataset-panel button { |
| font-family: 'Press Start 2P', monospace; |
| background: #2a3f3f; |
| border: 2px solid #88aaff; |
| color: #ddeeff; |
| padding: 6px 8px; |
| font-size: 0.55rem; |
| cursor: pointer; |
| box-shadow: 2px 2px 0 #001122; |
| } |
| #dataset-panel button:hover { |
| background: #3f5f5f; |
| } |
| #capture-count { |
| color: #aaffaa; |
| text-align: right; |
| } |
| #export-status { |
| font-size: 0.45rem; |
| color: #99ccff; |
| word-break: break-all; |
| max-width: 180px; |
| } |
| </style> |
| <script type="importmap"> |
| { |
| "imports": { |
| "three": "https://unpkg.com/three@0.128.0/build/three.module.js", |
| "three/addons/": "https://unpkg.com/three@0.128.0/examples/jsm/", |
| "jszip": "https://cdn.skypack.dev/jszip@3.10.1" |
| } |
| } |
| </script> |
| </head> |
| <body> |
| <div id="info">>> GHOST HUNTER // DATASET GYM // by webXOS </div> |
| <div id="timer-round">TIME 00:00 ROUND 1/10</div> |
| <div id="ghost-count">GHOSTS 0</div> |
| <div id="crosshair"></div> |
| <div id="instructions">[CLICK TO LOCK] W/A/S/D MOVE | HOLD LMB AUTO (tight spread) | KILL = SCREENSHOT</div> |
| <div id="lock-hint">↖ CLICK GAME AREA TO LOCK / ESC TO UNLOCK</div> |
| <div id="victory">VICTORY<span id="final-time"></span></div> |
| <div class="scanline"></div> |
|
|
| |
| <div id="dataset-panel"> |
| <div style="display: flex; justify-content: space-between;"> |
| <span>📸 CAPTURES</span> |
| <span id="capture-count">0</span> |
| </div> |
| <button id="export-dataset">💾 EXPORT DATASET (ZIP)</button> |
| <div id="export-status"></div> |
| </div> |
|
|
| <script type="module"> |
| import * as THREE from 'three'; |
| import { PointerLockControls } from 'three/addons/controls/PointerLockControls.js'; |
| import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js'; |
| import { RenderPass } from 'three/addons/postprocessing/RenderPass.js'; |
| import { UnrealBloomPass } from 'three/addons/postprocessing/UnrealBloomPass.js'; |
| import JSZip from 'jszip'; |
| |
| |
| const scene = new THREE.Scene(); |
| scene.background = new THREE.Color(0x050510); |
| const camera = new THREE.PerspectiveCamera(70, window.innerWidth / window.innerHeight, 0.1, 1000); |
| camera.position.set(0, 1.8, 0); |
| const renderer = new THREE.WebGLRenderer({ antialias: false, powerPreference: "high-performance", preserveDrawingBuffer: true }); |
| renderer.setSize(window.innerWidth, window.innerHeight); |
| renderer.setPixelRatio(Math.min(window.devicePixelRatio, 1.0)); |
| renderer.toneMapping = THREE.ReinhardToneMapping; |
| document.body.appendChild(renderer.domElement); |
| |
| |
| const renderScene = new RenderPass(scene, camera); |
| const bloomPass = new UnrealBloomPass(new THREE.Vector2(window.innerWidth, window.innerHeight), 1.0, 0.3, 0.6); |
| bloomPass.threshold = 0.1; |
| bloomPass.strength = 1.3; |
| bloomPass.radius = 0.7; |
| const composer = new EffectComposer(renderer); |
| composer.addPass(renderScene); |
| composer.addPass(bloomPass); |
| |
| |
| const controls = new PointerLockControls(camera, document.body); |
| scene.add(controls.getObject()); |
| |
| renderer.domElement.addEventListener('click', () => { |
| if (gameActive) controls.lock(); |
| }); |
| |
| |
| const keyState = { w: false, a: false, s: false, d: false }; |
| document.addEventListener('keydown', (e) => { |
| if (!gameActive) return; |
| switch(e.code) { |
| case 'KeyW': keyState.w = true; e.preventDefault(); break; |
| case 'KeyA': keyState.a = true; e.preventDefault(); break; |
| case 'KeyS': keyState.s = true; e.preventDefault(); break; |
| case 'KeyD': keyState.d = true; e.preventDefault(); break; |
| default: break; |
| } |
| }); |
| document.addEventListener('keyup', (e) => { |
| switch(e.code) { |
| case 'KeyW': keyState.w = false; e.preventDefault(); break; |
| case 'KeyA': keyState.a = false; e.preventDefault(); break; |
| case 'KeyS': keyState.s = false; e.preventDefault(); break; |
| case 'KeyD': keyState.d = false; e.preventDefault(); break; |
| default: break; |
| } |
| }); |
| |
| const velocity = new THREE.Vector3(); |
| const moveSpeed = 0.06; |
| const damping = 0.92; |
| const boundary = 20; |
| |
| |
| const patterns = [ |
| [[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1],[1,1,1,1,1]], |
| [[0,0,0,0,0],[0,0,0,0,0],[0,0,1,0,0],[0,0,0,0,0],[0,0,0,0,0]], |
| [[0,0,1,0,0],[0,0,1,0,0],[0,0,1,0,0],[0,0,1,0,0],[0,0,1,0,0]] |
| ]; |
| const cellSize = 1.8; |
| const jitter = 0.2; |
| const positions = []; |
| const colors = []; |
| function addPoint(px, py, pz) { |
| positions.push(px, py, pz); |
| colors.push(0.5+0.3*Math.random(), 0.7+0.3*Math.random(), 1.0); |
| } |
| const floorMin = -boundary, floorMax = boundary; |
| const cellsX = Math.floor((floorMax - floorMin) / cellSize); |
| const cellsZ = cellsX; |
| for (let i = 0; i < cellsX; i++) { |
| for (let j = 0; j < cellsZ; j++) { |
| const wx = floorMin + i * cellSize + cellSize/2; |
| const wz = floorMin + j * cellSize + cellSize/2; |
| const patIdx = (i + j) % patterns.length; |
| const pattern = patterns[patIdx]; |
| for (let r = 0; r < 5; r++) { |
| for (let c = 0; c < 5; c++) { |
| if (pattern[r][c] === 1) { |
| const offsetX = (c/4-0.5)*cellSize*0.8 + (Math.random()-0.5)*jitter; |
| const offsetZ = (r/4-0.5)*cellSize*0.8 + (Math.random()-0.5)*jitter; |
| const offsetY = (Math.random()-0.5)*0.15; |
| addPoint(wx+offsetX, 0+offsetY, wz+offsetZ); |
| } |
| } |
| } |
| } |
| } |
| for (let s = -1; s <= 1; s+=2) { |
| for (let z = -boundary; z <= boundary; z+= cellSize*1.5) { |
| for (let y = 1; y < 10; y+= cellSize*0.9) { |
| addPoint(s*boundary, y, z); |
| } |
| } |
| for (let x = -boundary; x <= boundary; x+= cellSize*1.5) { |
| for (let y = 1; y < 10; y+= cellSize*0.9) { |
| addPoint(x, y, s*boundary); |
| } |
| } |
| } |
| const worldGeometry = new THREE.BufferGeometry(); |
| worldGeometry.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3)); |
| worldGeometry.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3)); |
| const worldMaterial = new THREE.PointsMaterial({ |
| size: 0.18, |
| vertexColors: true, |
| blending: THREE.AdditiveBlending, |
| depthWrite: false, |
| transparent: true, |
| opacity: 0.8, |
| sizeAttenuation: true |
| }); |
| const worldPoints = new THREE.Points(worldGeometry, worldMaterial); |
| scene.add(worldPoints); |
| |
| |
| let gameActive = true; |
| let round = 1; |
| const maxRounds = 10; |
| let ghosts = []; |
| let enemyProjectiles = []; |
| let explosions = []; |
| let elapsedSeconds = 0; |
| |
| const timerRoundDiv = document.getElementById('timer-round'); |
| const ghostCountDiv = document.getElementById('ghost-count'); |
| const victoryDiv = document.getElementById('victory'); |
| const finalTimeSpan = document.getElementById('final-time'); |
| |
| |
| let lmbPressed = false; |
| let lastLMBShot = 0; |
| const LMB_COOLDOWN = 0.12; |
| const SHOTGUN_PELLETS = 3; |
| const SPREAD_ANGLE = 0.03; |
| |
| |
| let captures = []; |
| let captureIndex = 0; |
| const captureCountSpan = document.getElementById('capture-count'); |
| const exportBtn = document.getElementById('export-dataset'); |
| const exportStatus = document.getElementById('export-status'); |
| |
| function updateCaptureUI() { |
| captureCountSpan.innerText = captures.length; |
| } |
| |
| |
| function captureCurrentFrame(killCount) { |
| |
| renderer.render(scene, camera); |
| |
| renderer.domElement.toBlob((blob) => { |
| if (!blob) return; |
| const metadata = { |
| index: captureIndex++, |
| timestamp: performance.now(), |
| round: round, |
| ghostsRemaining: ghosts.length, |
| killsThisShot: killCount || 0, |
| playerPos: { |
| x: controls.getObject().position.x, |
| z: controls.getObject().position.z |
| }, |
| description: `Kill shot at round ${round}, ${ghosts.length} ghosts remain` |
| }; |
| captures.push({ blob, metadata }); |
| updateCaptureUI(); |
| }, 'image/png'); |
| } |
| |
| |
| function createGhostExplosion(position) { |
| const count = 20 + Math.floor(Math.random() * 20); |
| const positions = []; |
| const colors = []; |
| const velocities = []; |
| for (let i = 0; i < count; i++) { |
| |
| const vel = new THREE.Vector3( |
| (Math.random() - 0.5) * 0.5, |
| (Math.random() - 0.5) * 0.5, |
| (Math.random() - 0.5) * 0.5 |
| ).normalize().multiplyScalar(0.08 + Math.random() * 0.1); |
| velocities.push(vel); |
| positions.push(0, 0, 0); |
| colors.push(1.0, 0.8 + Math.random()*0.2, 0.3 + Math.random()*0.3); |
| } |
| const geom = new THREE.BufferGeometry(); |
| geom.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3)); |
| geom.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3)); |
| const mat = new THREE.PointsMaterial({ |
| size: 0.25, |
| vertexColors: true, |
| blending: THREE.AdditiveBlending, |
| depthWrite: false, |
| transparent: true, |
| opacity: 1.0, |
| sizeAttenuation: true |
| }); |
| const points = new THREE.Points(geom, mat); |
| points.position.copy(position); |
| scene.add(points); |
| explosions.push({ |
| mesh: points, |
| velocities: velocities, |
| life: 1.0, |
| age: 0 |
| }); |
| } |
| |
| |
| function firePrecisionShot() { |
| const origin = camera.position.clone(); |
| const baseDir = new THREE.Vector3(); |
| camera.getWorldDirection(baseDir); |
| |
| |
| const right = new THREE.Vector3().crossVectors(baseDir, camera.up).normalize(); |
| const up = new THREE.Vector3().crossVectors(right, baseDir).normalize(); |
| |
| let killedAny = false; |
| let killCount = 0; |
| |
| for (let i = 0; i < SHOTGUN_PELLETS; i++) { |
| |
| const spreadX = (Math.random() - 0.5) * SPREAD_ANGLE * 2; |
| const spreadY = (Math.random() - 0.5) * SPREAD_ANGLE * 2; |
| |
| const dir = baseDir.clone() |
| .addScaledVector(right, spreadX) |
| .addScaledVector(up, spreadY) |
| .normalize(); |
| |
| let bestHit = null; |
| let bestT = Infinity; |
| |
| for (let j = 0; j < ghosts.length; j++) { |
| const ghost = ghosts[j]; |
| const toGhost = new THREE.Vector3().subVectors(ghost.position, origin); |
| |
| const t = toGhost.dot(dir); |
| if (t < 0) continue; |
| if (t > 45) continue; |
| |
| const toGhostLenSq = toGhost.lengthSq(); |
| const perpDistSq = Math.max(0, toGhostLenSq - t * t); |
| const ghostRadius = ghost.userData.hitRadius || 2.5; |
| |
| if (perpDistSq < ghostRadius * ghostRadius) { |
| if (t < bestT) { |
| bestT = t; |
| bestHit = ghost; |
| } |
| } |
| } |
| |
| if (bestHit) { |
| |
| scene.remove(bestHit); |
| const idx = ghosts.indexOf(bestHit); |
| if (idx !== -1) ghosts.splice(idx, 1); |
| |
| |
| createGhostExplosion(bestHit.position.clone()); |
| |
| |
| showHitEffect(bestHit.position.clone()); |
| |
| killedAny = true; |
| killCount++; |
| } |
| } |
| |
| |
| if (killedAny) { |
| const flash = document.createElement('div'); |
| flash.className = 'kill-flash'; |
| document.body.appendChild(flash); |
| setTimeout(() => flash.remove(), 100); |
| |
| |
| captureCurrentFrame(killCount); |
| } |
| } |
| |
| |
| function showHitEffect(worldPos) { |
| const ndc = worldPos.clone().project(camera); |
| if (Math.abs(ndc.x) <= 1 && Math.abs(ndc.y) <= 1 && ndc.z <= 1) { |
| const screenX = (ndc.x * 0.5 + 0.5) * window.innerWidth; |
| const screenY = (-ndc.y * 0.5 + 0.5) * window.innerHeight; |
| |
| const div = document.createElement('div'); |
| div.className = 'hit-effect'; |
| div.style.left = screenX + 'px'; |
| div.style.top = screenY + 'px'; |
| document.body.appendChild(div); |
| setTimeout(() => div.remove(), 200); |
| } |
| } |
| |
| |
| document.addEventListener('mousedown', (e) => { |
| if (!controls.isLocked || !gameActive) return; |
| e.preventDefault(); |
| if (e.button === 0) { |
| lmbPressed = true; |
| } |
| |
| }); |
| |
| document.addEventListener('mouseup', (e) => { |
| if (e.button === 0) { |
| lmbPressed = false; |
| } |
| }); |
| |
| document.addEventListener('contextmenu', (e) => e.preventDefault()); |
| |
| |
| function createGhost(pos, roundNum) { |
| const pointCount = 60 + Math.floor(Math.random() * 30); |
| const positions = []; |
| const colors = []; |
| const visualRadius = 1.2 + roundNum * 0.2; |
| const hitRadius = visualRadius * 2.0; |
| for (let i = 0; i < pointCount; i++) { |
| const r = visualRadius * Math.pow(Math.random(), 0.7); |
| const theta = Math.random() * Math.PI * 2; |
| const phi = Math.acos(2 * Math.random() - 1); |
| positions.push( |
| r * Math.sin(phi) * Math.cos(theta), |
| r * Math.sin(phi) * Math.sin(theta), |
| r * Math.cos(phi) |
| ); |
| colors.push(0.7+0.3*Math.random(), 0.8+0.2*Math.random(), 1.0); |
| } |
| const geom = new THREE.BufferGeometry(); |
| geom.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3)); |
| geom.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3)); |
| const mat = new THREE.PointsMaterial({ |
| size: 0.2, |
| vertexColors: true, |
| blending: THREE.AdditiveBlending, |
| depthWrite: false, |
| sizeAttenuation: true, |
| transparent: true, |
| opacity: 0.95 |
| }); |
| const points = new THREE.Points(geom, mat); |
| points.position.copy(pos); |
| points.userData = { |
| visualRadius: visualRadius, |
| hitRadius: hitRadius, |
| shootInterval: 1.0 + Math.random() * 1.2, |
| lastShot: performance.now() / 1000, |
| baseY: pos.y, |
| timeOffset: Math.random() * 100, |
| rotSpeed: 0.002 + Math.random() * 0.004 |
| }; |
| scene.add(points); |
| return points; |
| } |
| |
| function spawnRound(roundNum) { |
| const count = roundNum * 2; |
| for (let i = 0; i < count; i++) { |
| let x, z; |
| do { |
| x = (Math.random() - 0.5) * 30; |
| z = (Math.random() - 0.5) * 30; |
| } while (Math.sqrt(x*x + z*z) < 5); |
| const y = 2.0 + Math.random() * 6; |
| ghosts.push(createGhost(new THREE.Vector3(x, y, z), roundNum)); |
| } |
| updateUI(); |
| } |
| |
| function updateUI() { |
| const mins = Math.floor(elapsedSeconds / 60); |
| const secs = Math.floor(elapsedSeconds % 60); |
| timerRoundDiv.innerText = `TIME ${mins.toString().padStart(2,'0')}:${secs.toString().padStart(2,'0')} ROUND ${round}/${maxRounds}`; |
| ghostCountDiv.innerText = `GHOSTS ${ghosts.length}`; |
| } |
| |
| function nextRound() { |
| if (round < maxRounds) { |
| round++; |
| spawnRound(round); |
| } else { |
| gameActive = false; |
| controls.unlock(); |
| victoryDiv.style.display = 'block'; |
| const mins = Math.floor(elapsedSeconds / 60); |
| const secs = Math.floor(elapsedSeconds % 60); |
| finalTimeSpan.innerText = `TIME: ${mins.toString().padStart(2,'0')}:${secs.toString().padStart(2,'0')}`; |
| } |
| } |
| |
| |
| function createEnemyProjectile(position, direction) { |
| const count = 12; |
| const positions = []; |
| const colors = []; |
| const radius = 0.6; |
| for (let i = 0; i < count; i++) { |
| const r = radius * (0.7 + 0.3 * Math.random()); |
| const theta = Math.random() * Math.PI * 2; |
| const phi = Math.acos(2 * Math.random() - 1); |
| positions.push( |
| r * Math.sin(phi) * Math.cos(theta), |
| r * Math.sin(phi) * Math.sin(theta), |
| r * Math.cos(phi) |
| ); |
| colors.push(1.0, 0.3 + 0.7*Math.random(), 0.0); |
| } |
| const geom = new THREE.BufferGeometry(); |
| geom.setAttribute('position', new THREE.Float32BufferAttribute(positions, 3)); |
| geom.setAttribute('color', new THREE.Float32BufferAttribute(colors, 3)); |
| const mat = new THREE.PointsMaterial({ |
| size: 0.3, |
| vertexColors: true, |
| blending: THREE.AdditiveBlending, |
| depthWrite: false, |
| sizeAttenuation: true |
| }); |
| const points = new THREE.Points(geom, mat); |
| points.position.copy(position); |
| points.userData = { |
| velocity: direction.clone().multiplyScalar(1.5), |
| life: 2.5 |
| }; |
| scene.add(points); |
| return points; |
| } |
| |
| |
| async function exportDataset() { |
| if (captures.length === 0) { |
| exportStatus.innerText = 'No captures yet!'; |
| setTimeout(() => { exportStatus.innerText = ''; }, 2000); |
| return; |
| } |
| |
| exportStatus.innerText = 'Building ZIP...'; |
| const zip = new JSZip(); |
| |
| |
| const imgFolder = zip.folder('images'); |
| const metadataList = []; |
| |
| for (let i = 0; i < captures.length; i++) { |
| const cap = captures[i]; |
| const filename = `frame_${String(i).padStart(4, '0')}.png`; |
| imgFolder.file(filename, cap.blob); |
| metadataList.push({ |
| ...cap.metadata, |
| filename: filename |
| }); |
| } |
| |
| |
| zip.file('metadata.json', JSON.stringify(metadataList, null, 2)); |
| |
| |
| const readme = `# Ghost Hunter RLHF Dataset (Precision Auto) |
| |
| This dataset contains screenshots captured during gameplay of "Ghost Hunter" (8-bit FPS). Each image corresponds to a moment when the player successfully destroyed a ghost with the precision auto-fire. The dataset is intended for reinforcement learning from human feedback (RLHF) tasks, such as training a preference model to distinguish between "good" and "bad" shots. |
| |
| ## Dataset Structure |
| |
| - \`images/\`: PNG frames captured at the moment of a kill. |
| - \`metadata.json\`: JSON array with per-frame metadata including round number, ghosts remaining, player position, kills in that shot, and timestamp. |
| |
| ## Stats |
| |
| - Total captures: ${captures.length} |
| - Rounds covered: ${new Set(metadataList.map(m => m.round)).size} |
| - Time span: ${elapsedSeconds.toFixed(1)} seconds |
| |
| ## Usage |
| |
| Use this dataset to fine-tune vision-language models or as a reward model input for RLHF. Each image can be paired with the question: "Is this a good aim?" or similar. |
| |
| ## License |
| |
| CC0 (public domain) - feel free to use for any purpose. |
| `; |
| zip.file('README.md', readme); |
| |
| |
| const content = await zip.generateAsync({ type: 'blob' }); |
| const url = URL.createObjectURL(content); |
| const a = document.createElement('a'); |
| a.href = url; |
| a.download = `ghost_hunter_dataset_${new Date().toISOString().slice(0,10)}.zip`; |
| a.click(); |
| URL.revokeObjectURL(url); |
| |
| exportStatus.innerText = `Exported ${captures.length} captures.`; |
| setTimeout(() => { exportStatus.innerText = ''; }, 3000); |
| } |
| |
| exportBtn.addEventListener('click', exportDataset); |
| |
| |
| spawnRound(1); |
| |
| |
| const clock = new THREE.Clock(); |
| function animate() { |
| const delta = Math.min(clock.getDelta(), 0.1); |
| const now = performance.now() / 1000; |
| |
| if (gameActive) { |
| elapsedSeconds += delta; |
| updateUI(); |
| |
| |
| if (controls.isLocked) { |
| const moveDir = new THREE.Vector3(); |
| if (keyState.w) moveDir.z = 1; |
| if (keyState.s) moveDir.z = -1; |
| if (keyState.a) moveDir.x = -1; |
| if (keyState.d) moveDir.x = 1; |
| if (moveDir.length() > 0) moveDir.normalize(); |
| |
| const cameraDir = new THREE.Vector3(); |
| camera.getWorldDirection(cameraDir); |
| cameraDir.y = 0; |
| cameraDir.normalize(); |
| const right = new THREE.Vector3().crossVectors(cameraDir, new THREE.Vector3(0,1,0)).normalize(); |
| |
| const moveWorld = new THREE.Vector3(); |
| if (keyState.w || keyState.s) moveWorld.addScaledVector(cameraDir, moveDir.z); |
| if (keyState.a || keyState.d) moveWorld.addScaledVector(right, moveDir.x); |
| |
| velocity.lerp(moveWorld.multiplyScalar(moveSpeed), 0.2); |
| const pos = controls.getObject().position; |
| pos.x += velocity.x; |
| pos.z += velocity.z; |
| if (Math.abs(pos.x) > boundary) pos.x = boundary * Math.sign(pos.x); |
| if (Math.abs(pos.z) > boundary) pos.z = boundary * Math.sign(pos.z); |
| velocity.multiplyScalar(damping); |
| } |
| |
| |
| if (lmbPressed && (now - lastLMBShot) > LMB_COOLDOWN) { |
| firePrecisionShot(); |
| lastLMBShot = now; |
| } |
| |
| |
| ghosts.forEach(ghost => { |
| if (now - ghost.userData.lastShot > ghost.userData.shootInterval) { |
| ghost.userData.lastShot = now; |
| const dir = new THREE.Vector3().subVectors(camera.position, ghost.position).normalize(); |
| enemyProjectiles.push(createEnemyProjectile(ghost.position.clone(), dir)); |
| } |
| ghost.position.y = ghost.userData.baseY + Math.sin(now * 2 + ghost.userData.timeOffset) * 0.3; |
| ghost.rotation.y += ghost.userData.rotSpeed; |
| }); |
| |
| |
| for (let i = enemyProjectiles.length - 1; i >= 0; i--) { |
| const proj = enemyProjectiles[i]; |
| proj.position.addScaledVector(proj.userData.velocity, delta * 20); |
| proj.userData.life -= delta; |
| if (proj.userData.life <= 0) { |
| scene.remove(proj); |
| enemyProjectiles.splice(i, 1); |
| proj.geometry.dispose(); |
| proj.material.dispose(); |
| } |
| } |
| |
| |
| for (let i = explosions.length - 1; i >= 0; i--) { |
| const exp = explosions[i]; |
| exp.age += delta; |
| if (exp.age >= exp.life) { |
| scene.remove(exp.mesh); |
| exp.mesh.geometry.dispose(); |
| exp.mesh.material.dispose(); |
| explosions.splice(i, 1); |
| continue; |
| } |
| |
| const positions = exp.mesh.geometry.attributes.position.array; |
| const vel = exp.velocities; |
| for (let j = 0; j < positions.length / 3; j++) { |
| positions[j*3] += vel[j].x * delta * 15; |
| positions[j*3+1] += vel[j].y * delta * 15; |
| positions[j*3+2] += vel[j].z * delta * 15; |
| } |
| exp.mesh.geometry.attributes.position.needsUpdate = true; |
| exp.mesh.material.opacity = 1.0 - exp.age / exp.life; |
| } |
| |
| |
| if (ghosts.length === 0 && gameActive) { |
| nextRound(); |
| } |
| } else { |
| ghosts.forEach(g => g.rotation.y += 0.002); |
| } |
| |
| worldMaterial.size = 0.16 + 0.02 * Math.sin(now * 6); |
| |
| composer.render(); |
| requestAnimationFrame(animate); |
| } |
| animate(); |
| |
| window.addEventListener('resize', () => { |
| camera.aspect = window.innerWidth / window.innerHeight; |
| camera.updateProjectionMatrix(); |
| renderer.setSize(window.innerWidth, window.innerHeight); |
| composer.setSize(window.innerWidth, window.innerHeight); |
| }); |
| </script> |
| </body> |
| </html> |
|
|