Class: Face

Inherits:
Object
  • Object
show all
Defined in:
lib/glitch3d/objects/face.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(v1, v2, v3) ⇒ Face

Returns a new instance of Face.



5
6
7
8
9
# File 'lib/glitch3d/objects/face.rb', line 5

def initialize(v1, v2, v3)
  @v1 = v1
  @v2 = v2
  @v3 = v3
end

Instance Attribute Details

#v1Object

Returns the value of attribute v1.



3
4
5
# File 'lib/glitch3d/objects/face.rb', line 3

def v1
  @v1
end

#v2Object

Returns the value of attribute v2.



3
4
5
# File 'lib/glitch3d/objects/face.rb', line 3

def v2
  @v2
end

#v3Object

Returns the value of attribute v3.



3
4
5
# File 'lib/glitch3d/objects/face.rb', line 3

def v3
  @v3
end

Instance Method Details

#fuck(new_vertex) ⇒ Object



20
21
22
# File 'lib/glitch3d/objects/face.rb', line 20

def fuck(new_vertex)
  send("#{rand_attr}=", new_vertex)
end

#rand_attrObject



16
17
18
# File 'lib/glitch3d/objects/face.rb', line 16

def rand_attr
  [:v1, :v2, :v3].sample
end

#to_sObject



11
12
13
14
# File 'lib/glitch3d/objects/face.rb', line 11

def to_s
  return nil unless !v1.nil? && !v2.nil? && !v3.nil?
  "f #{v1.index} #{v2.index} #{v3.index}"
end