From be958486b710602d0a696b4bcfbecc051185cf64 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Wed, 17 Apr 2024 20:45:18 +0200 Subject: [PATCH] add quick actions to hand --- app/content/main.tscn | 1 + .../controller_left/controller_left.tscn | 2 +- app/content/system/hands/hands.gd | 32 ++++++++++++++ app/content/system/hands/hands.tscn | 44 ++++++++----------- app/content/system/house/mini/Entity.gd | 2 - 5 files changed, 52 insertions(+), 29 deletions(-) diff --git a/app/content/main.tscn b/app/content/main.tscn index 519f72d..ccad3d5 100644 --- a/app/content/main.tscn +++ b/app/content/main.tscn @@ -72,6 +72,7 @@ ray_right = NodePath("../XRControllerRight/Raycast") enable_passthrough = true [node name="XRSimulator" parent="." instance=ExtResource("5_3qc8g")] +min_camera_height = 0.01 xr_origin = NodePath("../XROrigin3D") [node name="Menu" parent="." instance=ExtResource("8_du83w")] diff --git a/app/content/system/controller_left/controller_left.tscn b/app/content/system/controller_left/controller_left.tscn index 9e2efd1..a18969b 100644 --- a/app/content/system/controller_left/controller_left.tscn +++ b/app/content/system/controller_left/controller_left.tscn @@ -2,7 +2,7 @@ [ext_resource type="Script" path="res://content/system/controller_left/controller_left.gd" id="1_2j3qs"] [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"] +[ext_resource type="PackedScene" uid="uid://dscp8x0ari57n" path="res://content/system/raycast/raycast.tscn" id="4_n7lao"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m58yb"] ao_enabled = true diff --git a/app/content/system/hands/hands.gd b/app/content/system/hands/hands.gd index 00c64b9..33d3dae 100644 --- a/app/content/system/hands/hands.gd +++ b/app/content/system/hands/hands.gd @@ -5,9 +5,16 @@ const Initiator = preload ("res://lib/utils/pointer/initiator.gd") const Finger = preload ("res://lib/utils/touch/finger.gd") const Touch = preload ("res://lib/utils/touch/touch.gd") const Collide = preload ("res://lib/utils/touch/collide.gd") +const Miniature = preload ("res://content/system/house/mini/miniature.gd") +@onready var main = $"/root/Main" @onready var hand_right: OpenXRHand = $XRHandRight @onready var hand_left: OpenXRHand = $XRHandLeft +@onready var palm = $XRHandLeft/Palm +@onready var quick_actions = $XRHandLeft/Palm/QuickActions +@onready var mini_view_button = $XRHandLeft/Palm/QuickActions/MiniView +@onready var temperature_button = $XRHandLeft/Palm/QuickActions/Temperature +@onready var humidity_button = $XRHandLeft/Palm/QuickActions/Humidity @export var ray_left: RayCast3D @export var ray_right: RayCast3D var initiator: Initiator = Initiator.new() @@ -38,6 +45,24 @@ func _ready(): _ready_hand(hand_right) + mini_view_button.on_button_up.connect(func(): + House.body.mini_view.small.value=!House.body.mini_view.small.value + ) + + temperature_button.on_button_up.connect(func(): + if House.body.mini_view.heatmap_type.value == Miniature.HeatmapType.TEMPERATURE: + House.body.mini_view.heatmap_type.value=Miniature.HeatmapType.NONE + else: + House.body.mini_view.heatmap_type.value=Miniature.HeatmapType.TEMPERATURE + ) + + humidity_button.on_button_up.connect(func(): + if House.body.mini_view.heatmap_type.value == Miniature.HeatmapType.HUMIDITY: + House.body.mini_view.heatmap_type.value=Miniature.HeatmapType.NONE + else: + House.body.mini_view.heatmap_type.value=Miniature.HeatmapType.HUMIDITY + ) + func _ready_hand(hand: OpenXRHand): initiator.type = Initiator.Type.HAND_RIGHT if hand == hand_right else Initiator.Type.HAND_LEFT initiator.node = ray_left.get_parent() if hand == hand_left else ray_right.get_parent() @@ -45,7 +70,14 @@ func _ready_hand(hand: OpenXRHand): pointer = Pointer.new(initiator, ray_left if hand == hand_left else ray_right) add_child(pointer) +func _process(_delta): + if main.camera.global_transform.basis.z.dot(palm.global_transform.basis.y) > 0.85: + if quick_actions.is_inside_tree() == false: palm.add_child(quick_actions) + else: + if quick_actions.is_inside_tree(): palm.remove_child(quick_actions) + func _physics_process(_delta): + _process_hand(hand_left) _process_hand(hand_right) func _process_hand(hand: OpenXRHand): diff --git a/app/content/system/hands/hands.tscn b/app/content/system/hands/hands.tscn index 937bda1..6cb3398 100644 --- a/app/content/system/hands/hands.tscn +++ b/app/content/system/hands/hands.tscn @@ -3,6 +3,7 @@ [ext_resource type="Script" path="res://content/system/hands/hands.gd" id="1_c4f76"] [ext_resource type="PackedScene" uid="uid://c0kow4g10wolq" path="res://assets/models/hands_steam/right_hand.glb" id="1_uekbj"] [ext_resource type="PackedScene" uid="uid://dt4ksvogfctkr" path="res://assets/models/hands_steam/left_hand.glb" id="2_n73lt"] +[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_te2p8"] [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3bjtw"] transparency = 1 @@ -12,9 +13,6 @@ albedo_color = Color(1, 1, 1, 0.705882) radius = 0.001 height = 0.02 -[sub_resource type="BoxShape3D" id="BoxShape3D_1pxrt"] -size = Vector3(0.14, 0.0224609, 0.169383) - [sub_resource type="StandardMaterial3D" id="StandardMaterial3D_n27ki"] transparency = 1 albedo_color = Color(1, 1, 1, 0.705882) @@ -82,18 +80,25 @@ monitorable = false transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, 1, 0, 0, 0) shape = SubResource("CapsuleShape3D_dopke") -[node name="AnimatableBody3D" type="AnimatableBody3D" parent="XRHandLeft"] -transform = Transform3D(1, 8.67362e-19, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) -collision_layer = 8 -collision_mask = 8 +[node name="Palm" type="Node3D" parent="XRHandLeft"] +transform = Transform3D(-0.707107, -8.74228e-08, -0.707107, 6.18173e-08, -1, 6.18173e-08, -0.707107, -8.29045e-24, 0.707107, 0.01, -0.04, -5.58794e-09) -[node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandLeft/AnimatableBody3D"] -transform = Transform3D(1, 1.05818e-16, 4.75779e-13, -2.32831e-10, 1, -1.77636e-14, -4.97946e-12, 1.77636e-15, 1, -7.7486e-07, 1.33878e-09, -0.030436) -shape = SubResource("BoxShape3D_1pxrt") -disabled = true +[node name="QuickActions" type="Node3D" parent="XRHandLeft/Palm"] +transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0, 0) -[node name="RemoteTransform3D" type="RemoteTransform3D" parent="XRHandLeft"] -remote_path = NodePath("../AnimatableBody3D") +[node name="MiniView" parent="XRHandLeft/Palm/QuickActions" instance=ExtResource("3_te2p8")] +transform = Transform3D(1, -3.55271e-15, -4.33681e-19, 3.55271e-15, 1, 3.5525e-15, -4.33681e-19, -3.55291e-15, 1, -0.0600001, 0, 0) +label = "nest_multi_room" +icon = true + +[node name="Temperature" parent="XRHandLeft/Palm/QuickActions" instance=ExtResource("3_te2p8")] +label = "device_thermostat" +icon = true + +[node name="Humidity" parent="XRHandLeft/Palm/QuickActions" instance=ExtResource("3_te2p8")] +transform = Transform3D(1, 1.73472e-18, 0, 0, 1, 0, 0, 0, 1, 0.0600001, -5.68873e-13, 0) +label = "humidity_mid" +icon = true [node name="XRHandRight" type="OpenXRHand" parent="."] transform = Transform3D(0.999998, -0.000567105, 2.47889e-11, 0, -4.37113e-08, -0.999999, 0.000567104, 0.999999, -4.37113e-08, 0.264391, 0, 0) @@ -156,18 +161,5 @@ monitorable = false transform = Transform3D(1, -7.45058e-09, -2.22045e-16, 7.45058e-09, 1, 0, 0, 0, 1, 0, 0, 0) shape = SubResource("CapsuleShape3D_dopke") -[node name="AnimatableBody3D" type="AnimatableBody3D" parent="XRHandRight"] -transform = Transform3D(1, 0, 0, 0, 1, 3.55271e-15, 0, -3.55271e-15, 1, 0, 0, 0) -collision_layer = 8 -collision_mask = 8 - -[node name="CollisionShape3D" type="CollisionShape3D" parent="XRHandRight/AnimatableBody3D"] -transform = Transform3D(1, 0, 4.75779e-13, -2.32831e-10, 1, -1.77636e-14, -4.97946e-12, 1.77636e-15, 1, -7.7486e-07, 1.33878e-09, -0.030436) -shape = SubResource("BoxShape3D_1pxrt") -disabled = true - -[node name="RemoteTransform3D" type="RemoteTransform3D" parent="XRHandRight"] -remote_path = NodePath("../AnimatableBody3D") - [editable path="XRHandLeft/left_hand"] [editable path="XRHandRight/right_hand"] diff --git a/app/content/system/house/mini/Entity.gd b/app/content/system/house/mini/Entity.gd index 5c6915a..1629924 100644 --- a/app/content/system/house/mini/Entity.gd +++ b/app/content/system/house/mini/Entity.gd @@ -41,8 +41,6 @@ func _ready(): if Store.house.state.entities.size() == 0: return - print("Updating Dots") - for old_dot in dots.get_children(): dots.remove_child(old_dot) old_dot.free()