Hexagon Transforming each object in the scene in global world reference space quickly becomes tiresome, so let’s introduce a new group “shape”. A group takes any number of objects and provides a common reference space for its children via its own transform. A group also helps reduce the search space in large scenes, by aggregating the bounding boxes of its children into a bounding box for the entire group. That way ray intersection tests against the children of the group only needs to happen when the group bounding box is intersected. Neat.

Oh, and why not let shapes inherit the material from their parent group, when they have no material of their own?

world << Group.new do |g|
  g.material = Material.new do |m|
    m.color = Color[1.0, 0.8, 0.5]
    m.shininess = 300
    m.reflective = 0.9
  end
  0.upto(5) do |n|
    g << hexagon_side(n)
  end
end