extends Camera3D

func _ready() -> void:
	GameEngine.getGE().mainCamera = self

func getMouseRayCast() -> Vector3:
	var mousePos: Vector2 = get_viewport().get_mouse_position()	
	var originPoint: Vector3 = self.project_ray_origin(mousePos)
	var directionVec: Vector3 = self.project_ray_normal(mousePos)
	
	var rayLen: float = self.far
	var endPoint: Vector3 = originPoint + directionVec * rayLen
	
	var spaceState = get_world_3d().direct_space_state
	var query = PhysicsRayQueryParameters3D.create(originPoint, endPoint)
	var result = spaceState.intersect_ray(query)
	
	if not result.is_empty():
		return result["position"]
	else:
		return Vector3.INF
	
