[SOLVED] Screenshot with a camera and not the canvas

Interesting, but I am not sure what will change in @yaustar’s demo:

In camera-to-texture.js, I’m not even sure how these lines are working and how they need to change. The variable layer is not used elsewhere, but still, changing the renderTarget of that object change the behavior.

var layer = this.app.scene.layers.getLayerByName(this.layerName);
layer.renderTarget = this.renderTarget;

You can replace those two lines with

this.cameraEntity.camera.renderTarget = this.renderTarget;

The renderTarget is basically the place where the calculated pixels should be drawn. The original approach used a layer to mark all included objects, which is a bit more cumbersome. With the camera renderTarget everything seen by this camera is drawn to the renderTarget (screenshot texture).

2 Likes

Great! Thank you, exactly what I was looking for. :slight_smile:

Hello!

Trying this and I always have 3 reversed image that are the same? did this example fall behind the engine upgrades maybe?

Is it supposed to get a camera view screenshot?

thanks for the support.

ha! this seem to fix the problem!

Thank you!

Oh, my personal project (before I joined PlayCanvas again) is way outdated.

The official one should work: Capturing a screenshot | Learn PlayCanvas

1 Like

Amazing project, I was in need to be able to take screenshot from a camera view. Not all the canvas.

Thank you for sharing. It work just fine!

A post was split to a new topic: How to add screenshot to a material