Neural network effect particles speed

Hi, I was trying to get this effect to work based on this Topic How to make neural network effect? I’m creating the positions this way:

for ( let i = 0; i < maxParticleCount; i ++ ) {

					const x = Math.random() * r - r / 2
					const y = Math.random() * r - r / 2
					const z = Math.random() * r - r / 2

					particlePositions[i * 3] = x
					particlePositions[i * 3 + 1] = y
					particlePositions[i * 3 + 2] = z

					const v = new THREE.Vector3()
					particlesData.push({ velocity: v.normalize().randomDirection().divideScalar(2), numConnections: 0 })

				}

and updating them like this

for ( let i = 0; i < particleCount; i ++ ) {

					// get the particle
					const particleData = particlesData[ i ];

					const newV = v.set(particlePositions[i * 3], particlePositions[i * 3 + 1], particlePositions[i * 3 + 2]).clone()
					newV.add(particleData.velocity).setLength(500)
					particlePositions[i * 3] = newV.x
					particlePositions[i * 3 + 1] = newV.y
					particlePositions[i * 3 + 2] = newV.z

I can’t figure out why the particle speeds progressively decrease! Thanks!

Without knowing what else you do in the code, my hypothesis is that the velocity is fixed, and with every step the direction of the vector to the point gets closer with the direction of the velocity of the point … and this is seen as slowing down. When the vectors are in the same direction, motion will stop.

In the image below, red arrows is constant velocity, P1, P2, P3, are a sequence of movement of one point. The more the point moves, the shorter the move it. As I said, this might be a reason for slowing, but there is no guarantee this is the reason for slowing.

1 Like