Getting pc.rendertarget (as source) from secondary cam to cubemap.rendertarget

I have tried to combine knowledge from How to make a dynamic cubemap ? (reflexion project) and ☑ Save specific rendered entities to image (as well as yaustar’s referenced

without luck …

My last attemp of ‘Getting pc.rendertarget (as source) from secondary cam to cubemap.rendertarget’ strands at:

DynCubemap.prototype.onMouseDown = function (event) {
var asset =; //Getting the CubeMap
var texture =;

var colorBuffer = new pc.Texture(, {
    width: 512,
    height: 512,
    format: pc.PIXELFORMAT_R8_G8_B8
var renderTarget = new pc.RenderTarget(, texture, {
    colorBuffer: colorBuffer,
    depth: true,
    face: 0

var layer =;              
layer.renderTarget = renderTarget;
var cam ="Camera2"); console.log(" "; var camAsCam =; 
renderTarget =camAsCam.renderTarget.colorBuffer.getSource;
asset.loadFaces = true;;;

[numerous times the ‘cam’ or ‘camAsCam’ gets console-debugged with error of not existing]