mkdir -p $HOME/src/offscreen_sample # or anywhere you'd like
cd $HOME/src/offscreen_sample
cp package.json and offscree_sample.coffee in here
$ npm install # maybe npm start will take care of it but just in case
$ npm start && open out.png
> [email protected] start /Users/bsergean/src/offscreen_sample
> coffee offscreen_sample.coffee
THREE.WebGLRenderer 71
THREE.WebGLRenderer: TypeError: Object #<Object> has no method 'addEventListener'
THREE.WebGLRenderer: OES_texture_float extension not supported.
THREE.WebGLRenderer: OES_texture_float_linear extension not supported.
THREE.WebGLRenderer: OES_texture_half_float extension not supported.
THREE.WebGLRenderer: OES_texture_half_float_linear extension not supported.
THREE.WebGLRenderer: OES_standard_derivatives extension not supported.
THREE.WebGLRenderer: OES_element_index_uint extension not supported.
THREE.WebGLRenderer: EXT_texture_filter_anisotropic extension not supported.
Image written: out.png
Those warnings are harmless for our test case, but might be problematic for some folks. Support for extension is planned and coming -> stackgl/headless-gl#5
Tada ! You just created an image thanks to OpenGL and many awesome libraries. How cool is that. Now open the output image. On a Mac you can just do that:
open out.png
I can't figure out how to add a .png to a gist. I've updaloaded the very non-impressive image here -> http://imgur.com/Vq4FnN9
npm run compile
This will compile the .coffee file to javascript and print it in your terminal. It's almost the same as the .coffee.