Example 10 Let $0 \leqslant \theta \leqslant \pi$, then the maximum value of the function $f(\theta)=\sqrt{1-\cos \theta+\sin \theta}+\sqrt{\cos \theta+2}+\sqrt{3-\sin \theta}$ is $\qquad$.
Thus, when $\theta=\frac{\pi}{2}$, $y_{\text {max }}=[f(\theta)]_{\text {max }}=3 \sqrt{2}$.