Skip to content

Commit

Permalink
Merge pull request #171 from Nitwel/imp2
Browse files Browse the repository at this point in the history
Add door meshes, improve entity settings, disable hand when holding controllers
  • Loading branch information
Nitwel authored May 30, 2024
2 parents cfbd73b + 111a7c2 commit fd8d624
Show file tree
Hide file tree
Showing 24 changed files with 582 additions and 47 deletions.
9 changes: 8 additions & 1 deletion app/content/entities/camera/camera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const Entity = preload ("../entity.gd")
@export var view_width = 0.15

@onready var view = $View
@onready var http_request = $HTTPRequest
@onready var http_request: HTTPRequest = $HTTPRequest
@onready var mesh = $MeshInstance3D
@onready var refresh_timer = $RefreshTimer
@onready var settings = $Settings
Expand Down Expand Up @@ -33,6 +33,7 @@ func _ready():
)

R.effect(func(_arg):
print("Cam active: ", cam_active.value)
if cam_active.value:
refresh_timer.start()
else:
Expand Down Expand Up @@ -69,6 +70,10 @@ func set_state(stateInfo):
refresh_timer.timeout.connect(load_image.bind(url))

func load_image(url: String):
if http_request.get_http_client_status() != HTTPClient.STATUS_DISCONNECTED:
print("HTTP client is busy, skipping")
return

http_request.request("http://192.168.33.33:8123" + url)

var result = await http_request.request_completed
Expand Down Expand Up @@ -115,6 +120,8 @@ func load_image(url: String):
view.pixel_size = pixel_size
mesh.visible = false

print("Loaded image: ", url)

func get_options():
return {
"cam_active": cam_active.value,
Expand Down
9 changes: 5 additions & 4 deletions app/content/entities/camera/settings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_t8xp5"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="5_opf0y"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_smnuk"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_ikxbe"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("2_wwobq")
Expand All @@ -22,7 +22,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02

[sub_resource type="QuadMesh" id="QuadMesh_jill0"]
[sub_resource type="QuadMesh" id="QuadMesh_qfg01"]
size = Vector2(0.3, 0.2)

[sub_resource type="BoxShape3D" id="BoxShape3D_ctomk"]
Expand All @@ -34,8 +34,8 @@ collision_mask = 0
script = ExtResource("1_1ixy6")

[node name="Panel" parent="." instance=ExtResource("1_myvk1")]
material_override = SubResource("ShaderMaterial_smnuk")
mesh = SubResource("QuadMesh_jill0")
material_override = SubResource("ShaderMaterial_ikxbe")
mesh = SubResource("QuadMesh_qfg01")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)

Expand Down Expand Up @@ -82,6 +82,7 @@ horizontal_alignment = 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.01, 0)
label = "videocam_off"
icon = true
toggleable = true

[node name="FPSLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.05, 0)
Expand Down
8 changes: 4 additions & 4 deletions app/content/entities/light/settings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_2gpr3"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="4_upyp3"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_t0vpw"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_00j7x"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("2_m4moa")
Expand All @@ -21,7 +21,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02

[sub_resource type="QuadMesh" id="QuadMesh_s453u"]
[sub_resource type="QuadMesh" id="QuadMesh_3236q"]
size = Vector2(0.3, 0.25)

[sub_resource type="BoxShape3D" id="BoxShape3D_bu024"]
Expand All @@ -34,8 +34,8 @@ script = ExtResource("1_gw2gi")

[node name="Panel" parent="." instance=ExtResource("1_78ups")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -7.45058e-09, 0)
material_override = SubResource("ShaderMaterial_t0vpw")
mesh = SubResource("QuadMesh_s453u")
material_override = SubResource("ShaderMaterial_00j7x")
mesh = SubResource("QuadMesh_3236q")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.25)

