camera: added camera zooming
This commit is contained in:
parent
7fb2d4b1f9
commit
35e193d74f
4 changed files with 21 additions and 1 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
[ext_resource type="Texture2D" uid="uid://wdjmyv260he1" path="res://world/textures/grass.jpg" id="2_272bh"]
|
[ext_resource type="Texture2D" uid="uid://wdjmyv260he1" path="res://world/textures/grass.jpg" id="2_272bh"]
|
||||||
[ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"]
|
[ext_resource type="PackedScene" uid="uid://of6tq8gpjxtu" path="res://gears/gear_pickup.tscn" id="3_lquwl"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"]
|
[ext_resource type="PackedScene" uid="uid://bafl8q0r61xrg" path="res://gears/gear.tscn" id="4_7mycd"]
|
||||||
[ext_resource type="Texture2D" uid="uid://bkq72dydktldv" path="res://world/sky/kloofendal_48d_partly_cloudy_puresky_2k.hdr" id="8_5vw27"]
|
[ext_resource type="Texture2D" uid="uid://bkq72dydktldv" path="res://world/sky/sky.hdr" id="8_5vw27"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_7dm0k"]
|
||||||
size = Vector3(1000, 2, 1000)
|
size = Vector3(1000, 2, 1000)
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@ var locked_mouse_positon = Vector2(0,0)
|
||||||
var mouse_locked = false
|
var mouse_locked = false
|
||||||
var mouse_x_velocity = 0
|
var mouse_x_velocity = 0
|
||||||
var mouse_y_velocity = 0
|
var mouse_y_velocity = 0
|
||||||
|
var zoom_min = 0
|
||||||
|
var zoom_max = 100
|
||||||
|
var current_zoom = 0
|
||||||
|
|
||||||
func reset():
|
func reset():
|
||||||
basis = Basis()
|
basis = Basis()
|
||||||
|
|
@ -23,6 +26,10 @@ func _input(event):
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
mouse_x_velocity = event.relative.x
|
mouse_x_velocity = event.relative.x
|
||||||
mouse_y_velocity = event.relative.y
|
mouse_y_velocity = event.relative.y
|
||||||
|
elif event.is_action_pressed("zoom_in"):
|
||||||
|
current_zoom += 5
|
||||||
|
elif event.is_action_pressed("zoom_out"):
|
||||||
|
current_zoom -= 5
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
# rotate outer gimbal around y axis
|
# rotate outer gimbal around y axis
|
||||||
|
|
@ -57,3 +64,6 @@ func _process(delta):
|
||||||
# reset gimbals
|
# reset gimbals
|
||||||
if Input.is_action_pressed("cam_reset"):
|
if Input.is_action_pressed("cam_reset"):
|
||||||
reset()
|
reset()
|
||||||
|
|
||||||
|
current_zoom = clamp(current_zoom,zoom_min,zoom_max)
|
||||||
|
$InnerGimbal/Camera3D.position = Vector3($InnerGimbal/Camera3D.position.x,current_zoom,current_zoom)
|
||||||
|
|
|
||||||
|
|
@ -92,6 +92,16 @@ shift_lock={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
zoom_in={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
zoom_out={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[layer_names]
|
[layer_names]
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue