world: added grass and sky #5

Merged
jeremy merged 6 commits from devel into master 2026-01-27 10:52:35 +13:00
Showing only changes of commit fced905bae - Show all commits

View file

@ -7,8 +7,10 @@ var locked_mouse_positon = Vector2(0,0)
var mouse_locked = false
var mouse_x_velocity = 0
var mouse_y_velocity = 0
var zoom_min = 4
var zoom_max = 100
var zoom_max = 80
var zoom_speed = 20
var current_zoom = 8
func reset():
@ -27,9 +29,9 @@ func _input(event):
mouse_x_velocity = event.relative.x
mouse_y_velocity = event.relative.y
elif event.is_action_pressed("zoom_out"):
current_zoom += 5
current_zoom += 1
elif event.is_action_pressed("zoom_in"):
current_zoom -= 5
current_zoom -= 1
func _process(delta):
# rotate outer gimbal around y axis
@ -65,4 +67,9 @@ func _process(delta):
reset()
current_zoom = clamp(current_zoom, zoom_min, zoom_max)
$InnerGimbal/Camera3D.position = Vector3($InnerGimbal/Camera3D.position.x, current_zoom, current_zoom)
var pos = Vector3($InnerGimbal/Camera3D.position)
pos.y = lerp(pos.y, float(current_zoom), zoom_speed*delta)
pos.z = lerp(pos.z, float(current_zoom), zoom_speed*delta)

This is great work bro but these last three lines can be improved to something like this:

var p = Vector3($InnerGimbal/Camera3D.position)
p.y = lerp(p.y, float(current_zoom), zoom_speed * delta)
p.z = lerp(p.z, float(current_zoom), zoom_speed * delta)

$InnerGimbal/Camera3D.position = p

Since we instantiate p to be a copy of the Camera3D's position on the first line, we don't need to assign p.x manually. And the lines are shorter so they can fit in an editor without going over the edge 😁

Also we call lerp with p's properties instead of the long name ($InnerGimbal/...). If the path to the Camera3D changes we only need to change one reference where we define p instead of replacing the whole lot.

Also please put spaces on both sides of the asterisks 😁

This is great work bro but these last three lines can be improved to something like this: ```swift var p = Vector3($InnerGimbal/Camera3D.position) p.y = lerp(p.y, float(current_zoom), zoom_speed * delta) p.z = lerp(p.z, float(current_zoom), zoom_speed * delta) $InnerGimbal/Camera3D.position = p ``` Since we instantiate `p` to be a copy of the Camera3D's position on the first line, we don't need to assign `p.x` manually. And the lines are shorter so they can fit in an editor without going over the edge 😁 Also we call lerp with `p`'s properties instead of the long name (`$InnerGimbal/`...). If the path to the Camera3D changes we only need to change one reference where we define `p` instead of replacing the whole lot. Also please put spaces on both sides of the asterisks 😁
$InnerGimbal/Camera3D.position = pos