class IRB::RubyModel
def render_frame(i)
def render_frame(i) angle = i / 10.0 dir = Vec.new(*Complex.polar(1, angle).rect, Math.sin(angle)).normalize dir2 = Vec.new(*Complex.polar(1, angle - Math::PI/2).rect, 0) up = dir.cross(dir2) nm = dir.cross(up) @faces.each do |vertices| v0, v1, v2, = vertices if v1.sub(v0).cross(v2.sub(v0)).dot(dir) > 0 points = vertices.map {|p| [nm.dot(p), up.dot(p)] } (points + [points[0]]).each_cons(2) do |p1, p2| yield p1, p2 end end end end