I'm trying to use the WebGLExtract class to create screenshots, but am getting a black image instead (of the correct dimensions).
var sourceCanvas = renderer.extract.canvas();
var sourceContext = sourceCanvas.getContext('2d');
var extractCanvas = document.createElement('canvas');
var extractContext = extractCanvas.getContext('2d');
var imageData = sourceContext.getImageData(x, y, width, height);
extractCanvas.width = width;
extractCanvas.height = height;
extractContext.putImageData(imageData, 0, 0);
return extractCanvas.toDataURL();
I've also tried just accessing sourceCanvas.toDataURL() directly, but with the same results. Any chance I've forgotten something obvious?
It can happen in some cases, but if you pass your stage there, and it gets imageData just after rendering it - I'm sure it'll work.
renderer.extract.canvas(stage);
And if you are friday-night-drunk and forgot where is your stage
renderer.extract.canvas(renderer._lastObjectRendered);
Hey @noffle is this still an issue?
@ivanpopelyshev That did it! Thank you so much. :heart: And thanks @englercj for poking me on this.
@ivanpopelyshev 小锌邪褋懈斜芯 褌械斜械 芯谐褉芯屑薪芯械!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
It can happen in some cases, but if you pass your stage there, and it gets imageData just after rendering it - I'm sure it'll work.
And if you are friday-night-drunk and forgot where is your stage