Sha256: 4cec021ffb3628f3dec30e5af496f532d65544f28c41851f363a149d98769f9e

Contents?: true

Size: 801 Bytes

Versions: 5

Compression:

Stored size: 801 Bytes

Contents

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

5 entries across 5 versions & 1 rubygems

Version Path
mittsu-0.5.0 lib/mittsu/cameras/camera.rb
mittsu-0.4.1 lib/mittsu/cameras/camera.rb
mittsu-0.4.0 lib/mittsu/cameras/camera.rb
mittsu-0.3.3 lib/mittsu/cameras/camera.rb
mittsu-0.3.2 lib/mittsu/cameras/camera.rb