فهرست منبع

add option to disable hardware antialiasing- wastful for direct volume rendering

Alexander Rose 4 سال پیش
والد
کامیت
f8e6d5cbfb
5فایلهای تغییر یافته به همراه22 افزوده شده و 15 حذف شده
  1. 3 1
      src/apps/viewer/index.html
  2. 2 0
      src/apps/viewer/index.ts
  3. 13 12
      src/mol-canvas3d/canvas3d.ts
  4. 2 1
      src/mol-plugin/config.ts
  5. 2 1
      src/mol-plugin/context.ts

+ 3 - 1
src/apps/viewer/index.html

@@ -46,12 +46,14 @@
             }
 
             var debugMode = getParam('debug-mode', '[^&]+').trim() === '1';
-            if (debugMode) molstar.setDebugMode(debugMode);
+            if (debugMode) molstar.setDebugMode(debugMode, debugMode);
 
+            var disableAntialiasing = getParam('disable-antialiasing', '[^&]+').trim() === '1';
             var hideControls = getParam('hide-controls', '[^&]+').trim() === '1';
             var pdbProvider = getParam('pdb-provider', '[^&]+').trim().toLowerCase();
             var emdbProvider = getParam('emdb-provider', '[^&]+').trim().toLowerCase();
             var viewer = new molstar.Viewer('app', {
+                disableAntialiasing: disableAntialiasing,
                 layoutShowControls: !hideControls,
                 viewportShowExpand: false,
                 pdbProvider: pdbProvider || 'pdbe',

+ 2 - 0
src/apps/viewer/index.ts

@@ -58,6 +58,7 @@ const DefaultViewerOptions = {
     layoutShowSequence: true,
     layoutShowLog: true,
     layoutShowLeftPanel: true,
+    disableAntialiasing: false,
 
     viewportShowExpand: PluginConfig.Viewport.ShowExpand.defaultValue,
     viewportShowControls: PluginConfig.Viewport.ShowControls.defaultValue,
@@ -104,6 +105,7 @@ export class Viewer {
                 remoteState: o.layoutShowRemoteState ? 'default' : 'none'
             },
             config: [
+                [PluginConfig.General.DisableAntialiasing, o.disableAntialiasing],
                 [PluginConfig.Viewport.ShowExpand, o.viewportShowExpand],
                 [PluginConfig.Viewport.ShowControls, o.viewportShowControls],
                 [PluginConfig.Viewport.ShowSettings, o.viewportShowSettings],

+ 13 - 12
src/mol-canvas3d/canvas3d.ts

@@ -113,10 +113,10 @@ namespace Canvas3D {
     export interface DragEvent { current: Representation.Loci, buttons: ButtonsType, button: ButtonsType.Flag, modifiers: ModifiersKeys, pageStart: Vec2, pageEnd: Vec2 }
     export interface ClickEvent { current: Representation.Loci, buttons: ButtonsType, button: ButtonsType.Flag, modifiers: ModifiersKeys }
 
-    export function fromCanvas(canvas: HTMLCanvasElement, props: Partial<Canvas3DProps> = {}) {
+    export function fromCanvas(canvas: HTMLCanvasElement, props: Partial<Canvas3DProps> = {}, attribs: Partial<{ antialias: boolean }> = {}) {
         const gl = getGLContext(canvas, {
             alpha: true,
-            antialias: true,
+            antialias: attribs.antialias ?? true,
             depth: true,
             preserveDrawingBuffer: false,
             premultipliedAlpha: false,
@@ -207,17 +207,17 @@ namespace Canvas3D {
             let loci: Loci = EmptyLoci;
             let repr: Representation.Any = Representation.Empty;
             if (pickingId) {
-            loci = handleHelper.getLoci(pickingId);
-            reprRenderObjects.forEach((_, _repr) => {
-                const _loci = _repr.getLoci(pickingId);
-                if (!isEmptyLoci(_loci)) {
-                    if (!isEmptyLoci(loci)) {
-                        console.warn('found another loci, this should not happen');
+                loci = handleHelper.getLoci(pickingId);
+                reprRenderObjects.forEach((_, _repr) => {
+                    const _loci = _repr.getLoci(pickingId);
+                    if (!isEmptyLoci(_loci)) {
+                        if (!isEmptyLoci(loci)) {
+                            console.warn('found another loci, this should not happen');
+                        }
+                        loci = _loci;
+                        repr = _repr;
                     }
-                    loci = _loci;
-                    repr = _repr;
-                }
-            });
+                });
             }
             return { loci, repr };
         }
@@ -381,6 +381,7 @@ namespace Canvas3D {
                 instanceCount: r.values.instanceCount.ref.value,
                 materialId: r.materialId,
             })));
+            console.log(webgl.stats);
         }
 
         function add(repr: Representation.Any) {

+ 2 - 1
src/mol-plugin/config.ts

@@ -22,7 +22,8 @@ function item<T>(key: string, defaultValue?: T) { return new PluginConfigItem(ke
 export const PluginConfig = {
     item,
     General: {
-        IsBusyTimeoutMs: item('plugin-config.is-busy-timeout', 750)
+        IsBusyTimeoutMs: item('plugin-config.is-busy-timeout', 750),
+        DisableAntialiasing: item('plugin-config.disable-antialiasing', false)
     },
     State: {
         DefaultServer: item('plugin-state.server', 'https://webchem.ncbr.muni.cz/molstar-state'),

+ 2 - 1
src/mol-plugin/context.ts

@@ -187,7 +187,8 @@ export class PluginContext {
             this.layout.setRoot(container);
             if (this.spec.layout && this.spec.layout.initial) this.layout.setProps(this.spec.layout.initial);
 
-            (this.canvas3d as Canvas3D) = Canvas3D.fromCanvas(canvas);
+            const antialias = !(this.config.get(PluginConfig.General.DisableAntialiasing) ?? false);
+            (this.canvas3d as Canvas3D) = Canvas3D.fromCanvas(canvas, {}, { antialias });
             this.canvas3dInit.next(true);
             this.canvas3d?.setProps(this.spec.components?.viewport?.canvas3d || { renderer: { backgroundColor: Color(0xFCFBF9) } });
             this.canvas3d!.animate();