Skip to content

Instantly share code, notes, and snippets.

@mcallegari10
Created October 26, 2020 21:24
Show Gist options
  • Save mcallegari10/4725617474afa5057f54e26c0a49f120 to your computer and use it in GitHub Desktop.
Save mcallegari10/4725617474afa5057f54e26c0a49f120 to your computer and use it in GitHub Desktop.
Old particle Generator for the Wolox landing page
function* generateNewParticles() {
let randoms = [],
particles = []
while (true) {
randoms = [random(), random(), random()]
particles = [0, 0, getRandomFloat(-500, -200)]
yield { randoms, particles }
}
}
const particlesGenerator = generateNewParticles()
function renderFlyingParticles() {
const positionArray = particlesGeometry.attributes.position.array
moveParticles()
const { randoms, particles } = particlesGenerator.next().value
positionArray.set(particles, flyingParticles + 1)
particlesRandoms.push(...randoms)
flyingParticles++
particlesGeometry.attributes.position.needsUpdate = true
requestAnimationFrame(renderFlyingParticles)
renderer.render(scene, camera)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment