Node.js & three.js load Texture on cube

こ雲淡風輕ζ 提交于 2019-12-23 03:09:55

问题


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?

来源:https://stackoverflow.com/questions/32919875/node-js-three-js-load-texture-on-cube

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!