Another option is to render the building on the screen by using the code
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
and creating an alpha gradient for the building (from top to bottom).
When drawing to any output, WebGL considers the source information and the destination information (what has already been drawn to the output) and combines them according to your instructions.
The process of drawing to an output can be summarized as follows:
SOURCE_VALUE * [SOURCE_FACTOR] [BLEND EQUATION] DESTINATION_VALUE * [DESTINATION_FACTOR];
The default equation is:
SOURCE_VALUE * 1 + DESTINATION_VALUE * 0;
This equation essentially replaces all existing information in the buffer with the new information. What we aim to achieve is to retain the existing information where we are not drawing and only incorporate the new information where we are drawing. This modifies the equation to:
SOURCE_VALUE * SRC_ALPHA + DESTINATION_VALUE * ONE_MINUS_SRC_ALPHA;
If one fragment of your building is 20% transparent, it will display 20% of the building's color and 80% of the color of what lies behind the building.
This method of rendering semitransparent objects takes into account the depth buffer.