JavaScript (ES6), 176 bytes
Builds the output character by character.
n=>(y=h=n*6-2,n+=n-1,g=x=>y?`| /\\
`[X=w-x-n,s=y>h/2,c=x-n>4&X>4,~x?x--<n|X<0|y>4&y<h-3&c||`03123${y/h|y==4*c}210101`[y%3*4|X-y%3*s*2&3]:(n+=y--%3&&-s|1,x=w,4)]+g(x):"")(w=n*4)
Try it online!
Variables
Below are the most important variables used in the code:
- \$x\$ : current column, initialized to the width \$w=8n-4\$
- \$y\$ : current row, initialized to the height \$h=6n-2\$
- \$y \bmod 3\$ : cube row (1 = top, 0 = middle, 2 = bottom)
- \$s\$ : side (1 = top half / 0 = bottom half)
- \$p\$ : left/right padding, initialized to \$2n-1\$ (the name \$p\$ is used here for clarity; in the code, we actually re-use the input variable \$n\$)
- \$c\$ : a flag set when we are located in the center part
For \$n=3\$, this leads to the following diagram:
x=20 x=-1
| | | y | y%3 | s | p
-v--------------------v--+----+-----+---+---
...../.\./.\./.\.....\n | 16 | 1 | 1 | 5
....|\./|\./|\./|....\n | 15 | 0 | 1 | 4
....|.|.|.|.|.|.|....\n | 14 | 2 | 1 | 4
.../.\|/.\|/.\|/.\...\n | 13 | 1 | 1 | 3
..|\./|ccccccc|\./|..\n | 12 | 0 | 1 | 2
..|.|.|ccccccc|.|.|..\n | 11 | 2 | 1 | 2
./.\|/ccccccccc\|/.\.\n | 10 | 1 | 1 | 1
|\./|ccccccccccc|\./|\n | 9 | 0 | 1 | 0
|.|.|ccccccccccc|.|.|\n | 8 | 2 | 0 | 0
.\|/.\ccccccccc/.\|/.\n | 7 | 1 | 0 | 1
..|\./|ccccccc|\./|..\n | 6 | 0 | 0 | 2
..|.|.|ccccccc|.|.|..\n | 5 | 2 | 0 | 2
...\|/.\./.\./.\|/...\n | 4 | 1 | 0 | 3
....|\./|\./|\./|....\n | 3 | 0 | 0 | 4
....|.|.|.|.|.|.|....\n | 2 | 2 | 0 | 4
.....\|/.\|/.\|/.....\n | 1 | 1 | 0 | 5
Commented
n => ( // n = input
y = h = n * 6 - 2, // initialize y and h to 6n - 2
n += n - 1, // turn n into the padding, initialized to 2n - 1
g = x => // g = recursive function taking x
y ? // if y is not 0:
`| /\\\n`[ // lookup string of possible characters
X = w - x - n, // set X = w - x - n
s = y > h / 2, // set s = 1 for top half / 0 for bottom half
c = x - n > 4 & // set c if we're in the center of the row,
X > 4, // i.e. x - n > 4 and X > 4
~x ? // if x is not equal to -1:
x-- < n | X < 0 | // append a space if we're too far to the left,
y > 4 & // too far to the right, or in the center of
y < h - 3 & c // the pattern
|| ( // otherwise, use a cube pattern:
`0312` + // "|\ /" for the middle row
`3${y / h | // either "\|/ " or "\ / " for the top row
y == 4 * c // (depending on y and c)
}21` + //
`0101` // or "| | " for the bottom row
)[ y % 3 * 4 | // get the position of the pattern
X - // get the position of the character in the
y % 3 * s * 2 // pattern
& 3 ] //
: // else (end of row):
( n += y-- % 3 // add -1, 0 or 1 to the padding
&& -s | 1, //
x = w, // reset x to w
4 ) // append a line-feed
] + g(x) // append the result of a recursive call
: // else (end of recursion):
"" // stop
)(w = n * 4) // initial call to g with x = w = 4n