Forked from charlieroberts/marching_hydra_local.js
Created
September 19, 2019 07:21
-
-
Save brucelane/399668c5bdeb496cd01740ad5bae249b to your computer and use it in GitHub Desktop.
marching.js with hydra generated textures (local)
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
// first, download the hydra-synth repo: https://github.com/ojack/hydra-synth | |
// second, build it with browserify: browserify index.js -o hydra.js --standalone Hydra | |
// third, place the resulting hydra.js file in the smae directory as marching.js | |
script = document.createElement('script') | |
script.src = 'http://localhost:12000/hydra.js' | |
document.querySelector('head').appendChild( script ) | |
canvas = document.createElement('canvas') | |
hydra = new Hydra({ canvas }) | |
// thanks to Steven Yi: https://t.co/Ggr9acQnEv?amp=1 | |
hydra.shape(2, 0.3, 0.1) | |
.color(4,2,1) | |
.hue(() => (time / 8) % 1) | |
.repeatY(30) | |
.mult(osc(5).rotate(-Math.PI/2)) | |
.add(solid(.5)) | |
.modulate(noise()) | |
.mult(osc(10)) | |
.diff(solid(1,1,0)) | |
.invert() | |
.kaleid(16) | |
.modulate(noise(1.1)) | |
.add(src(o0).scale(1.25).rotate(Math.PI/2), 0.9) | |
.out() | |
a = Texture('canvas', { canvas }) | |
march( | |
b = Julia().texture( a ) | |
) | |
.fog( .15, Vec3(0) ) | |
.render(3, true ) | |
.camera( 0,0,3 ) | |
onframe = t => { | |
b.fold = 1.5 + sin(t) * .5 | |
a.gltexture.setPixels( canvas ) | |
b.rotate( t * 5, 0,1,1 ) | |
} | |
a.strength = .5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment