Files
Hugo Locurcio bac1e69164 Use static typing in all demos (#1063)
This leads to code that is easier to understand and runs
faster thanks to GDScript's typed instructions.

The untyped declaration warning is now enabled on all projects
where type hints were added. All projects currently run without
any untyped declration warnings.

Dodge the Creeps and Squash the Creeps demos intentionally don't
use type hints to match the documentation, where type hints haven't
been adopted yet (given its beginner focus).
2024-06-01 12:12:18 +02:00

20 lines
686 B
GDScript

@tool
@icon("res://marker/AxisMarker3D.svg")
class_name AxisMarker3D
extends Node3D
func _process(_delta: float) -> void:
var holder: Node3D = get_child(0).get_child(0)
var cube: Node3D = holder.get_child(0)
# "Hide" the origin vector if the AxisMarker is at (0, 0, 0)
if position == Vector3():
holder.transform = Transform3D()
cube.transform = Transform3D().scaled(Vector3.ONE * 0.0001)
return
holder.transform = Transform3D(Basis(), position / 2)
holder.transform = holder.transform.looking_at(position, Vector3.UP)
holder.transform = get_parent().global_transform * holder.transform
cube.transform = Transform3D(Basis().scaled(Vector3(0.1, 0.1, position.length())))