babylon.postProcessRenderPass.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. module BABYLON {
  2. export class PostProcessRenderPass {
  3. private _enabled = true;
  4. private _renderList: Mesh[];
  5. private _renderTexture: RenderTargetTexture;
  6. private _scene: Scene;
  7. private _refCount = 0;
  8. constructor(scene: Scene, public name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void) {
  9. this._renderTexture = new RenderTargetTexture(name, size, scene);
  10. this.setRenderList(renderList);
  11. this._renderTexture.onBeforeRender = beforeRender;
  12. this._renderTexture.onAfterRender = afterRender;
  13. this._scene = scene;
  14. }
  15. public incRefCount(): number {
  16. if (this._refCount == 0) {
  17. this._scene.customRenderTargets.push(this._renderTexture);
  18. }
  19. return ++this._refCount;
  20. }
  21. public decRefCount(): number {
  22. this._refCount--;
  23. if (this._refCount <= 0) {
  24. this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture), 1);
  25. }
  26. return this._refCount;
  27. }
  28. public setRenderList(renderList: Mesh[]): void {
  29. this._renderTexture.renderList = renderList;
  30. }
  31. public getRenderTexture(): RenderTargetTexture {
  32. return this._renderTexture;
  33. }
  34. public _update(): void {
  35. this.setRenderList(this._renderList);
  36. }
  37. }
  38. }