That example is a bit old, written before the Playcanvas Layers system was introduced. Now the way to do that would be to create a new Layer in the editor, assign it to your active camera and objects you would like to render on and in code make the following change:
// // Set the render target on an entity's camera component
// this.entity.camera.renderTarget = renderTarget;
// added a new Layer named Render
var layer = this.app.scene.layers.getLayerByName('Render');
layer.renderTarget = renderTarget;
If you would like to render to texture the whole Layers composition including the skybox etc, take a look at the following project by @yaustar :
Hey Thanks for the reply I used the layers and the code suggested above.
I am able to get the 3d object, but i am unable to get the skybox.
Also, I am able to get the model wrapped ona a cylinder like shown in this example - PlayCanvas 3D HTML5 Game Engine
but i want it to get wrapped only the curved surface. My project is about wrapping a watch around a cylinder in AR, with cylinder having camera feed texture.
As the 3d models always load on top of the marker, I was just trying to experiement, if i can mimic it getting wrapped aroung hand with this.
Edit: About the Skybox though, since that is rendered on its own layer I think still it will not be included on the rendered texture. There is a quick and dirty solution to grab a texture from the Application texture, but that will kill performance.
Will research further on what is the optimal way Most likely using a pc.PostEffect to copy the colorBuffer to a render texture.
I just went through this project. The plane appears black and doesn’t render anything when I launch the project. Do I need to change anything, or is this project outdated?