Created
March 6, 2020 02:23
-
-
Save charlieroberts/5518b0f99af48c27bdc015502a89137c to your computer and use it in GitHub Desktop.
folding "lifeform" using marching.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copy and paste into https://charlieroberts.github.io/marching/playground/ | |
// select all and hit ctrl+enter | |
quality = 'med' // try 'high' if you have a nice gfx card | |
size = .025/8 | |
box = Box(size).material('white glow') | |
count = 25 | |
mrrr = Mirror( box ).translate(size,size,size) | |
mirrors = [ mrrr ] | |
for( let i = 0; i < count; i++ ) { | |
const s = size + size*i | |
mrrr = Mirror( mrrr ).translate(s,s/2,s/3) | |
mirrors.push( mrrr ) | |
} | |
march( mrrr ) | |
.fog( .85, Vec3(0) ) | |
.vignette( .05 ) | |
.render( 'fractal.' + quality ) | |
.camera( 0,0,1.9,.25 ) | |
t = 92.5 | |
onframe = () => { | |
t += .0125/12 | |
mirrors.forEach( (v,i) => { | |
if( i !== 0 ) | |
v.rotate(t*2, cos(i*t),i/2,sin(i/3*t)) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment