Skip to content

setting initial options hide water with select on load #103

Open
@Jhsmit

Description

@Jhsmit

I'm setting hideStructure: ['water'], of the initial options and then using loadComplete.subscribe to set colors.

This gives me an error Uncaught (in promise) Error: Could not find node 'undefined'.
Perhaps its trying to color the water which isnt there?

code example on plnkr: https://plnkr.co/edit/V0wwfwfsGVplURYD

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
    <title>PDBe Molstar - Basic</title>

    <!-- Molstar CSS & JS -->
    <link rel="stylesheet" type="text/css" href="https://www.ebi.ac.uk/pdbe/pdb-component-library/css/pdbe-molstar-3.1.2.css">
    <script type="text/javascript" src="https://www.ebi.ac.uk/pdbe/pdb-component-library/js/pdbe-molstar-plugin-3.1.3.js"></script>
    <style>
      #myViewer{
        float:left;
        width:500px;
        height: 500px;
        position:relative;
      }
    </style>
  </head>

  <body>

    <h4>PDBe Mol* JS Plugin Demo</h4>

    <!-- Molstar container -->
    <div id="myViewer"></div>
      
    <script>

      var selectSections = [
        {
          struct_asym_id: 'B', 
          start_residue_number: 8, 
          end_residue_number: 10, 
          color:{r:255,g:0,b:255},
          sideChain: true
        },
        {
          struct_asym_id: 'B', 
          start_residue_number: 2, 
          end_residue_number: 5, 
          color:{r:255,g:0,b:0}
        }
      ]

      //Create plugin instance
      var viewerInstance = new PDBeMolstarPlugin();
  
      //Set options (Checkout available options list in the documentation)
      var options = {
        moleculeId: '2nnu',
        hideControls: true,
        // comment / uncomment to trigger bug
        hideStructure: ['water'],
      }
      
      //Get element from HTML/Template to place the viewer 
      var viewerContainer = document.getElementById('myViewer');
  
      //Call render method to display the 3D view
      viewerInstance.render(viewerContainer, options);
      
      //Trigger color and spin upon load complete
      viewerInstance.events.loadComplete.subscribe(() => {
      viewerInstance.visual.toggleSpin(true);
      viewerInstance.visual.select({ data: selectSections, nonSelectedColor: {r:255,g:255,b:255}})
      });
      
    </script>
  </body>

</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions