AxisMarker3D.gd 671 B

12345678910111213141516171819
  1. @tool
  2. @icon("res://marker/AxisMarker3D.svg")
  3. class_name AxisMarker3D
  4. extends Node3D
  5. func _process(_delta):
  6. var holder: Node3D = get_child(0).get_child(0)
  7. var cube: Node3D = holder.get_child(0)
  8. # "Hide" the origin vector if the AxisMarker is at (0, 0, 0)
  9. if position == Vector3():
  10. holder.transform = Transform3D()
  11. cube.transform = Transform3D().scaled(Vector3.ONE * 0.0001)
  12. return
  13. holder.transform = Transform3D(Basis(), position / 2)
  14. holder.transform = holder.transform.looking_at(position, Vector3.UP)
  15. holder.transform = get_parent().global_transform * holder.transform
  16. cube.transform = Transform3D(Basis().scaled(Vector3(0.1, 0.1, position.length())))