anaglyphPostProcess.ts 1.4 KB

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