Explorar el Código

debug-mode url param, canvas3d console stats

Alexander Rose hace 4 años
padre
commit
1569958a29
Se han modificado 2 ficheros con 14 adiciones y 0 borrados
  1. 3 0
      src/apps/viewer/index.html
  2. 11 0
      src/mol-canvas3d/canvas3d.ts

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

@@ -45,6 +45,9 @@
                 return decodeURIComponent(((window.location.search || '').match(r) || [])[1] || '');
             }
 
+            var debugMode = getParam('debug-mode', '[^&]+').trim() === '1';
+            if (debugMode) molstar.setDebugMode(debugMode);
+
             var hideControls = getParam('hide-controls', '[^&]+').trim() === '1';
             var pdbProvider = getParam('pdb-provider', '[^&]+').trim().toLowerCase();
             var emdbProvider = getParam('emdb-provider', '[^&]+').trim().toLowerCase();

+ 11 - 0
src/mol-canvas3d/canvas3d.ts

@@ -362,10 +362,19 @@ namespace Canvas3D {
 
             camera.setState({ radiusMax: scene.boundingSphere.radius }, 0);
             reprCount.next(reprRenderObjects.size);
+            if (isDebugMode) consoleStats();
 
             return true;
         }
 
+        function consoleStats() {
+            console.table(scene.renderables.map(r => ({
+                drawCount: r.values.drawCount.ref.value,
+                instanceCount: r.values.instanceCount.ref.value,
+                materialId: r.materialId,
+            })));
+        }
+
         function add(repr: Representation.Any) {
             registerAutoUpdate(repr);
 
@@ -384,6 +393,7 @@ namespace Canvas3D {
             reprRenderObjects.set(repr, newRO);
 
             scene.update(repr.renderObjects, false);
+            if (isDebugMode) consoleStats();
         }
 
         function remove(repr: Representation.Any) {
@@ -394,6 +404,7 @@ namespace Canvas3D {
                 renderObjects.forEach(o => scene.remove(o));
                 reprRenderObjects.delete(repr);
                 scene.update(repr.renderObjects, false, true);
+                if (isDebugMode) consoleStats();
             }
         }