Is it possible to take screenshots from a camera and not from the canvas. In your playcanvas tutorials, you use the canvas to make the screenshot.
We want to take screenshots from another camera that is not the main camera, is that possible? so that a camera would just that screenshots in the background and not be the rendered camera on the canvas.
yes, but when you say render to a texture, will it still be the main camera that is rendered on the canvas? of can it be another enabled camera that is not the one displayed?
to make a screenshot i would have to make an image element to have a png. So how can a turn my texture to an image element.
Because in my project, when you click on the button it takes multiple screenshots from different cameras and downloads them directly on my computer. Additionally we want to change the resolution of the screenshot to a 3300 x 3300.
var canvas = document.getElementById('application-canvas');
var dataURL = canvas.toDataURL('image/png');
var image = new Image();
image.src = dataURL;
// put the right link in the <a> and take the shot
this.button.href = dataURL;
this.button.download = "screenshot.png";
this.button.click();
this is my code, but in our case, we don’t want the canvas to make the screenshot, but a camera that is not the main cam. and to be able to change the resolution of the image, but I am having doubts that it’s possible, because the downloaded image is the one from the dataUrl and i doubt we can change the size.
For now, we disable and enable different cameras to have different screenshots, but we see the change in the canvas, and that is not what we want.
@yaustar, the project in this link doen’t work, i don’t have access to it
But yes I am trying to turn a texture to an image, but I am not finding any solutions
Actually trying this now and it’s a lot more difficult than I first thought as I can’t seem to convert a texture to something I can create an image out of yet.
However, as a work around, could you add a HTML DOM object/image to the screen that covers the canvas, enable/disable the cameras to take the screenshots from the canvas and when it’s all done, enable the main camera and remove the DOM?
I see you use layer with the renderTarget, but with that I am finding hard to have multiple cameras. I am trying to have multiple hidden camera screenshot.
well I am trying to get like 6 screenshots from different cameras with one click of a button.
I tried by having the 6 camera in the same layer, but enabling them one at a time to get one screenshot for each. that did not work, the screenshot were just blank.
I tried by having 6 camera enabled at the start each in different layer but this happened.
Building on top of this solution: Instead of setting the renterTaget of a layer to the texture, you can directly set the renderTarget of the screenshot camera to the texture. Then you don’t have to create another layer and tag every object you want to see in the screenshot.
(I would have commented directly on the demo project, but the devlog is empty, so I can’t.)