node.js server rendering with node-webgl and/or headless-gl

I have been trying (with great pain … but finally some success) to use node + three.js to render some models on a Linux server box.

The only workable approach I found was to use the fork of three.js that @kabbi did back in March. I’m using Xvfb on the server on Linux, and @kabbi fork which is using node-webgl to create GL context from node. @kabbi did not have to modify too many files to make this works, mostly adding some cast to WebGLRenderer.js, make some of the LoadUtils code work differently. The nodes header.js file is used to create a shim/wrapper so that the global document (not accessible from node) is using the fake one that node-webgl provides.

Here is the commit that had node / node-webgl support -> kabbi@d97012f

(the kind of “cast” I’m talking about, mostly around some uniforms)

                case '1iv':
-                   _gl.uniform1iv( location, value );
+                   _gl.uniform1iv( location, new Int32Array(value) );

I would like to have people advices on how to merge this back into the main repo, whether this is feasible or not, and on how to move forward. Any thought, anyone ?

Also, my current main interest is to do offscreen rendering, so a library like is actually making more sense for my use case. I tried to create a context from headless-gl and pass it to the WebGLRenderer with no luck (getting a white image with my test-case).

BTW for my test cases I tried to use node-canvas to render text into textures, but I got some crashes with node-canvas and ended up using 3D Fonts (TextGeometry) which work well.

Thanks for any help (and for this awesome library). Once one experiences the speed and ease of doing OpenGL in a browser it’s very hard to go back to C++ 😉

Author: Fantashit

1 thought on “node.js server rendering with node-webgl and/or headless-gl

Comments are closed.