Question

Hi I am passing in a canvas DOMelement to my call to the WebGLRenderer() like this:

var jqc = $('#myCanvas'); //get canvas with jQuery;
var par = {canvas:jqc.get()}; //create parameter object with canvas DOMElement in it
var renderer = new THREE.WebGLRenderer(par); //create new WebGLRenderer using myCanvas
//program fails in constructor

Is there something that I am missing?

I have tried the above whilst not giving the constructor any parameters and the code works fine it's just when using the par object to try and get it to use the canvas I already have on the page, that it breaks.

Was it helpful?

Solution

.get returns an array, even if it only contains one element. Try:

var par = { canvas: jqc.get(0) };
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top