@@ -7,6 +7,37 @@ import { DroneManager } from './drones.js';
77import { EffectsManager } from './effects.js' ;
88import { ControlPanel } from './controls.js' ;
99
10+ function drawWindArrow ( degrees ) {
11+ const canvas = document . getElementById ( 'wind-canvas' ) ;
12+ if ( ! canvas ) return ;
13+ const ctx = canvas . getContext ( '2d' ) ;
14+ const cx = 30 , cy = 30 , r = 22 ;
15+ ctx . clearRect ( 0 , 0 , 60 , 60 ) ;
16+
17+ // Circle
18+ ctx . strokeStyle = 'rgba(139, 148, 158, 0.5)' ;
19+ ctx . lineWidth = 1 ;
20+ ctx . beginPath ( ) ;
21+ ctx . arc ( cx , cy , r , 0 , Math . PI * 2 ) ;
22+ ctx . stroke ( ) ;
23+
24+ // Arrow
25+ const rad = ( degrees - 90 ) * Math . PI / 180 ;
26+ ctx . strokeStyle = '#58a6ff' ;
27+ ctx . lineWidth = 2 ;
28+ ctx . beginPath ( ) ;
29+ ctx . moveTo ( cx , cy ) ;
30+ ctx . lineTo ( cx + Math . cos ( rad ) * r * 0.8 , cy + Math . sin ( rad ) * r * 0.8 ) ;
31+ ctx . stroke ( ) ;
32+
33+ // N marker
34+ ctx . fillStyle = '#8b949e' ;
35+ ctx . font = '8px sans-serif' ;
36+ ctx . textAlign = 'center' ;
37+ ctx . fillText ( 'N' , cx , cy - r - 4 ) ;
38+ }
39+ drawWindArrow ( 0 ) ; // Initial draw
40+
1041const container = document . getElementById ( 'scene-container' ) ;
1142const statusEl = document . getElementById ( 'connection-status' ) ;
1243const fpsEl = document . getElementById ( 'fps' ) ;
@@ -30,11 +61,18 @@ const connection = new signalR.HubConnectionBuilder()
3061 . build ( ) ;
3162
3263connection . on ( 'ReceiveFrame' , ( frame ) => {
33- droneManager . update ( frame . drones ?? [ ] ) ;
64+ const drones = frame . drones ?? [ ] ;
65+ droneManager . update ( drones ) ;
3466 effectsManager . update ( frame ) ;
35- controlPanel . updateDroneList ( frame . drones ?? [ ] ) ;
67+ controlPanel . updateDroneList ( drones ) ;
3668 droneCountEl . textContent = `Drones: ${ droneManager . count } ` ;
3769 simTimeEl . textContent = `T: ${ frame . time ?. toFixed ( 1 ) ?? '0.0' } s` ;
70+
71+ const avgBattery = drones . length > 0
72+ ? ( drones . reduce ( ( s , d ) => s + ( d . battery ?? 100 ) , 0 ) / drones . length ) . toFixed ( 0 )
73+ : '--' ;
74+ const battEl = document . getElementById ( 'avg-battery' ) ;
75+ if ( battEl ) battEl . textContent = `Bat: ${ avgBattery } %` ;
3876} ) ;
3977
4078connection . onreconnecting ( ( ) => {
0 commit comments