def update_shadow_camera(camera, light)
      shadow_camera = light.shadow_camera
      points_frustum = light.pointa_frustum
      points_world = light.points_world

      @min.set(Float::INFINITY, Float::INFINITY, Float::INFINITY)
      @max.set(-Float::INFINITY, -Float::INFINITY, -Float::INFINITY)

      8.times do |i|
        p = points_world[i]

        p.copy(points_frustum[i])
        p.unproject(camera)

        p.apply_matrix4(shadow_camera.matrix_world_inverse)

        @min.x = p.x if (p.x < @min.x)
        @max.x = p.x if (p.x > @max.x)

        @min.y = p.y if (p.y < @min.y)
        @max.y = p.y if (p.y > @max.y)

        @min.z = p.z if (p.z < @min.z)
        @max.z = p.z if (p.z > @max.z)
      end

      shadow_camera.left = @min.x
      shadow_camera.right = @max.x
      shadow_camera.top = @max.y
      shadow_camera.bottom = @min.y

      # can't really fit near/far
      # shadow_camera.near = @min.x
      # shadow_camera.far = @max.z

      shadow_camera.update_projection_matrix
    end
def update_shadow_camera(camera, light)
      shadow_camera = light.shadow_camera
      points_frustum = light.pointa_frustum
      points_world = light.points_world

      @min.set(Float::INFINITY, Float::INFINITY, Float::INFINITY)
      @max.set(-Float::INFINITY, -Float::INFINITY, -Float::INFINITY)

      8.times do |i|
        p = points_world[i]

        p.copy(points_frustum[i])
        p.unproject(camera)

        p.apply_matrix4(shadow_camera.matrix_world_inverse)

        @min.x = p.x if (p.x < @min.x)
        @max.x = p.x if (p.x > @max.x)

        @min.y = p.y if (p.y < @min.y)
        @max.y = p.y if (p.y > @max.y)

        @min.z = p.z if (p.z < @min.z)
        @max.z = p.z if (p.z > @max.z)
      end

      shadow_camera.left = @min.x
      shadow_camera.right = @max.x
      shadow_camera.top = @max.y
      shadow_camera.bottom = @min.y

      # can't really fit near/far
      # shadow_camera.near = @min.x
      # shadow_camera.far = @max.z

      shadow_camera.update_projection_matrix
    end
fit shadow camera's ortho frustum to camera frustum