Expand Down
8 changes: 4 additions & 4 deletions app/content/entities/line_chart/settings.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="5_ecnnd"]
[ext_resource type="PackedScene" uid="uid://wgnowarejk5y" path="res://content/ui/components/select/select.tscn" id="6_egqee"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_3ewpv"]
[sub_resource type="ShaderMaterial" id="ShaderMaterial_pqb3y"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_vjmg5")
Expand All @@ -22,7 +22,7 @@ shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02

[sub_resource type="QuadMesh" id="QuadMesh_t2fh8"]
[sub_resource type="QuadMesh" id="QuadMesh_b6qk4"]
size = Vector2(0.3, 0.2)

[sub_resource type="BoxShape3D" id="BoxShape3D_53oq0"]
Expand All @@ -34,8 +34,8 @@ collision_mask = 0
script = ExtResource("1_xxfkt")

[node name="Panel" parent="." instance=ExtResource("2_4g761")]
material_override = SubResource("ShaderMaterial_3ewpv")
mesh = SubResource("QuadMesh_t2fh8")
material_override = SubResource("ShaderMaterial_pqb3y")
mesh = SubResource("QuadMesh_b6qk4")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)

Expand Down
36 changes: 36 additions & 0 deletions app/content/entities/media_player/media_player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,40 @@ const Entity = preload ("../entity.gd")
@onready var artist = $PlayingInfo/Artist
@onready var http_request = $PlayingInfo/HTTPRequest
@onready var slider = $Slider
@onready var settings = $Settings

var playing = false
var volume = 50

var show_volume = R.state(true)
var show_image = R.state(true)

# Called when the node enters the scene tree for the first time.
func _ready():
super()

remove_child(settings)

R.effect(func(_arg):
if show_settings.value:
add_child(settings)
elif settings.is_inside_tree():
remove_child(settings)
camera_follower.reset()
App.house.save_all_entities()
)

R.effect(func(_arg):
if show_volume.value:
add_child(slider)
else:
remove_child(slider)
)

R.effect(func(_arg):
logo.visible=show_image.value
)

icon.value = "pause_circle"

var stateInfo = await HomeApi.get_state(entity_id)
Expand Down Expand Up @@ -94,3 +120,13 @@ func load_image(url: String):
var texture = ImageTexture.create_from_image(image)
logo.texture = texture
logo.pixel_size = pixel_size

func get_options():
return {
"show_volume": show_volume.value,
"show_image": show_image.value
}

func set_options(options):
if options.has("show_volume"): show_volume.value = options["show_volume"]
if options.has("show_image"): show_image.value = options["show_image"]
19 changes: 14 additions & 5 deletions app/content/entities/media_player/media_player.tscn
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
[gd_scene load_steps=7 format=3 uid="uid://dyktdg7ggiwl4"]
[gd_scene load_steps=9 format=3 uid="uid://dyktdg7ggiwl4"]

[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="1_8opk3"]
[ext_resource type="Script" path="res://content/entities/media_player/media_player.gd" id="1_ame17"]
[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="3_24ewx"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="3_bguto"]
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_w73hw"]
[ext_resource type="FontVariation" uid="uid://sshfnckriqxn" path="res://assets/icons/icons.tres" id="5_koe28"]
[ext_resource type="PackedScene" uid="uid://cm070pgl3s7gm" path="res://content/entities/media_player/settings.tscn" id="6_iuvm7"]

[sub_resource type="BoxShape3D" id="BoxShape3D_vi3eg"]
size = Vector3(0.23, 0.142768, 0.01)
Expand All @@ -13,6 +15,14 @@ size = Vector3(0.23, 0.142768, 0.01)
collision_mask = 0
script = ExtResource("1_ame17")

[node name="Movable" type="Node" parent="."]
script = ExtResource("3_bguto")
resizable = true

[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")]
script = ExtResource("3_24ewx")
focus_point = NodePath("../Settings")

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.0364514, -0.01)
shape = SubResource("BoxShape3D_vi3eg")
Expand Down Expand Up @@ -56,10 +66,6 @@ pixel_size = 0.001

[node name="HTTPRequest" type="HTTPRequest" parent="PlayingInfo"]

[node name="Movable" type="Node" parent="."]
script = ExtResource("3_bguto")
resizable = true

[node name="Slider" parent="." instance=ExtResource("4_w73hw")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0562844, 0)
max = 100.0
Expand All @@ -74,3 +80,6 @@ text = "volume_up"
font = ExtResource("5_koe28")
font_size = 18
outline_size = 4

[node name="Settings" parent="." instance=ExtResource("6_iuvm7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.27, 0, 0)
30 changes: 30 additions & 0 deletions app/content/entities/media_player/settings.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
extends StaticBody3D

const MediaPlayer = preload ("./media_player.gd")

@onready var close_button: Button3D = $Close
@onready var id_input: Input3D = $IDInput
@onready var volume_button: Button3D = $VolumeButton
@onready var image_button: Button3D = $ImageButton

var media_player: MediaPlayer

func _ready():
media_player = get_parent()

close_button.on_button_up.connect(func():
media_player.show_settings.value=false
)

id_input.text = media_player.entity_id

R.effect(func(_arg):
volume_button.label="check" if media_player.show_volume.value else "close"
)

R.effect(func(_arg):
image_button.label="check" if media_player.show_image.value else "close"
)

R.bind(volume_button, "active", media_player.show_volume, volume_button.on_toggled)
R.bind(image_button, "active", media_player.show_image, image_button.on_toggled)
102 changes: 102 additions & 0 deletions app/content/entities/media_player/settings.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
[gd_scene load_steps=9 format=3 uid="uid://cm070pgl3s7gm"]

[ext_resource type="Script" path="res://content/entities/media_player/settings.gd" id="1_03bil"]
[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="2_kt6qc"]
[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="3_abcrk"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="4_u2igx"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="5_1jm5m"]

[sub_resource type="ShaderMaterial" id="ShaderMaterial_ncmoa"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("3_abcrk")
shader_parameter/color = Color(1, 1, 1, 0.3)
shader_parameter/border_color = Color(1, 1, 1, 1)
shader_parameter/edge_color = Color(0, 0, 0, 1)
shader_parameter/size = Vector2(7.5, 5)
shader_parameter/border_size = 0.01
shader_parameter/border_fade_in = 0.05
shader_parameter/border_fade_out = 0.0
shader_parameter/corner_radius = 0.2
shader_parameter/roughness = 0.3
shader_parameter/grain_amount = 0.02

[sub_resource type="QuadMesh" id="QuadMesh_qm2qb"]
size = Vector2(0.3, 0.2)

[sub_resource type="BoxShape3D" id="BoxShape3D_53oq0"]
size = Vector3(0.3, 0.2, 0.02)

[node name="Settings" type="StaticBody3D"]
script = ExtResource("1_03bil")

[node name="Panel" parent="." instance=ExtResource("2_kt6qc")]
material_override = SubResource("ShaderMaterial_ncmoa")
mesh = SubResource("QuadMesh_qm2qb")
skeleton = NodePath("../..")
size = Vector2(0.3, 0.2)

[node name="Name" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.07, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Media Player Settings"
font_size = 20
outline_size = 0
horizontal_alignment = 0

[node name="Close" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.12, 0.07, 0)
label = "close"
icon = true

[node name="IDLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, 0.03, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "ID:"
font_size = 18
outline_size = 0
horizontal_alignment = 0

[node name="IDInput" parent="." instance=ExtResource("5_1jm5m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.03, 0.03, 0)
disabled = true

[node name="VideoLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.02, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Show Volume:"
font_size = 18
outline_size = 0
horizontal_alignment = 0

[node name="VolumeButton" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.02, 0)
label = "close"
icon = true
toggleable = true

[node name="VideoLabel2" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.07, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Show Image:"
font_size = 18
outline_size = 0
horizontal_alignment = 0

[node name="ImageButton" parent="." instance=ExtResource("4_u2igx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.07, 0)
label = "close"
icon = true
toggleable = true

[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.01)
shape = SubResource("BoxShape3D_53oq0")
15 changes: 13 additions & 2 deletions app/content/system/controller_left/controller_left.gd
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ func _setup_hand():
auto_hand.hand_active_changed.connect(func(hand: int, active: bool):
if hand != 0: return

hand_active=active
hand_active=active&&_is_hand_simulated() == false

$IndexTip/TouchArea/CollisionShape3D.disabled=!active
$IndexTip/TouchArea/CollisionShape3D.disabled=!hand_active
hand_mesh.visible=active
)

Expand Down Expand Up @@ -155,6 +155,17 @@ func _setup_hand():
pointer = Pointer.new(initiator, ray)
add_child(pointer)

func _is_hand_simulated():
var hand_trackers = XRServer.get_trackers(XRServer.TRACKER_HAND)

for tracker in hand_trackers.values():
if tracker.hand != XRPositionalTracker.TrackerHand.TRACKER_HAND_LEFT:
continue

return tracker.hand_tracking_source == XRHandTracker.HAND_TRACKING_SOURCE_CONTROLLER

return false

func _get_entity(node: Node):
if node is Entity:
return node
Expand Down
Loading

0 comments on commit fd8d624

Please sign in to comment.