RenderingPipeline: how do you check if camera was already added to it?

I’m switching cameras in my Babylon.js scene, and some of thos e cameras are added late, after asynchronously downloading glb files with cameras in them, when those cameras are done loading I add them to a previously setup DefaultRenderingPipeline so I get the same rendering across all scene cameras. But I get this persisting message everytime I re-add a camera (my setup requires dynamic camera reloads):

BJS - [<TIME>]: You're trying to reuse a post process not defined as reusable.

	console.<computed>	@	index.js:1446
Logger._ErrorEnabled	@	logger.js:59
Camera.attachPostProcess	@	camera.js:524
(anonymous)	@	postProcessRenderEffect.js:96
PostProcessRenderEffect._attachCameras	@	postProcessRenderEffect.js:95
PostProcessRenderPipeline._attachCameras	@	postProcessRenderPipeline.js:129
PostProcessRenderPipelineManager.attachCamerasToRenderPipeline	@	postProcessRenderPipelineManager.js:65
DefaultRenderingPipeline._buildPipeline	@	defaultRenderingPipeline.js:670
DefaultRenderingPipeline.prepare	@	defaultRenderingPipeline.js:512

The code adding the camera is:

scene.postProcessRenderPipelineManager.supportedPipelines.forEach(
      (pipeline: PostProcessRenderPipeline): void => {
        if (
          pipeline instanceof DefaultRenderingPipeline &&
          scene.activeCamera instanceof Camera
        ) {
          pipeline.addCamera(scene.activeCamera);
          pipeline.prepare(); // also not sure this is necessary
        }
      }
    );

I’m assuming this error comes up because of repeating the camera addition to the Pipeline, how can I check if the camera is already available for that Pipeline? Checked the docs and didn’t find if the Pipelines keeps references to the cameras added to it…

Currently using 4.1.0-alpha.22

I will add a new renderPipeline.cameras for you :slight_smile:

1 Like