diff --git a/app/addons/godot-xr-tools/hands/animations/left/hand_blend_tree.tres b/app/addons/godot-xr-tools/hands/animations/left/hand_blend_tree.tres index ae6f20a..011abdb 100644 --- a/app/addons/godot-xr-tools/hands/animations/left/hand_blend_tree.tres +++ b/app/addons/godot-xr-tools/hands/animations/left/hand_blend_tree.tres @@ -29,4 +29,4 @@ nodes/OpenHand/node = SubResource("4") nodes/OpenHand/position = Vector2(-600, 100) nodes/Trigger/node = SubResource("5") nodes/Trigger/position = Vector2(-360, 20) -node_connections = [&"output", 0, &"Grip", &"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1"] +node_connections = [&"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1", &"output", 0, &"Grip"] diff --git a/app/addons/godot-xr-tools/hands/animations/right/hand_blend_tree.tres b/app/addons/godot-xr-tools/hands/animations/right/hand_blend_tree.tres index f56fb58..f1d41a1 100644 --- a/app/addons/godot-xr-tools/hands/animations/right/hand_blend_tree.tres +++ b/app/addons/godot-xr-tools/hands/animations/right/hand_blend_tree.tres @@ -29,4 +29,4 @@ nodes/OpenHand/node = SubResource("3") nodes/OpenHand/position = Vector2(-600, 100) nodes/Trigger/node = SubResource("5") nodes/Trigger/position = Vector2(-360, 40) -node_connections = [&"output", 0, &"Grip", &"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1"] +node_connections = [&"Grip", 0, &"Trigger", &"Grip", 1, &"ClosedHand2", &"Trigger", 0, &"OpenHand", &"Trigger", 1, &"ClosedHand1", &"output", 0, &"Grip"] diff --git a/app/content/system/house/house.gd b/app/content/system/house/house.gd index c5517fa..d7891c0 100644 --- a/app/content/system/house/house.gd +++ b/app/content/system/house/house.gd @@ -6,7 +6,7 @@ const RoomType = preload ("./room/room.gd") @onready var levels = $Levels @onready var collision_shape = $Levels/CollisionShape3D @onready var align_reference = $AlignReference -@onready var mini_view = $Miniature +@onready var mini_view = $Levels/Miniature var fixing_reference: bool = false var editing_room: RoomType = null @@ -23,7 +23,7 @@ func update_house(): align_reference.update_align_reference() - for index in range(Store.house.state.rooms.size() - 1, -1, -1): + for index in range(Store.house.state.rooms.size()): var new_room = Store.house.state.rooms[index] if new_room.corners.size() == 0: diff --git a/app/content/system/house/house.tscn b/app/content/system/house/house.tscn index aad1919..17f7d78 100644 --- a/app/content/system/house/house.tscn +++ b/app/content/system/house/house.tscn @@ -23,8 +23,8 @@ script = ExtResource("2_w1auk") restricted = true lock_rotation = true +[node name="Miniature" parent="Levels" instance=ExtResource("4_qjbly")] + [node name="AlignReference" parent="." instance=ExtResource("3_e1tcn")] visible = false disabled = true - -[node name="Miniature" parent="." instance=ExtResource("4_qjbly")] diff --git a/app/content/system/house/mini/miniature.gd b/app/content/system/house/mini/miniature.gd index 7cd4b08..3efc769 100644 --- a/app/content/system/house/mini/miniature.gd +++ b/app/content/system/house/mini/miniature.gd @@ -3,63 +3,88 @@ extends Node3D const ConstructRoomMesh = preload ("res://lib/utils/mesh/construct_room_mesh.gd") const wall_material = preload ("./mini_wall.tres") +@onready var body = $Body +@onready var model = $Body/Model @onready var walls_mesh = $Body/Model/WallsMesh @onready var floor_mesh = $Body/Model/FloorMesh @onready var collision_shape = $Body/CollisionShape3D -@onready var toggle_heatmap = $HeatmapButton +@onready var toggle_heatmap = $Body/HeatmapButton # var temperature_scale := Vector2( - 20.0, 60.0) -var temperature_scale := Vector2(22.0, 25.0) +var temperature_scale := Vector2(22.0, 26.0) -var enabled = true: - set(value): - enabled = value - update() +var heatmap = R.state(false) +var small = R.state(false) func _ready(): - update() - if Store.house.is_loaded() == false: await Store.house.on_loaded - if Store.house.state.rooms.size() == 0: - return + R.effect(func(_arg): + if Store.house.state.rooms.size() == 0: + return - var room = Store.house.state.rooms[0] + if heatmap.value == false: + return - var corners = room.corners - var height = room.height + for room in Store.house.state.rooms: + var corners=room.corners + var height=room.height - walls_mesh.mesh = ConstructRoomMesh.generate_wall_mesh_grid(corners, height) - floor_mesh.mesh = ConstructRoomMesh.generate_ceiling_mesh_grid(corners) + walls_mesh.mesh=ConstructRoomMesh.generate_wall_mesh_grid(corners, height) + floor_mesh.mesh=ConstructRoomMesh.generate_ceiling_mesh_grid(corners) - walls_mesh.material_override = wall_material - floor_mesh.material_override = wall_material - - active = true - EventSystem.on_slow_tick.connect(update_data) - - toggle_heatmap.on_button_down.connect(func(): - active=true - EventSystem.on_slow_tick.connect(update_data) + walls_mesh.material_override=wall_material + floor_mesh.material_override=wall_material ) - toggle_heatmap.on_button_up.connect(func(): - wall_material.set_shader_parameter("data", []) - wall_material.set_shader_parameter("data_size", 0) - active=false - EventSystem.on_slow_tick.disconnect(update_data) + R.bind(toggle_heatmap, "active", heatmap, toggle_heatmap.on_toggled) + + R.effect(func(_arg): + var tween:=create_tween() + tween.set_parallel(true) + if small.value: + + var aabb=House.body.get_level_aabb(0) + aabb.position.y=- 0.03 + aabb.size.y=0.06 + + var center=aabb.position + aabb.size / 2 + + collision_shape.shape.size=aabb.size * 0.1 + + var camera=$"/root/Main/XROrigin3D/XRCamera3D" + var camera_position=camera.global_position + var camera_direction=- camera.global_transform.basis.z + + camera_position.y *= 0.5 + camera_direction.y=0 + + var target_position=camera_position + camera_direction.normalized() * 0.2 + var new_position=target_position - center * 0.1 + + tween.tween_property(model, "scale", Vector3(0.1, 0.1, 0.1), 0.5) + tween.tween_property(body, "position", new_position, 0.5) + else: + tween.tween_property(model, "scale", Vector3(1, 1, 1), 0.5) + tween.tween_property(body, "position", Vector3(0, 0, 0), 0.5) ) -func update(): - walls_mesh.visible = enabled - floor_mesh.visible = enabled - collision_shape.disabled = not enabled + R.effect(func(_arg): + walls_mesh.visible=heatmap.value + floor_mesh.visible=heatmap.value + collision_shape.disabled=!heatmap.value + + if heatmap.value: + EventSystem.on_slow_tick.connect(update_data) + else: + EventSystem.on_slow_tick.disconnect(update_data) + wall_material.set_shader_parameter("data", []) + wall_material.set_shader_parameter("data_size", 0) + ) const SensorEntity = preload ("res://content/entities/sensor/sensor.gd") -var active: bool = false - func update_data(_delta: float) -> void: var data_list = [] diff --git a/app/content/system/house/mini/miniature.tscn b/app/content/system/house/mini/miniature.tscn index 1ae4bd5..eba1d0d 100644 --- a/app/content/system/house/mini/miniature.tscn +++ b/app/content/system/house/mini/miniature.tscn @@ -9,9 +9,6 @@ [node name="Miniature" type="Node3D"] script = ExtResource("1_b53yn") -[node name="HeatmapButton" parent="." instance=ExtResource("3_tgdcf")] -toggleable = true - [node name="Body" type="StaticBody3D" parent="."] [node name="CollisionShape3D" type="CollisionShape3D" parent="Body"] @@ -27,3 +24,8 @@ skeleton = NodePath("../../..") [node name="FloorMesh" type="MeshInstance3D" parent="Body/Model"] skeleton = NodePath("../../..") + +[node name="HeatmapButton" parent="Body" instance=ExtResource("3_tgdcf")] +label = "heat" +icon = true +toggleable = true diff --git a/app/content/ui/components/button/button.gd b/app/content/ui/components/button/button.gd index 71ccca3..4fc6ff9 100644 --- a/app/content/ui/components/button/button.gd +++ b/app/content/ui/components/button/button.gd @@ -5,6 +5,7 @@ class_name Button3D signal on_button_down() signal on_button_up() +signal on_toggled(active: bool) const IconFont = preload ("res://assets/icons/icons.tres") const ECHO_WAIT_INITIAL = 0.5 @@ -57,6 +58,8 @@ const ECHO_WAIT_REPEAT = 0.1 var active: bool = false: set(value): + if active != value: + on_toggled.emit(value) active = value if !is_inside_tree(): return update_animation(1.0 if active else 0.0) diff --git a/app/content/ui/menu/view/view_menu.gd b/app/content/ui/menu/view/view_menu.gd index 4324da8..0eab8fb 100644 --- a/app/content/ui/menu/view/view_menu.gd +++ b/app/content/ui/menu/view/view_menu.gd @@ -7,5 +7,5 @@ func _ready(): background.visible = false mini_view.on_button_down.connect(func(): - House.body.mini_view.enabled=!House.body.mini_view.enabled + House.body.mini_view.small.value=!House.body.mini_view.small.value )