postProcessRenderPipelineManagerSceneComponent.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { SceneComponentConstants } from "../../sceneComponent.js";
  2. import { PostProcessRenderPipelineManager } from "./postProcessRenderPipelineManager.js";
  3. import { Scene } from "../../scene.js";
  4. Object.defineProperty(Scene.prototype, "postProcessRenderPipelineManager", {
  5. get: function () {
  6. if (!this._postProcessRenderPipelineManager) {
  7. // Register the G Buffer component to the scene.
  8. let component = this._getComponent(SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  9. if (!component) {
  10. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  11. this._addComponent(component);
  12. }
  13. this._postProcessRenderPipelineManager = new PostProcessRenderPipelineManager();
  14. }
  15. return this._postProcessRenderPipelineManager;
  16. },
  17. enumerable: true,
  18. configurable: true,
  19. });
  20. /**
  21. * Defines the Render Pipeline scene component responsible to rendering pipelines
  22. */
  23. export class PostProcessRenderPipelineManagerSceneComponent {
  24. /**
  25. * Creates a new instance of the component for the given scene
  26. * @param scene Defines the scene to register the component in
  27. */
  28. constructor(scene) {
  29. /**
  30. * The component name helpful to identify the component in the list of scene components.
  31. */
  32. this.name = SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  33. this.scene = scene;
  34. }
  35. /**
  36. * Registers the component in a given scene
  37. */
  38. register() {
  39. this.scene._gatherRenderTargetsStage.registerStep(SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  40. }
  41. /**
  42. * Rebuilds the elements related to this component in case of
  43. * context lost for instance.
  44. */
  45. rebuild() {
  46. if (this.scene._postProcessRenderPipelineManager) {
  47. this.scene._postProcessRenderPipelineManager._rebuild();
  48. }
  49. }
  50. /**
  51. * Disposes the component and the associated resources
  52. */
  53. dispose() {
  54. if (this.scene._postProcessRenderPipelineManager) {
  55. this.scene._postProcessRenderPipelineManager.dispose();
  56. }
  57. }
  58. _gatherRenderTargets() {
  59. if (this.scene._postProcessRenderPipelineManager) {
  60. this.scene._postProcessRenderPipelineManager.update();
  61. }
  62. }
  63. }
  64. //# sourceMappingURL=postProcessRenderPipelineManagerSceneComponent.js.map