@@ -16,6 +16,8 @@ import Lidar, { LIDAR_LAYER } from '../components/Lidar.jsx';
1616
1717const WS_URL = `${ config . WS_BASE_URL } /ws/self_driving_car` ;
1818
19+ const TRAINING_FRAME_RENDER_INTERVAL = 100 ;
20+
1921const Agent = ( { agent, coordinateTransformer, onCamerasCreated } ) => {
2022 const { pos, color, id, heading, pitch } = agent ;
2123 const groupRef = useRef ( ) ;
@@ -30,20 +32,22 @@ const Agent = ({ agent, coordinateTransformer, onCamerasCreated }) => {
3032 'Left' : new THREE . PerspectiveCamera ( 75 , 4 / 3 , 1 , 1000 ) ,
3133 'Right' : new THREE . PerspectiveCamera ( 75 , 4 / 3 , 1 , 1000 ) ,
3234 'Rear' : new THREE . PerspectiveCamera ( 120 , 4 / 3 , 1 , 1000 ) ,
33- 'Lidar (Top-Down) ' : new THREE . OrthographicCamera ( - 500 , 500 , 500 , - 500 , 1 , 2000 )
35+ 'Lidar' : new THREE . OrthographicCamera ( - 500 , 500 , 500 , - 500 , 1 , 2000 )
3436 } ;
3537
36- cameras [ 'Front (Wide)' ] . position . set ( 0 , 10 , 20 ) ;
37- cameras [ 'Front (Narrow)' ] . position . set ( 0 , 10 , 20 ) ;
38- cameras [ 'Left' ] . position . set ( - 10 , 10 , 0 ) ;
39- cameras [ 'Left' ] . rotateY ( THREE . MathUtils . degToRad ( - 90 ) ) ;
40- cameras [ 'Right' ] . position . set ( 10 , 10 , 0 ) ;
41- cameras [ 'Right' ] . rotateY ( THREE . MathUtils . degToRad ( 90 ) ) ;
42- cameras [ 'Rear' ] . position . set ( 0 , 10 , - 20 ) ;
43- cameras [ 'Rear' ] . rotateY ( THREE . MathUtils . degToRad ( 180 ) ) ;
44- cameras [ 'Lidar (Top-Down)' ] . position . set ( 0 , 1000 , 0 ) ;
45- cameras [ 'Lidar (Top-Down)' ] . lookAt ( 0 , 0 , 0 ) ;
46- cameras [ 'Lidar (Top-Down)' ] . layers . enable ( LIDAR_LAYER ) ;
38+ const y = 15 ;
39+ cameras [ 'Front (Wide)' ] . position . set ( 0 , y , 21 ) ;
40+ cameras [ 'Front (Wide)' ] . rotateY ( Math . PI ) ;
41+ cameras [ 'Front (Narrow)' ] . position . set ( 0 , y , 21 ) ;
42+ cameras [ 'Front (Narrow)' ] . rotateY ( Math . PI ) ;
43+ cameras [ 'Left' ] . position . set ( - 11 , y , 0 ) ;
44+ cameras [ 'Left' ] . rotateY ( Math . PI / 2 ) ;
45+ cameras [ 'Right' ] . position . set ( 11 , y , 0 ) ;
46+ cameras [ 'Right' ] . rotateY ( - Math . PI / 2 ) ;
47+ cameras [ 'Rear' ] . position . set ( 0 , y , - 21 ) ;
48+ cameras [ 'Lidar' ] . position . set ( 0 , 1000 , 0 ) ;
49+ cameras [ 'Lidar' ] . lookAt ( 0 , 0 , 0 ) ;
50+ cameras [ 'Lidar' ] . layers . enable ( LIDAR_LAYER ) ;
4751
4852 camerasRef . current = cameras ;
4953 onCamerasCreated ( id , cameras ) ;
@@ -233,11 +237,11 @@ const MessagePanel = ({ messages }) => {
233237 ref = { containerRef }
234238 style = { {
235239 position : 'absolute' , bottom : '10px' , left : '10px' , width : '450px' ,
236- maxHeight : '40vh ' , overflowY : 'auto' , background : 'rgba(0,0,0,0.6)' ,
240+ maxHeight : '30vh ' , overflowY : 'auto' , background : 'rgba(0,0,0,0.6)' ,
237241 color : '#fff' , border : '1px solid #444' ,
238242 } }
239243 >
240- { messages . length === 0 && < Text p style = { { margin : 0 , fontSize : '12px' } } > [No messages]</ Text > }
244+ { messages . length === 0 && < Text p style = { { margin : 0 , fontSize : '12px' } } > [No interpretability messages yet. ]</ Text > }
241245 { messages . map ( ( msg , i ) => (
242246 < div key = { i } style = { { marginBottom : '12px' , padding : '8px' , background : 'rgba(255,255,255,0.05)' , borderRadius : '4px' , fontSize : '12px' } } >
243247 < Text p style = { { margin : 0 , fontWeight : 'bold' } } >
@@ -394,6 +398,7 @@ export default function SelfDrivingCarExample() {
394398 agentCamerasRef = { agentCamerasRef }
395399 cameraTargetsRef = { cameraTargetsRef }
396400 setCameraFeedData = { setCameraFeedData }
401+ training = { training }
397402 />
398403 </ Canvas >
399404
@@ -434,12 +439,21 @@ const SceneContent = ({
434439 setCoordinateTransformer,
435440 agentCamerasRef,
436441 cameraTargetsRef,
437- setCameraFeedData
442+ setCameraFeedData,
443+ training,
438444} ) => {
439445 const { scene } = useThree ( ) ;
446+ const frameCountRef = useRef ( 0 ) ;
440447
441448 useFrame ( ( { gl, scene } ) => {
442449 gl . autoClear = true ;
450+
451+ frameCountRef . current ++ ;
452+ if ( training && ( frameCountRef . current % TRAINING_FRAME_RENDER_INTERVAL !== 1 ) ) {
453+ // During training, only render camera feeds intermittently to save performance
454+ return ;
455+ }
456+
443457 const newFeedData = { } ;
444458 const renderWidth = 400 ;
445459 const renderHeight = 300 ;
0 commit comments