I made a custom gizmo with OpenGL
I want to do something after clicking on points like print("Hello World") and change the color of selected point.
import bpy
import gpu
from gpu_extras import batch
import bgl
from random import random
positions = (
(-1, -1, -1), (+1, -1, -1),
(-1, +1, -1), (+1, +1, -1),
(-1, -1, +1), (+1, -1, +1),
(-1, +1, +1), (+1, +1, +1))
colors = (
(1, 1, 1,1), (1, 1, 1,1),
(1, 1, 1,1), (1, 1, 1,1),
(1, 1, 1,1), (1, 1, 1,1),
(1, 1, 1,1), (1, 1, 1,1))
shader = gpu.shader.from_builtin("3D_FLAT_COLOR")
batch = batch.batch_for_shader(shader, "POINTS", {"pos": positions, "color": colors})
def draw():
shader.bind()
bgl.glPointSize(5)
batch.draw(shader)
bpy.types.SpaceView3D.draw_handler_add(draw, (), "WINDOW", "POST_VIEW")

