I am working on enhancing the variability of camera positions in order to make the 3D scene more captivating. However, I am facing an issue where the camera gets stuck at -12, causing it to oscillate between 12.00 and 12.05 before finally moving beyond that point. To avoid this, I need to increment the camera.position.z back to 30 once it reaches -12. How can I achieve this without encountering the trap at -12?
camera.position.set(0, -8, 30);
function render() {
time += 0.1;
requestAnimationFrame(render);
if (camera.position.z > 20) {
camera.position.z -= 0.1;
camera.position.y += 0.1;
}
else if (camera.position.z <= 20 && camera.position.z >= -12){
camera.position.z -= 0.1;
}
else {camera.position.z = 30}
}