void SelectFromRectangle(Rectangle screenRect, bool isSelectionModification, bool removeSelection) { var unprojectedSelectionRect = _camera.UnprojectRectangle(screenRect); var currentState = _selectionManager.GetState(); if (currentState.Mode == GeometrySelectionMode.Face && currentState is FaceSelectionState faceState) { if (GeometryIntersection.IntersectFaces(unprojectedSelectionRect, faceState.RenderObject.Geometry, faceState.RenderObject.ModelMatrix, out var faces)) { var faceSelectionCommand = new FaceSelectionCommand(faces, isSelectionModification, removeSelection); _commandManager.ExecuteCommand(faceSelectionCommand); return; } } else if (currentState.Mode == GeometrySelectionMode.Vertex && currentState is VertexSelectionState vertexState) { if (GeometryIntersection.IntersectVertices(unprojectedSelectionRect, vertexState.RenderObject.Geometry, vertexState.RenderObject.ModelMatrix, out var vertices)) { var vertexSelectionCommand = new VertexSelectionCommand(vertices, isSelectionModification, removeSelection); _commandManager.ExecuteCommand(vertexSelectionCommand); return; } } var selectedObjects = _sceneManger.SelectObjects(unprojectedSelectionRect); if (selectedObjects.Count() == 0 && isSelectionModification == false) { // Only clear selection if we are not in geometry mode and the selection count is not empty if (currentState.Mode != GeometrySelectionMode.Object || currentState.SelectionCount() != 0) { var selectionCommand = new ObjectSelectionCommand(new List <ISelectable>(), false, false); _commandManager.ExecuteCommand(selectionCommand); } } else if (selectedObjects != null) { var selectionCommand = new ObjectSelectionCommand(selectedObjects, isSelectionModification, removeSelection); _commandManager.ExecuteCommand(selectionCommand); } }