Skip to content

Commit

Permalink
add better light bulb model
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitwel committed Jun 11, 2024
1 parent 7e01b99 commit d712c81
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 29 deletions.
3 changes: 3 additions & 0 deletions app/assets/light.blend
Git LFS file not shown
55 changes: 55 additions & 0 deletions app/assets/light.blend.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://dgrfnjvkf4vra"
path="res://.godot/imported/light.blend-a8d09ffaaed84fc638afde063bc32057.scn"

[deps]

source_file="res://assets/light.blend"
dest_files=["res://.godot/imported/light.blend-a8d09ffaaed84fc638afde063bc32057.scn"]

[params]

nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
fbx/importer=0
fbx/allow_geometry_helper_nodes=false
fbx/embedded_image_handling=1
gltf/naming_version=1
gltf/embedded_image_handling=1
blender/nodes/visible=0
blender/nodes/punctual_lights=true
blender/nodes/cameras=true
blender/nodes/custom_properties=true
blender/nodes/modifiers=1
blender/meshes/colors=false
blender/meshes/uvs=true
blender/meshes/normals=true
blender/meshes/tangents=true
blender/meshes/skins=2
blender/meshes/export_bones_deforming_mesh_only=false
blender/materials/unpack_enabled=true
blender/materials/export_materials=1
blender/animation/limit_playback=true
blender/animation/always_sample=true
blender/animation/group_tracks=true
Binary file added app/assets/light.blend1
Binary file not shown.
3 changes: 3 additions & 0 deletions app/assets/models/light/light.glb
Git LFS file not shown
39 changes: 39 additions & 0 deletions app/assets/models/light/light.glb.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[remap]

importer="scene"
importer_version=1
type="PackedScene"
uid="uid://d0wr17viu6o1d"
path="res://.godot/imported/light.glb-6e86d2536024075819ae2da177da28e3.scn"

[deps]

source_file="res://assets/models/light/light.glb"
dest_files=["res://.godot/imported/light.glb-6e86d2536024075819ae2da177da28e3.scn"]

[params]

nodes/root_type=""
nodes/root_name=""
nodes/apply_root_scale=true
nodes/root_scale=1.0
nodes/import_as_skeleton_bones=false
meshes/ensure_tangents=true
meshes/generate_lods=true
meshes/create_shadow_meshes=true
meshes/light_baking=1
meshes/lightmap_texel_size=0.2
meshes/force_disable_compression=false
skins/use_named_skins=true
animation/import=true
animation/fps=30
animation/trimming=false
animation/remove_immutable_tracks=true
animation/import_rest_as_RESET=false
import_script/path=""
_subresources={}
fbx/importer=0
fbx/allow_geometry_helper_nodes=false
fbx/embedded_image_handling=1
gltf/naming_version=1
gltf/embedded_image_handling=1
6 changes: 6 additions & 0 deletions app/content/entities/light/glass_bulb.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://0ojuvv6njowp"]

[resource]
transparency = 1
albedo_color = Color(1, 0.85, 0, 0.52549)
emission_energy_multiplier = 7.43
9 changes: 7 additions & 2 deletions app/content/entities/light/light.gd
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
extends Entity

const Entity = preload ("../entity.gd")
const GlassBulbMaterial = preload ("./glass_bulb.tres")
const RodBulbMaterial = preload ("./rod_bulb.tres")

@export var color_off = Color(0.23, 0.23, 0.23)
@export var color_on = Color(1.0, 0.85, 0.0)

@onready var lightbulb = $Lightbulb
@onready var slider: Slider3D = $Slider
@onready var color_wheel = $ColorWheel
@onready var modes: Select3D = $Modes
@onready var snap_sound = $SnapSound
@onready var settings = $Settings
@onready var movable = $Movable
@onready var light_radiation = $light/LightRadiation

var active = R.state(false)
var brightness = R.state(0) # 0-255
Expand Down Expand Up @@ -130,6 +132,7 @@ func set_state(stateInfo):
color_wheel.color = color.value

var tween = create_tween()
tween.set_parallel(true)

var target_color = color_off

Expand All @@ -140,7 +143,9 @@ func set_state(stateInfo):
target_color = color_off.lerp(color.value if show_color_wheel.value else color_on, brightness.value / 255.0)

icon_color.value = target_color
tween.tween_property(lightbulb, "material_override:albedo_color", target_color, 0.3)
tween.tween_property(GlassBulbMaterial, "albedo_color", Color(target_color.r, target_color.g, target_color.b, 0.5), 0.3)
tween.tween_property(RodBulbMaterial, "albedo_color", target_color, 0.3)
tween.tween_property(light_radiation, "modulate", Color(target_color.r, target_color.g, target_color.b, 1.0 if active.value else 0.0), 0.3)

