Sha256: 0bc8aad442f00a526cdead8a992679bdf17b194324dd79411b6077425503b7f2
Contents?: true
Size: 560 Bytes
Versions: 1
Compression:
Stored size: 560 Bytes
Contents
module Rubytracer class Scene attr_reader :lighting def initialize(objects=[], lighting=[]) @objects = objects @lighting = lighting end def add_object(object) @objects << object end def add_light(light) @lighting << light end def intersect(ray) min = [nil, Float::INFINITY] @objects.map { |object| [object, object.intersect(ray)[0]] }.each do |object, intersection| min = [object, intersection] if intersection > 0 && intersection < min[1] end min end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubytracer-0.1.0 | lib/rubytracer/scene.rb |