# Issue with vtkMoleculeMapper and VTK.js

**URL:** https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238
**Category:** Web
**Created:** [February 23, 2021, 5:02pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238 "2021-02-23T17:02:14Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![LunarLanding](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lunarlanding/32/3061_2.png) [@LunarLanding](https://discourse.vtk.org/u/LunarLanding)
#### Post date: [February 23, 2021, 5:02pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/1 "2021-02-23T17:02:14Z")

</div>

Hi, I’m trying to use vtkMoleculeMapper but I get a blank canvas and a javascript error (Jupyter Lab, pyvista & Panel ). Can anyone reproduce this? Most likely I made a mistake setting up the pipeline; I would be grateful for any pointers.

```auto
import vtk

import panel as pn
pn.extension('vtk')

import numpy as np
import pyvista as pv

N=10
a=np.random.rand(N,3)*10
b=pv.wrap(a)

ids=np.ones(N,dtype=np.uint8)
b['atomic_number']=ids
b.set_active_scalars('atomic_number')
poly = b

ps2mf=vtk.vtkPointSetToMoleculeFilter()

ps2mf.SetInputData(poly)

moleculeMapper=vtk.vtkMoleculeMapper()
# moleculeMapper.UseFastSettings()
moleculeMapper.SetRenderAtoms(True)

moleculeMapper.SetInputConnection(ps2mf.GetOutputPort())

mapper = moleculeMapper

actor = vtk.vtkActor()
actor.SetMapper(moleculeMapper)

ren = vtk.vtkRenderer()
ren.AddActor(actor)

ren.ResetCamera()

win = vtk.vtkRenderWindow()
win.AddRenderer(ren)

geom_pane = pn.pane.VTK(win, width=500, height=500)

# should show some molecules, and yet I get on the javascript console:
# Uncaught (in promise) TypeError: t.oglmapper is undefined
# traverseOpaquePass index.js:63
# traverse index.js:27
# traverse index.js:35
# traverse index.js:75
# traverseAllPasses index.js:1066
# u index.js:348
# render index.js:741
# render index.js:57
# l index.js:257

geom_pane

```

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [February 23, 2021, 6:06pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/2 "2021-02-23T18:06:43Z")

</div>

The vtkOpenGLMoleculeMapper is missing from the VTK python wheels, therefore the vtkMoleculeMapper is unable to render.

You can check this:

```python
>>> vtk.vtkOpenGLMoleculeMapper
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'vtkmodules.all' has no attribute 'vtkOpenGLMoleculeMapper'

```

Compare to the vtkOpenGLActor, which is probably present:

```python
>>> vtk.vtkOpenGLActor
<class 'vtkmodules.vtkRenderingOpenGL2.vtkOpenGLActor'>

```

This should be fixed for the next VTK release, but until then the use of molecule rendering requires building VTK from source with the vtkDomainsChemistryOpenGL2 module enabled.

---

<div class="post-metadata">

### Author: ![Sebastien\_Jourdain](https://discourse.vtk.org/user_avatar/discourse.vtk.org/sebastien_jourdain/32/100_2.png) [@Sebastien\_Jourdain](https://discourse.vtk.org/u/Sebastien_Jourdain)
#### Post date: [February 23, 2021, 6:25pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/3 "2021-02-23T18:25:53Z")

</div>

On top of what @dgobbi is saying, I’m not sure Panel/vtk.js will properly handle the conversion of such mapper. But vtk.js can [render molecules](https://kitware.github.io/vtk-js/examples/PDBReader.html) directly if need be but the integration with JupyterLab does not exist.

---

<div class="post-metadata">

### Author: ![LunarLanding](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lunarlanding/32/3061_2.png) [@LunarLanding](https://discourse.vtk.org/u/LunarLanding)
#### Post date: [February 23, 2021, 7:14pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/4 "2021-02-23T19:14:42Z")

</div>

Thanks to both for the clarification. I will look into compiling, or wait.  
Meanwhile I tried the next best method, ‘vtkGlyph3DMapper’. The OpenGL class for this one does exist, however I get the same javascript error. I posted it here: [vtkGlyph3DMapper on Panel + JupyterLab gives javascript error, blank screen](https://discourse.vtk.org/t/vtkglyph3dmapper-on-panel-jupyterlab-gives-javascript-error-blank-screen/5240)

---

<div class="post-metadata">

### Author: ![LunarLanding](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lunarlanding/32/3061_2.png) [@LunarLanding](https://discourse.vtk.org/u/LunarLanding)
#### Post date: [April 23, 2021, 10:40am UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/5 "2021-04-23T10:40:35Z")

</div>

Hi, vtk 9.01 is out, on conda-forge too. However `vtkOpenGLMoleculeMapper` is still not present on the python module. At the time of your reply I assumed vtk was moving the MoleculeMapper into its main code base, but I guess it still requires including the `vtkDomainsChemistryOpenGL2` in the build. Is this the case?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [April 23, 2021, 12:38pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/6 "2021-04-23T12:38:52Z")

</div>

In the main code base, [!7646](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/7646) placed vtkDomainsChemistryOpenGL2 into the default build. But the next release (9.1.0) is still a ways off, several weeks at least, no date has been set.

When building 9.0.1, vtkDomainsChemistryOpenGL2 must still be explicitly enabled in the build.

---

<div class="post-metadata">

### Author: ![LunarLanding](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lunarlanding/32/3061_2.png) [@LunarLanding](https://discourse.vtk.org/u/LunarLanding)
#### Post date: [April 23, 2021, 12:46pm UTC](https://discourse.vtk.org/t/issue-with-vtkmoleculemapper-and-vtk-js/5238/7 "2021-04-23T12:46:36Z")

</div>

Thanks, I’ll keep an eye out for 9.1.0 .
