diff --git a/objects/hud/3d_text.gd b/objects/hud/3d_text.gd new file mode 100644 index 0000000..aef81de --- /dev/null +++ b/objects/hud/3d_text.gd @@ -0,0 +1,28 @@ +tool +extends ViewportContainer + + +export var text: String = "" setget _set_text +export var text_material: Material = null setget _set_material + + +onready var text_mesh = $"%TextMesh" +onready var animation_player = $"%AnimationPlayer" + + +func _ready() -> void: + pass + + +func _set_text(value: String) -> void: + text = value + if not is_instance_valid(text_mesh): + yield(self, "ready") + text_mesh.mesh.text = text + + +func _set_material(value: Material) -> void: + text_material = value + if not is_instance_valid(text_mesh): + yield(self, "ready") + text_mesh.mesh.material = text_material diff --git a/objects/hud/3d_text.tscn b/objects/hud/3d_text.tscn new file mode 100644 index 0000000..156b609 --- /dev/null +++ b/objects/hud/3d_text.tscn @@ -0,0 +1,80 @@ +[gd_scene load_steps=8 format=2] + +[ext_resource path="res://ui/PressStart2P-Regular.ttf" type="DynamicFontData" id=1] +[ext_resource path="res://objects/hud/3d_text.gd" type="Script" id=2] + +[sub_resource type="DynamicFont" id=1] +font_data = ExtResource( 1 ) + +[sub_resource type="TextMesh" id=2] +resource_local_to_scene = true +font = SubResource( 1 ) +pixel_size = 0.05 +depth = 0.1 + +[sub_resource type="Environment" id=4] +background_mode = 1 +ambient_light_color = Color( 1, 1, 1, 1 ) +ambient_light_energy = 0.5 + +[sub_resource type="Animation" id=5] +length = 0.001 +tracks/0/type = "value" +tracks/0/path = NodePath("TextMesh:translation") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0 ), +"transitions": PoolRealArray( 1 ), +"update": 0, +"values": [ Vector3( 0, 1, 0 ) ] +} + +[sub_resource type="Animation" id=6] +resource_name = "appear" +tracks/0/type = "value" +tracks/0/path = NodePath("TextMesh:translation") +tracks/0/interp = 2 +tracks/0/loop_wrap = true +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/keys = { +"times": PoolRealArray( 0, 1 ), +"transitions": PoolRealArray( 1, 1 ), +"update": 0, +"values": [ Vector3( 0, 1, -100 ), Vector3( 0, 1, 0 ) ] +} + +[node name="3DText" type="ViewportContainer"] +anchor_right = 1.0 +anchor_bottom = 1.0 +script = ExtResource( 2 ) + +[node name="Viewport" type="Viewport" parent="."] +size = Vector2( 256, 192 ) +transparent_bg = true +handle_input_locally = false +usage = 3 +render_target_update_mode = 3 +gui_disable_input = true + +[node name="TextMesh" type="MeshInstance" parent="Viewport"] +unique_name_in_owner = true +transform = Transform( 1.1, 0, 0, 0, 1.5, 0, 0, 0, 2, 0, 1, 0 ) +mesh = SubResource( 2 ) + +[node name="DirectionalLight" type="DirectionalLight" parent="Viewport"] +transform = Transform( 0.893849, 0.317044, -0.317044, 0, 0.707107, 0.707107, 0.448368, -0.632047, 0.632047, 0, 1, 0 ) +light_specular = 16.0 + +[node name="Camera" type="Camera" parent="Viewport"] +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 5 ) +environment = SubResource( 4 ) + +[node name="AnimationPlayer" type="AnimationPlayer" parent="Viewport"] +unique_name_in_owner = true +autoplay = "appear" +anims/RESET = SubResource( 5 ) +anims/appear = SubResource( 6 ) diff --git a/ui/PressStart2P-Regular.ttf b/ui/PressStart2P-Regular.ttf new file mode 100644 index 0000000..2442aff Binary files /dev/null and b/ui/PressStart2P-Regular.ttf differ