Structural regulation and optical behavior of three-dimensional metal halide perovskites under pressure