Three-Dimensional Numerical Modeling of the Hydrodynamic and Gravitational Instability of a Protoplanetary Disk