diff --git a/src/components/DriftParticlesLeft.jsx b/src/components/DriftParticlesLeft.jsx index 56545c3..ea780dd 100644 --- a/src/components/DriftParticlesLeft.jsx +++ b/src/components/DriftParticlesLeft.jsx @@ -3,9 +3,9 @@ import { Particles3 } from "./Particles3"; export const DriftParticlesLeft = ({turboColor,scale, ...props}) => { - if(scale < 0.8) { - return null; - } + // if(scale < 0.8) { + // return null; + // } return ( diff --git a/src/components/DriftParticlesRight.jsx b/src/components/DriftParticlesRight.jsx index fd72b4e..6e08f49 100644 --- a/src/components/DriftParticlesRight.jsx +++ b/src/components/DriftParticlesRight.jsx @@ -3,9 +3,9 @@ import { Particles4 } from "./Particles4"; export const DriftParticlesRight = ({turboColor,scale, ...props}) => { - if(scale < 0.8) { - return null; - } + // if(scale < 0.8) { + // return null; + // } return ( diff --git a/src/components/Particles1.jsx b/src/components/Particles1.jsx index b28f556..ef156ad 100644 --- a/src/components/Particles1.jsx +++ b/src/components/Particles1.jsx @@ -13,6 +13,17 @@ export const Particles1 = ({ turboColor, scale, numParticles = 50, ...props }) = }, [numParticles]); useFrame((state, delta) => { + if (!instancedMeshRef.current) { + return; + } + + // Manage visibility directly in the animation loop + instancedMeshRef.current.visible = scale >= 0.8; + + if (scale < 0.8) { + return; + } + const deltaScaled = delta * 144; // Scale for 144 FPS particlesData.forEach((particle, i) => { particle.velocity.y += particle.gravity * deltaScaled; @@ -25,7 +36,6 @@ export const Particles1 = ({ turboColor, scale, numParticles = 50, ...props }) = particle.position.set(-0.6, 0.05, 0.5); particle.velocity.set(-Math.random() * 0.05, Math.random() * 0.05, Math.random() * 0.02); } - const matrix = new THREE.Matrix4(); matrix.setPosition(particle.position); instancedMeshRef.current.setMatrixAt(i, matrix); @@ -35,7 +45,7 @@ export const Particles1 = ({ turboColor, scale, numParticles = 50, ...props }) = }); return ( - + = 0.8}> { + if (!instancedMeshRef.current) { + return; + } + + // Manage visibility directly in the animation loop + instancedMeshRef.current.visible = scale >= 0.8; + + if (scale < 0.8) { + return; + } + const deltaScaled = delta * 144; // Scale for 144 FPS particlesData.forEach((particle, i) => { particle.velocity.y += particle.gravity * deltaScaled; @@ -25,7 +36,6 @@ export const Particles2 = ({ turboColor, scale, numParticles = 50, ...props }) = particle.position.set(0.6, 0.05, 0.5); particle.velocity.set(Math.random() * 0.05, Math.random() * 0.05, Math.random() * 0.02); } - const matrix = new THREE.Matrix4(); matrix.setPosition(particle.position); instancedMeshRef.current.setMatrixAt(i, matrix); @@ -35,7 +45,7 @@ export const Particles2 = ({ turboColor, scale, numParticles = 50, ...props }) = }); return ( - + = 0.8}>