I've been trying to render images using the official three.js package, three
on npm
by using the canvas
package on npm
. So far, not much luck.
I believe this should be possible as node-canvas (https://github.com/Automattic/node-canvas) is a full stack canvas renderer, I just don' know how to fix the bridge between this library and three.js to make them work together for server-sided rendering
Here is my failed approach:
By following an old github post I've managed to modify the beginning of the three.js
file as follows:
var Canvas = require('canvas');
var self = self || {}; // File:src/Three.js
var canvasWidth = 1024;
var canvasHeight = 1024;
var window = {
innerWidth: canvasWidth,
innerHeight: canvasHeight
};
var document = {
createElement: function(name) {
if (name == "canvas") {
return new Canvas(canvasWidth, canvasHeight);
}
}
};
now when I use the canvas renderer to render stuff out, I get no errors.
renderer = new THREE.CanvasRenderer();
Not sure how I can manage this thing to output a file, or render anything at all.
Any help is appreaciated.