Skip to content

Commit

Permalink
Update CrystalDiffraction.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
HWJones authored Dec 12, 2024
1 parent d224f46 commit b5ddbb1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions components/CrystalDiffraction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ const CrystalDiffraction = () => {
const reciprocalScale = 2;

useEffect(() => {
let animationFrame;
if (isAnimating) {
const animate = () => {
setRotationZ(prev => (prev + 0.5) % 360);
animationFrame = requestAnimationFrame(animate);
};
let animationFrame: number | undefined;
if (isAnimating) {
const animate = () => {
setRotationZ(prev => (prev + 0.5) % 360);
animationFrame = requestAnimationFrame(animate);
};
animationFrame = requestAnimationFrame(animate);
}
return () => {
if (animationFrame) {
cancelAnimationFrame(animationFrame);
}
return () => cancelAnimationFrame(animationFrame);
}, [isAnimating]);
};
}, [isAnimating]);

// Generate 3D crystal lattice points
const generateLatticePoints = () => {
Expand Down

0 comments on commit b5ddbb1

Please sign in to comment.