UNPKG

molstar

Version:

A comprehensive macromolecular library.

39 lines (38 loc) 1.63 kB
/** * Copyright (c) 2020-2025 mol* contributors, licensed under MIT, See LICENSE file for more info. * * @author Alexander Rose <alexander.rose@weirdbyte.de> */ import { DrawPass } from './draw.js'; import { PickPass } from './pick.js'; import { MultiSamplePass } from './multi-sample.js'; import { IlluminationPass } from './illumination.js'; export class Passes { constructor(webgl, assetManager, attribs = {}) { this.webgl = webgl; const drs = this.webgl.getDrawingBufferSize(); this.draw = new DrawPass(webgl, assetManager, drs.width, drs.height, attribs.transparency || 'blended'); this.pick = new PickPass(webgl, drs.width, drs.height, attribs.pickScale || 0.25); this.multiSample = new MultiSamplePass(webgl, this.draw); this.illumination = new IlluminationPass(webgl, this.draw); } getByteCount() { return this.draw.getByteCount() + this.pick.getByteCount() + this.multiSample.getByteCount() + this.illumination.getByteCount(); } setPickScale(pickScale) { this.pick.setPickScale(pickScale); } setTransparency(transparency) { this.draw.setTransparency(transparency); } updateSize() { const drs = this.webgl.getDrawingBufferSize(); // Avoid setting dimensions to 0x0 because it causes "empty textures are not allowed" error. const width = Math.max(drs.width, 2); const height = Math.max(drs.height, 2); this.draw.setSize(width, height); this.pick.setSize(width, height); this.multiSample.syncSize(); this.illumination.setSize(width, height); } }