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

[BUG] defaultcolors not applied when using addModelsAsFrames #764

Open
dsvatunek opened this issue Jan 29, 2024 · 1 comment
Open

[BUG] defaultcolors not applied when using addModelsAsFrames #764

dsvatunek opened this issue Jan 29, 2024 · 1 comment
Labels

Comments

@dsvatunek
Copy link

Describe the bug

When using

viewer = $3Dmol.createViewer("Model", {defaultcolors: $3Dmol.elementColors.Jmol});

the color scheme gets applied to models added using

viewer.addModel(xyz_data, "xyz");

but not when using

viewer.addModelsAsFrames(xyz_data, "xyz");

To Reproduce

This code gives the default color for the nitrogen atom
default


<div style="text-align: center;">
        <div id="Model" style="width: 500px; height: 500px;"></div>
</div>

<script>
  $(document).ready(function() {
    var viewer = $3Dmol.createViewer("Model", {defaultcolors: $3Dmol.elementColors.Jmol});
    var xyz_data = `1
test
N 0.0 0.0 0.0
1
test
N 0.0 0.0 0.0`;
    viewer.addModelsAsFrames(xyz_data, "xyz");
    viewer.setStyle({}, {stick: {radius: 0.15},sphere: {scale: 0.25}});
    viewer.zoomTo();
    viewer.setViewStyle({style: 'outline', color: 'black', width: 0.02});
    viewer.render();
});	
</script>

While using addModel gives the correct jmol color:
jmol


<div style="text-align: center;">
        <div id="Model" style="width: 500px; height: 500px;"></div>
</div>

<script>
  $(document).ready(function() {
    var viewer = $3Dmol.createViewer("Model", {defaultcolors: $3Dmol.elementColors.Jmol});
    var xyz_data = `1
test
N 0.0 0.0 0.0`;
    viewer.addModel(xyz_data, "xyz");
    viewer.setStyle({}, {stick: {radius: 0.15},sphere: {scale: 0.25}});
    viewer.zoomTo();
    viewer.setViewStyle({style: 'outline', color: 'black', width: 0.02});
    viewer.render();
});	
</script>

Expected behavior

defaultcolors should be applied to models added using addModelsAsFrames

@dsvatunek dsvatunek added the bug label Jan 29, 2024
dkoes added a commit that referenced this issue Jan 29, 2024
Options were not being set correctly for any of the multimodel addModel
variants.  They are now.
@dkoes
Copy link
Contributor

dkoes commented Jan 29, 2024

Thanks for the complete bug report! Fixed in the above commit:
https://3dmol.org/tests/auto/generate_test.cgi?test=defaultcolors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants