Unmanned Aerial Vehicles (UAVs) have emerged as a critical component in next-generation wireless networks, particularly for disaster recovery scenarios, due to their flexibility, mobility, and rapid deployment capabilities. This paper focuses on optimizing UAV trajectories to ensure effective communication in disaster-stricken areas using terahertz (THz) links. We address specific challenges such as energy consumption, user priority levels, and navigating complex urban environments to maintain Line of Sight (LoS) connections amidst 3D obstacles. Our contributions include the development of a detailed modeling approach using online 3D map data, the formulation of an optimal trajectory optimization problem, and the proposal of a Genetic Algorithm (GA)-based method alongside an enhanced heuristic algorithm for faster convergence. Through 3D simulations, we demonstrate the trade-off between minimizing total service time and prioritizing higher-weight nodes, showing the impact of different priority weight factors on the trajectory time. The proposed algorithms are evaluated using real-world data from the West Bay area of Doha, Qatar, demonstrating their effectiveness in optimizing UAV trajectories for emergency response.