rhetorical
This commit is contained in:
parent
aa4046e7dc
commit
4525ab50ff
12 changed files with 138 additions and 2 deletions
|
|
@ -23,6 +23,11 @@ drag_camera={
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[layer_names]
|
||||||
|
|
||||||
|
3d_physics/layer_1="Drag"
|
||||||
|
3d_physics/layer_2="Interaction"
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
renderer/rendering_method="mobile"
|
renderer/rendering_method="mobile"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://bjxjcx2qu16q5"]
|
[gd_scene load_steps=7 format=3 uid="uid://bjxjcx2qu16q5"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_vcwhe"]
|
[ext_resource type="Script" uid="uid://bjnv2g1ni0525" path="res://src/drag/draggable_object.gd" id="1_vcwhe"]
|
||||||
|
[ext_resource type="Script" uid="uid://ctu7escah5lo1" path="res://src/interactible/interaction_source.gd" id="2_627mb"]
|
||||||
|
[ext_resource type="Script" uid="uid://e8xu57ewvb5a" path="res://src/interactible/proximity_rotator.gd" id="3_00eeh"]
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_vcwhe"]
|
||||||
radius = 0.49570328
|
radius = 0.49570328
|
||||||
|
|
@ -21,9 +23,17 @@ script = ExtResource("1_vcwhe")
|
||||||
shape = SubResource("SphereShape3D_vcwhe")
|
shape = SubResource("SphereShape3D_vcwhe")
|
||||||
|
|
||||||
[node name="InteractionArea" type="Area3D" parent="."]
|
[node name="InteractionArea" type="Area3D" parent="."]
|
||||||
|
script = ExtResource("2_627mb")
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractionArea"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="InteractionArea"]
|
||||||
shape = SubResource("CapsuleShape3D_vcwhe")
|
shape = SubResource("CapsuleShape3D_vcwhe")
|
||||||
|
|
||||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
mesh = SubResource("CylinderMesh_627mb")
|
mesh = SubResource("CylinderMesh_627mb")
|
||||||
|
|
||||||
|
[node name="ProximityRotator" type="Node" parent="."]
|
||||||
|
script = ExtResource("3_00eeh")
|
||||||
|
|
||||||
|
[connection signal="drag_ended" from="." to="InteractionArea" method="request_interaction"]
|
||||||
|
[connection signal="interaction_reciever_entered" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_entered"]
|
||||||
|
[connection signal="interaction_reciever_exited" from="InteractionArea" to="ProximityRotator" method="_on_interaction_area_interaction_reciever_exited"]
|
||||||
|
|
|
||||||
20
scenes/interactible_object.tscn
Normal file
20
scenes/interactible_object.tscn
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
[gd_scene load_steps=4 format=3 uid="uid://q1y0r2rn0qb4"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://mjx50qh1bwv3" path="res://src/interactible/interaction_reciever.gd" id="1_auicg"]
|
||||||
|
|
||||||
|
[sub_resource type="CylinderMesh" id="CylinderMesh_nql6a"]
|
||||||
|
height = 0.75
|
||||||
|
|
||||||
|
[sub_resource type="CylinderShape3D" id="CylinderShape3D_auicg"]
|
||||||
|
height = 1.0
|
||||||
|
radius = 0.75
|
||||||
|
|
||||||
|
[node name="InteractibleObject" type="Area3D"]
|
||||||
|
script = ExtResource("1_auicg")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||||
|
mesh = SubResource("CylinderMesh_nql6a")
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5867026, 0)
|
||||||
|
shape = SubResource("CylinderShape3D_auicg")
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://c7r4rhgj3ucao"]
|
[gd_scene load_steps=6 format=3 uid="uid://c7r4rhgj3ucao"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bjxjcx2qu16q5" path="res://scenes/draggable_object.tscn" id="1_bb6uc"]
|
[ext_resource type="PackedScene" uid="uid://bjxjcx2qu16q5" path="res://scenes/draggable_object.tscn" id="1_bb6uc"]
|
||||||
[ext_resource type="Script" uid="uid://crjao0jjv5yqs" path="res://src/drag/draggable_camera.gd" id="1_hem3r"]
|
[ext_resource type="Script" uid="uid://crjao0jjv5yqs" path="res://src/drag/draggable_camera.gd" id="1_hem3r"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dfxlr4svnsdyx" path="res://scenes/ui.tscn" id="3_hflkp"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://q1y0r2rn0qb4" path="res://scenes/interactible_object.tscn" id="4_f680m"]
|
||||||
|
|
||||||
[sub_resource type="BoxMesh" id="BoxMesh_cbcd7"]
|
[sub_resource type="BoxMesh" id="BoxMesh_cbcd7"]
|
||||||
size = Vector3(3.535, 1, 1)
|
size = Vector3(3.535, 1, 1)
|
||||||
|
|
@ -20,3 +22,11 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.236948, 0.9448395, 0.00390
|
||||||
|
|
||||||
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 0.8403207, 0.5420896, 0, -0.5420896, 0.8403207, 0, 1.9293891, 0)
|
transform = Transform3D(1, 0, 0, 0, 0.8403207, 0.5420896, 0, -0.5420896, 0.8403207, 0, 1.9293891, 0)
|
||||||
|
|
||||||
|
[node name="UI" type="CanvasLayer" parent="."]
|
||||||
|
layer = 100
|
||||||
|
|
||||||
|
[node name="UserInterface" parent="UI" instance=ExtResource("3_hflkp")]
|
||||||
|
|
||||||
|
[node name="InteractibleObject" parent="." instance=ExtResource("4_f680m")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.11957906, 0.7987209, 0.07669878)
|
||||||
|
|
|
||||||
22
scenes/ui.tscn
Normal file
22
scenes/ui.tscn
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
[gd_scene format=3 uid="uid://dfxlr4svnsdyx"]
|
||||||
|
|
||||||
|
[node name="UserInterface" type="Control"]
|
||||||
|
layout_mode = 3
|
||||||
|
anchors_preset = 15
|
||||||
|
anchor_right = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
metadata/_edit_lock_ = true
|
||||||
|
|
||||||
|
[node name="TabBar" type="TabBar" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 10
|
||||||
|
anchor_right = 1.0
|
||||||
|
offset_bottom = 31.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
deselect_enabled = true
|
||||||
|
tab_count = 2
|
||||||
|
tab_0/title = "Реагенты"
|
||||||
|
tab_1/title = "Отчёт"
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
extends Area3D
|
extends Area3D
|
||||||
|
|
||||||
|
signal drag_started
|
||||||
|
signal drag_ended
|
||||||
|
|
||||||
var mouse_in: bool = false
|
var mouse_in: bool = false
|
||||||
var dragged: bool = false
|
var dragged: bool = false
|
||||||
|
|
@ -21,5 +23,7 @@ func _input(event: InputEvent) -> void:
|
||||||
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT:
|
||||||
if mouse_in and event.pressed:
|
if mouse_in and event.pressed:
|
||||||
dragged = true
|
dragged = true
|
||||||
|
drag_started.emit()
|
||||||
if event.pressed == false:
|
if event.pressed == false:
|
||||||
dragged = false
|
dragged = false
|
||||||
|
drag_ended.emit()
|
||||||
|
|
|
||||||
17
src/interactible/interaction_reciever.gd
Normal file
17
src/interactible/interaction_reciever.gd
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
extends Area3D
|
||||||
|
|
||||||
|
class_name InteractionReciever
|
||||||
|
|
||||||
|
signal interacted(source: InteractionSource)
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
area_entered.connect(on_area_entered)
|
||||||
|
area_exited.connect(on_area_exited)
|
||||||
|
|
||||||
|
func on_area_entered(area: Area3D):
|
||||||
|
if area is InteractionSource:
|
||||||
|
area.interaction_requested.connect(interacted.emit)
|
||||||
|
|
||||||
|
func on_area_exited(area: Area3D):
|
||||||
|
if area is InteractionSource:
|
||||||
|
area.interaction_requested.disconnect(interacted.emit)
|
||||||
1
src/interactible/interaction_reciever.gd.uid
Normal file
1
src/interactible/interaction_reciever.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://mjx50qh1bwv3
|
||||||
22
src/interactible/interaction_source.gd
Normal file
22
src/interactible/interaction_source.gd
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
extends Area3D
|
||||||
|
|
||||||
|
class_name InteractionSource
|
||||||
|
|
||||||
|
signal interaction_requested
|
||||||
|
signal interaction_reciever_entered(reicever: InteractionReciever)
|
||||||
|
signal interaction_reciever_exited(reicever: InteractionReciever)
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
area_entered.connect(on_area_entered)
|
||||||
|
area_exited.connect(on_area_exited)
|
||||||
|
|
||||||
|
func on_area_entered(area: Area3D):
|
||||||
|
if area is InteractionReciever:
|
||||||
|
interaction_reciever_entered.emit(area)
|
||||||
|
|
||||||
|
func on_area_exited(area: Area3D):
|
||||||
|
if area is InteractionReciever:
|
||||||
|
interaction_reciever_exited.emit(area)
|
||||||
|
|
||||||
|
func request_interaction() -> void:
|
||||||
|
interaction_requested.emit()
|
||||||
1
src/interactible/interaction_source.gd.uid
Normal file
1
src/interactible/interaction_source.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://ctu7escah5lo1
|
||||||
23
src/interactible/proximity_rotator.gd
Normal file
23
src/interactible/proximity_rotator.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
@export var rotated: Node3D
|
||||||
|
@onready var start_rotation = rotated.quaternion
|
||||||
|
var reiciever: InteractionReciever
|
||||||
|
|
||||||
|
func _on_interaction_area_interaction_reciever_entered(reicever: InteractionReciever) -> void:
|
||||||
|
if self.reicever == null:
|
||||||
|
self.reciever = reicever
|
||||||
|
|
||||||
|
|
||||||
|
func _on_interaction_area_interaction_reciever_exited(reicever: InteractionReciever) -> void:
|
||||||
|
if self.reicever == reicever:
|
||||||
|
self.reciever = null
|
||||||
|
|
||||||
|
func _process(_delta: float) -> void:
|
||||||
|
if reiciever == null:
|
||||||
|
rotated.quaternion = start_rotation
|
||||||
|
|
||||||
|
var camera: Camera3D = get_viewport().get_camera_3d()
|
||||||
|
var angle_to: Quaternion = Quaternion(-camera.basis.z,1.5707963267948966)
|
||||||
|
var calculated_angle: Quaternion = start_rotation.slerp()
|
||||||
|
rotated.quaternion = calculated_angle
|
||||||
1
src/interactible/proximity_rotator.gd.uid
Normal file
1
src/interactible/proximity_rotator.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://e8xu57ewvb5a
|
||||||
Loading…
Add table
Add a link
Reference in a new issue