Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help with embedding #18

Closed
aumics opened this issue Sep 9, 2019 · 1 comment
Closed

Help with embedding #18

aumics opened this issue Sep 9, 2019 · 1 comment

Comments

@aumics
Copy link

aumics commented Sep 9, 2019

Hello,

First off -- what an awesome tool, thanks for making this!

Disclaimer: I'm rather new to JS.

  1. the options of %width/height doesn't seem to work; any value blows up the embedding to full width
  2. I'm struggling to customize the options for embedding a 3D view of simple molecules. For example, trying to turn off hydrogens and I can't seem to get it to work. I'll appreciate a pointer to what I'm doing wrong.
<h1>Not Aspirin</h1>
<p>Blah blah</p>
<div style="width:600px; height:300px; border:5px; border-color:#333;">
  <span>qwerty</span>
  <div id="icn3dwrap"></div>
</div>

<script type="text/javascript">
  $( document ).ready(function() {
        var options = {};
        options['surface'] = 'molecular surface';
        // setStyle(hideHydrogens);

        //Options are available at: https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#DisplayOptions
        //options['proteins'] = 'sphere';

        var cfg = {
            divid: 'icn3dwrap',
            width: '50%',
            height: '50%',
            resize: true,
            rotate: 'right',
            mobilemenu: true,
            showcommand: true,
//            showtitle: true,
        };
        cfg['cid'] = '6106';
        if(Object.keys(options).length > 0) cfg['options'] = options;

        var icn3dui = new iCn3DUI(cfg);

        //communicate with the 3D viewer with chained functions
        $.when(icn3dui.show3DStructure()).then(function() {
          icn3dui.setOption('background','white');
          // icn3dui.setOption('opacity','0.2');
          icn3dui.setStyle('hideHydrogens')
          // icn3dui.addLabel('abcdef',0,0,0,50)
             // icn3dui.setOption('color', 'cyan');
        });
  });
</script>
  </body>
@jiywang3
Copy link
Contributor

jiywang3 commented Sep 9, 2019

Thanks for reporting the problem of width and height. It's fixed in the recent release.

You code looks good. You just need to add the libraries at the top of your code:

<script src="https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/jquery.min.js"></script> <script src="https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/jquery-ui.min.js"></script> <script src="https://www.ncbi.nlm.nih.gov/Structure/icn3d/lib/three.min.js"></script> <script src="https://test.ncbi.nlm.nih.gov/Structure/icn3d2/icn3d_full_ui.min.js"></script>

Let me know if you see any other problems.

@jiywang3 jiywang3 closed this as completed Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants