In this enhanced version of the Subjunctive Fractal Visualizer, the scroll-to-zoom functionality has been added to provide an intuitive way to explore the Apollonian Net fractals and the latent space they fill.
Key updates and additions:
1. Scroll to Zoom:
- Users can now zoom in and out of the fractal latent space using the mouse scroll wheel.
- Scrolling up zooms in, bringing the viewer closer to the fractals, while scrolling down zooms out, providing a broader view of the composition.
- The `zoomFactor` variable keeps track of the current zoom level, which is used to adjust the camera's position along the z-axis.
- The `scrollSensitivity` constant determines the sensitivity of the zooming behavior, controlling how much the zoom level changes with each scroll event.
2. Zoom Indicator:
- A zoom indicator has been added to display the current zoom level to the user.
- The zoom indicator is positioned at the top center of the screen and shows the current zoom factor in the format "Zoom: Nx", where N is the zoom multiplier.
- When the user scrolls to zoom, the zoom indicator fades in, displaying the updated zoom level. After a short delay, the indicator fades out to avoid visual clutter.
- The opacity transition of the zoom indicator is controlled using CSS transitions for a smooth visual effect.
3. Camera Position Adjustment:
- The camera's position along the z-axis is dynamically adjusted based on the current zoom factor.
- As the user zooms in, the camera moves closer to the fractals, and as they zoom out, the camera moves further away.
- The camera position is calculated by