Specify the sensitivity of scene.mouse.pick?

16 views
Skip to first unread message

Richard Darwin

unread,
Oct 13, 2024, 4:51:07 PM10/13/24
to VPython-users
I have a program that shows local stars in spectral-class colours and radius appropriate to their mass--A stars are bigger spheres than M stars.  However, the small diameter of the M stars makes it very difficult to click on them when I want to display a name-and-type label. Is it possible to adjust the mouse.pick operation (which presumably involves a collision detection of some sort) so that I can click on tiny objects?

Bruce Sherwood

unread,
Oct 13, 2024, 9:16:43 PM10/13/24
to VPython-users
You can't change the picking machinery, but the following does what you want, by enclosing the small sphere inside a large sphere whose opacity is zero:

scene.width = scene.height = 300
scene.background = color.white
scene.range = 1
a = sphere(radius=.01, color=color.red, name='inner')
b = sphere(radius=.2, color=color.cyan, opacity=0, name='outer')

def getevent():
    hit = scene.mouse.pick
    if hit != None:
        print(hit.name)

scene.bind("mousedown", getevent)

Bruce

Richard Darwin

unread,
Oct 13, 2024, 10:33:46 PM10/13/24
to VPython-users
Thanks for the quick turn-around, Bruce.  
Reply all
Reply to author
Forward
0 new messages