Phase 3: AR hunt /hunt + launch page /play - shared-visual ghosts, colour lure, hauntometer

This commit is contained in:
2026-06-23 11:33:00 +10:00
parent a6c45437c3
commit 6aae22b648
2 changed files with 57 additions and 2 deletions
+5 -2
View File
@@ -23,7 +23,7 @@ const COLORS = ['Red', 'Blue', 'Yellow'];
export function createHunt(THREE, scene, opts = {}) {
const roster = opts.roster || [];
const maxActive = opts.maxActive ?? 4;
let maxActive = opts.maxActive ?? 4;
const spawnArcDeg = opts.spawnArcDeg ?? 90; // ±45° — tighter so ghosts land in front
const fleeMinMs = opts.fleeMinMs ?? 12000; // longer discovery window
const fleeMaxMs = opts.fleeMaxMs ?? 18000;
@@ -82,7 +82,8 @@ export function createHunt(THREE, scene, opts = {}) {
fleeAt: performance.now() + (fleeMinMs + Math.random() * (fleeMaxMs - fleeMinMs)), // escapes if ignored
});
haunt = Math.min(100, haunt + 4); // presence raises the meter
onEvent({ type: 'spawn', id, ghost: g, haunt });
const p = visual.object3d.position;
onEvent({ type: 'spawn', id, ghost: g, haunt, pos: { x: +p.x.toFixed(2), y: +p.y.toFixed(2), z: +p.z.toFixed(2) } });
}
// --- capture attempt: called by the page with a charge level 0..1 ---
@@ -150,6 +151,8 @@ export function createHunt(THREE, scene, opts = {}) {
return {
update, spawn, fireAt, capture, flee, setLure, listActive,
setMaxActive(n) { maxActive = Math.max(1, n | 0); },
get maxActive() { return maxActive; },
get haunt() { return haunt; },
get captured() { return captured.slice(); },
get luredColor() { return luredColor; },