-
Notifications
You must be signed in to change notification settings - Fork 10
/
camera.gd
39 lines (33 loc) · 1010 Bytes
/
camera.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
extends Camera
onready var line = get_node("../../LineRenderer")
onready var orbit = get_node("../../Orbit")
var mouseDown = false
var orbitSpeed = 0.5
var orbitDir = 0
func _ready():
pass
func _process(delta):
if orbitDir == 0:
orbit.rotate(Vector3(0,1,0), delta * orbitSpeed)
elif orbitDir == 1:
orbit.rotate(Vector3(0,1,0), -delta * orbitSpeed)
if orbitDir == 2:
orbit.rotate(Vector3(1,0,0), delta * orbitSpeed)
if orbitDir == 3:
orbit.rotate(Vector3(1,0,0), -delta * orbitSpeed)
if Input.is_action_just_pressed("ui_up"):
orbitDir = 3
if Input.is_action_just_pressed("ui_down"):
orbitDir = 2
if Input.is_action_just_pressed("ui_left"):
orbitDir = 1
if Input.is_action_just_pressed("ui_right"):
orbitDir = 0
func _input(event):
if event is InputEventMouseButton:
if !event.pressed:
var pickLength = 1
var mousePos = event.position
var from = project_ray_origin(mousePos)
var to = from + project_ray_normal(mousePos) * pickLength
line.points.append(to)