Skip to content

Instantly share code, notes, and snippets.

@mcallegari10
Created October 20, 2020 19:56
Show Gist options
  • Save mcallegari10/f961e83b12cf5f82bc06f6c3b060f17f to your computer and use it in GitHub Desktop.
Save mcallegari10/f961e83b12cf5f82bc06f6c3b060f17f to your computer and use it in GitHub Desktop.
Particles Geometry
const particlesGeometry = new THREE.BufferGeometry()
const particlesVertices = []
const particlesRandoms = []
const flyingParticles = 150
let isPlaying = false
let animFrame = null
const offscreenLimit = 100
const particleAcceleration = 0.002
const minParticlePosition = -100
const maxParticlePosition = 100
for (let i = 0; i < flyingParticles; i++) {
particlesVertices.push(0, 0, getRandomFloat(-20, -10))
particlesRandoms.push(
getRandomFloat(minParticlePosition, maxParticlePosition),
getRandomFloat(minParticlePosition, maxParticlePosition),
getRandomFloat(minParticlePosition, maxParticlePosition)
)
}
particlesGeometry.addAttribute('position', new THREE.Float32BufferAttribute(particlesVertices, 3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment