Skip to content

3D plot atoms are black without shading or lighting #53

@Irratzo

Description

@Irratzo

Description

In a Jupyter notebook, ase_view.make_render(atoms), which uses pythreejs (version pythreejs==2.4.2) underneath, paints atoms as black spheres, with no lighting or shading. Plotting the same node with ASE standard viewer instead, in the same Python environment, paints atoms with lighting and shading (ase.visualize.view(atoms, viewer='x3d')). So, this concerns the pythreejs 3D plots, not the SVG 2D plots. Those work without issues. At first glance, it looked as if the ambient light might be missing. See attached screenshot. But that was not it, see below.

Screenshot 2023-06-02 at 16 06 08

Minimal working example (MWE)

Install Python environment as described below.

Then run ase-notebook by. example. In the pythreejs plots, the atoms should appear black, in the SVG plots they appear in the right color.

System & version info

ase-notebook v0.3.1, fork PhilippRue/ase-notebook, latest commit.

Created virtualenv environment for ase-notebook from its setup.py with Python version 3.10.9. Note: Did not install all extras at once (pip install -e ".[threejs,svgconcat,svg2pdf,testing,code_style,flake8_plugins,docs]") casue that led to unresolved environment.

cd ase-notebook
python -m venv venv
source venv/bin/activate

pip install --upgrade pip
pip install -e .
pip install pytest coverage pytest-cov # [testing]
pip install -e ".[threejs,svgoncat,svg2pdf]"
# # only for testing effect of commit 4c856b11 mentioned above
# pip install "importlib_resources<2"

Resulted in environment pip freeze > requirements.txt.

Analysis 1

All tests passed.

$ pytest -v

ase_notebook/color.py::ase_notebook.color.Color PASSED [2%]
[...]
tests/test_backend/test_threejs.py::test_create_arrow_texture PASSED [100%]

The colors are there.

ase_view.get_atom_colors(atoms)
['#DF6633',
 '#DF6633',
 '#DF6633',
 '#DF6633',
 '#FFFF2F',
 '#FFFF2F',
 '#FFFF2F',
 '#FFFF2F',
 '#FFFF2F',
 '#FFFF2F',
 '#FFFF2F',
 '#FFFF2F']

This also means that the underlying data.load_data_file function works irrespective of the removal of dependency importlib_resources in that commit. Tested it with version before and after that change, same behavior.

Currently suspect that it the cause is a newer version with some of the dependencies involved in the 3D plotting, maybe pythreejs, ipywidgets, etc. Will try to downgrade some of them and see if the issue disappears.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions