(define (make-background color)
  (lambda (selector)
    (case selector
      ((get-background)
       (lambda () color))
      (else
       (render-error "make-background" "Invalid selector: " selector)))))

(define (make-fog color distance)
  (lambda (selector)
    (case selector
      ((get-color)
       (lambda () color))
      ((get-distance)
       (lambda () distance))
      ((apply-fog)
       (lambda (object-distance object-color)
         (if (= distance INFINITY)
           object-color
          (if (>= object-distance distance)
            color
            (let
              ((fraction (/ object-distance distance)))
              (v+ (v-scale object-color (- 1.0 fraction))
                  (v-scale color fraction)))))))
      (else
        (render-error "make-fog" "Invalid selector: " selector)))))

(define (get-x p)
  ((p 'get-x)))

(define (get-y p)
  ((p 'get-y)))

(define (get-z p)
  ((p 'get-z)))

; TODO dont need anymore
;(define (get-clock) scene-clock)
