I'm currently working on a personal project using Three.js. In my code, I am utilizing the requestAnimationFrame
function and trying to figure out how to call a specific function every 2 seconds. Despite my search efforts, I have been unable to find a satisfactory solution.
Here is a snippet of my code:
function render() {
// Call the createNewObject() function every 2 seconds
if(eachTwoSecond) {
createNewObject();
}
requestAnimationFrame(render);
renderer.render(scene, camera);
}
Any suggestions or ideas would be greatly appreciated!