private async Task Update() { while (!IsDisposed) { if (IsActive) { gizmo.Update(); if (gizmo.HasSelection && IsMouseAvailable) { IsControllingMouse = true; if (game.Input.IsMouseButtonPressed(MouseButton.Left)) { clickedElement = gizmo.SelectedElement; } else if (game.Input.IsMouseButtonReleased(MouseButton.Left)) { if (clickedElement.HasValue && clickedElement == gizmo.SelectedElement) { Int3 selectedElement = clickedElement.Value; // If looking along a coordinate axis and the corresponding element is clicked, switch projection mode if (gizmo.IsViewParallelToAxis && selectedElement.LengthSquared() == 1) { var camera = Camera.Camera; camera.Dispatcher.Invoke(() => camera.OrthographicProjection = !camera.OrthographicProjection); } else { var viewDirection = new Vector3(-selectedElement.X, -selectedElement.Y, -selectedElement.Z); Camera.ResetCamera(viewDirection); } } clickedElement = null; IsControllingMouse = false; } } else { IsControllingMouse = false; } } await game.Script.NextFrame(); } }