Module Import alias identifier ImportFrom alias ImportFrom alias ImportFrom alias alias alias ImportFrom alias Assign NameStore Str Assign NameStore Str ClassDef bases AttributeLoad NameLoad attr body FunctionDef arguments args NameParam defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword Str keyword Str keyword TupleLoad Num Num Assign AttributeStore NameLoad attr AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad TupleLoad Num Num UnaryOpUSub AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Num keyword AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Num keyword AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Assign NameStore Call NameLoad Str Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Num Expr Call AttributeLoad NameLoad attr keyword NameLoad keyword Str Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Str keyword AttributeLoad NameLoad attr keyword NameLoad Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign NameStore SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index Str Assign AttributeStore NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num Assign AttributeStore NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Slice Num Assign AttributeStore NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Slice Num Num Assign AttributeStore NameLoad attr SubscriptLoad NameLoad ExtSlice Slice Index Num decorator_list FunctionDef arguments args NameParam defaults body Assign NameStore AttributeLoad NameLoad attr Assign NameStore Call AttributeLoad NameLoad attr NameLoad ListLoad TupleLoad Str AttributeLoad NameLoad attr Num TupleLoad Str AttributeLoad NameLoad attr Num TupleLoad Str AttributeLoad NameLoad attr Num Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str AttributeLoad NameLoad attr Assign SubscriptStore NameLoad Index Str BinOpMult AttributeLoad NameLoad attr AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Call AttributeLoad NameLoad attr NameLoad Assign SubscriptStore AttributeLoad NameLoad attr Index Str AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index Str AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index Str TupleLoad Num Num Num Assign SubscriptStore AttributeLoad NameLoad attr Index Str TupleLoad Num Num Num decorator_list FunctionDef arguments args NameParam NameParam defaults body If CompareEq AttributeLoad NameLoad attr Str body If AttributeLoad AttributeLoad NameLoad attr attr body Expr Call AttributeLoad AttributeLoad NameLoad attr attr orelse Expr Call AttributeLoad AttributeLoad NameLoad attr attr decorator_list FunctionDef arguments args NameParam NameParam defaults body AugAssignAdd AttributeStore NameLoad attr Num AugAssignAdd AttributeStore NameLoad attr Num Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr TupleLoad Num Num Num Call NameLoad AttributeLoad NameLoad attr TupleLoad Num Num Num Assign SubscriptStore AttributeLoad NameLoad attr Index Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam defaults body Assign TupleStore NameStore NameStore AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr Num Num NameLoad NameLoad Assign AttributeStore NameLoad attr Call NameLoad Num BinOpDiv NameLoad Call NameLoad NameLoad Num Num Assign SubscriptStore AttributeLoad NameLoad attr Index Str AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body AugAssignSub AttributeStore NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num Assign AttributeStore NameLoad attr Call NameLoad Num AttributeLoad NameLoad attr Assign AttributeStore NameLoad attr Call NameLoad TupleLoad Num Num UnaryOpUSub AttributeLoad NameLoad attr Assign SubscriptStore AttributeLoad NameLoad attr Index Str AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad AttributeLoad NameLoad attr attr Str decorator_list decorator_list If CompareEq NameLoad Str body Assign NameStore Call NameLoad Expr Call AttributeLoad NameLoad attr
N/A N/A numpy np vispy gloo vispy app vispy.util.transforms perspective translate rotate vispy.io load_data_file N/A vertex 
#version 120

uniform mat4 u_model;
uniform mat4 u_view;
uniform mat4 u_projection;
uniform vec3 u_light_position;
uniform vec3 u_light_spec_position;

attribute vec3  a_position;
attribute vec3  a_color;
attribute float a_radius;

varying vec3  v_color;
varying vec4  v_eye_position;
varying float v_radius;
varying vec3  v_light_direction;

void main (void) {
    v_radius = a_radius;
    v_color = a_color;

    v_eye_position = u_view * u_model * vec4(a_position,1.0);
    v_light_direction = normalize(u_light_position);
    float dist = length(v_eye_position.xyz);

    gl_Position = u_projection * v_eye_position;

    // stackoverflow.com/questions/8608844/...
    //  ... resizing-point-sprites-based-on-distance-from-the-camera
    vec4  proj_corner = u_projection * vec4(a_radius, a_radius, v_eye_position.z, v_eye_position.w);  // # noqa
    gl_PointSize = 512.0 * proj_corner.x / proj_corner.w;
}
 N/A fragment 
#version 120

uniform mat4 u_model;
uniform mat4 u_view;
uniform mat4 u_projection;
uniform vec3 u_light_position;
uniform vec3 u_light_spec_position;

