Skip to content

Commit 9947e99

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 4894a62 commit 9947e99

13 files changed

Lines changed: 440 additions & 358 deletions

File tree

app/src/components/containers/VisualizationContainer.tsx

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ interface VisualizationContainerProps {
2323
onDrop: (event: React.DragEvent) => void;
2424
}
2525

26-
2726
export const VisualizationContainer: React.FC<VisualizationContainerProps> = ({
2827
onPointerMissed,
2928
onDragOver,
@@ -79,7 +78,7 @@ export const VisualizationContainer: React.FC<VisualizationContainerProps> = ({
7978
// Extract constrained atom indices from frame constraints
8079
const constrainedAtomIds = useMemo(() => {
8180
const constrainedIds = new Set<number>();
82-
81+
8382
if (currentFrame?.constraints) {
8483
for (const constraint of currentFrame.constraints) {
8584
if (constraint.type === "FixAtoms" && constraint.indices) {
@@ -89,7 +88,7 @@ export const VisualizationContainer: React.FC<VisualizationContainerProps> = ({
8988
}
9089
}
9190
}
92-
91+
9392
return constrainedIds;
9493
}, [currentFrame?.constraints]);
9594

@@ -126,14 +125,20 @@ export const VisualizationContainer: React.FC<VisualizationContainerProps> = ({
126125
position={[0, 100, 0]}
127126
intensity={1.0}
128127
castShadow
129-
shadow-mapSize-width={(roomConfig.Camera.camera_far || 300) * 10} // Adjust the width of the shadow map
130-
shadow-mapSize-height={(roomConfig.Camera.camera_far || 300) * 10} // Adjust the height of the shadow map
128+
shadow-mapSize-width={
129+
(roomConfig.Camera.camera_far || 300) * 10
130+
} // Adjust the width of the shadow map
131+
shadow-mapSize-height={
132+
(roomConfig.Camera.camera_far || 300) * 10
133+
} // Adjust the height of the shadow map
131134
shadow-camera-near={10} // Adjust the near clipping plane of the shadow camera
132135
shadow-camera-far={800} // Adjust the far clipping plane of the shadow camera
133136
shadow-camera-left={-1 * (roomConfig.Camera.camera_far || 300)} // Set the left boundary for the shadow camera frustum
134-
shadow-camera-right={(roomConfig.Camera.camera_far || 300)} // Set the right boundary for the shadow camera frustum
135-
shadow-camera-top={(roomConfig.Camera.camera_far || 300)} // Set the top boundary for the shadow camera frustum
136-
shadow-camera-bottom={-1 * (roomConfig.Camera.camera_far || 300)} // Set the bottom boundary for the shadow camera frustum
137+
shadow-camera-right={roomConfig.Camera.camera_far || 300} // Set the right boundary for the shadow camera frustum
138+
shadow-camera-top={roomConfig.Camera.camera_far || 300} // Set the top boundary for the shadow camera frustum
139+
shadow-camera-bottom={
140+
-1 * (roomConfig.Camera.camera_far || 300)
141+
} // Set the bottom boundary for the shadow camera frustum
137142
/>
138143
</>
139144
) : (
@@ -147,10 +152,23 @@ export const VisualizationContainer: React.FC<VisualizationContainerProps> = ({
147152
vectors={vectorFieldData}
148153
arrowsConfig={{
149154
normalize: roomConfig.VectorDisplay.normalize || true,
150-
colorrange: (roomConfig.VectorDisplay.colorrange || [0, 1.0]) as [number, number],
151-
scale_vector_thickness: roomConfig.VectorDisplay.scale_vector_thickness || false,
155+
colorrange: (roomConfig.VectorDisplay.colorrange || [
156+
0, 1.0,
157+
]) as [number, number],
158+
scale_vector_thickness:
159+
roomConfig.VectorDisplay.scale_vector_thickness || false,
152160
opacity: roomConfig.VectorDisplay.opacity || 1.0,
153-
colormap: vectorColormap.length > 0 ? vectorColormap : (roomConfig.VectorDisplay.default_colormap as [number, number, number][]) || [[0.66, 1.0, 0.5], [0.0, 1.0, 0.5]],
161+
colormap:
162+
vectorColormap.length > 0
163+
? vectorColormap
164+
: (roomConfig.VectorDisplay.default_colormap as [
165+
number,
166+
number,
167+
number,
168+
][]) || [
169+
[0.66, 1.0, 0.5],
170+
[0.0, 1.0, 0.5],
171+
],
154172
}}
155173
pathTracingSettings={roomConfig.PathTracer}
156174
/>

app/src/components/particles.tsx

Lines changed: 61 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -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}

app/src/components/progressbar.tsx

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -183,67 +183,67 @@ const FrameRateControl: React.FC<FrameRateControlProps> = ({
183183
className="d-flex justify-content-center align-items-center user-select-none"
184184
style={{ display: "flex", height: "100%" }}
185185
>
186-
<FormControl
187-
type="number"
188-
value={frameRate}
189-
onChange={handleChange}
190-
min={1}
191-
size="sm"
186+
<FormControl
187+
type="number"
188+
value={frameRate}
189+
onChange={handleChange}
190+
min={1}
191+
size="sm"
192+
style={{
193+
width: "40px",
194+
height: "18px",
195+
fontSize: "10px",
196+
textAlign: "center",
197+
}}
198+
title="Frame rate (1 = every frame, 2 = every 2nd frame, etc.)"
199+
/>
200+
201+
{/* Frame loading icon */}
202+
<OverlayTrigger
203+
placement="top"
204+
delay={{ show: 0, hide: 100 }}
205+
overlay={<Tooltip>Loading frame data...</Tooltip>}
206+
>
207+
<div
192208
style={{
193-
width: "40px",
194-
height: "18px",
195-
fontSize: "10px",
196-
textAlign: "center",
209+
height: "100%",
210+
animation: showLoadingIcon ? "pulse 1s infinite" : "none",
211+
visibility: showLoadingIcon ? "visible" : "hidden",
212+
alignItems: "center",
213+
justifyContent: "center",
214+
display: "flex",
197215
}}
198-
title="Frame rate (1 = every frame, 2 = every 2nd frame, etc.)"
199-
/>
216+
title="Loading frame data..."
217+
>
218+
<IoMdCodeDownload />
219+
</div>
220+
</OverlayTrigger>
200221

201-
{/* Frame loading icon */}
222+
{/* Server connection spinner */}
223+
{!connected && (
202224
<OverlayTrigger
203225
placement="top"
204226
delay={{ show: 0, hide: 100 }}
205-
overlay={<Tooltip>Loading frame data...</Tooltip>}
227+
overlay={<Tooltip>Not connected to server</Tooltip>}
206228
>
207229
<div
208230
style={{
209-
height: "100%",
210-
animation: showLoadingIcon ? "pulse 1s infinite" : "none",
211-
visibility: showLoadingIcon ? "visible" : "hidden",
212-
alignItems: "center",
213-
justifyContent: "center",
214-
display: "flex",
231+
height: "25px",
232+
width: "25px",
215233
}}
216-
title="Loading frame data..."
217-
>
218-
<IoMdCodeDownload />
219-
</div>
220-
</OverlayTrigger>
221-
222-
{/* Server connection spinner */}
223-
{!connected && (
224-
<OverlayTrigger
225-
placement="top"
226-
delay={{ show: 0, hide: 100 }}
227-
overlay={<Tooltip>Not connected to server</Tooltip>}
228234
>
229235
<div
236+
className="spinner-border spinner-border-sm text-primary"
237+
role="status"
230238
style={{
231-
height: "25px",
232-
width: "25px",
239+
width: "15px",
240+
height: "15px",
233241
}}
234-
>
235-
<div
236-
className="spinner-border spinner-border-sm text-primary"
237-
role="status"
238-
style={{
239-
width: "15px",
240-
height: "15px",
241-
}}
242-
></div>
243-
<span className="visually-hidden">Loading...</span>
244-
</div>
245-
</OverlayTrigger>
246-
)}
242+
></div>
243+
<span className="visually-hidden">Loading...</span>
244+
</div>
245+
</OverlayTrigger>
246+
)}
247247
</div>
248248
);
249249
};

app/src/contexts/AppContext.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ interface AppState {
103103
// Vector data
104104
vectorProperties: Record<string, unknown>;
105105
setVectorProperties: (properties: Record<string, unknown>) => void;
106-
perParticleVectors: { start: THREE.Vector3; end: THREE.Vector3; vectorType: string }[];
106+
perParticleVectors: {
107+
start: THREE.Vector3;
108+
end: THREE.Vector3;
109+
vectorType: string;
110+
}[];
107111
vectorFieldData: [number, number, number][][];
108112
// Computed colormap for vectors
109113
vectorColormap: HSLColor[];

0 commit comments

Comments
 (0)