Huge amount of code for proper corner calculation and applying texture? Also, external wall and internal wall must have different material applied to it. Check screenshots above.
Your PG:
PG from babylon doc: