babylon.renderPass.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. "use strict";
  2. var BABYLON = BABYLON || {};
  3. (function () {
  4. BABYLON.RenderPass = function RenderPass(scene, name, size, renderList, beforeRender, afterRender) {
  5. this._name = name;
  6. this._enabled = true;
  7. this._renderList = renderList;
  8. this._renderTexture = new BABYLON.RenderTargetTexture(name, size, scene);
  9. this.setRenderList(renderList);
  10. this._renderTexture.onBeforeRender = beforeRender;
  11. this._renderTexture.onAfterRender = afterRender;
  12. this._refCount = 0;
  13. };
  14. BABYLON.RenderPass.prototype.incRefCount = function () {
  15. if (this._refCount == 0) {
  16. scene.customRenderTargets.push(this._renderTexture);
  17. }
  18. this._refCount++;
  19. };
  20. BABYLON.RenderPass.prototype.decRefCount = function () {
  21. this._refCount--;
  22. if (this._refCount <= 0) {
  23. scene.customRenderTargets.splice(scene.customRenderTargets.indexOf(this._renderTexture), 1);
  24. }
  25. };
  26. BABYLON.RenderPass.prototype.setRenderList = function (renderList) {
  27. this._renderTexture.renderList = renderList;
  28. };
  29. BABYLON.RenderPass.prototype.getRenderTexture = function () {
  30. return this._renderTexture;
  31. };
  32. BABYLON.RenderPass.prototype._update = function () {
  33. this.setRenderList(this._renderList);
  34. };
  35. })();