frame-of-mind/src/base-environments/youth_room/fairylights.tscn

83 lines
3.1 KiB
Plaintext
Raw Normal View History

2024-02-10 12:34:34 +00:00
[gd_scene load_steps=9 format=3 uid="uid://cg70r0102t8nl"]
[ext_resource type="Texture2D" uid="uid://i75aktvgsdwg" path="res://base-environments/youth_room/import/textures/wires_normal.png" id="1_p3lcj"]
[ext_resource type="Texture2D" uid="uid://chisldkpt6bf5" path="res://base-environments/youth_room/import/textures/wires_albedo.png" id="1_xsr58"]
[ext_resource type="Script" path="res://addons/LineRenderer/line_renderer.gd" id="2_javfj"]
[ext_resource type="ArrayMesh" uid="uid://f5fr2e5gq313" path="res://base-environments/youth_room/shaders/fairy_light_diode.res" id="4_qh8yy"]
[sub_resource type="GDScript" id="GDScript_2caij"]
script/source = "@tool
extends Node3D
@export var light_array: Array[Vector3]:
2024-10-18 16:12:40 +00:00
set(points):
light_array = points
if is_inside_tree():
rebuild()
2024-02-10 12:34:34 +00:00
@onready var wires:LineRenderer3D = $wires
@onready var diodes:MultiMeshInstance3D = $diodes
@export var seed:int = 42
var rng = RandomNumberGenerator.new()
@export var size:float = 0.1:
2024-10-18 16:12:40 +00:00
set(new_size):
size = new_size
rebuild()
if is_inside_tree():
wires.end_thickness = size*0.1
wires.start_thickness = size*0.1
2024-02-10 12:34:34 +00:00
# Called when the node enters the scene tree for the first time.
func _ready():
2024-10-18 16:12:40 +00:00
rebuild()
2024-02-10 12:34:34 +00:00
func rebuild():
2024-10-18 16:12:40 +00:00
rng.seed = seed
rng.state = 0
for child in wires.get_children(): child.free()
wires.points = light_array
diodes.multimesh.instance_count = light_array.size()
var meshBuffer:PackedFloat32Array
for point in light_array:
rng
var base:Basis = Basis(Vector3(rng.randf_range(-1, 1), rng.randf_range(-1, 1), rng.randf_range(-1, 1)).normalized(), rng.randf_range(0, PI*2))
base = base.scaled(Vector3(size, size, size))
meshBuffer.append_array([base.x.x, base.x.y, base.x.z, point.x, base.y.x, base.y.y, base.y.z, point.y, base.z.x, base.z.y, base.z.z, point.z])
diodes.multimesh.buffer = meshBuffer
2024-02-10 12:34:34 +00:00
"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5ca5e"]
transparency = 2
alpha_scissor_threshold = 0.5
alpha_antialiasing_mode = 0
cull_mode = 2
albedo_color = Color(0.368627, 0.368627, 0.368627, 1)
albedo_texture = ExtResource("1_xsr58")
normal_enabled = true
normal_texture = ExtResource("1_p3lcj")
2024-10-18 16:12:40 +00:00
[sub_resource type="ImmediateMesh" id="ImmediateMesh_lq63p"]
2024-02-10 12:34:34 +00:00
[sub_resource type="MultiMesh" id="MultiMesh_ic3h7"]
transform_format = 1
2024-10-18 16:12:40 +00:00
instance_count = 2
2024-02-10 12:34:34 +00:00
mesh = ExtResource("4_qh8yy")
2024-10-18 16:12:40 +00:00
buffer = PackedFloat32Array(0.0998169, 0.00482103, -0.00365424, 0, -0.00428558, 0.0989875, 0.0135316, 0, 0.0042696, -0.0133502, 0.0990128, 0, 0.0700075, -0.0358849, 0.0617351, 0, 0.0525334, 0.0844406, -0.0104897, 1, -0.0483653, 0.0397751, 0.0779663, 0)
2024-02-10 12:34:34 +00:00
[node name="fairylights" type="Node3D"]
script = SubResource("GDScript_2caij")
light_array = Array[Vector3]([Vector3(0, 0, 0), Vector3(0, 1, 0)])
[node name="wires" type="MeshInstance3D" parent="."]
material_override = SubResource("StandardMaterial3D_5ca5e")
2024-10-18 16:12:40 +00:00
mesh = SubResource("ImmediateMesh_lq63p")
2024-02-10 12:34:34 +00:00
script = ExtResource("2_javfj")
points = Array[Vector3]([Vector3(0, 0, 0), Vector3(0, 1, 0)])
start_thickness = 0.01
end_thickness = 0.01
use_global_coords = false
tile_texture = false
[node name="diodes" type="MultiMeshInstance3D" parent="."]
multimesh = SubResource("MultiMesh_ic3h7")