doctype html html head meta charset utf 8 title star concrete block fence archviz title style body margin 0 overflow hidden font family sans serif background 000 info position fixed bottom 10px left 12px color fff opacity 6 font size 12px style head body div id info module 245 245 80 mm 4 rows 10 cols drag to orbit scroll to zoom div script type importmap imports three https unpkg com three 0 160 0 build three module js orbitcontrols https unpkg com three 0 160 0 examples jsm controls orbitcontrols js script script type module import as three from three import orbitcontrols from orbitcontrols parameters mm scaled to m const m 0 245 module width height 245 mm const d 0 080 module depth 80 mm const joint 0 006 6 mm joint between modules const pitch m joint const cols 10 rows 4 const base h 0 35 low base wall height const post w 0 30 post width renderer scene const renderer new three webglrenderer antialias true renderer setsize innerwidth innerheight renderer shadowmap enabled true renderer shadowmap type three pcfsoftshadowmap renderer tonemapping three acesfilmictonemapping renderer tonemappingexposure 1 15 document body appendchild renderer domelement const scene new three scene scene background new three color 0xcfd8e0 scene fog new three fog 0xcfd8e0 30 90 const camera new three perspectivecamera 38 innerwidth innerheight 0 1 200 35mm equivalent feel via narrower fov eye level camera position set 4 5 1 65 5 2 camera lookat 0 1 0 0 const controls new orbitcontrols camera renderer domelement controls target set 0 1 0 0 controls update lighting golden hour const sun new three directionallight 0xffd9a0 3 2 sun position set 9 3 2 4 low from the side sun castshadow true sun shadow mapsize set 4096 4096 sun shadow camera left 12 sun shadow camera right 12 sun shadow camera top 8 sun shadow camera bottom 4 sun shadow camera far 40 sun shadow bias 0 0004 scene add sun scene add new three hemispherelight 0xbfd0e0 0x8a7a60 0 55 concrete material procedural fine texture function concretetexture const c document createelement canvas c width c height 512 const ctx c getcontext 2d ctx fillstyle c9c2b4 ctx fillrect 0 0 512 512 for let i 0 i 26000 i const v math random ctx fillstyle v 0 5 rgba 255 255 255 0 045 rgba 60 55 45 0 05 ctx fillrect math random 512 math random 512 1 4 1 4 for let i 0 i 300 i pores ctx fillstyle rgba 80 75 65 0 12 ctx beginpath ctx arc math random 512 math random 512 math random 1 6 0 7 ctx fill const t new three canvastexture c t wraps t wrapt three repeatwrapping t repeat set 4 4 return t const concrete new three meshstandardmaterial map concretetexture color 0xd8d1c2 roughness 0 92 metalness 0 0 const darkconcrete concrete clone darkconcrete color set 0x9a948a the module extruded plate with star shaped through opening identical for every copy geometry built once instanced below function starshape const s new three shape s moveto m 2 m 2 s lineto m 2 m 2 s lineto m 2 m 2 s lineto m 2 m 2 s closepath const hole new three path const spikes 4 r1 0 082 r2 0 034 for let i 0 i spikes 2 i const a i spikes 2 math pi 2 math pi 2 const r i 2 0 r1 r2 const x math cos a r y math sin a r i 0 hole moveto x y hole lineto x y hole closepath s holes push hole return s const modulegeo new three extrudegeometry starshape depth d bevelenabled true bevelthickness 0 0025 bevelsize 0 0025 bevelsegments 2 modulegeo center const fencegroup new three group fence line along x at z 0 for let col 0 col cols col for let row 0 row rows row const m new three mesh modulegeo concrete m castshadow m receiveshadow true m position set col cols 1 2 pitch base h m 2 row pitch 0 fencegroup add m scene add fencegroup base wall posts const basegeo new three boxgeometry cols pitch joint post w 2 base h d 0 04 const base new three mesh basegeo darkconcrete base position set 0 base h 2 0 base castshadow base receiveshadow true scene add base const capgeo new three boxgeometry cols pitch joint post w 2 0 02 0 04 d 0 08 const cap new three mesh capgeo darkconcrete cap position set 0 base h 0 02 0 cap castshadow cap receiveshadow true scene add cap for const side of 1 1 const h base h rows pitch 0 12 const post new three mesh new three boxgeometry post w h d 0 04 darkconcrete post position set side cols pitch 2 post w 2 0 01 h 2 0 post castshadow post receiveshadow true scene add post ground const groundtex concretetexture groundtex repeat set 30 30 const ground new three mesh new three planegeometry 120 120 new three meshstandardmaterial map groundtex color 0xbdb6a8 roughness 1 ground rotation x math pi 2 ground position y 0 001 ground receiveshadow true scene add ground house behind fence minimalist const house new three group const glassmat new three meshphysicalmaterial color 0x223344 roughness 0 05 metalness 0 transparent true opacity 0 55 const stonemat new three meshstandardmaterial color 0x7a7568 roughness 0 9 const metalmat new three meshstandardmaterial color 0x2a2a2a roughness 0 4 metalness 0 7 const volume1 new three mesh new three boxgeometry 9 3 4 5 concrete volume1 position set 2 1 7 9 const volume2 new three mesh new three boxgeometry 5 4 2 5 stonemat volume2 position set 4 2 2 1 10 5 const glasswall new three mesh new three boxgeometry 6 5 2 6 0 08 glassmat glasswall position set 2 1 5 6 45 const frame new three mesh new three boxgeometry 6 7 0 08 0 12 metalmat frame position set 2 2 85 6 44 volume1 volume2 glasswall frame foreach o o castshadow o receiveshadow true house add o scene add house vegetation olive trees grasses stylized function tree x z s 1 const g new three group const trunk new three mesh new three cylindergeometry 0 06 s 0 1 s 1 4 s 7 new three meshstandardmaterial color 0x5a4a38 roughness 1 trunk position y 0 7 s trunk castshadow true const foliagemat new three meshstandardmaterial color 0x6b7a52 roughness 1 flatshading true for let i 0 i 4 i const f new three mesh new three icosahedrongeometry 0 55 math random 0 4 s 0 foliagemat f position set math random 0 5 0 9 s 1 5 math random 0 8 s math random 0 5 0 9 s f castshadow true g add f g add trunk g position set x 0 z scene add g tree 6 5 4 1 3 tree 6 5 5 1 1 tree 9 7 1 5 tree 9 3 5 0 9 tree 3 7 1 2 tree 3 8 1 0 const grassmat new three meshstandardmaterial color 0x9a9a6a roughness 1 for let i 0 i 90 i const blade new three mesh new three conegeometry 0 03 0 4 math random 0 5 4 grassmat blade position set math random 0 5 22 0 2 1 5 math random 6 blade castshadow true scene add blade animate addeventlistener resize camera aspect innerwidth innerheight camera updateprojectionmatrix renderer setsize innerwidth innerheight function loop requestanimationframe loop controls update renderer render scene camera script body html