passes.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Copyright (c) 2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author Alexander Rose <alexander.rose@weirdbyte.de>
  5. */
  6. import { DrawPass } from './draw';
  7. import { PickPass } from './pick';
  8. import { MultiSamplePass } from './multi-sample';
  9. import { WebGLContext } from '../../mol-gl/webgl/context';
  10. import { AssetManager } from '../../mol-util/assets';
  11. export class Passes {
  12. readonly draw: DrawPass;
  13. readonly pick: PickPass;
  14. readonly multiSample: MultiSamplePass;
  15. constructor(private webgl: WebGLContext, assetManager: AssetManager, attribs: Partial<{ pickScale: number, enableWboit: boolean, enableDpoit: boolean }> = {}) {
  16. const { gl } = webgl;
  17. this.draw = new DrawPass(webgl, assetManager, gl.drawingBufferWidth, gl.drawingBufferHeight, attribs.enableWboit || false, attribs.enableDpoit || false);
  18. this.pick = new PickPass(webgl, this.draw, attribs.pickScale || 0.25);
  19. this.multiSample = new MultiSamplePass(webgl, this.draw);
  20. }
  21. updateSize() {
  22. const { gl } = this.webgl;
  23. // Avoid setting dimensions to 0x0 because it causes "empty textures are not allowed" error.
  24. const width = Math.max(gl.drawingBufferWidth, 2);
  25. const height = Math.max(gl.drawingBufferHeight, 2);
  26. this.draw.setSize(width, height);
  27. this.pick.syncSize();
  28. this.multiSample.syncSize();
  29. }
  30. }