commit
e2faa98b11
3
assets/canvas.png
Normal file
3
assets/canvas.png
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
version https://git-lfs.github.com/spec/v1
|
||||||
|
oid sha256:f523eb87489026aa87814b63b31e0ce83ca91a0729ef7d93079e39a67e348fb5
|
||||||
|
size 237647
|
34
assets/canvas.png.import
Normal file
34
assets/canvas.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://hy2f6is7qjyv"
|
||||||
|
path="res://.godot/imported/canvas.png-aa470cb9edfe91c0a54e6c5fa29d4c26.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/canvas.png"
|
||||||
|
dest_files=["res://.godot/imported/canvas.png-aa470cb9edfe91c0a54e6c5fa29d4c26.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
|
@ -1,12 +1,19 @@
|
||||||
extends Entity
|
extends Entity
|
||||||
|
|
||||||
const Entity = preload("../entity.gd")
|
const Entity = preload("../entity.gd")
|
||||||
|
const color_wheel_img := preload("res://assets/canvas.png")
|
||||||
|
|
||||||
@export var color_off = Color(0.23, 0.23, 0.23)
|
@export var color_off = Color(0.23, 0.23, 0.23)
|
||||||
@export var color_on = Color(1.0, 0.85, 0.0)
|
@export var color_on = Color(1.0, 0.85, 0.0)
|
||||||
|
|
||||||
@onready var animation: AnimationPlayer = $AnimationPlayer
|
@onready var animation: AnimationPlayer = $AnimationPlayer
|
||||||
@onready var slider: Slider3D = $Slider
|
@onready var slider: Slider3D = $Slider
|
||||||
|
@onready var color_wheel = $ColorWheel
|
||||||
|
@onready var color_puck = $ColorWheel/Puck
|
||||||
|
@onready var modes = $Modes
|
||||||
|
@onready var mode_next = $Modes/Next
|
||||||
|
@onready var mode_before = $Modes/Previous
|
||||||
|
@onready var mode_label = $Modes/Label
|
||||||
|
|
||||||
var state = true
|
var state = true
|
||||||
var brightness = 0 # 0-255
|
var brightness = 0 # 0-255
|
||||||
|
@ -18,6 +25,58 @@ func _ready():
|
||||||
var stateInfo = await HomeApi.get_state(entity_id)
|
var stateInfo = await HomeApi.get_state(entity_id)
|
||||||
set_state(stateInfo["state"] == "on")
|
set_state(stateInfo["state"] == "on")
|
||||||
|
|
||||||
|
if stateInfo.has("attributes") && stateInfo["attributes"].has("effect_list") && stateInfo["attributes"]["effect_list"].size() > 0:
|
||||||
|
mode_label.text = stateInfo["attributes"]["effect"]
|
||||||
|
|
||||||
|
mode_next.on_button_down.connect(func():
|
||||||
|
var index = stateInfo["attributes"]["effect_list"].find(stateInfo["attributes"]["effect"])
|
||||||
|
if index == -1:
|
||||||
|
index = 0
|
||||||
|
else:
|
||||||
|
index = (index + 1) % stateInfo["attributes"]["effect_list"].size()
|
||||||
|
|
||||||
|
mode_label.text = stateInfo["attributes"]["effect_list"][index]
|
||||||
|
|
||||||
|
HomeApi.set_state(entity_id, "on", {"effect": stateInfo["attributes"]["effect_list"][index]})
|
||||||
|
)
|
||||||
|
|
||||||
|
mode_before.on_button_down.connect(func():
|
||||||
|
var index = stateInfo["attributes"]["effect_list"].find(stateInfo["attributes"]["effect"])
|
||||||
|
if index == -1:
|
||||||
|
index = 0
|
||||||
|
else:
|
||||||
|
index = (index - 1) % stateInfo["attributes"]["effect_list"].size()
|
||||||
|
|
||||||
|
mode_label.text = stateInfo["attributes"]["effect_list"][index]
|
||||||
|
|
||||||
|
HomeApi.set_state(entity_id, "on", {"effect": stateInfo["attributes"]["effect_list"][index]})
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
remove_child(modes)
|
||||||
|
|
||||||
|
|
||||||
|
if stateInfo.has("attributes") && stateInfo["attributes"].has("supported_color_modes") && stateInfo["attributes"]["supported_color_modes"].has("rgb"):
|
||||||
|
color_wheel.get_node("Clickable").on_press_down.connect(func(event: EventPointer):
|
||||||
|
var target_point = color_wheel.to_local(event.ray.get_collision_point())
|
||||||
|
|
||||||
|
var delta = Vector2(target_point.x, target_point.z) * (1.0 / 0.08)
|
||||||
|
if delta.length() > 1:
|
||||||
|
delta = delta.normalized()
|
||||||
|
|
||||||
|
var color = color_wheel_img.get_image().get_pixel((delta.x * 0.5 + 0.5) * 1000, (delta.y * 0.5 + 0.5) * 1000)
|
||||||
|
|
||||||
|
color_puck.material_override.albedo_color = color
|
||||||
|
color_puck.position = Vector3(target_point.x, color_puck.position.y, target_point.z)
|
||||||
|
|
||||||
|
var attributes = {
|
||||||
|
"rgb_color": [int(color.r * 255), int(color.g * 255), int(color.b * 255)],
|
||||||
|
}
|
||||||
|
|
||||||
|
HomeApi.set_state(entity_id, "on", attributes)
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
remove_child(color_wheel)
|
||||||
|
|
||||||
await HomeApi.watch_state(entity_id, func(new_state):
|
await HomeApi.watch_state(entity_id, func(new_state):
|
||||||
if (new_state["state"] == "on") == state:
|
if (new_state["state"] == "on") == state:
|
||||||
return
|
return
|
||||||
|
@ -58,4 +117,4 @@ func _on_click(event):
|
||||||
attributes["brightness"] = int(brightness)
|
attributes["brightness"] = int(brightness)
|
||||||
|
|
||||||
HomeApi.set_state(entity_id, "on" if !state else "off", attributes)
|
HomeApi.set_state(entity_id, "on" if !state else "off", attributes)
|
||||||
set_state(!state, brightness)
|
set_state(!state, brightness)
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
[gd_scene load_steps=10 format=3 uid="uid://cw86rc42dv2d8"]
|
[gd_scene load_steps=18 format=3 uid="uid://cw86rc42dv2d8"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://content/entities/light/light.gd" id="1_ykxy3"]
|
[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"]
|
[ext_resource type="Script" path="res://content/functions/movable.gd" id="4_4sfxb"]
|
||||||
[ext_resource type="Material" uid="uid://vce66e7sbc3n" path="res://content/entities/light/light_on.tres" id="5_50gph"]
|
[ext_resource type="Material" uid="uid://vce66e7sbc3n" path="res://content/entities/light/light_on.tres" id="5_50gph"]
|
||||||
[ext_resource type="Script" path="res://content/functions/occludable.gd" id="5_oh4jg"]
|
[ext_resource type="Script" path="res://content/functions/occludable.gd" id="5_oh4jg"]
|
||||||
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"]
|
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://hy2f6is7qjyv" path="res://assets/canvas.png" id="7_ximu1"]
|
||||||
|
[ext_resource type="Script" path="res://content/functions/clickable.gd" id="8_1sfll"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bsjqdvkt0u87c" path="res://content/ui/components/button/button.tscn" id="8_nhcff"]
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_ukj14"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_ukj14"]
|
||||||
radius = 0.05
|
radius = 0.05
|
||||||
|
@ -46,9 +49,29 @@ _data = {
|
||||||
"light": SubResource("Animation_7o31s")
|
"light": SubResource("Animation_7o31s")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_k3ob2"]
|
||||||
|
points = PackedVector3Array(0, -0.005, -0.08, -0.00784652, -0.005, -0.0796241, 0, 0.005, -0.08, 0.00783085, -0.005, -0.0796241, -0.00784652, 0.005, -0.0796241, -0.0156147, -0.005, -0.0784651, 0.00783085, 0.005, -0.0796241, 0.0155991, -0.005, -0.0784651, -0.0156147, 0.005, -0.0784651, -0.0232263, -0.005, -0.0765701, 0.0155991, 0.005, -0.0784651, 0.0232106, -0.005, -0.0765701, -0.0232263, 0.005, -0.0765701, -0.0306186, -0.005, -0.0739233, 0.0232106, 0.005, -0.0765701, 0.030603, -0.005, -0.0739233, -0.0306186, 0.005, -0.0739233, -0.0377134, -0.005, -0.070556, 0.030603, 0.005, -0.0739233, 0.0376977, -0.005, -0.070556, -0.0377134, 0.005, -0.070556, -0.0444479, -0.005, -0.0665309, 0.0376977, 0.005, -0.070556, 0.0444323, -0.005, -0.0665309, -0.0444479, 0.005, -0.0665309, -0.0507596, -0.005, -0.0618481, 0.0444323, 0.005, -0.0665309, 0.0507439, -0.005, -0.0618481, -0.0507596, 0.005, -0.0618481, -0.0565701, -0.005, -0.0565701, 0.0507439, 0.005, -0.0618481, 0.0565544, -0.005, -0.0565701, -0.0565701, 0.005, -0.0565701, -0.0618481, -0.005, -0.0507596, 0.0565544, 0.005, -0.0565701, 0.0618324, -0.005, -0.0507596, -0.0618481, 0.005, -0.0507596, -0.0665309, -0.005, -0.0444479, 0.0618324, 0.005, -0.0507596, 0.0665153, -0.005, -0.0444479, -0.0665309, 0.005, -0.0444479, -0.070556, -0.005, -0.0377134, 0.0665153, 0.005, -0.0444479, 0.0705403, -0.005, -0.0377134, -0.070556, 0.005, -0.0377134, -0.0739233, -0.005, -0.0306186, 0.0705403, 0.005, -0.0377134, 0.0739076, -0.005, -0.0306186, -0.0739233, 0.005, -0.0306186, -0.0765701, -0.005, -0.0232263, 0.0739076, 0.005, -0.0306186, 0.0765544, -0.005, -0.0232263, -0.0765701, 0.005, -0.0232263, -0.0784651, -0.005, -0.0156147, 0.0765544, 0.005, -0.0232263, 0.0784495, -0.005, -0.0156147, -0.0784651, 0.005, -0.0156147, -0.0796241, -0.005, -0.00784652, 0.0784495, 0.005, -0.0156147, 0.0796085, -0.005, -0.00784652, -0.0796241, 0.005, -0.00784652, -0.08, -0.005, 0, 0.0796085, 0.005, -0.00784652, 0.08, -0.005, 0, -0.08, 0.005, 0, -0.0796241, -0.005, 0.00783085, 0.08, 0.005, 0, 0.0796085, -0.005, 0.00783085, -0.0796241, 0.005, 0.00783085, -0.0784651, -0.005, 0.0155991, 0.0796085, 0.005, 0.00783085, 0.0784495, -0.005, 0.0155991, -0.0784651, 0.005, 0.0155991, -0.0765701, -0.005, 0.0232106, 0.0784495, 0.005, 0.0155991, 0.0765544, -0.005, 0.0232106, -0.0765701, 0.005, 0.0232106, -0.0739233, -0.005, 0.030603, 0.0765544, 0.005, 0.0232106, 0.0739076, -0.005, 0.030603, -0.0739233, 0.005, 0.030603, -0.070556, -0.005, 0.0376977, 0.0739076, 0.005, 0.030603, 0.0705403, -0.005, 0.0376977, -0.070556, 0.005, 0.0376977, -0.0665309, -0.005, 0.0444323, 0.0705403, 0.005, 0.0376977, 0.0665153, -0.005, 0.0444323, -0.0665309, 0.005, 0.0444323, -0.0618481, -0.005, 0.0507439, 0.0665153, 0.005, 0.0444323, 0.0618324, -0.005, 0.0507439, -0.0618481, 0.005, 0.0507439, -0.0565701, -0.005, 0.0565544, 0.0618324, 0.005, 0.0507439, 0.0565544, -0.005, 0.0565544, -0.0565701, 0.005, 0.0565544, -0.0507596, -0.005, 0.0618324, 0.0565544, 0.005, 0.0565544, 0.0507439, -0.005, 0.0618324, -0.0507596, 0.005, 0.0618324, -0.0444479, -0.005, 0.0665153, 0.0507439, 0.005, 0.0618324, 0.0444323, -0.005, 0.0665153, -0.0444479, 0.005, 0.0665153, -0.0377134, -0.005, 0.0705403, 0.0444323, 0.005, 0.0665153, 0.0376977, -0.005, 0.0705403, -0.0377134, 0.005, 0.0705403, -0.0306186, -0.005, 0.0739076, 0.0376977, 0.005, 0.0705403, 0.030603, -0.005, 0.0739076, -0.0306186, 0.005, 0.0739076, -0.0232263, -0.005, 0.0765544, 0.030603, 0.005, 0.0739076, 0.0232106, -0.005, 0.0765544, -0.0232263, 0.005, 0.0765544, -0.0156147, -0.005, 0.0784495, 0.0232106, 0.005, 0.0765544, 0.0155991, -0.005, 0.0784495, -0.0156147, 0.005, 0.0784495, -0.00784652, -0.005, 0.0796085, 0.0155991, 0.005, 0.0784495, 0.00783085, -0.005, 0.0796085, -0.00784652, 0.005, 0.0796085, 0, -0.005, 0.08, 0.00783085, 0.005, 0.0796085, 0, 0.005, 0.08)
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_7p762"]
|
||||||
|
|
||||||
|
[sub_resource type="CylinderMesh" id="CylinderMesh_c10un"]
|
||||||
|
top_radius = 0.08
|
||||||
|
bottom_radius = 0.08
|
||||||
|
height = 0.01
|
||||||
|
|
||||||
|
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1jd14"]
|
||||||
|
resource_local_to_scene = true
|
||||||
|
|
||||||
|
[sub_resource type="CylinderMesh" id="CylinderMesh_x68ys"]
|
||||||
|
top_radius = 0.01
|
||||||
|
bottom_radius = 0.01
|
||||||
|
height = 0.005
|
||||||
|
|
||||||
[node name="Light" type="StaticBody3D" groups=["entity"]]
|
[node name="Light" type="StaticBody3D" groups=["entity"]]
|
||||||
collision_mask = 0
|
collision_mask = 0
|
||||||
script = ExtResource("1_ykxy3")
|
script = ExtResource("1_ykxy3")
|
||||||
|
color_off = null
|
||||||
|
color_on = null
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||||
shape = SubResource("SphereShape3D_ukj14")
|
shape = SubResource("SphereShape3D_ukj14")
|
||||||
|
@ -80,8 +103,51 @@ libraries = {
|
||||||
}
|
}
|
||||||
|
|
||||||
[node name="Slider" parent="." instance=ExtResource("6_mhjlm")]
|
[node name="Slider" parent="." instance=ExtResource("6_mhjlm")]
|
||||||
transform = Transform3D(-4.37114e-08, 1, 0, 1, 4.37114e-08, 8.74228e-08, 8.74228e-08, 3.82137e-15, -1, 0.00190757, -0.00579122, -0.0914348)
|
transform = Transform3D(1.91069e-15, 4.37114e-08, 1, 1, -4.37114e-08, 0, 4.37114e-08, 1, -4.37114e-08, 0.08, 0, 0)
|
||||||
max = 100.0
|
max = 100.0
|
||||||
value = 100.0
|
value = 100.0
|
||||||
step = 1.0
|
step = 1.0
|
||||||
size = Vector3(10, 0.4, 1)
|
size = Vector3(10, 0.4, 1)
|
||||||
|
|
||||||
|
[node name="ColorWheel" type="StaticBody3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.15, 0, 0)
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="ColorWheel"]
|
||||||
|
shape = SubResource("ConvexPolygonShape3D_k3ob2")
|
||||||
|
|
||||||
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="ColorWheel"]
|
||||||
|
material_override = SubResource("StandardMaterial3D_7p762")
|
||||||
|
mesh = SubResource("CylinderMesh_c10un")
|
||||||
|
skeleton = NodePath("../..")
|
||||||
|
|
||||||
|
[node name="Decal" type="Decal" parent="ColorWheel/MeshInstance3D"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.005, 0)
|
||||||
|
size = Vector3(0.15, 0.001, 0.15)
|
||||||
|
texture_albedo = ExtResource("7_ximu1")
|
||||||
|
|
||||||
|
[node name="Clickable" type="Node" parent="ColorWheel"]
|
||||||
|
script = ExtResource("8_1sfll")
|
||||||
|
|
||||||
|
[node name="Puck" type="MeshInstance3D" parent="ColorWheel"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -4.65661e-10, 0.01, 0)
|
||||||
|
material_override = SubResource("StandardMaterial3D_1jd14")
|
||||||
|
mesh = SubResource("CylinderMesh_x68ys")
|
||||||
|
|
||||||
|
[node name="Modes" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.11, 0)
|
||||||
|
|
||||||
|
[node name="Next" parent="Modes" instance=ExtResource("8_nhcff")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, -0.04, 0, 0)
|
||||||
|
label = "navigate_next"
|
||||||
|
icon = true
|
||||||
|
|
||||||
|
[node name="Previous" parent="Modes" instance=ExtResource("8_nhcff")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 2.98023e-08, -1, 0, 1, 2.98023e-08, -0.1, 0, 0)
|
||||||
|
label = "navigate_before"
|
||||||
|
icon = true
|
||||||
|
|
||||||
|
[node name="Label" type="Label3D" parent="Modes"]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.01, 0, 0)
|
||||||
|
pixel_size = 0.001
|
||||||
|
text = "Default"
|
||||||
|
horizontal_alignment = 0
|
||||||
|
|
|
@ -37,7 +37,9 @@ func update_house():
|
||||||
var new_room = Store.house.rooms[index]
|
var new_room = Store.house.rooms[index]
|
||||||
create_room(new_room.name, 0)
|
create_room(new_room.name, 0)
|
||||||
|
|
||||||
for entity in Store.house.entities:
|
for entity_index in range(Store.house.entities.size()):
|
||||||
|
var entity = Store.house.entities[entity_index]
|
||||||
|
|
||||||
var entity_instance = create_entity_in(entity.id, entity.room)
|
var entity_instance = create_entity_in(entity.id, entity.room)
|
||||||
|
|
||||||
if entity_instance == null:
|
if entity_instance == null:
|
||||||
|
@ -174,8 +176,6 @@ func create_entity_in(entity_id: String, room_name: String):
|
||||||
room.get_node("Entities").add_child(entity)
|
room.get_node("Entities").add_child(entity)
|
||||||
entity.global_position = room.get_aabb().position + room.get_aabb().size / 2.0
|
entity.global_position = room.get_aabb().position + room.get_aabb().size / 2.0
|
||||||
|
|
||||||
save_all_entities()
|
|
||||||
|
|
||||||
return entity
|
return entity
|
||||||
|
|
||||||
func update_mini_view():
|
func update_mini_view():
|
||||||
|
@ -189,6 +189,17 @@ func update_mini_view():
|
||||||
|
|
||||||
collision_shape.global_position = center
|
collision_shape.global_position = center
|
||||||
collision_shape.shape.size = aabb.size
|
collision_shape.shape.size = aabb.size
|
||||||
|
|
||||||
|
var camera = get_node("/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.0
|
||||||
|
|
||||||
|
|
||||||
|
var target_position = camera_position + camera_direction.normalized() * 0.2
|
||||||
|
levels.global_position = target_position - center * 0.1
|
||||||
else:
|
else:
|
||||||
levels.position = Vector3(0, 0, 0)
|
levels.position = Vector3(0, 0, 0)
|
||||||
|
|
||||||
|
|
|
@ -63,4 +63,5 @@ lights_and_shadows/directional_shadow/soft_shadow_filter_quality.mobile=4
|
||||||
[xr]
|
[xr]
|
||||||
|
|
||||||
openxr/enabled=true
|
openxr/enabled=true
|
||||||
|
openxr/startup_alert=false
|
||||||
shaders/enabled=true
|
shaders/enabled=true
|
||||||
|
|
Loading…
Reference in New Issue
Block a user