Я пытаюсь визуализировать куб на стороне сервера и смог сделать это с помощью CanvasRenderer, но я хочу иметь возможность визуализировать его с помощью WebGLRenderer, что должно дать лучшие результаты. я сузил его до этого фрагмента кода:
var jsdom = require('jsdom')
, document = jsdom.jsdom('<!doctype html><html><head></head><body></body></html>')
, window = document.createWindow()
, THREE = require('three');
document.onload = docOnLoad();
function docOnLoad()
{
console.log("docOnLoad called.");
global.document = document;
global.window = window;
//renderer = new THREE.CanvasRenderer(); //works
renderer = new THREE.WebGLRenderer();
renderer.setSize(400, 400);
document.body.appendChild(renderer.domElement);
}
При использовании WebGLRenderer я получил:
_glExtensionTextureFloat = _gl.getExtension( 'OES_texture_float');
^
TypeError: Cannot call method 'getExtension' of undefined
at initGL (C:\programming\nodejs\node_modules\three\three.js:25870:34)
при попытке отладки кода three.js console.log(_gl) действительно показывает, что _gl не определено, а источником является строка #25856, где:
_gl = _canvas.getContext( 'webgl', attributes ) || _canvas.getContext( 'experimental-webgl', attributes );
теперь console.log() из _canvas показывает: [Canvas 0x0]
Кто-нибудь сталкивался с чем-то подобным?