-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhud.js
More file actions
119 lines (101 loc) · 4.46 KB
/
Copy pathhud.js
File metadata and controls
119 lines (101 loc) · 4.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// ========================================
// HUD Updates
// ========================================
function updateHUD() {
// Calculate actual speed from movement
const moveSpeed = speedBoost ? baseSpeed * 2 : baseSpeed;
let actualSpeed = 0;
// Count how many directions we're moving
if (moveForward || moveBackward) actualSpeed += moveSpeed;
if (moveLeft || moveRight) actualSpeed += moveSpeed;
if (moveUp || moveDown) actualSpeed += moveSpeed;
// Convert to cosmic units (fraction of light speed)
const speedC = actualSpeed * 0.01;
document.getElementById('hud-speed').textContent = speedC.toFixed(3) + 'c';
// Coordinates in light years (scaled down for readability)
// 1 unit = 0.001 light years
const lyScale = 0.001;
document.getElementById('hud-x').textContent = (camera.position.x * lyScale).toFixed(4);
document.getElementById('hud-y').textContent = (camera.position.y * lyScale).toFixed(4);
document.getElementById('hud-z').textContent = (camera.position.z * lyScale).toFixed(4);
// Target (nearest wormhole) in light years
if (wormholes.length > 0) {
let nearest = null;
let minDist = Infinity;
wormholes.forEach(w => {
const dist = camera.position.distanceTo(w.group.position);
if (dist < minDist) {
minDist = dist;
nearest = w;
}
});
if (nearest) {
const distLY = (minDist * lyScale).toFixed(3);
document.getElementById('hud-target').textContent = nearest.type.toUpperCase();
document.getElementById('hud-distance').textContent = `${distLY} LY`;
// Add target lock effect when close
const hudDistance = document.getElementById('hud-distance');
if (minDist < 30) {
hudDistance.classList.add('hud-target-lock');
} else {
hudDistance.classList.remove('hud-target-lock');
}
// Warning for My World View
const hudTarget = document.getElementById('hud-target');
if (nearest.id === 'my_world_view') {
hudTarget.textContent += ' [⚠️ CONSTRUCTION ZONE]';
hudTarget.style.color = '#ff9e3d';
hudTarget.classList.add('warning-pulse');
} else {
hudTarget.style.color = ''; // Reset color
hudTarget.classList.remove('warning-pulse');
}
}
// Check if in deep space - only sides, up/down, or way behind wormholes
const deepSpaceWarning = document.getElementById('deep-space-warning');
const hud = document.getElementById('hud');
// Trigger warning if:
// - Too far left/right (|x| > 150)
// - Too far up/down (|y| > 120)
// - Way past wormholes into deep space behind (z < -300)
const tooFarSides = Math.abs(camera.position.x) > 150;
const tooFarVertical = Math.abs(camera.position.y) > 120;
const tooFarBehind = camera.position.z < -300;
if (tooFarSides || tooFarVertical || tooFarBehind) {
deepSpaceWarning.classList.remove('hidden');
hud.classList.add('deep-space-mode');
} else {
deepSpaceWarning.classList.add('hidden');
hud.classList.remove('deep-space-mode');
}
} else {
document.getElementById('hud-target').textContent = '---';
document.getElementById('hud-distance').textContent = '---';
}
}
// ========================================
// 3D Enhancements - Nebula Clouds
// ========================================
function createNebula() {
const nebulaGroup = new THREE.Group();
// Create 3 colored fog clouds (subtle background elements)
const colors = [0x00ff88, 0x06ffa5, 0xff6b35];
colors.forEach((color, i) => {
const geometry = new THREE.SphereGeometry(15, 16, 16); // Smaller - was 30
const material = new THREE.MeshBasicMaterial({
color: color,
transparent: true,
opacity: 0.03, // Much more transparent - was 0.1
blending: THREE.AdditiveBlending
});
const nebula = new THREE.Mesh(geometry, material);
nebula.position.set(
(Math.random() - 0.5) * 300,
(Math.random() - 0.5) * 150,
-250 + Math.random() * -100 // Much farther away - was -150
);
nebulaGroup.add(nebula);
});
nebulaGroup.name = 'nebula';
scene.add(nebulaGroup);
}