@@ -23,26 +23,21 @@ def __init__(self, *args, **kwargs):
2323 self .scene = self ._fresnel (* args , ** kwargs )
2424
2525
26- def interactive (self , intensity = 0.4 , standalone = True ):
26+ def interactive (self , standalone = True ):
2727 """
2828 Conjure up interactive rendering window
2929
3030 Parameters
3131 ----------
32- intensity : float
33- Intensity of extra light for interactive volume rendering
3432 standalone : bool
3533 Set to True if called within standalone script
3634 """
3735
38- self .scene .lights .append (fl .light .Light (direction = [0 ,0 ,1 ],
39- color = [intensity ]* 3 ,
40- theta = np .pi ))
41-
4236 view = interact .SceneView (self .scene )
4337
4438 if standalone :
4539 view .show ()
40+
4641 interact .app .exec_ ()
4742
4843 else :
@@ -92,6 +87,7 @@ def _fresnel(self,
9287 bonds ,
9388 colors ,
9489 radii ,
90+ intensity = 0. ,
9591 metal = 0.4 ,
9692 specular = 0.8 ,
9793 spec_trans = 0.1 ,
@@ -106,10 +102,12 @@ def _fresnel(self,
106102 List of 3D positions of the monomers to be displayed
107103 bonds : Mx2 int array
108104 List of pairwise inter-monomer bonds to be displayed
109- colors : Nx3 or Nx4 float array
110- List of RGB colors to be assigned to each monomer
105+ colors : Nx3 or Nx4 or Mx3 or Mx4 float array
106+ List of RGB colors to be assigned to each monomer or bond
111107 radii : Mx1 float array
112108 List of bond/particle radii
109+ intensity : float
110+ Intensity of extra light for gamma correction
113111 roughness : float
114112 Roughness of the rendering material. Nominally in the range [0.1,1]
115113 metal : float
@@ -134,7 +132,13 @@ def _fresnel(self,
134132 geometry .radius [:] = radii [bonds ].min (axis = 1 )
135133
136134 corrected_colors = fl .color .linear (colors )
137- geometry .color [:] = corrected_colors [bonds ]
135+
136+ if corrected_colors .shape [0 ] == positions .shape [0 ]:
137+ geometry .color [:] = corrected_colors [bonds ]
138+ elif corrected_colors .shape [0 ] == bonds .shape [0 ]:
139+ geometry .color [:] = corrected_colors [:, None , :]
140+ else :
141+ raise ValueError ("Color array does not match particle or bond dimensions" )
138142
139143 geometry .material = fl .material .Material (color = fl .color .linear ([.25 ,.25 ,.25 ]),
140144 roughness = roughness ,
@@ -168,5 +172,6 @@ def _fresnel(self,
168172 geometry2 .outline_material = geometry .outline_material
169173
170174 scene .camera = fl .camera .Orthographic .fit (scene , view = 'isometric' , margin = 0 )
171-
175+ scene .lights .append (fl .light .Light (direction = [0 ,0 ,1 ], color = [intensity ]* 3 , theta = np .pi ))
176+
172177 return scene
0 commit comments