obj_parser 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -35,6 +35,7 @@ module ObjParser
35
35
  end
36
36
 
37
37
  def compute_tangents
38
+ return if textures.count == 0 || normals.count == 0
38
39
  self.resolve_faces
39
40
  self.tangents = []
40
41
  self.tangents_indexes = []
@@ -1,3 +1,3 @@
1
1
  module ObjParser
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -11,7 +11,7 @@ describe ObjParser::ObjParser do
11
11
  obj.textures.count.must_equal(4)
12
12
  obj.vertice_indexes.count.must_equal(36)
13
13
  obj.normals_indexes.count.must_equal(36)
14
- obj.textures_indexes.count.must_equal(36)
14
+ obj.textures_indexes.count.must_equal(36)
15
15
  end
16
16
 
17
17
  private
@@ -22,7 +22,6 @@ describe ObjParser::Obj do
22
22
 
23
23
  it 'compute tangents' do
24
24
  @obj.compute_tangents
25
- puts @obj.tangents.map(&:data)
26
25
  result = @obj.faces.each_with_index.map do |face, index|
27
26
  face.vertice.map do |vertex|
28
27
  ("%.2f" % ObjParser::MathUtils::dot(vertex.tangent.data[0..2], vertex.normal.data)).to_f
@@ -31,4 +30,16 @@ describe ObjParser::Obj do
31
30
  result.must_equal(0)
32
31
  end
33
32
 
33
+ it 'compute tangents does nothing when normals and textures are defined' do
34
+ t = @obj.textures
35
+ @obj.textures = []
36
+ @obj.compute_tangents
37
+ @obj.tangents.must_equal([])
38
+
39
+ @obj.textures = t
40
+ @obj.normals = []
41
+ @obj.compute_tangents
42
+ @obj.tangents.must_equal([])
43
+ end
44
+
34
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obj_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: