-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsun.py
26 lines (19 loc) · 798 Bytes
/
sun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from panda3d.core import DirectionalLight
from ursina import Entity
class SunLight(Entity):
def __init__(self, direction, resolution, car):
super().__init__()
self.car = car
self.resolution = resolution
self.dlight = DirectionalLight("sun")
self.dlight.setShadowCaster(True, self.resolution, self.resolution)
lens = self.dlight.getLens()
lens.setNearFar(-80, 200)
lens.setFilmSize((100, 100))
self.dlnp = render.attachNewNode(self.dlight)
self.dlnp.lookAt(direction)
render.setLight(self.dlnp)
def update(self):
self.dlnp.setPos(self.car.world_position)
def update_resolution(self):
self.dlight.setShadowCaster(True, self.resolution, self.resolution)