babylon.refractionPostProcess.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536
  1. var __extends = (this && this.__extends) || function (d, b) {
  2. for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
  3. function __() { this.constructor = d; }
  4. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5. };
  6. var BABYLON;
  7. (function (BABYLON) {
  8. var RefractionPostProcess = (function (_super) {
  9. __extends(RefractionPostProcess, _super);
  10. function RefractionPostProcess(name, refractionTextureUrl, color, depth, colorLevel, options, camera, samplingMode, engine, reusable) {
  11. var _this = this;
  12. _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable);
  13. this.color = color;
  14. this.depth = depth;
  15. this.colorLevel = colorLevel;
  16. this.onActivateObservable.add(function (cam) {
  17. _this._refRexture = _this._refRexture || new BABYLON.Texture(refractionTextureUrl, cam.getScene());
  18. });
  19. this.onApplyObservable.add(function (effect) {
  20. effect.setColor3("baseColor", _this.color);
  21. effect.setFloat("depth", _this.depth);
  22. effect.setFloat("colorLevel", _this.colorLevel);
  23. effect.setTexture("refractionSampler", _this._refRexture);
  24. });
  25. }
  26. // Methods
  27. RefractionPostProcess.prototype.dispose = function (camera) {
  28. if (this._refRexture) {
  29. this._refRexture.dispose();
  30. }
  31. _super.prototype.dispose.call(this, camera);
  32. };
  33. return RefractionPostProcess;
  34. })(BABYLON.PostProcess);
  35. BABYLON.RefractionPostProcess = RefractionPostProcess;
  36. })(BABYLON || (BABYLON = {}));