js/render.js
// Render a scene (many times per second)
Render a scene (many times per second)
Render a scene ( many times per second )
function render() {
  time = Date.now();
  player.animate();
  floor.mesh.rotation.z += 0.0001;
  let newEntities = [];
  for (let entity of entities) {
    entity.animate();
    if (entity.isDead())    scene.remove(entity.mesh);
    else                    newEntities.push(entity);
  }
  entities = newEntities;
  updateColors();
  var delta = clock.getDelta() * spawnerOptions.timeScale;
  tick += delta;
  if (tick < 0) tick = 0;
  if (delta > 0) {
    options.position = player.position;
    for (let x = 0; x < spawnerOptions.spawnRate * delta; x++) {
      particleSystem.spawnParticle(options);
    }
  }
  particleSystem.update(tick);
  controls.update();
  renderer.render(scene, camera);
  controls.target = player.position;
  requestAnimationFrame(render);
}
function render ( ) { time = Date . now ( ) ; player . animate ( ) ; floor . mesh . rotation . z += 0.0001 ; let newEntities = [ ] ; for ( let entity of entities ) { entity . animate ( ) ; if ( entity . isDead ( ) ) scene . remove ( entity . mesh ) ; else newEntities . push ( entity ) ; } entities = newEntities ; updateColors ( ) ; var delta = clock . getDelta ( ) * spawnerOptions . timeScale ; tick += delta ; if ( tick < 0 ) tick = 0 ; if ( delta > 0 ) { options . position = player . position ; for ( let x = 0 ; x < spawnerOptions . spawnRate * delta ; x ++ ) { particleSystem . spawnParticle ( options ) ; } } particleSystem . update ( tick ) ; controls . update ( ) ; renderer . render ( scene , camera ) ; controls . target = player . position ; requestAnimationFrame ( render ) ; }
Render a scene (many times per second)
Render a scene ( many times per second )
// Animate the player // move the floor // Loop over all entities, animating them, and culling out any that died // Remove dead entities, preserve living entities // Update all colors // Not needed as long as colors are toggled and no new objs added // particle stuff // camera stuff // Render the scene repeatedly