Zoom in and out using camera FOV

On rotation of the 3D object, need to zoom out the long sides of the rectangle and zoom in the small sides.

I have to create a building like structure with dynamic height, width, and length. I have to disable the mouse zoom in/out, which I can do, but the object should get zoom in and out when rotated. width/length wise (which will be the only rotation we will allow later in app). When the object is rotated, and if the larger side comes in front, then the object should get zoom out, when the shorter side comes in front, it should get zoom in.

I tried setting the camera FOV referring this https://stackoverflow.com/questions/14614252/how-to-fit-camera-to-object?rq=1. It works fine until the building length is 70 or so, but after that, when I rotate length to width side, the camera goes inside the wall and I can see the inside of the building.

See the fiddle here https://jsfiddle.net/5exceptions/ub1Ltydj/15/