From ad9245a922340ef7e5a5dd622735e4519cab3959 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Wed, 29 May 2024 22:48:01 +0200 Subject: [PATCH] fix camera --- app/content/entities/camera/camera.gd | 9 ++++++++- app/content/entities/camera/settings.tscn | 9 +++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/content/entities/camera/camera.gd b/app/content/entities/camera/camera.gd index a07509c..ef5fbb3 100644 --- a/app/content/entities/camera/camera.gd +++ b/app/content/entities/camera/camera.gd @@ -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 @@ -33,6 +33,7 @@ func _ready(): ) R.effect(func(_arg): + print("Cam active: ", cam_active.value) if cam_active.value: refresh_timer.start() else: @@ -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 @@ -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, diff --git a/app/content/entities/camera/settings.tscn b/app/content/entities/camera/settings.tscn index 0fa36df..c4cbac9 100644 --- a/app/content/entities/camera/settings.tscn +++ b/app/content/entities/camera/settings.tscn @@ -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_p3rs7"] resource_local_to_scene = true render_priority = 10 shader = ExtResource("2_wwobq") @@ -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_nlygn"] size = Vector2(0.3, 0.2) [sub_resource type="BoxShape3D" id="BoxShape3D_ctomk"] @@ -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_p3rs7") +mesh = SubResource("QuadMesh_nlygn") skeleton = NodePath("../..") size = Vector2(0.3, 0.2) @@ -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)