@@ -111,7 +111,7 @@ function Connection({
111111}
112112
113113// Layer visualization
114- function LayerVisualization ( {
114+ function LayerVisualization ( {
115115 layerIndex,
116116 neurons,
117117 type,
@@ -131,59 +131,59 @@ function LayerVisualization({
131131 const displayNeurons = Math . min ( neurons , 8 ) ;
132132 const spacing = 0.7 ;
133133 const startY = ( ( displayNeurons - 1 ) * spacing ) / 2 ;
134-
134+
135135 const positions : [ number , number , number ] [ ] = useMemo ( ( ) => {
136136 return Array . from ( { length : displayNeurons } , ( _ , i ) => [
137137 xPosition ,
138138 startY - i * spacing ,
139139 0
140140 ] as [ number , number , number ] ) ;
141141 } , [ displayNeurons , xPosition , startY , spacing ] ) ;
142-
142+
143143 return (
144144 < group >
145145 { positions . map ( ( pos , i ) => (
146- < Neuron
147- key = { i }
148- position = { pos }
146+ < Neuron
147+ key = { i }
148+ position = { pos }
149149 color = { color }
150150 size = { 0.25 }
151151 pulseSpeed = { 2 + layerIndex * 0.5 }
152152 />
153153 ) ) }
154-
154+
155155 { /* Layer label using Html */ }
156156 < Html
157157 position = { [ xPosition , startY + 1 , 0 ] }
158158 center
159- style = { {
159+ style = { {
160160 pointerEvents : 'none' ,
161161 userSelect : 'none'
162162 } }
163163 >
164164 < div className = "text-center whitespace-nowrap" >
165- < div className = { `text-sm font-bold ${ isSelected ? 'text-cyan-400' : 'text-white ' } ` } >
165+ < div className = { `text-sm font-bold ${ isSelected ? 'text-cyan-400' : 'text-[var(--text-primary)] ' } ` } >
166166 { name }
167167 </ div >
168- < div className = "text-xs text-gray-400 " >
169- { type === 'dense' ? `${ neurons } units` :
168+ < div className = "text-xs text-[var(--text-muted)] " >
169+ { type === 'dense' ? `${ neurons } units` :
170170 type === 'conv2d' ? `${ neurons } filters` :
171171 type === 'input' ? 'Input' : '' }
172172 </ div >
173173 </ div >
174174 </ Html >
175-
175+
176176 { /* Ellipsis for more neurons */ }
177177 { neurons > 8 && (
178178 < Html
179179 position = { [ xPosition , - startY - 0.8 , 0 ] }
180180 center
181181 style = { { pointerEvents : 'none' } }
182182 >
183- < div className = "text-gray-400 text-lg" > ⋮</ div >
183+ < div className = "text-[var(--text-muted)] text-lg" > ⋮</ div >
184184 </ Html >
185185 ) }
186-
186+
187187 { /* Selection ring */ }
188188 { isSelected && (
189189 < mesh rotation = { [ Math . PI / 2 , 0 , 0 ] } position = { [ xPosition , 0 , 0 ] } >
@@ -299,64 +299,89 @@ function NetworkScene() {
299299 ) ;
300300}
301301
302- // Grid floor
302+ // Grid floor - adapts to theme
303303function GridFloor ( ) {
304+ const theme = useNetworkStore ( state => state . ui . theme ) ;
305+ const gridColor = theme === 'dark' ? '#0a0a0f' : '#e2e8f0' ;
306+ const opacity = theme === 'dark' ? 0.3 : 0.5 ;
307+
304308 return (
305309 < mesh rotation = { [ - Math . PI / 2 , 0 , 0 ] } position = { [ 0 , - 3 , 0 ] } receiveShadow >
306310 < planeGeometry args = { [ 50 , 50 , 50 , 50 ] } />
307- < meshStandardMaterial
308- color = "#0a0a0f"
311+ < meshStandardMaterial
312+ color = { gridColor }
309313 wireframe
310314 transparent
311- opacity = { 0.3 }
315+ opacity = { opacity }
312316 />
313317 </ mesh >
314318 ) ;
315319}
316320
321+ // Background stars - only shown in dark mode
322+ function BackgroundStars ( ) {
323+ const theme = useNetworkStore ( state => state . ui . theme ) ;
324+
325+ if ( theme !== 'dark' ) return null ;
326+
327+ // Use useMemo to generate consistent star positions
328+ const stars = useMemo ( ( ) => {
329+ return Array . from ( { length : 100 } ) . map ( ( _ , i ) => ( {
330+ position : [
331+ ( Math . sin ( i * 1.234 ) * 0.5 ) * 40 ,
332+ ( Math . cos ( i * 2.345 ) * 0.5 ) * 40 ,
333+ - 20 - ( Math . sin ( i * 3.456 ) * 0.5 + 0.5 ) * 20
334+ ] as [ number , number , number ] ,
335+ size : 0.02 + ( Math . sin ( i * 4.567 ) * 0.5 + 0.5 ) * 0.03 ,
336+ opacity : 0.5 + ( Math . cos ( i * 5.678 ) * 0.5 + 0.5 ) * 0.5
337+ } ) ) ;
338+ } , [ ] ) ;
339+
340+ return (
341+ < >
342+ { stars . map ( ( star , i ) => (
343+ < mesh key = { i } position = { star . position } >
344+ < sphereGeometry args = { [ star . size , 8 , 8 ] } />
345+ < meshBasicMaterial color = "#ffffff" transparent opacity = { star . opacity } />
346+ </ mesh >
347+ ) ) }
348+ </ >
349+ ) ;
350+ }
351+
317352// Main component
318353export default function NetworkVisualization ( ) {
354+ const theme = useNetworkStore ( state => state . ui . theme ) ;
355+
319356 return (
320357 < div className = "w-full h-full" >
321358 < Canvas
322359 camera = { { position : [ 0 , 3 , 12 ] , fov : 50 } }
323360 gl = { { antialias : true , alpha : true } }
324361 style = { { background : 'transparent' } }
325362 >
326- { /* Lighting */ }
327- < ambientLight intensity = { 0.5 } />
328- < pointLight position = { [ 10 , 10 , 10 ] } intensity = { 1 } color = "#ffffff" />
363+ { /* Lighting - adjusted for theme */ }
364+ < ambientLight intensity = { theme === 'dark' ? 0.5 : 0.8 } />
365+ < pointLight position = { [ 10 , 10 , 10 ] } intensity = { theme === 'dark' ? 1 : 0.8 } color = "#ffffff" />
329366 < pointLight position = { [ - 10 , 5 , - 10 ] } intensity = { 0.5 } color = "#a855f7" />
330367 < pointLight position = { [ 0 , - 5 , 5 ] } intensity = { 0.3 } color = "#00d4ff" />
331-
368+
332369 { /* Controls */ }
333- < OrbitControls
370+ < OrbitControls
334371 enablePan = { true }
335372 enableZoom = { true }
336373 enableRotate = { true }
337374 minDistance = { 5 }
338375 maxDistance = { 30 }
339376 target = { [ 0 , 0 , 0 ] }
340377 />
341-
378+
342379 { /* Scene */ }
343380 < NetworkScene />
344381 < GridFloor />
345-
346- { /* Background stars effect */ }
347- { Array . from ( { length : 100 } ) . map ( ( _ , i ) => (
348- < mesh
349- key = { i }
350- position = { [
351- ( Math . random ( ) - 0.5 ) * 40 ,
352- ( Math . random ( ) - 0.5 ) * 40 ,
353- - 20 - Math . random ( ) * 20
354- ] }
355- >
356- < sphereGeometry args = { [ 0.02 + Math . random ( ) * 0.03 , 8 , 8 ] } />
357- < meshBasicMaterial color = "#ffffff" transparent opacity = { 0.5 + Math . random ( ) * 0.5 } />
358- </ mesh >
359- ) ) }
382+
383+ { /* Background stars effect - dark mode only */ }
384+ < BackgroundStars />
360385 </ Canvas >
361386 </ div >
362387 ) ;
0 commit comments