blackAndWhitePostProcess.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { __decorate } from "../tslib.es6.js";
  2. import { PostProcess } from "./postProcess.js";
  3. import "../Shaders/blackAndWhite.fragment.js";
  4. import { RegisterClass } from "../Misc/typeStore.js";
  5. import { serialize } from "../Misc/decorators.js";
  6. import { SerializationHelper } from "../Misc/decorators.serialization.js";
  7. /**
  8. * Post process used to render in black and white
  9. */
  10. export class BlackAndWhitePostProcess extends PostProcess {
  11. /**
  12. * Gets a string identifying the name of the class
  13. * @returns "BlackAndWhitePostProcess" string
  14. */
  15. getClassName() {
  16. return "BlackAndWhitePostProcess";
  17. }
  18. /**
  19. * Creates a black and white post process
  20. * @see https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/usePostProcesses#black-and-white
  21. * @param name The name of the effect.
  22. * @param options The required width/height ratio to downsize to before computing the render pass.
  23. * @param camera The camera to apply the render pass to.
  24. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  25. * @param engine The engine which the post process will be applied. (default: current engine)
  26. * @param reusable If the post process can be reused on the same frame. (default: false)
  27. */
  28. constructor(name, options, camera, samplingMode, engine, reusable) {
  29. super(name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable);
  30. /**
  31. * Linear about to convert he result to black and white (default: 1)
  32. */
  33. this.degree = 1;
  34. this.onApplyObservable.add((effect) => {
  35. effect.setFloat("degree", this.degree);
  36. });
  37. }
  38. /**
  39. * @internal
  40. */
  41. static _Parse(parsedPostProcess, targetCamera, scene, rootUrl) {
  42. return SerializationHelper.Parse(() => {
  43. return new BlackAndWhitePostProcess(parsedPostProcess.name, parsedPostProcess.options, targetCamera, parsedPostProcess.renderTargetSamplingMode, scene.getEngine(), parsedPostProcess.reusable);
  44. }, parsedPostProcess, scene, rootUrl);
  45. }
  46. }
  47. __decorate([
  48. serialize()
  49. ], BlackAndWhitePostProcess.prototype, "degree", void 0);
  50. RegisterClass("BABYLON.BlackAndWhitePostProcess", BlackAndWhitePostProcess);
  51. //# sourceMappingURL=blackAndWhitePostProcess.js.map