vrMultiviewToSingleviewPostProcess.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Texture } from "../Materials/Textures/texture.js";
  2. import { PostProcess } from "./postProcess.js";
  3. import "../Shaders/vrMultiviewToSingleview.fragment.js";
  4. import "../Engines/Extensions/engine.multiview.js";
  5. /**
  6. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  7. * This will not be used for webXR as it supports displaying texture arrays directly
  8. */
  9. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  10. /**
  11. * Gets a string identifying the name of the class
  12. * @returns "VRMultiviewToSingleviewPostProcess" string
  13. */
  14. getClassName() {
  15. return "VRMultiviewToSingleviewPostProcess";
  16. }
  17. /**
  18. * Initializes a VRMultiviewToSingleview
  19. * @param name name of the post process
  20. * @param camera camera to be applied to
  21. * @param scaleFactor scaling factor to the size of the output texture
  22. */
  23. constructor(name, camera, scaleFactor) {
  24. super(name, "vrMultiviewToSingleview", ["imageIndex"], ["multiviewSampler"], scaleFactor, camera, Texture.BILINEAR_SAMPLINGMODE);
  25. const cam = camera ?? this.getCamera();
  26. this.onSizeChangedObservable.add(() => { });
  27. this.onApplyObservable.add((effect) => {
  28. if (cam._scene.activeCamera && cam._scene.activeCamera.isLeftCamera) {
  29. effect.setInt("imageIndex", 0);
  30. }
  31. else {
  32. effect.setInt("imageIndex", 1);
  33. }
  34. effect.setTexture("multiviewSampler", cam._multiviewTexture);
  35. });
  36. }
  37. }
  38. //# sourceMappingURL=vrMultiviewToSingleviewPostProcess.js.map