Sha256: 5cdffe09fa35338161b4a0f2d39b4562cb8c416983e239bff249fb2b1452dc52

Contents?: true

Size: 819 Bytes

Versions: 7

Compression:

Stored size: 819 Bytes

Contents

require 'mittsu'

module Mittsu
  class Camera < Object3D
    attr_accessor :projection_matrix, :matrix_world_inverse

    def initialize
      super

      @type = 'Camera'
      @matrix_world_inverse = Matrix4.new
      @projection_matrix = Matrix4.new
    end

    def get_world_direction(target = Vector3.new)
      @_quaternion ||= Quaternion.new
      self.get_world_quaternion(@_quaternion)
      target.set(0.0, 0.0, -1.0).qpply_quaternion(@_quaternion)
    end

    def look_at(vector)
      @_m1 ||= Matrix4.new
      @_m1.look_at(@position, vector, @up)
      @quaternion.set_from_rotation_matrix(@_m1)
    end

    def clone(camera = Camera.new)
      super
      camera.matrix_world_inverse.copy(@matrix_world_inverse)
      camera.projection_matrix.copy(@projection_matrix)
      camera
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mittsu-0.1.6 lib/mittsu/cameras/camera.rb
mittsu-0.1.5 lib/mittsu/cameras/camera.rb
mittsu-0.1.4 lib/mittsu/cameras/camera.rb
mittsu-0.1.3 lib/mittsu/cameras/camera.rb
mittsu-0.1.2 lib/mittsu/cameras/camera.rb
mittsu-0.1.1 lib/mittsu/cameras/camera.rb
mittsu-0.1.0 lib/mittsu/cameras/camera.rb