diff --git a/src/models/icosahedron/components/Icosahedron.gd b/src/models/icosahedron/components/Icosahedron.gd index c7d6498..9e0bec1 100644 --- a/src/models/icosahedron/components/Icosahedron.gd +++ b/src/models/icosahedron/components/Icosahedron.gd @@ -10,8 +10,11 @@ const EDGE_NOISE = preload('res://src/models/icosahedron/resources/edge_noise.re @export var DEBUG_VISUAL: bool @export var scaling_enabled = false @export var scale_factor: float -@export var shader_type: int -@export var inital_transfrm: Quaternion +@export var shader_type: int = 0: + set(val): + shader_type = val + set_shader_type(val) +@export var inital_transfrm := Quaternion() @onready var cut_plane: CutPlane = $CutPlane @onready var mesh_icosahedron: MeshIcosahedron = $MeshIcosahedron @@ -19,6 +22,12 @@ var cutplane_vector := Vector3(1,1,1).normalized() var scale_timer: ScaleTimer var sf: float +func set_shader_type(_type: int): + var variant = IcosahedronVarints.figure_variants[_type] + if variant.get("cutplane"): + set_cutplane(variant.cutplane) + set_color(G.theme.figure_variants.get(variant.name, G.theme.base_color)) + func init(shader_args: Dictionary, transform_args: Dictionary = {}) -> Icosahedron: scale_factor = G.settings.SCALE_FACTOR scaling_enabled = G.settings.get("SCALING_ENABLED", true) diff --git a/src/models/icosahedron/test/variant_test.gd b/src/models/icosahedron/test/variant_test.gd new file mode 100644 index 0000000..0796730 --- /dev/null +++ b/src/models/icosahedron/test/variant_test.gd @@ -0,0 +1,35 @@ +@tool +extends Node3D + +const IcosahedronScene = preload('res://src/models/icosahedron/Icosahedron.tscn') +var G: Globals = Globals.new() +@onready var icosahedron: Icosahedron = $Icosahedron + +@export var a := false: + set(val): + var new_figure = IcosahedronScene.instantiate() + new_figure.shader_type = 1 + self.add_child(new_figure) + new_figure.owner = get_tree().edited_scene_root + print_debug(new_figure.shader_type) + print_debug(G.tw) + +@export var b := false: + set(val): + for i in self.get_children(): + remove_child(i) + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + #if not get_tree().edited_scene_root.get_node_or_null('./globals'): + #var globals = Globals.new() + #globals.set_name('globals') + #get_tree().edited_scene_root.call_deferred('add_child', globals) + #G = get_tree().edited_scene_root.get_node('./globals') + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass diff --git a/src/models/icosahedron/test/variant_test.tscn b/src/models/icosahedron/test/variant_test.tscn new file mode 100644 index 0000000..402b16a --- /dev/null +++ b/src/models/icosahedron/test/variant_test.tscn @@ -0,0 +1,12 @@ +[gd_scene load_steps=4 format=3 uid="uid://cd21bp42ng8gy"] + +[ext_resource type="Script" path="res://src/models/icosahedron/test/variant_test.gd" id="1_4av47"] +[ext_resource type="PackedScene" uid="uid://c28nbcejwepp8" path="res://src/models/icosahedron/Icosahedron.tscn" id="2_d25gj"] +[ext_resource type="Script" path="res://src/models/icosahedron/components/Icosahedron.gd" id="3_bof8s"] + +[node name="VariantTest" type="Node3D"] +script = ExtResource("1_4av47") + +[node name="Icosahedron" type="MeshInstance3D" parent="." instance=ExtResource("2_d25gj")] +script = ExtResource("3_bof8s") +shader_type = 1