varying vec3  v_color;
varying vec4  v_eye_position;
varying float v_radius;
varying vec3  v_light_direction;
void main()
{
    // r^2 = (x - x0)^2 + (y - y0)^2 + (z - z0)^2
    vec2 texcoord = gl_PointCoord* 2.0 - vec2(1.0);
    float x = texcoord.x;
    float y = texcoord.y;
    float d = 1.0 - x*x - y*y;
    if (d <= 0.0)
        discard;

    float z = sqrt(d);
    vec4 pos = v_eye_position;
    pos.z += v_radius*z;
    vec3 pos2 = pos.xyz;
    pos = u_projection * pos;
//    gl_FragDepth = 0.5*(pos.z / pos.w)+0.5;
    vec3 normal = vec3(x,y,z);
    float diffuse = clamp(dot(normal, v_light_direction), 0.0, 1.0);

    // Specular lighting.
    vec3 M = pos2.xyz;
    vec3 O = v_eye_position.xyz;
    vec3 L = u_light_spec_position;
    vec3 K = normalize(normalize(L - M) + normalize(O - M));
    // WARNING: abs() is necessary, otherwise weird bugs may appear with some
    // GPU drivers...
    float specular = clamp(pow(abs(dot(normal, K)), 40.), 0.0, 1.0);
    vec3 v_light = vec3(1., 1., 1.);
    gl_FragColor.rgb = (.15*v_color + .55*diffuse * v_color
                        + .35*specular * v_light);
}
 Canvas N/A N/A app Canvas N/A __init__ N/A N/A self N/A N/A N/A N/A N/A N/A app Canvas __init__ self title Molecular viewer keys interactive size N/A 1200 800 N/A N/A self ps N/A self pixel_scale N/A N/A self translate 40 N/A N/A self program N/A N/A gloo Program vertex fragment N/A N/A self view N/A translate N/A 0 0 N/A N/A self translate N/A N/A self model N/A N/A np eye 4 dtype N/A np float32 N/A N/A self projection N/A N/A np eye 4 dtype N/A np float32 N/A N/A N/A self apply_zoom N/A fname N/A load_data_file molecular_viewer/micelle.npz N/A N/A N/A self load_molecule fname N/A N/A N/A self load_data N/A N/A self theta 0 N/A N/A self phi 0 N/A N/A N/A gloo set_state depth_test True clear_color black N/A N/A self _timer N/A N/A app Timer auto connect N/A self on_timer start True N/A N/A N/A self show N/A load_molecule N/A N/A self fname N/A N/A N/A molecule N/A N/A N/A np load fname N/A molecule N/A N/A self _nAtoms N/A N/A molecule shape N/A 0 N/A N/A self coords N/A molecule N/A N/A N/A 3 N/A N/A self atomsColours N/A molecule N/A N/A N/A 3 6 N/A N/A self atomsScales N/A molecule N/A N/A N/A 6 N/A load_data N/A N/A self N/A N/A N/A n N/A self _nAtoms N/A data N/A N/A np zeros n N/A N/A a_position N/A np float32 3 N/A a_color N/A np float32 3 N/A a_radius N/A np float32 1 N/A N/A data N/A a_position N/A self coords N/A N/A data N/A a_color N/A self atomsColours N/A N/A data N/A a_radius N/A N/A self atomsScales N/A self ps N/A N/A N/A N/A self program bind N/A N/A gloo VertexBuffer data N/A N/A N/A self program N/A u_model N/A self model N/A N/A N/A self program N/A u_view N/A self view N/A N/A N/A self program N/A u_light_position N/A 0.0 0.0 2.0 N/A N/A N/A self program N/A u_light_spec_position N/A -5.0 5.0 -5.0 N/A on_key_press N/A N/A self event N/A N/A N/A N/A N/A event text N/A N/A N/A N/A self timer running N/A N/A N/A N/A N/A self timer stop N/A N/A N/A N/A N/A self timer start N/A on_timer N/A N/A self event N/A N/A N/A N/A self theta 0.25 N/A N/A self phi 0.25 N/A N/A self model N/A N/A np dot N/A rotate N/A self theta N/A 0 0 1 N/A rotate N/A self phi N/A 0 1 0 N/A N/A N/A self program N/A u_model N/A self model N/A N/A N/A self update N/A on_resize N/A N/A self event N/A N/A N/A N/A width height N/A event size N/A apply_zoom N/A N/A self N/A N/A N/A N/A width height N/A self physical_size N/A N/A N/A gloo set_viewport 0 0 width height N/A N/A self projection N/A perspective 25.0 N/A width N/A float height 2.0 100.0 N/A N/A N/A self program N/A u_projection N/A self projection N/A on_mouse_wheel N/A N/A self event N/A N/A N/A N/A self translate N/A N/A event delta N/A 1 N/A N/A self translate N/A max -1 N/A self translate N/A N/A self view N/A translate N/A 0 0 N/A N/A self translate N/A N/A N/A self program N/A u_view N/A self view N/A N/A N/A self update N/A on_draw N/A N/A self event N/A N/A N/A N/A N/A gloo clear N/A N/A N/A N/A self program draw points N/A N/A N/A N/A __name__ __main__ N/A N/A mvc N/A Canvas N/A N/A N/A app run