Merge pull request #91 from Nitwel/gestures
Decouple menu from following hands
This commit is contained in:
commit
8ee72032b3
|
@ -8,6 +8,8 @@ var sky_passthrough = preload("res://assets/materials/sky_passthrough.material")
|
|||
@onready var controller_left = $XROrigin3D/XRControllerLeft
|
||||
@onready var controller_right = $XROrigin3D/XRControllerRight
|
||||
@onready var house = $House
|
||||
@onready var menu = $Menu
|
||||
@onready var keyboard = $Keyboard
|
||||
|
||||
func _ready():
|
||||
# In case we're running on the headset, use the passthrough sky
|
||||
|
@ -18,6 +20,67 @@ func _ready():
|
|||
else:
|
||||
house.visible = true
|
||||
|
||||
controller_left.button_pressed.connect(func(name):
|
||||
_emit_action(name, true, false)
|
||||
)
|
||||
|
||||
controller_right.button_pressed.connect(func(name):
|
||||
_emit_action(name, true, true)
|
||||
)
|
||||
|
||||
controller_left.button_released.connect(func(name):
|
||||
_emit_action(name, false, false)
|
||||
)
|
||||
|
||||
controller_right.button_released.connect(func(name):
|
||||
_emit_action(name, false, true)
|
||||
)
|
||||
|
||||
remove_child(menu)
|
||||
remove_child(keyboard)
|
||||
|
||||
EventSystem.on_action_down.connect(func(action):
|
||||
if action.name == "menu_button":
|
||||
_toggle_menu()
|
||||
)
|
||||
|
||||
EventSystem.on_focus_in.connect(func(event):
|
||||
if keyboard.is_inside_tree():
|
||||
return
|
||||
|
||||
add_child(keyboard)
|
||||
if event.previous_target == null:
|
||||
keyboard.global_transform = menu.get_node("AnimationContainer/KeyboardPlace").global_transform
|
||||
)
|
||||
|
||||
EventSystem.on_focus_out.connect(func(event):
|
||||
if !keyboard.is_inside_tree():
|
||||
return
|
||||
|
||||
remove_child(keyboard)
|
||||
)
|
||||
|
||||
func _toggle_menu():
|
||||
if menu.show_menu == false:
|
||||
add_child(menu)
|
||||
menu.global_transform = _get_menu_transform()
|
||||
menu.show_menu = !menu.show_menu
|
||||
await menu.get_node("AnimationPlayer").animation_finished
|
||||
if menu.show_menu == false:
|
||||
remove_child(menu)
|
||||
|
||||
func _emit_action(name: String, value, right_controller: bool = true):
|
||||
var event = EventAction.new()
|
||||
event.name = name
|
||||
event.value = value
|
||||
event.right_controller = right_controller
|
||||
|
||||
match typeof(value):
|
||||
TYPE_BOOL:
|
||||
EventSystem.emit("action_down" if value else "action_up", event)
|
||||
TYPE_FLOAT, TYPE_VECTOR2:
|
||||
EventSystem.emit("action_value", event)
|
||||
|
||||
func _process(delta):
|
||||
if OS.get_name() != "Android":
|
||||
|
||||
|
@ -34,7 +97,18 @@ func _process(delta):
|
|||
camera.position += movement
|
||||
controller_left.position += movement
|
||||
controller_right.position += movement
|
||||
|
||||
|
||||
func _input(evnet):
|
||||
if Input.is_key_pressed(KEY_M):
|
||||
_toggle_menu()
|
||||
|
||||
func _get_menu_transform():
|
||||
var transform = camera.get_global_transform()
|
||||
transform.origin -= transform.basis.z * 0.5
|
||||
|
||||
transform.basis = transform.basis.rotated(transform.basis.x, deg_to_rad(90))
|
||||
|
||||
return transform
|
||||
|
||||
func vector_key_mapping(key_positive_x: int, key_negative_x: int, key_positive_y: int, key_negative_y: int):
|
||||
var x = 0
|
||||
|
@ -54,4 +128,4 @@ func vector_key_mapping(key_positive_x: int, key_negative_x: int, key_positive_y
|
|||
if vec:
|
||||
vec = vec.normalized()
|
||||
|
||||
return vec
|
||||
return vec
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://eecv28y6jxk4"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://eecv28y6jxk4"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://clc5dre31iskm" path="res://addons/godot-xr-tools/xr/start_xr.tscn" id="1_i4c04"]
|
||||
[ext_resource type="Script" path="res://content/main.gd" id="1_uvrd4"]
|
||||
|
@ -7,16 +7,10 @@
|
|||
[ext_resource type="PackedScene" uid="uid://bsx12q23v8apy" path="res://content/system/hands/hands.tscn" id="4_v8xu6"]
|
||||
[ext_resource type="PackedScene" uid="uid://ctltchlf2j2r4" path="res://addons/xr-simulator/XRSimulator.tscn" id="5_3qc8g"]
|
||||
[ext_resource type="Material" uid="uid://bf5ina366dwm6" path="res://assets/materials/sky.material" id="5_wgwf8"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3kdssrmv84kv" path="res://content/ui/menu/menu.tscn" id="8_du83w"]
|
||||
[ext_resource type="PackedScene" uid="uid://83lb5p4e0qk0" path="res://content/scenes/house.tscn" id="8_qkrg7"]
|
||||
[ext_resource type="PackedScene" uid="uid://lrehk38exd5n" path="res://content/system/keyboard/keyboard.tscn" id="9_e5n3p"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m58yb"]
|
||||
ao_enabled = true
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ir3co"]
|
||||
material = SubResource("StandardMaterial3D_m58yb")
|
||||
size = Vector3(0.01, 0.01, 0.01)
|
||||
|
||||
[sub_resource type="Sky" id="Sky_vhymk"]
|
||||
sky_material = ExtResource("5_wgwf8")
|
||||
|
||||
|
@ -29,10 +23,24 @@ ambient_light_sky_contribution = 0.72
|
|||
ssao_radius = 6.52
|
||||
ssao_intensity = 5.68
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m58yb"]
|
||||
ao_enabled = true
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_ir3co"]
|
||||
material = SubResource("StandardMaterial3D_m58yb")
|
||||
size = Vector3(0.01, 0.01, 0.01)
|
||||
|
||||
[node name="Main" type="Node3D"]
|
||||
transform = Transform3D(1, -0.000296142, 0.000270963, 0.000296143, 1, -4.61078e-06, -0.000270962, 4.67014e-06, 1, 0, 0, 0)
|
||||
script = ExtResource("1_uvrd4")
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_7ghp0")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(0.834925, -0.386727, -0.39159, 0.550364, 0.586681, 0.594058, 2.91038e-11, -0.711511, 0.702675, -2.91038e-10, 7.21041, 2.06458)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="XROrigin3D" type="XROrigin3D" parent="."]
|
||||
|
||||
[node name="XRCamera3D" type="XRCamera3D" parent="XROrigin3D"]
|
||||
|
@ -61,23 +69,19 @@ ray_right = NodePath("../XRControllerRight/Raycast")
|
|||
[node name="StartXR" parent="." instance=ExtResource("1_i4c04")]
|
||||
enable_passthrough = true
|
||||
|
||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]
|
||||
environment = SubResource("Environment_7ghp0")
|
||||
|
||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||
transform = Transform3D(0.834925, -0.386727, -0.39159, 0.550364, 0.586681, 0.594058, 0, -0.711511, 0.702675, 0, 7.21041, 2.06458)
|
||||
shadow_enabled = true
|
||||
|
||||
[node name="XRSimulator" parent="." instance=ExtResource("5_3qc8g")]
|
||||
xr_origin = NodePath("../XROrigin3D")
|
||||
|
||||
[node name="Menu" parent="." instance=ExtResource("8_du83w")]
|
||||
transform = Transform3D(0.999998, -0.000514899, -6.55874e-05, 1.96975e-05, 0.163911, -0.986474, 0.000518685, 0.986474, 0.163911, -0.0165588, 0.796337, -0.634317)
|
||||
|
||||
[node name="Keyboard" parent="." instance=ExtResource("9_e5n3p")]
|
||||
transform = Transform3D(0.499999, -0.000139169, -6.50204e-05, 5.24307e-05, 0.353553, -0.353553, 0.000144383, 0.353553, 0.353553, -0.0199266, 0.550784, -0.47368)
|
||||
|
||||
[node name="House" parent="." instance=ExtResource("8_qkrg7")]
|
||||
transform = Transform3D(0.404247, 0.000180645, 0.914648, 0.00017221, 0.999999, -0.000273614, -0.914648, 0.00026812, 0.404247, -0.343479, 0.000110551, 1.91547)
|
||||
visible = false
|
||||
|
||||
[node name="Keyboard" parent="." instance=ExtResource("9_e5n3p")]
|
||||
transform = Transform3D(0.499999, -6.98142e-12, 0, 4.74065e-12, 0.5, -2.27374e-13, 0, 2.27374e-13, 0.5, -0.125313, 0.424282, -0.263966)
|
||||
|
||||
[node name="Rooms" type="Node3D" parent="."]
|
||||
|
||||
[editable path="XROrigin3D/XRControllerLeft"]
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
[gd_scene load_steps=11 format=3 uid="uid://b30w6tywfj4fp"]
|
||||
[gd_scene load_steps=10 format=3 uid="uid://b30w6tywfj4fp"]
|
||||
|
||||
[ext_resource type="Script" path="res://content/system/controller_left/controller_left.gd" id="1_2j3qs"]
|
||||
[ext_resource type="PackedScene" uid="uid://c3kdssrmv84kv" path="res://content/ui/menu/menu.tscn" id="1_ccbr3"]
|
||||
[ext_resource type="PackedScene" uid="uid://dqjcqdhe3rbtn" path="res://assets/models/trash_bin/trash_bin.gltf" id="3_m33ce"]
|
||||
[ext_resource type="PackedScene" uid="uid://d3f8glx1xgm5w" path="res://content/system/raycast/raycast.tscn" id="4_n7lao"]
|
||||
|
||||
|
@ -103,11 +102,8 @@ script = ExtResource("1_2j3qs")
|
|||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
mesh = SubResource("BoxMesh_ir3co")
|
||||
|
||||
[node name="Menu" parent="." instance=ExtResource("1_ccbr3")]
|
||||
transform = Transform3D(1, -0.000382732, -0.000120985, 8.65898e-05, 0.5, -0.866025, 0.000391948, 0.866025, 0.5, 0.0669508, 0.0876772, -0.101157)
|
||||
|
||||
[node name="trash_bin" parent="." instance=ExtResource("3_m33ce")]
|
||||
transform = Transform3D(0.03, 0, 0, 0, 0.03, 0, 0, 0, 0.03, 0.106903, -0.228617, 0.132214)
|
||||
transform = Transform3D(0.03, 0, 0, 0, 0.03, 0, 0, 0, 0.03, 0.0864577, -0.119983, 0.0462675)
|
||||
|
||||
[node name="Area3D" type="Area3D" parent="trash_bin"]
|
||||
transform = Transform3D(25, 0, 0, 0, 25, 0, 0, 0, 25, 0, 0, 0)
|
||||
|
|
|
@ -20,26 +20,27 @@ collision_mask = 2
|
|||
script = ExtResource("1_maojw")
|
||||
|
||||
[node name="Backspace" parent="." instance=ExtResource("1_xdpwr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.66, 0, 0.02)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.349964, 0, -0.0700361)
|
||||
focusable = false
|
||||
label = "backspace"
|
||||
icon = true
|
||||
metadata/key = 4194308
|
||||
|
||||
[node name="Caps" parent="." instance=ExtResource("1_xdpwr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, 0, 0.15)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.370036, 0, 0.059964)
|
||||
focusable = false
|
||||
label = "keyboard_capslock"
|
||||
icon = true
|
||||
toggleable = true
|
||||
|
||||
[node name="Paste" parent="." instance=ExtResource("1_xdpwr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.66, 0, 0.18)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.349964, 0, 0.089964)
|
||||
focusable = false
|
||||
label = "assignment"
|
||||
icon = true
|
||||
|
||||
[node name="Keys" type="Node3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.310036, 0, -0.090036)
|
||||
script = ExtResource("3_mx544")
|
||||
columns = 11
|
||||
depth_gap = 0.06
|
||||
|
@ -49,11 +50,11 @@ size = Vector3(0.6, 1, 1)
|
|||
script = ExtResource("4_86fct")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.300719, -0.009645, 0.0928761)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0093171, -0.009645, 0.00284005)
|
||||
shape = SubResource("BoxShape3D_k5ib7")
|
||||
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.300719, -0.009645, 0.0928761)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0093171, -0.009645, 0.00284005)
|
||||
material_override = ExtResource("5_8c8rc")
|
||||
mesh = SubResource("BoxMesh_7rntc")
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ extends Node3D
|
|||
const Proxy = preload("res://lib/utils/proxy.gd")
|
||||
const Notification = preload("res://content/ui/components/notification/notification.tscn")
|
||||
|
||||
@onready var _controller := XRHelpers.get_xr_controller(self)
|
||||
|
||||
@onready var nav_view = $AnimationContainer/Navigation/View
|
||||
@onready var nav_edit: Button3D = $AnimationContainer/Navigation/Edit
|
||||
@onready var menu_edit: Node3D = $AnimationContainer/Content/EditMenu
|
||||
|
@ -22,7 +20,7 @@ const Notification = preload("res://content/ui/components/notification/notificat
|
|||
|
||||
var selected_nav = null
|
||||
|
||||
var show_menu := true:
|
||||
var show_menu := false:
|
||||
set(value):
|
||||
show_menu = value
|
||||
if value:
|
||||
|
@ -33,11 +31,6 @@ var show_menu := true:
|
|||
AudioPlayer.play_effect("close_menu")
|
||||
|
||||
func _ready():
|
||||
_controller.button_pressed.connect(func(button):
|
||||
if button == "by_button":
|
||||
show_menu = !show_menu
|
||||
)
|
||||
|
||||
EventSystem.on_notify.connect(func(event: EventNotify):
|
||||
var notification_node = Notification.instantiate()
|
||||
notification_node.text = event.message
|
||||
|
@ -47,10 +40,6 @@ func _ready():
|
|||
child.position += Vector3(0, 0, -0.06)
|
||||
|
||||
notify_place.add_child(notification_node)
|
||||
|
||||
|
||||
|
||||
|
||||
)
|
||||
|
||||
var nav_buttons = [
|
||||
|
|
|
@ -1,13 +1,17 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://c3kdssrmv84kv"]
|
||||
[gd_scene load_steps=16 format=3 uid="uid://c3kdssrmv84kv"]
|
||||
|
||||
[ext_resource type="Script" path="res://content/ui/menu/menu.gd" id="1_ng4u3"]
|
||||
[ext_resource type="Material" uid="uid://bnwimm214q67g" path="res://assets/materials/sec-500.material" id="2_0x5at"]
|
||||
[ext_resource type="Script" path="res://content/functions/movable.gd" id="2_8coxu"]
|
||||
[ext_resource type="PackedScene" uid="uid://crrb0l3ekuotj" path="res://content/ui/menu/edit/edit_menu.tscn" id="4_r2raj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_w4i01"]
|
||||
[ext_resource type="ArrayMesh" uid="uid://cbqhhnknyium2" path="res://assets/immersive_home_panels/immersive_home_panels.obj" id="7_f4u4o"]
|
||||
[ext_resource type="PackedScene" uid="uid://c01gkeldvjwtr" path="res://content/ui/menu/room/room_menu.tscn" id="10_u4i1x"]
|
||||
[ext_resource type="PackedScene" uid="uid://c6r4higceibif" path="res://content/ui/menu/settings/settings_menu.tscn" id="11_7wm6b"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_e1esh"]
|
||||
size = Vector3(0.38, 0.01, 0.32)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ti5t2"]
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_08du6"]
|
||||
|
@ -154,10 +158,18 @@ _data = {
|
|||
"hide_menu": SubResource("Animation_lkh72")
|
||||
}
|
||||
|
||||
[node name="Menu" type="Node3D"]
|
||||
[node name="Menu" type="StaticBody3D"]
|
||||
script = ExtResource("1_ng4u3")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.02, -0.00426685, 1.49012e-08)
|
||||
shape = SubResource("BoxShape3D_e1esh")
|
||||
|
||||
[node name="Movable" type="Node" parent="."]
|
||||
script = ExtResource("2_8coxu")
|
||||
|
||||
[node name="AnimationContainer" type="StaticBody3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.2, 0, -0.15)
|
||||
|
||||
[node name="Background" type="MeshInstance3D" parent="AnimationContainer"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.21, 0, 0.15)
|
||||
|
@ -215,6 +227,11 @@ visible = false
|
|||
|
||||
[node name="NotifyPlace" type="Marker3D" parent="AnimationContainer"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.2, 0, -0.05)
|
||||
gizmo_extents = 0.02
|
||||
|
||||
[node name="KeyboardPlace" type="Marker3D" parent="AnimationContainer"]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.353553, 0.353553, 0, -0.353553, 0.353553, 0.2, 0.130848, 0.45)
|
||||
gizmo_extents = 0.02
|
||||
|
||||
[node name="ImmersiveHomePanels" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(-4.37114e-10, 0, 0.01, 0, 0.01, 0, -0.01, 0, -4.37114e-10, 0.32, 0, -0.0500001)
|
||||
|
|
6
lib/events/event_action.gd
Normal file
6
lib/events/event_action.gd
Normal file
|
@ -0,0 +1,6 @@
|
|||
extends Event
|
||||
class_name EventAction
|
||||
|
||||
var name: String
|
||||
var right_controller: bool
|
||||
var value # Boolean, Float or Vector2
|
|
@ -17,6 +17,10 @@ signal on_ray_leave(event: EventPointer)
|
|||
signal on_key_down(event: EventKey)
|
||||
signal on_key_up(event: EventKey)
|
||||
|
||||
signal on_action_down(event: EventAction)
|
||||
signal on_action_up(event: EventAction)
|
||||
signal on_action_value(event: EventAction)
|
||||
|
||||
signal on_focus_in(event: EventFocus)
|
||||
signal on_focus_out(event: EventFocus)
|
||||
|
||||
|
|
2
lib/utils/gesture/gesture.gd
Normal file
2
lib/utils/gesture/gesture.gd
Normal file
|
@ -0,0 +1,2 @@
|
|||
extends RefCounted
|
||||
|
|
@ -22,6 +22,8 @@ func _ready():
|
|||
|
||||
func _physics_process(_delta):
|
||||
for area in areas_entered.keys():
|
||||
if areas_entered.has(area) == false:
|
||||
return
|
||||
_emit_event("touch_move", area)
|
||||
|
||||
func _on_area_entered(finger_type, area):
|
||||
|
|
Loading…
Reference in New Issue
Block a user