anaglyphPostProcess.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import { Nullable } from "../types";
  2. import { Engine } from "../Engines/engine";
  3. import { PostProcess, PostProcessOptions } from "./postProcess";
  4. import { Camera } from "../Cameras/camera";
  5. import { Effect } from "../Materials/effect";
  6. import "../Shaders/anaglyph.fragment";
  7. import { _TypeStore } from '../Misc/typeStore';
  8. /**
  9. * Postprocess used to generate anaglyphic rendering
  10. */
  11. export class AnaglyphPostProcess extends PostProcess {
  12. private _passedProcess: Nullable<PostProcess>;
  13. /**
  14. * Gets a string identifying the name of the class
  15. * @returns "AnaglyphPostProcess" string
  16. */
  17. public getClassName(): string {
  18. return "AnaglyphPostProcess";
  19. }
  20. /**
  21. * Creates a new AnaglyphPostProcess
  22. * @param name defines postprocess name
  23. * @param options defines creation options or target ratio scale
  24. * @param rigCameras defines cameras using this postprocess
  25. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  26. * @param engine defines hosting engine
  27. * @param reusable defines if the postprocess will be reused multiple times per frame
  28. */
  29. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean) {
  30. super(name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable);
  31. this._passedProcess = rigCameras[0]._rigPostProcess;
  32. this.onApplyObservable.add((effect: Effect) => {
  33. effect.setTextureFromPostProcess("leftSampler", this._passedProcess);
  34. });
  35. }
  36. }
  37. _TypeStore.RegisteredTypes["BABYLON.AnaglyphPostProcess"] = AnaglyphPostProcess;