My game in Three.js doesn't start off with any lag, but after a few minutes, the performance begins to slow down on computers running it. I've tried reviewing my code and checking my arrays, adjusting values to troubleshoot, but so far, nothing seems to work!
// cloud and skeleton spawning
for(i = 0; i < 100; i++){
makeCloud()
}
for (i = 0; i < 30; i++){
makeSkeleton()
}
// render function
function render() {
requestAnimationFrame(render);
renderer.render(scene, camera);
// skybox position update
skybox.position.set(player.position.x + 125, player.position.y + 125, player.position.z + 125);
// camera positioning
camera.position.set(player.position.x, player.position.y - 1, player.position.z);
// other functions called...
}
render()
// various functions for distance, collision, barriers, cloud creation, etc...
// expected and actual results
<p>My expected results after changing values of arrays and making the map smaller was that the lag issue would stop.</p>
<p>My actual results was just lag.</p>