# syncs a sphere mesh with a GPUParticlesAttractorSphere3D bounds.
# also runs in editor for preview.
@tool
class_name VisualAttractorSphere
extends GPUParticlesAttractorSphere3D

func _get_configuration_warnings() -> PackedStringArray:
	var warnings: PackedStringArray = []
	
	if not has_node("Visual"):
		warnings.append("Missing Visual child node - this node requires a Visual child containing the mesh to display")
		
	return warnings

var initial_rotation: Vector3 = Vector3.ZERO

func _ready() -> void:
	initial_rotation = global_rotation

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
	var visual = get_node_or_null("Visual")
	# assume visual mesh is 1m radius
	if visual:
		visual.scale = Vector3(radius, radius, radius)

	# in the actual game, keep the rotation fixed.
	if !Engine.is_editor_hint():
		global_rotation = initial_rotation