Skip to content

Commit

Permalink
made Sky parent to camera and set world_rotation to 0 instead of sett…
Browse files Browse the repository at this point in the history
…ing the position every frame, to avoid the one frame delay when moving the camera. moving the camera too fast could result in the sky dome clipping through the far clip plane. also improved how the scale is determined.
  • Loading branch information
pokepetter committed Oct 15, 2023
1 parent f32184c commit d94a7f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions ursina/prefabs/sky.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,29 @@ class Sky(Entity):

def __init__(self, **kwargs):
from ursina.shaders import unlit_shader
super().__init__(parent=render, name='sky', model='sky_dome', texture='sky_default', scale=9900, shader=unlit_shader)
super().__init__(parent=camera, name='sky', model='sky_dome', texture='sky_default', scale=9900, shader=unlit_shader)

for key, value in kwargs.items():
setattr(self, key, value)


def update(self):
self.world_position = camera.world_position
self.scale = camera.clip_plane_far / 2
self.world_rotation = Vec3(0,0,0)
self.scale = camera.clip_plane_far * .95

if __name__ == '__main__':
app = Ursina()
Sky(texture='sky_sunset')
camera.fov = 90
EditorCamera()

# test
def input(key):
if key == '-':
camera.clip_plane_far -= 100 + (held_keys['control']*10)
print(camera.clip_plane_far)
elif key == '+':
camera.clip_plane_far += 100 + (held_keys['control']*10)
print(camera.clip_plane_far)

app.run()
1 change: 1 addition & 0 deletions ursina/shaders/screenspace_shaders/fxaa.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
# Button(scale=.25, model='circle')
camera.shader = fxaa_shader
camera.clip_plane_far=100
Sky()

def input(key):
if key == 'space':
Expand Down

0 comments on commit d94a7f3

Please sign in to comment.