Merge pull request #52 from Nitwel/testing

Move away from decal cursors
This commit is contained in:
Nitwel 2023-11-26 13:48:59 +01:00 committed by GitHub
commit 35a1abb2e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 6 deletions

View File

@ -3,25 +3,27 @@
importer="texture" importer="texture"
type="CompressedTexture2D" type="CompressedTexture2D"
uid="uid://bl33klueufwja" 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={ metadata={
"vram_texture": false "imported_formats": ["s3tc_bptc", "etc2_astc"],
"vram_texture": true
} }
[deps] [deps]
source_file="res://assets/materials/pointer.png" 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] [params]
compress/mode=0 compress/mode=2
compress/high_quality=false compress/high_quality=false
compress/lossy_quality=0.7 compress/lossy_quality=0.7
compress/hdr_compression=1 compress/hdr_compression=1
compress/normal_map=0 compress/normal_map=0
compress/channel_pack=0 compress/channel_pack=0
mipmaps/generate=false mipmaps/generate=true
mipmaps/limit=-1 mipmaps/limit=-1
roughness/mode=0 roughness/mode=0
roughness/src_normal="" roughness/src_normal=""
@ -31,4 +33,4 @@ process/normal_map_invert_y=false
process/hdr_as_srgb=false process/hdr_as_srgb=false
process/hdr_clamp_exposure=false process/hdr_clamp_exposure=false
process/size_limit=0 process/size_limit=0
detect_3d/compress_to=1 detect_3d/compress_to=0

View File

@ -1,6 +1,10 @@
extends RayCast3D extends RayCast3D
@onready var cursor: Node3D = $Cursor
@onready var decal: Decal = $Decal
@export var is_right: bool = true @export var is_right: bool = true
@export var with_decal: bool = false
var controller: XRController3D var controller: XRController3D
var timespan_click = 200.0 var timespan_click = 200.0
@ -22,6 +26,20 @@ func _ready():
func _physics_process(_delta): func _physics_process(_delta):
_handle_enter_leave() _handle_enter_leave()
_handle_move() _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(): func _handle_move():
var time_passed = Time.get_ticks_msec() - time_pressed var time_passed = Time.get_ticks_msec() - time_pressed

View File

@ -14,3 +14,10 @@ size = Vector3(0.02, 4.91995, 0.02)
texture_albedo = ExtResource("1_2f2iv") texture_albedo = ExtResource("1_2f2iv")
upper_fade = 0.000985425 upper_fade = 0.000985425
lower_fade = 0.000919435 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")