Sha256: 1ca88f8af748eb76a195190b5a4bf909eb7a9cc3b07e5caa6fd85b9ea29b32b5

Contents?: true

Size: 819 Bytes

Versions: 8

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).apply_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

8 entries across 8 versions & 1 rubygems

Version Path
mittsu-0.3.1 lib/mittsu/cameras/camera.rb
mittsu-0.3.0 lib/mittsu/cameras/camera.rb
mittsu-0.2.4 lib/mittsu/cameras/camera.rb
mittsu-0.2.3 lib/mittsu/cameras/camera.rb
mittsu-0.2.2 lib/mittsu/cameras/camera.rb
mittsu-0.2.1 lib/mittsu/cameras/camera.rb
mittsu-0.2.0 lib/mittsu/cameras/camera.rb
mittsu-0.1.7 lib/mittsu/cameras/camera.rb