From 60af53431f8141d090b95a28a30ebe77fb3c35b7 Mon Sep 17 00:00:00 2001 From: Nitwel Date: Sun, 26 Nov 2023 13:48:27 +0100 Subject: [PATCH] move away from decal cursors --- assets/materials/pointer.png.import | 14 ++++++++------ content/system/raycast/raycast.gd | 18 ++++++++++++++++++ content/system/raycast/raycast.tscn | 7 +++++++ 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/assets/materials/pointer.png.import b/assets/materials/pointer.png.import index 76e851c..75ff2f3 100644 --- a/assets/materials/pointer.png.import +++ b/assets/materials/pointer.png.import @@ -3,25 +3,27 @@ importer="texture" type="CompressedTexture2D" uid="uid://bl33klueufwja" -path="res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.ctex" +path.s3tc="res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.s3tc.ctex" +path.etc2="res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.etc2.ctex" metadata={ -"vram_texture": false +"imported_formats": ["s3tc_bptc", "etc2_astc"], +"vram_texture": true } [deps] source_file="res://assets/materials/pointer.png" -dest_files=["res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.ctex"] +dest_files=["res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.s3tc.ctex", "res://.godot/imported/pointer.png-bc1b217fc800145e13fa1a1689c1f1ee.etc2.ctex"] [params] -compress/mode=0 +compress/mode=2 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/generate=true mipmaps/limit=-1 roughness/mode=0 roughness/src_normal="" @@ -31,4 +33,4 @@ 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 +detect_3d/compress_to=0 diff --git a/content/system/raycast/raycast.gd b/content/system/raycast/raycast.gd index db1c963..a3b2935 100644 --- a/content/system/raycast/raycast.gd +++ b/content/system/raycast/raycast.gd @@ -1,6 +1,10 @@ extends RayCast3D +@onready var cursor: Node3D = $Cursor +@onready var decal: Decal = $Decal + @export var is_right: bool = true +@export var with_decal: bool = false var controller: XRController3D var timespan_click = 200.0 @@ -22,6 +26,20 @@ func _ready(): func _physics_process(_delta): _handle_enter_leave() _handle_move() + _handle_cursor() + +func _handle_cursor(): + var collider = get_collider() + + if collider == null: + cursor.visible = false + if with_decal: decal.visible = true + return + + cursor.visible = true + decal.visible = false + cursor.global_transform.origin = get_collision_point() + get_collision_normal() * 0.001 # offset to avoid z-fighting + cursor.global_transform.basis = Basis.looking_at(get_collision_normal(), Vector3.UP) func _handle_move(): var time_passed = Time.get_ticks_msec() - time_pressed diff --git a/content/system/raycast/raycast.tscn b/content/system/raycast/raycast.tscn index 70784d7..805f0dc 100644 --- a/content/system/raycast/raycast.tscn +++ b/content/system/raycast/raycast.tscn @@ -14,3 +14,10 @@ size = Vector3(0.02, 4.91995, 0.02) texture_albedo = ExtResource("1_2f2iv") upper_fade = 0.000985425 lower_fade = 0.000919435 + +[node name="Cursor" type="Node3D" parent="."] + +[node name="CursorSprite" type="Sprite3D" parent="Cursor"] +transform = Transform3D(0.03, 3.25261e-20, -2.20405e-39, -3.25261e-20, 0.03, -2.03288e-21, 0, 2.03288e-21, 0.03, 0, 0, 0) +pixel_size = 0.001 +texture = ExtResource("1_2f2iv")