Refactor the Three.js camera into a factory function and handle Vite HMR cleanup with dispose methods to prevent WebGL leaks.