mirror of
https://github.com/godotengine/godot-demo-projects.git
synced 2026-01-06 07:50:22 +01:00
Improve style in many demos (#1263)
This commit is contained in:
@@ -1,26 +1,28 @@
|
||||
extends Camera3D
|
||||
|
||||
|
||||
const ROTATION_COEFF = 0.02
|
||||
|
||||
var _rotation_enabled := false
|
||||
var _rotation_enabled: bool = false
|
||||
var _rotation_pivot: Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
_initialize_pivot.call_deferred()
|
||||
|
||||
|
||||
func _unhandled_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
_rotation_enabled = event.pressed
|
||||
func _unhandled_input(input_event: InputEvent) -> void:
|
||||
if input_event is InputEventMouseButton:
|
||||
if input_event.button_index == MOUSE_BUTTON_RIGHT:
|
||||
_rotation_enabled = input_event.pressed
|
||||
|
||||
return
|
||||
|
||||
if not _rotation_enabled:
|
||||
return
|
||||
|
||||
if event is InputEventMouseMotion:
|
||||
var rotation_delta: float = event.screen_relative.x
|
||||
if input_event is InputEventMouseMotion:
|
||||
var rotation_delta: float = input_event.screen_relative.x
|
||||
_rotation_pivot.rotate(Vector3.UP, -rotation_delta * ROTATION_COEFF)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user