func _on_click(event):
if event.target == self:
Expand Down
61 changes: 42 additions & 19 deletions app/content/entities/light/light.tscn
Original file line number Diff line number Diff line change
@@ -1,18 +1,34 @@
[gd_scene load_steps=11 format=3 uid="uid://4smofj8ou0g7"]
[gd_scene load_steps=16 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"]
[ext_resource type="Material" uid="uid://vce66e7sbc3n" path="res://content/entities/light/light_on.tres" id="5_50gph"]
[ext_resource type="PackedScene" uid="uid://chrjqr4l7atrc" path="res://content/ui/components/color_wheel/color_wheel.tscn" id="5_qj75k"]
[ext_resource type="PackedScene" uid="uid://pk5k1q8bx0rj" path="res://content/ui/components/slider/slider.tscn" id="6_mhjlm"]
[ext_resource type="PackedScene" uid="uid://wgnowarejk5y" path="res://content/ui/components/select/select.tscn" id="7_wbegr"]
[ext_resource type="AudioStream" uid="uid://du7ur0lu28cvn" path="res://assets/sound/finger-snap.mp3" id="8_3togy"]
[ext_resource type="Script" path="res://content/functions/camera_follower.gd" id="9_a7u7m"]
[ext_resource type="Material" uid="uid://0ojuvv6njowp" path="res://content/entities/light/glass_bulb.tres" id="10_km446"]
[ext_resource type="PackedScene" uid="uid://d0wr17viu6o1d" path="res://assets/models/light/light.glb" id="10_r1hbr"]
[ext_resource type="PackedScene" uid="uid://de34yde00ngkv" path="res://content/entities/light/settings.tscn" id="10_su84f"]
[ext_resource type="Material" uid="uid://0damlhnr8fs8" path="res://content/entities/light/rod_bulb.tres" id="11_be3ic"]

[sub_resource type="SphereShape3D" id="SphereShape3D_ukj14"]
radius = 0.05

[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0kqsy"]
albedo_color = Color(0.41598, 0.41598, 0.41598, 1)

[sub_resource type="Gradient" id="Gradient_kd20m"]
colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 0)

[sub_resource type="GradientTexture2D" id="GradientTexture2D_qnato"]
gradient = SubResource("Gradient_kd20m")
width = 512
height = 512
fill = 1
fill_from = Vector2(0.5, 0.5)
fill_to = Vector2(0.5, 1)

[node name="Light" type="StaticBody3D"]
collision_mask = 0
script = ExtResource("1_ykxy3")
Expand All @@ -29,30 +45,15 @@ script = ExtResource("9_a7u7m")
enabled = false
focus_point = NodePath("../Settings")

[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")

[node name="CSGSphere3D" type="CSGSphere3D" parent="Lightbulb"]
radius = 0.05
radial_segments = 36
rings = 12

[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Lightbulb"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.0485739, 0)
radius = 0.02
height = 0.03
sides = 36

[node name="Slider" parent="." instance=ExtResource("6_mhjlm")]
transform = Transform3D(-4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 0, 0, 1, 0.08, 0, 0)
max = 100.0
value = 100.0
value = 0.0
step = 1.0

[node name="ColorWheel" parent="." instance=ExtResource("5_qj75k")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.15, 0, 0)
color = Color(0, 0.616667, 1, 1)
color = Color(0, 0, 0, 1)
size = Vector3(0.15, 0.2, 0.01)

[node name="Modes" parent="." instance=ExtResource("7_wbegr")]
Expand All @@ -64,3 +65,25 @@ volume_db = -20.0

[node name="Settings" parent="." instance=ExtResource("10_su84f")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29, 0, 0)

[node name="light" parent="." instance=ExtResource("10_r1hbr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.03, 0)

[node name="Cylinder" parent="light" index="0"]
material_override = SubResource("StandardMaterial3D_0kqsy")

[node name="Sphere" parent="light" index="1"]
sorting_offset = -0.1
material_override = ExtResource("10_km446")

[node name="Cylinder_001" parent="light" index="2"]
material_override = ExtResource("11_be3ic")

[node name="LightRadiation" type="Sprite3D" parent="light"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.05, 0)
modulate = Color(1, 1, 0, 1)
pixel_size = 0.0002
billboard = 1
texture = SubResource("GradientTexture2D_qnato")

[editable path="light"]
7 changes: 0 additions & 7 deletions app/content/entities/light/light_on.tres

This file was deleted.

5 changes: 5 additions & 0 deletions app/content/entities/light/rod_bulb.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://0damlhnr8fs8"]

[resource]
shading_mode = 0
albedo_color = Color(1, 0.85098, 0, 1)
2 changes: 1 addition & 1 deletion app/content/system/areas/areas.gd
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func load_areas():
if HomeApi.has_integration() == false:
continue

HomeApi.api.integration_handler.create_area.call_deferred(area.id, area.display_name)
HomeApi.api.integration_handler.create_area.call_deferred(area.id, area.name)

func create_area(name: String):
var area = AreaScene.instantiate()
Expand Down

0 comments on commit d712c81

Please sign in to comment.