mirror of
https://github.com/Relintai/material-maker.git
synced 2024-11-13 06:27:18 +01:00
Improve the camera zoom behavior
- Invert the scroll wheel action to be more consistent with most 3D programs out there (Godot, Blender, …). - Clamp the camera distance to reasonable values.
This commit is contained in:
parent
b325d68f96
commit
d7b16b8126
@ -7,6 +7,9 @@ const ENVIRONMENTS = [
|
|||||||
"experiment", "lobby", "night", "park", "schelde"
|
"experiment", "lobby", "night", "park", "schelde"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const CAMERA_DISTANCE_MIN = 1.0
|
||||||
|
const CAMERA_DISTANCE_MAX = 10.0
|
||||||
|
|
||||||
onready var objects = $MaterialPreview/Preview3d/Objects
|
onready var objects = $MaterialPreview/Preview3d/Objects
|
||||||
onready var current_object = objects.get_child(0)
|
onready var current_object = objects.get_child(0)
|
||||||
|
|
||||||
@ -77,9 +80,17 @@ func on_gui_input(event):
|
|||||||
$Config/Rotate.pressed = false
|
$Config/Rotate.pressed = false
|
||||||
match event.button_index:
|
match event.button_index:
|
||||||
BUTTON_WHEEL_UP:
|
BUTTON_WHEEL_UP:
|
||||||
camera.translation.z *= 1.01 if event.shift else 1.1
|
camera.translation.z = clamp(
|
||||||
|
camera.translation.z / (1.01 if event.shift else 1.1),
|
||||||
|
CAMERA_DISTANCE_MIN,
|
||||||
|
CAMERA_DISTANCE_MAX
|
||||||
|
)
|
||||||
BUTTON_WHEEL_DOWN:
|
BUTTON_WHEEL_DOWN:
|
||||||
camera.translation.z /= 1.01 if event.shift else 1.1
|
camera.translation.z = clamp(
|
||||||
|
camera.translation.z * (1.01 if event.shift else 1.1),
|
||||||
|
CAMERA_DISTANCE_MIN,
|
||||||
|
CAMERA_DISTANCE_MAX
|
||||||
|
)
|
||||||
elif event is InputEventMouseMotion:
|
elif event is InputEventMouseMotion:
|
||||||
var motion = 0.01*event.relative
|
var motion = 0.01*event.relative
|
||||||
var camera_basis = camera.global_transform.basis
|
var camera_basis = camera.global_transform.basis
|
||||||
|
Loading…
Reference in New Issue
Block a user