First you have to convent your 3D hyper-spectral data to 2D data after than apply PCA on 2D data and calculate score. Finally reshape your score data to form 3D score images.
Here is a very good source of PCA including presentation and source code Presentation Principal Component Analysis (PCA) : An Overview Article Principal component analysis - a tutorial Alaa