Browse Source

fix using default values for webgl1/wboit features in the default viewer app

dsehnal 3 years ago
parent
commit
6ed232b3d9
2 changed files with 10 additions and 3 deletions
  1. 8 1
      src/apps/viewer/app.ts
  2. 2 2
      src/apps/viewer/index.html

+ 8 - 1
src/apps/viewer/app.ts

@@ -101,7 +101,14 @@ export class Viewer {
     }
 
     static async create(elementOrId: string | HTMLElement, options: Partial<ViewerOptions> = {}) {
-        const o = { ...DefaultViewerOptions, ...options };
+        const definedOptions = {} as any;
+        // filter for defined properies only so the default values
+        // are property applied
+        for (const p of Object.keys(options) as (keyof ViewerOptions)[]) {
+            if (options[p] !== void 0) definedOptions[p] = options[p];
+        }
+
+        const o: ViewerOptions = { ...DefaultViewerOptions, ...definedOptions };
         const defaultSpec = DefaultPluginUISpec();
 
         const spec: PluginUISpec = {

+ 2 - 2
src/apps/viewer/index.html

@@ -57,7 +57,7 @@
             var pickScale = getParam('pick-scale', '[^&]+').trim();
             var pickPadding = getParam('pick-padding', '[^&]+').trim();
             var disableWboit = getParam('disable-wboit', '[^&]+').trim() === '1';
-            var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1';
+            var preferWebgl1 = getParam('prefer-webgl1', '[^&]+').trim() === '1' || void 0;
 
             molstar.Viewer.create('app', {
                 layoutShowControls: !hideControls,
@@ -71,7 +71,7 @@
                 pixelScale: parseFloat(pixelScale) || 1,
                 pickScale: parseFloat(pickScale) || 0.25,
                 pickPadding: isNaN(parseFloat(pickPadding)) ? 1 : parseFloat(pickPadding),
-                enableWboit: !disableWboit,
+                enableWboit: disableWboit ? true : void 0, // use default value if disable-wboit is not set
                 preferWebgl1: preferWebgl1,
             }).then(viewer => {
                 var snapshotId = getParam('snapshot-id', '[^&]+').trim();