I am trying to do a bounding box redraw, but it seems my transform is not correct, can anyone guide me?

      def calculate_bounding_draw(view, selection)
        if selection.size > 0
          @bounding_box = Geom::BoundingBox.new
          @bounding_box_ids = [] # Store IDs of entities within the Bounding Box
      
          selection.each do |entity|
            if entity.is_a?(Sketchup::ComponentInstance) || entity.is_a?(Sketchup::Group)
              definition = entity.definition  # Get ComponentDefinition / GroupDefinition
              @bounding_box.add(definition.bounds) # Get original Bounding Box
              @bounding_box_ids << entity.entityID
            elsif entity.respond_to?(:bounds)
              @bounding_box.add(entity.bounds) # Add entity bounds to the Bounding Box
              @bounding_box_ids << entity.entityID
            end
          end
      
          @bounding_box_count = selection.size # Store the count of selected entities
        else
          @bounding_box = nil
          @bounding_box_ids = nil
          @bounding_box_count = 1 # Default count when selection is empty
        end
      
        view.invalidate # Refresh the view
      end

      def draw(view)
        # Check if there is at least one entity in selection
        if @bounding_box_count && @bounding_box_count >= 1
          # Always draw Bounding Box edges
          draw_bounding_box_edges(view) if @bounding_box && !@bounding_box.empty?

          # Draw Bounding Box faces if needed
          if @hovering_axis.nil?
            draw_bounds(view) if @bounding_box && @hovered_bounding_face
          end
        end
      end

      def draw_bounding_box_edges(view) 
        return if @bounding_box.nil? || @bounding_box.empty?
      
        # Expand the Bounding Box
        min_pt = @bounding_box.min
        max_pt = @bounding_box.max
        offset = defined?(OFFSET_FACE) ? OFFSET_FACE : 1.0
      
        expanded_min = Geom::Point3d.new(min_pt.x - offset, min_pt.y - offset, min_pt.z - offset)
        expanded_max = Geom::Point3d.new(max_pt.x + offset, max_pt.y + offset, max_pt.z + offset)
      
        # Define the corners of the bounding box
        corners = [
          expanded_min, # 0: bottom-front-left
          Geom::Point3d.new(expanded_max.x, expanded_min.y, expanded_min.z), # 1: bottom-front-right
          Geom::Point3d.new(expanded_max.x, expanded_max.y, expanded_min.z), # 2: bottom-back-right
          Geom::Point3d.new(expanded_min.x, expanded_max.y, expanded_min.z), # 3: bottom-back-left
          Geom::Point3d.new(expanded_min.x, expanded_min.y, expanded_max.z), # 4: top-front-left
          Geom::Point3d.new(expanded_max.x, expanded_min.y, expanded_max.z), # 5: top-front-right
          expanded_max, # 6: top-back-right
          Geom::Point3d.new(expanded_min.x, expanded_max.y, expanded_max.z)  # 7: top-back-left
        ]
      
        # Define the edges of the bounding box
        edges = {
          bottom_front: [corners[0], corners[1]],
          bottom_right: [corners[1], corners[2]],
          bottom_back: [corners[2], corners[3]],
          bottom_left: [corners[3], corners[0]],
      
          top_front: [corners[4], corners[5]],
          top_right: [corners[5], corners[6]],
          top_back: [corners[6], corners[7]],
          top_left: [corners[7], corners[4]],
      
          vertical_front_left: [corners[0], corners[4]],
          vertical_front_right: [corners[1], corners[5]],
          vertical_back_right: [corners[2], corners[6]],
          vertical_back_left: [corners[3], corners[7]]
        }
      
        # Draw all edges with normal lines
        view.line_width = 1
        view.line_stipple = ""
        view.drawing_color = @color_back
        edges.each_value { |start_point, end_point| view.draw(GL_LINES, start_point, end_point) }
      end

Check the Ruby API docs for the bounds method. It says that for a ComponentDefinition the bounds are returned in the definition coordinates. You need to use the Group or ComponentInstance Transformation to convert them to model coordinates.