@@ -19,19 +19,24 @@ class Fresnel():
1919 """
2020
2121 def __init__ (self , * args , ** kwargs ):
22+
2223 self .scene = self ._fresnel (* args , ** kwargs )
2324
2425
25- def interactive (self , standalone = True ):
26+ def interactive (self , intensity = 0.4 , standalone = True ):
2627 """
2728 Conjure up interactive rendering window
2829
2930 Parameters
3031 ----------
32+ intensity : float
33+ Intensity of extra light for interactive volume rendering
3134 standalone : bool
3235 Set to True if called within standalone script
3336 """
3437
38+ self .scene .lights .append (fl .light .Light (direction = [0 ,0 ,1 ], color = [intensity ]* 3 , theta = np .pi ))
39+
3540 view = interact .SceneView (self .scene )
3641
3742 if standalone :
@@ -85,10 +90,10 @@ def _fresnel(self,
8590 bonds ,
8691 colors ,
8792 radii ,
88- roughness = 0.3 ,
8993 metal = 0.4 ,
9094 specular = 0.8 ,
91- spec_trans = 0. ,
95+ spec_trans = 0.1 ,
96+ roughness = 0.2 ,
9297 outline = 0.05 ):
9398 """
9499 Render individual polymer conformations within IPython notebooks using the Fresnel backend
@@ -123,23 +128,24 @@ def _fresnel(self,
123128
124129 geometry = fl .geometry .Cylinder (scene , N = bonds .shape [0 ], outline_width = outline )
125130
126- geometry .color [:] = colors [bonds ]
127131 geometry .points [:] = positions [bonds ]
128132 geometry .radius [:] = radii [bonds ].min (axis = 1 )
129-
130- geometry .material = fl .material .Material (color = fl .color .linear ([0.25 ,0.25 ,0.25 ]),
133+ geometry .color [:] = fl .color .linear (colors [bonds ].reshape (- 1 , 3 )).reshape ((- 1 , 2 , 3 ))
134+
135+ geometry .material = fl .material .Material (color = fl .color .linear ([.25 ,.25 ,.25 ]),
131136 roughness = roughness ,
132137 metal = metal ,
133138 specular = specular ,
134139 spec_trans = spec_trans ,
135- primitive_color_mix = 1. )
136-
137- geometry .outline_material = fl .material .Material (color = fl .color .linear ([0 .25 ,0 .25 ,0 .25 ]),
140+ primitive_color_mix = 1. ,
141+ solid = 0. )
142+ geometry .outline_material = fl .material .Material (color = fl .color .linear ([.25 ,.25 ,.25 ]),
138143 roughness = 2 * roughness ,
139144 metal = metal ,
140145 specular = specular ,
141146 spec_trans = spec_trans ,
142- primitive_color_mix = 0. , solid = 0. )
147+ primitive_color_mix = 0. ,
148+ solid = 0. )
143149
144150 polymer_mask = np .ones (positions .shape [0 ], dtype = bool )
145151 polymer_mask [bonds ] = False
@@ -149,17 +155,13 @@ def _fresnel(self,
149155 if num_unbound_atoms > 0 :
150156 geometry2 = fl .geometry .Sphere (scene , N = num_unbound_atoms , outline_width = outline )
151157
152- geometry2 .color [:] = colors [polymer_mask ]
153158 geometry2 .radius [:] = radii [polymer_mask ]
154159 geometry2 .position [:] = positions [polymer_mask ]
155-
156- geometry2 .material = fl .material .Material (color = fl .color .linear ([0.25 ,0.25 ,0.25 ]),
157- roughness = roughness ,
158- metal = metal ,
159- specular = specular ,
160- spec_trans = spec_trans ,
161- primitive_color_mix = 1. , solid = 0. )
162-
160+ geometry2 .color [:] = fl .color .linear (colors [polymer_mask ])
161+
162+ geometry2 .material = geometry .material
163+ geometry2 .outline_material = geometry .material .outline_material
164+
163165 scene .camera = fl .camera .Orthographic .fit (scene , view = 'isometric' , margin = 0 )
164166
165167 return scene
0 commit comments