@@ -64,8 +64,11 @@ export const Player = ({
6464 if ( playing ) {
6565 if ( selectedFrames . indices . size > 0 && selectedFrames . active ) {
6666 // Selection mode - check if we're at the last selected frame
67- const selectedFramesList = Array . from ( selectedFrames . indices ) . sort ( ( a , b ) => a - b ) ;
68- const lastSelectedFrame = selectedFramesList [ selectedFramesList . length - 1 ] ;
67+ const selectedFramesList = Array . from ( selectedFrames . indices ) . sort (
68+ ( a , b ) => a - b ,
69+ ) ;
70+ const lastSelectedFrame =
71+ selectedFramesList [ selectedFramesList . length - 1 ] ;
6972 if ( step >= lastSelectedFrame ) {
7073 setStep ( selectedFramesList [ 0 ] ) ; // Jump to first selected frame
7174 }
@@ -93,18 +96,24 @@ export const Player = ({
9396 // Check if frame selection is active
9497 if ( selectedFrames . indices . size > 0 && selectedFrames . active ) {
9598 // Playing within selected frames only
96- const selectedFramesList = Array . from ( selectedFrames . indices ) . sort ( ( a , b ) => a - b ) ;
99+ const selectedFramesList = Array . from ( selectedFrames . indices ) . sort (
100+ ( a , b ) => a - b ,
101+ ) ;
97102 const currentIndex = selectedFramesList . indexOf ( prevStep ) ;
98-
103+
99104 if ( currentIndex !== - 1 ) {
100105 // Current frame is in selection, move to next selected frame
101106 let nextIndex = currentIndex ;
102-
107+
103108 // Apply frame rate (skip selected frames)
104- for ( let i = 0 ; i < frameRate && nextIndex < selectedFramesList . length - 1 ; i ++ ) {
109+ for (
110+ let i = 0 ;
111+ i < frameRate && nextIndex < selectedFramesList . length - 1 ;
112+ i ++
113+ ) {
105114 nextIndex ++ ;
106115 }
107-
116+
108117 if ( nextIndex < selectedFramesList . length ) {
109118 nextStep = selectedFramesList [ nextIndex ] ;
110119 } else {
@@ -120,7 +129,9 @@ export const Player = ({
120129 }
121130 } else {
122131 // Current frame is not in selection, find next selected frame
123- const nextSelectedFrame = selectedFramesList . find ( frame => frame > prevStep ) ;
132+ const nextSelectedFrame = selectedFramesList . find (
133+ ( frame ) => frame > prevStep ,
134+ ) ;
124135 if ( nextSelectedFrame !== undefined ) {
125136 nextStep = nextSelectedFrame ;
126137 } else if ( loop ) {
@@ -265,7 +276,6 @@ export const ParticleInstances = ({
265276} ) => {
266277 const meshRef = useRef < THREE . InstancedMesh | null > ( null ) ;
267278
268-
269279 useEffect ( ( ) => {
270280 console . log ( "Updating frame:" , frame ) ;
271281 } , [ frame ] ) ;
@@ -313,10 +323,14 @@ export const ParticleInstances = ({
313323
314324 const visibleArray = Array . from ( actualVisibleIndices ) ;
315325 const highlightColor = highlight ? selection_color : null ;
316-
326+
317327 // Pre-calculate scale multipliers to avoid repeated conditionals
318- const scaleMultiplier = highlight === "backside" ? 1.25 :
319- highlight === "selection" ? 1.01 : 1.0 ;
328+ const scaleMultiplier =
329+ highlight === "backside"
330+ ? 1.25
331+ : highlight === "selection"
332+ ? 1.01
333+ : 1.0 ;
320334
321335 for ( let i = 0 ; i < visibleArray . length ; i ++ ) {
322336 const atomIdx = visibleArray [ i ] ;
@@ -327,12 +341,12 @@ export const ParticleInstances = ({
327341 }
328342
329343 const radius = radii [ atomIdx ] * scaleMultiplier ;
330-
344+
331345 // Optimize matrix operations by setting elements directly
332346 matrix . makeScale ( radius , radius , radius ) ;
333347 matrix . setPosition ( position ) ;
334348 meshRef . current . setMatrixAt ( i , matrix ) ;
335-
349+
336350 // Set color efficiently
337351 color . set ( highlightColor || colors [ atomIdx ] || "#ffffff" ) ;
338352 meshRef . current . setColorAt ( i , color ) ;
@@ -712,7 +726,10 @@ export const PerParticleVectors: React.FC<PerParticleVectorsProps> = ({
712726
713727 // Group vectors by type
714728 const vectorsByType = useMemo ( ( ) => {
715- const grouped : Record < string , { start : THREE . Vector3 ; end : THREE . Vector3 } [ ] > = { } ;
729+ const grouped : Record <
730+ string ,
731+ { start : THREE . Vector3 ; end : THREE . Vector3 } [ ]
732+ > = { } ;
716733 for ( const vector of vectors ) {
717734 if ( ! grouped [ vector . vectorType ] ) {
718735 grouped [ vector . vectorType ] = [ ] ;
@@ -728,54 +745,67 @@ export const PerParticleVectors: React.FC<PerParticleVectorsProps> = ({
728745 // Helper function to convert hex color to HSL colormap
729746 const hexToHSLColormap = ( hexColor : string ) : [ number , number , number ] [ ] => {
730747 // Simple hex to HSL conversion for single color
731- const hex = hexColor . replace ( '#' , '' ) ;
748+ const hex = hexColor . replace ( "#" , "" ) ;
732749 const r = parseInt ( hex . substr ( 0 , 2 ) , 16 ) / 255 ;
733750 const g = parseInt ( hex . substr ( 2 , 2 ) , 16 ) / 255 ;
734751 const b = parseInt ( hex . substr ( 4 , 2 ) , 16 ) / 255 ;
735-
752+
736753 const max = Math . max ( r , g , b ) ;
737754 const min = Math . min ( r , g , b ) ;
738755 const diff = max - min ;
739756 const l = ( max + min ) / 2 ;
740-
757+
741758 let h = 0 ;
742759 let s = 0 ;
743-
760+
744761 if ( diff !== 0 ) {
745762 s = l > 0.5 ? diff / ( 2 - max - min ) : diff / ( max + min ) ;
746-
763+
747764 switch ( max ) {
748- case r : h = ( g - b ) / diff + ( g < b ? 6 : 0 ) ; break ;
749- case g : h = ( b - r ) / diff + 2 ; break ;
750- case b : h = ( r - g ) / diff + 4 ; break ;
765+ case r :
766+ h = ( g - b ) / diff + ( g < b ? 6 : 0 ) ;
767+ break ;
768+ case g :
769+ h = ( b - r ) / diff + 2 ;
770+ break ;
771+ case b :
772+ h = ( r - g ) / diff + 4 ;
773+ break ;
751774 }
752775 h /= 6 ;
753776 }
754-
777+
755778 return [ [ h , s , l ] ] ;
756779 } ;
757780
758781 return (
759782 < >
760783 { Object . entries ( vectorsByType ) . map ( ( [ vectorType , typeVectors ] ) => {
761- const vectorColor = arrowsConfig . vector_colors ?. [ vectorType ] || "#ff0000" ;
784+ const vectorColor =
785+ arrowsConfig . vector_colors ?. [ vectorType ] || "#ff0000" ;
762786 const colormap = hexToHSLColormap ( vectorColor ) ;
763-
787+
764788 const startMap = typeVectors . map ( ( vec ) => vec . start . toArray ( ) ) ;
765789 const endMap = typeVectors . map ( ( vec ) => vec . end . toArray ( ) ) ;
766-
790+
767791 // Calculate color range for this vector type
768- const distances = typeVectors . map ( ( vector ) => vector . start . distanceTo ( vector . end ) ) ;
769- const colorRange : [ number , number ] = arrowsConfig . normalize
792+ const distances = typeVectors . map ( ( vector ) =>
793+ vector . start . distanceTo ( vector . end ) ,
794+ ) ;
795+ const colorRange : [ number , number ] = arrowsConfig . normalize
770796 ? [ 0 , Math . max ( ...distances ) ]
771- : ( Array . isArray ( arrowsConfig . colorrange ) ? arrowsConfig . colorrange : [ 0 , 1 ] ) ;
797+ : Array . isArray ( arrowsConfig . colorrange )
798+ ? arrowsConfig . colorrange
799+ : [ 0 , 1 ] ;
772800
773801 return (
774802 < Arrows
775803 key = { vectorType }
776804 start = { startMap }
777805 end = { endMap }
778- scale_vector_thickness = { arrowsConfig . scale_vector_thickness || false }
806+ scale_vector_thickness = {
807+ arrowsConfig . scale_vector_thickness || false
808+ }
779809 colormap = { colormap }
780810 colorrange = { colorRange }
781811 opacity = { arrowsConfig . opacity || 1.0 }
0 commit comments