add camera settings

This commit is contained in:
Nitwel 2024-05-27 12:30:43 +02:00
parent 32236f7004
commit 510e9b0c46
7 changed files with 157 additions and 41 deletions

View File

@ -8,8 +8,6 @@ const Entity = preload ("../entity.gd")
@onready var http_request = $HTTPRequest
@onready var mesh = $MeshInstance3D
@onready var refresh_timer = $RefreshTimer
@onready var button = $Button
@onready var slider = $Slider
var cam_active = R.state(false)
var cam_fps = R.state(10)
@ -18,12 +16,6 @@ var cam_fps = R.state(10)
func _ready():
super()
button.on_button_up.connect(func():
cam_active.value=!cam_active.value
)
R.bind(slider, "value", cam_fps, slider.on_value_changed)
R.effect(func(_arg):
refresh_timer.wait_time=1.0 / cam_fps.value
)
@ -31,10 +23,8 @@ func _ready():
R.effect(func(_arg):
if cam_active.value:
refresh_timer.start()
button.label="videocam"
else:
refresh_timer.stop()
button.label="videocam_off"
)
icon.value = "photo_camera"

View File

@ -2,8 +2,8 @@
[ext_resource type="Script" path="res://content/entities/camera/camera.gd" id="1_htxq3"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="2_e2u6o"]
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="3_8whxu"]
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="4_lfexu"]
[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="3_j7lrc"]
[ext_resource type="PackedScene" uid="uid://dejilst6cwqvi" path="res://content/entities/camera/settings.tscn" id="3_qlnvv"]
[sub_resource type="QuadMesh" id="QuadMesh_830bv"]
size = Vector2(0.15, 0.15)
@ -29,19 +29,11 @@ shape = SubResource("BoxShape3D_te0pn")
script = ExtResource("2_e2u6o")
resizable = true
[node name="CameraFollower" type="Node" parent="."]
script = ExtResource("3_j7lrc")
[node name="RefreshTimer" type="Timer" parent="."]
wait_time = 0.1
[node name="Button" parent="." instance=ExtResource("3_8whxu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.1, 0)
label = "videocam_off"
icon = true
[node name="Slider" parent="." instance=ExtResource("4_lfexu")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.02, -0.1, 0)
min = 1.0
max = 30.0
value = 1.0
step = 1.0
label_unit = "FPS"
size = Vector3(0.1, 0.02, 0.01)
[node name="Settings" parent="." instance=ExtResource("3_qlnvv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.24, 0, 0)

View File

@ -0,0 +1,26 @@
extends Node3D
const Camera = preload ("./camera.gd")
@onready var close_button: Button3D = $Close
@onready var id_input: Input3D = $IDInput
@onready var video_button: Button3D = $VideoButton
@onready var fps_slider: Slider3D = $FPSSlider
var camera: Camera
func _ready():
camera = get_parent()
close_button.on_button_up.connect(func():
camera.show_settings.value=false
)
id_input.text = camera.entity_id
R.effect(func(_arg):
video_button.label="videocam" if camera.cam_active.value else "videocam_off"
)
R.bind(video_button, "active", camera.cam_active, video_button.on_toggled)
R.bind(fps_slider, "value", camera.cam_fps, fps_slider.on_value_changed)

View File

@ -0,0 +1,98 @@
[gd_scene load_steps=9 format=3 uid="uid://dejilst6cwqvi"]
[ext_resource type="Script" path="res://content/entities/camera/settings.gd" id="1_1ixy6"]
[ext_resource type="PackedScene" uid="uid://dnam3fe36gg62" path="res://content/ui/components/panel/panel.tscn" id="1_myvk1"]
[ext_resource type="Shader" path="res://content/ui/components/panel/glass.gdshader" id="2_wwobq"]
[ext_resource type="PackedScene" uid="uid://blrhy2uccrdn4" path="res://content/ui/components/input/input.tscn" id="3_dog14"]
[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_jtvwv"]
resource_local_to_scene = true
render_priority = 10
shader = ExtResource("2_wwobq")
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_myer6"]
size = Vector2(0.3, 0.2)
[node name="Settings" type="Node3D"]
script = ExtResource("1_1ixy6")
[node name="Panel" parent="." instance=ExtResource("1_myvk1")]
material_override = SubResource("ShaderMaterial_jtvwv")
mesh = SubResource("QuadMesh_myer6")
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 = "Camera Settings"
font_size = 24
outline_size = 0
horizontal_alignment = 0
[node name="Close" parent="." instance=ExtResource("5_opf0y")]
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("3_dog14")]
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.01, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Video: "
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="VideoButton" parent="." instance=ExtResource("5_opf0y")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.06, -0.01, 0)
label = "videocam_off"
icon = true
[node name="FPSLabel" type="Label3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.14, -0.05, 0)
pixel_size = 0.001
render_priority = 15
outline_render_priority = 14
text = "Refresh Rate: "
font_size = 18
outline_size = 0
horizontal_alignment = 0
[node name="FPSSlider" parent="." instance=ExtResource("4_t8xp5")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.04, -0.05, 0)
min = 1.0
max = 30.0
value = 1.0
step = 1.0
label_unit = "FPS"
size = Vector3(0.11, 0.02, 0.01)

View File

@ -1,16 +1,35 @@
extends StaticBody3D
var camera_follower: CameraFollower
@export var entity_id: String
var icon = R.state("question_mark")
var icon_color = R.state(Color(1, 1, 1, 1))
var show_settings = R.state(false)
func _ready():
var movable = get_node("Movable")
camera_follower = get_node_or_null("CameraFollower")
if camera_follower == null:
camera_follower = CameraFollower.new()
add_child(camera_follower)
R.effect(func(_args):
if show_settings.value == true:
camera_follower.enabled=true
)
if movable:
movable.on_moved.connect(func():
App.house.save_all_entities()
)
func set_options(_options):
return
func get_options():
return {}
return {}
func toggle_settings():
show_settings.value = !show_settings.value

View File

@ -15,7 +15,6 @@ const Entity = preload ("../entity.gd")
@onready var snap_sound = $SnapSound
@onready var settings = $Settings
@onready var movable = $Movable
@onready var camera_follower = $CameraFollower
var active = R.state(false)
var brightness = R.state(0) # 0-255
@ -25,7 +24,6 @@ var color_wheel_supported = R.state(false)
var show_brightness = R.state(true)
var show_modes = R.state(true)
var modes_supported = R.state(false)
var show_settings = R.state(false)
# Called when the node enters the scene tree for the first time.
func _ready():
@ -168,13 +166,6 @@ func quick_action():
func _toggle():
HomeApi.set_state(entity_id, "off" if active.value else "on")
func toggle_settings():
if show_settings.value == false:
show_settings.value = true
camera_follower.enabled = true
else:
show_settings.value = false
func get_options():
return {
"color_wheel": show_color_wheel.value,

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://cw86rc42dv2d8"]
[gd_scene load_steps=11 format=3 uid="uid://4smofj8ou0g7"]
[ext_resource type="Script" path="res://content/entities/light/light.gd" id="1_ykxy3"]
[ext_resource type="Script" path="res://content/functions/movable.gd" id="4_4sfxb"]
@ -24,6 +24,11 @@ shape = SubResource("SphereShape3D_ukj14")
script = ExtResource("4_4sfxb")
resizable = true
[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")]
script = ExtResource("9_a7u7m")
enabled = false
focus_point = NodePath("../FocusPoint")
[node name="Lightbulb" type="CSGCombiner3D" parent="."]
transform = Transform3D(1, 9.69949e-05, 0.000589194, -9.77749e-05, 0.999999, 0.00135802, -0.000589065, -0.00135808, 0.999999, 0, 0, 0)
material_override = ExtResource("5_50gph")
@ -73,11 +78,6 @@ horizontal_alignment = 0
stream = ExtResource("8_3togy")
volume_db = -20.0
[node name="CameraFollower" type="Node" parent="." node_paths=PackedStringArray("focus_point")]
script = ExtResource("9_a7u7m")
enabled = false
focus_point = NodePath("../FocusPoint")
[node name="FocusPoint" type="Marker3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29, 0, 0)
gizmo_extents = 0.1