1

Essentially, I am generating a static scene using the three.js module with node.js.

Unfortunately, as the scene is being rendered without a browser, I can not use THREE.ImageUtils.loadTexture.

I am given an error when using this - I understand that document does not exist as I am rendering it server side.

var materials = [
new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture('url here'')}),
new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture('url here'')}),
new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture('url here'')}),
new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture('url here'')}),
new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture('url here'')}),
new THREE.MeshLambertMaterial({map: THREE.ImageUtils.loadTexture('url here')})
];

returns

/usr/src/node-v0.10.40/node_modules/three/three.js:13028
            var image = document.createElement( 'img' );
                        ^
ReferenceError: document is not defined

So in a sum - I need to load a texture onto a cube using SoftwareRenderer in three.js, however the catch is I am rendering it with node, not loading it in a browser. How would I go about doing this?

  • A port from a long time ago, but I'm rnning into the same problem. Did you happen to find any resolution for this? I'm also trying to redner out threejs serverside over node-canvas. Looking forward to hear your answer. Cheers – Mia Mar 19 '16 at 16:18
  • @Mia No, I am still trying to work out a solution. In fact, I just ran into my own question and saw your comment. I believe you can only use three.js on node for rendering data. It could be possible to use web sockets or socket.io as a solution. – Isaac Godfrey Mar 24 '16 at 14:02

0 Answers0