Draw dots in 3D space

Awesome! thanks! I tried it out and it worked.
I played with the code and some parameters (dots size and positions). I can see that dots speed increases when it get closer to the viewer. However, their size doesn’t increase when they move towards the viewer.In fact, the size remains the same. I expected the distance to be a function of both the speed and the size. Do you think it’s something I should do manually ?

#Monitor settings
widthPix = 1920 # screen width in px
heightPix = 1080 # screen height in px
monitorwidth = 53.1 # monitor width in cm
viewdist = 60. # viewing distance in cm
monitorname = 'BOE CQ LCD'
scrn = 0 # 0 to use main screen, 1 to use external screen
mon = monitors.Monitor(monitorname, width=monitorwidth, distance=viewdist)
mon.setSizePix((widthPix, heightPix))



scrDist = 0.50  # 50cm
scrWidth = 0.53  # 53cm
scrAspect = 1.0

# Create a window

win = psychopy.visual.Window(
    monitor=mon, 
    size=(1000, 800),
    color='Black',
    colorSpace='rgb',
    units='deg',
    screen=scrn,
    allowGUI=True,
    fullscr=False)

#Frustum
frustum = vt.computeFrustum(scrWidth, scrAspect, scrDist, nearClip=0.1, farClip=10000.0)
P = vt.perspectiveProjectionMatrix(*frustum)

# Transformation for points (model/view matrix)
MV = mt.translationMatrix((0.0, 0.0, -scrDist))  # X, Y, Z

win.projectionMatrix = P
win.viewMatrix = MV

# create array of random points
nPoints = 900
pos = np.zeros((nPoints, 3), dtype=np.float32)

# random X, Y
pos[:, :2] = np.random.uniform(-500, 500, (nPoints, 2))
# random Z to far clipping plane, -1000.0 is -farClip
pos[:, 2] = np.random.uniform(0.0, -1000.0, (nPoints,))

while 1:
    # --- render loop ---
    win.applyEyeTransform()
    # draw 3D stuff here
    GL.glColor3f(1.0, 1.0, 1.0)
    GL.glPointSize(5.0);
    
    GL.glBegin(GL.GL_POINTS)
    for i in range(nPoints):   # go over our array and draw the points using the coordinates
        # color can be varied with distance if you like
        GL.glVertex3f(*pos[i, :])  # position

    GL.glEnd()

    win.flip()

    # transform points -Z direction, in OpenGL -Z coordinates are forward
    pos[:, 2] += 5.0  # distance to move the dots per frame towards the viewer

    # if a point its behind us, return to initial -Z position
    pos[:, 2] = np.where(pos[:, 2] > 0.0, -1000.0, pos[:, 2])

   # check events to break out of the loop!

    if len(event.getKeys())>0:
        break
    event.clearEvents()
    
win.close()