Because the lights are objects that apply to each and every object in the 3D environment, they are dealt with like the camera. Open Object. py and modify the code thus:
from LoadMesh import *
..
from Light import *
class Object:
def __init__(self, obj_name):
..
def add_component(self, component):
..)
def get_component(self, class_type):
..
def update(self, camera: Camera,
lights: Light([]), events = None):
self.material.use()
for c in self.components:
if isinstance(c, Transform):
..
transformation.load()
for l in lights:
light_pos = Uniform(“vec3”,
l.position)
light_pos.find_variable(
self.material.program_id,
l.light_variable)
light_pos.load()
light_atten = Uniform(“float”,
l.atten)
light_atten.find_variable(
self.material.program_id,
l.atten_variable)
light_atten.load()
color = Uniform(“vec3”, l.color)
color.find_variable(
self.material.program_id,
l.color_variable)
color.load()
elif isinstance(c, LoadMesh):
c.draw()