I'm utilizing the Three.js Loading Manager to control the initiation and halting of my requestAnimationFrame
animation cycle. Here's the code snippet:
var loadingManager = new THREE.LoadingManager();
var isAnimationRunning = new Boolean();
loadingManager.onLoad = function () {
isAnimationRunning = true;
};
function startAnimationLoop() {
if (!isAnimating) {
isAnimating = animationDisplay.requestAnimationFrame(animate);
}
}
function stopAnimationLoop() {
if (isAnimating) {
animationDisplay.cancelAnimationFrame(isAnimating);
isAnimating = undefined;
}
}
Here's how it's incorporated into the rendering loop:
if (isAnimationRunning == true) {
startAnimationLoop(); //not working
} else if (isAnimationRunning == false) {
stopAnimationLoop();
}
It appears that isAnimationRunning
isn't being set to true in the onLoad
function since the animation loop isn't starting. Can someone point out what I might be doing wrong here? Appreciate the help.