mittsu 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build-workflow.yml +25 -4
  3. data/.gitignore +1 -0
  4. data/lib/mittsu/cameras/perspective_camera.rb +3 -3
  5. data/lib/mittsu/core/buffer_geometry.rb +2 -2
  6. data/lib/mittsu/core/object_3d.rb +6 -6
  7. data/lib/mittsu/extras/geometries/circle_geometry.rb +3 -3
  8. data/lib/mittsu/extras/geometries/cylinder_geometry.rb +5 -5
  9. data/lib/mittsu/extras/geometries/dodecahedron_geometry.rb +2 -2
  10. data/lib/mittsu/extras/geometries/icosahedron_geometry.rb +2 -2
  11. data/lib/mittsu/extras/geometries/lathe_geometry.rb +3 -3
  12. data/lib/mittsu/extras/geometries/parametric_geometry.rb +19 -19
  13. data/lib/mittsu/extras/geometries/polyhedron_geometry.rb +6 -6
  14. data/lib/mittsu/extras/geometries/ring_geometry.rb +4 -4
  15. data/lib/mittsu/extras/geometries/sphere_geometry.rb +4 -4
  16. data/lib/mittsu/extras/geometries/torus_geometry.rb +7 -7
  17. data/lib/mittsu/extras/geometries/torus_knot_buffer_geometry.rb +9 -9
  18. data/lib/mittsu/extras/image_utils.rb +1 -1
  19. data/lib/mittsu/lights/spot_light.rb +1 -1
  20. data/lib/mittsu/loaders/loader.rb +2 -2
  21. data/lib/mittsu/math.rb +0 -5
  22. data/lib/mittsu/math/color.rb +3 -3
  23. data/lib/mittsu/math/euler.rb +24 -24
  24. data/lib/mittsu/math/matrix4.rb +10 -10
  25. data/lib/mittsu/math/quaternion.rb +17 -17
  26. data/lib/mittsu/math/ray.rb +1 -1
  27. data/lib/mittsu/math/sphere.rb +1 -1
  28. data/lib/mittsu/math/triangle.rb +1 -1
  29. data/lib/mittsu/math/vector.rb +3 -3
  30. data/lib/mittsu/math/vector4.rb +8 -8
  31. data/lib/mittsu/renderers/opengl/lights/spot_light.rb +1 -1
  32. data/lib/mittsu/renderers/opengl_renderer.rb +1 -1
  33. data/lib/mittsu/version.rb +1 -1
  34. data/mittsu.gemspec +1 -1
  35. metadata +10 -10
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a55da556e2ceb6e5babfd2a3ad6d2323ed55d8a6826711e788a4ca6d4c4d3f5
4
- data.tar.gz: 1bb2eb47e77bd8cf29b3b76528c279de08ae8070bc8f2fa7a87450761db8fa47
3
+ metadata.gz: bce7b85c4911927e9f33bb5212d9011122a33356cc8811b33482af05577b9977
4
+ data.tar.gz: 23620dc7e242612382df2647df7b45f2a21364543deb0d64e389844d65a069c1
5
5
  SHA512:
6
- metadata.gz: 6738337c1dbe38d39bbe163a108e06abbe9f6838db2dcbe6314696bb3f8344878c060d7b85e9e98149fe455d72a58d1781718a569bac7ec20808fe806eec7eac
7
- data.tar.gz: 97defbe815a66d53398b93252be981484d186c11f785cde562cc20845c6dbed2256ccafce957c891ffe08c73f118700488fdf179d4f6832e96f501262e8feb8e
6
+ metadata.gz: 192b53dca3a2f7ecc79c22cdeae9410d7ce5dcf4af30803d9f0242bdc9caa10cef93cc8a1948932da102cbfe049e6d67951ce983e27ed40f20809fa18b044897
7
+ data.tar.gz: d08903f9f798c488b35f52f991e311bdbd2f95427094c10b55c5c6d67570d4956c8616d52ad025b9507945e57a5e3ecbff876c50472317493e778d6819286d8e
@@ -1,10 +1,19 @@
1
1
  name: Build
2
- on: [push]
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request:
7
+ branches:
8
+ - main
3
9
 
4
10
  jobs:
5
11
  linux:
6
12
  name: Linux
7
13
  runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby: ['2.5.x', '2.6.x', '2.7.x', '3.0.x']
8
17
  steps:
9
18
  - uses: actions/checkout@v1
10
19
  - name: Cache gems
@@ -18,20 +27,28 @@ jobs:
18
27
  gems-v1-${{ runner.os }}-
19
28
  - uses: actions/setup-ruby@v1
20
29
  with:
21
- ruby-version: '2.x'
30
+ ruby-version: ${{ matrix.ruby }}
22
31
  - run: sudo apt-get update; sudo apt-get install cmake xorg-dev libgl1-mesa-dev
23
32
  - run: bash install-glfw.sh
33
+ - run: gem install bundler
24
34
  - run: bundle install --path vendor/bundle
25
35
  - name: Test & publish code coverage
26
36
  uses: paambaati/codeclimate-action@v2.2.1
37
+ if: github.event_name == 'push'
27
38
  env:
28
39
  CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
29
40
  with:
30
41
  coverageCommand: bundle exec rake test
42
+ - name: Test
43
+ if: github.event_name != 'push'
44
+ run: bundle exec rake test
31
45
 
32
46
  macos:
33
47
  name: macOS
34
48
  runs-on: macos-latest
49
+ strategy:
50
+ matrix:
51
+ ruby: ['2.5.x', '2.6.x', '2.7.x', '3.0.x']
35
52
  steps:
36
53
  - uses: actions/checkout@v1
37
54
  - name: Cache gems
@@ -45,7 +62,7 @@ jobs:
45
62
  gems-v1-${{ runner.os }}-
46
63
  - uses: actions/setup-ruby@v1
47
64
  with:
48
- ruby-version: '2.x'
65
+ ruby-version: ${{ matrix.ruby }}
49
66
  - run: brew install glfw
50
67
  - run: bundle install --path vendor/bundle
51
68
  - run: bundle exec rake test
@@ -55,6 +72,9 @@ jobs:
55
72
  runs-on: windows-latest
56
73
  env:
57
74
  MITTSU_LIBGLFW_FILE: c:\projects\mittsu\glfw-3.3.1.bin.WIN32\lib-mingw\glfw3.dll
75
+ strategy:
76
+ matrix:
77
+ ruby: ['2.5.x', '2.6.x', '2.7.x', '3.0.x']
58
78
  steps:
59
79
  - uses: actions/checkout@v1
60
80
  - name: Cache gems
@@ -68,7 +88,8 @@ jobs:
68
88
  gems-v1-${{ runner.os }}-
69
89
  - uses: actions/setup-ruby@v1
70
90
  with:
71
- ruby-version: '2.x'
91
+ ruby-version: ${{ matrix.ruby }}
72
92
  - run: .\install-glfw.ps1
93
+ - run: gem install bundler
73
94
  - run: bundle install --path vendor/bundle
74
95
  - run: bundle exec rake test
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /test/reports
11
11
  *.gem
12
+ .tool-versions
@@ -22,7 +22,7 @@ module Mittsu
22
22
  # 35mm (fullframe) camera is used if frame size is not specified;
23
23
  # Formula based on http://www.bobatkins.com/photography/technical/field_of_view.html
24
24
  def set_lens(focal_length, frame_height = 24.0)
25
- @fov = 2.0 * Math.rad_to_deg(Math.atan(frame_height / (focal_length * 2.0)))
25
+ @fov = 2.0 * Math.rad_to_deg(::Math.atan(frame_height / (focal_length * 2.0)))
26
26
  update_projection_matrix
27
27
  end
28
28
 
@@ -72,11 +72,11 @@ module Mittsu
72
72
  end
73
73
 
74
74
  def update_projection_matrix
75
- new_fov = Math.rad_to_deg(2.0 * Math.atan(Math.tan(Math.deg_to_rad(@fov) * 0.5) / @zoom))
75
+ new_fov = Math.rad_to_deg(2.0 * ::Math.atan(::Math.tan(Math.deg_to_rad(@fov) * 0.5) / @zoom))
76
76
 
77
77
  if @full_width
78
78
  aspect = @full_width / @full_height
79
- top = Math.tan(Math.deg_to_rad(new_fov * 0.5)) * @near
79
+ top = ::Math.tan(Math.deg_to_rad(new_fov * 0.5)) * @near
80
80
  bottom = -top
81
81
  left = aspect * bottom
82
82
  right = aspect * top
@@ -179,7 +179,7 @@ module Mittsu
179
179
  max_radius_sq = [max_radius_sq, center.distance_to_squared(vector)].max
180
180
  end
181
181
 
182
- @bounding_sphere.radius = Math.sqrt(max_radius_sq)
182
+ @bounding_sphere.radius = ::Math.sqrt(max_radius_sq)
183
183
 
184
184
  if @bounding_radius.nan?
185
185
  puts 'ERROR: Mittsu::BufferGeometry#computeBoundingSphere: Computed radius is NaN. The "position" attribute is likely to have NaN values.'
@@ -558,7 +558,7 @@ module Mittsu
558
558
  normals.each_slice(3).with_index do |normal, i|
559
559
  x, y, z = *normal
560
560
 
561
- n = 1.0 / Math.sqrt(x * x + y * y + z * z)
561
+ n = 1.0 / ::Math.sqrt(x * x + y * y + z * z)
562
562
 
563
563
  i *= 3
564
564
  normals[i] *= n
@@ -97,18 +97,18 @@ module Mittsu
97
97
  end
98
98
 
99
99
  def rotate_x(angle)
100
- @_v1 ||= Vector3.new(1, 0, 0)
101
- self.rotate_on_axis(@_v1, angle)
100
+ @_x_axis ||= Vector3.new(1, 0, 0)
101
+ self.rotate_on_axis(@_x_axis, angle)
102
102
  end
103
103
 
104
104
  def rotate_y(angle)
105
- @_v1 ||= Vector3.new(0, 1, 0)
106
- self.rotate_on_axis(@_v1, angle)
105
+ @_y_axis ||= Vector3.new(0, 1, 0)
106
+ self.rotate_on_axis(@_y_axis, angle)
107
107
  end
108
108
 
109
109
  def rotate_z(angle)
110
- @_v1 ||= Vector3.new(0, 0, 1)
111
- self.rotate_on_axis(@_v1, angle)
110
+ @_z_axis ||= Vector3.new(0, 0, 1)
111
+ self.rotate_on_axis(@_z_axis, angle)
112
112
  end
113
113
 
114
114
  def translate_on_axis(axis, distance)
@@ -3,7 +3,7 @@ require 'mittsu/math'
3
3
 
4
4
  module Mittsu
5
5
  class CircleGeometry < Geometry
6
- def initialize(radius = 50.0, segments = 8, theta_start = 0.0, theta_length = (Math::PI * 2.0))
6
+ def initialize(radius = 50.0, segments = 8, theta_start = 0.0, theta_length = (::Math::PI * 2.0))
7
7
  super()
8
8
 
9
9
  @type = 'CircleGeometry'
@@ -27,8 +27,8 @@ module Mittsu
27
27
  vertex = Vector3.new
28
28
  segment = theta_start + i.to_f / segments.to_f * theta_length
29
29
 
30
- vertex.x = radius * Math.cos(segment)
31
- vertex.y = radius * Math.sin(segment)
30
+ vertex.x = radius * ::Math.cos(segment)
31
+ vertex.y = radius * ::Math.sin(segment)
32
32
 
33
33
  @vertices << vertex
34
34
  uvs << Vector2.new((vertex.x / radius + 1.0) / 2.0, (vertex.y / radius + 1.0) / 2.0)
@@ -3,7 +3,7 @@ require 'mittsu/math'
3
3
 
4
4
  module Mittsu
5
5
  class CylinderGeometry < Geometry
6
- def initialize(radius_top = 20.0, radius_bottom = 20.0, height = 100.0, radial_segments = 8, height_segments = 1, open_ended = false, theta_start = 0.0, theta_length = (Math::PI * 2.0))
6
+ def initialize(radius_top = 20.0, radius_bottom = 20.0, height = 100.0, radial_segments = 8, height_segments = 1, open_ended = false, theta_start = 0.0, theta_length = (::Math::PI * 2.0))
7
7
  super()
8
8
 
9
9
  @type = 'CylinderGeometry'
@@ -35,9 +35,9 @@ module Mittsu
35
35
  u = x.to_f / radial_segments
36
36
 
37
37
  vertex = Vector3.new
38
- vertex.x = radius * Math.sin(u * theta_length + theta_start)
38
+ vertex.x = radius * ::Math.sin(u * theta_length + theta_start)
39
39
  vertex.y = -v * height + height_half
40
- vertex.z = radius * Math.cos(u * theta_length + theta_start)
40
+ vertex.z = radius * ::Math.cos(u * theta_length + theta_start)
41
41
 
42
42
  @vertices << vertex
43
43
 
@@ -63,10 +63,10 @@ module Mittsu
63
63
  nb = @vertices[index_rows[1][x + 1]].clone
64
64
  end
65
65
 
66
- na.y = Math.sqrt(na.x * na.x + na.z * na.z) * tan_theta
66
+ na.y = ::Math.sqrt(na.x * na.x + na.z * na.z) * tan_theta
67
67
  na.normalize
68
68
 
69
- nb.y = Math.sqrt(nb.x * nb.x + nb.z * nb.z) * tan_theta
69
+ nb.y = ::Math.sqrt(nb.x * nb.x + nb.z * nb.z) * tan_theta
70
70
  nb.normalize
71
71
 
72
72
  for y in 0...height_segments do
@@ -5,7 +5,7 @@ require 'mittsu/extras/geometries/polyhedron_geometry'
5
5
  module Mittsu
6
6
  class DodecahedronGeometry < PolyhedronGeometry
7
7
  def initialize(radius = 1.0, detail = 0)
8
- t = (1.0 + Math.sqrt(5.0)) / 2.0
8
+ t = (1.0 + ::Math.sqrt(5.0)) / 2.0
9
9
  r = 1.0 / t
10
10
 
11
11
  vertices = [
@@ -53,4 +53,4 @@ module Mittsu
53
53
  }
54
54
  end
55
55
  end
56
- end
56
+ end
@@ -5,7 +5,7 @@ require 'mittsu/extras/geometries/polyhedron_geometry'
5
5
  module Mittsu
6
6
  class IcosahedronGeometry < PolyhedronGeometry
7
7
  def initialize(radius = 1.0, detail = 0)
8
- t = (1.0 + Math.sqrt(5)) / 2.0
8
+ t = (1.0 + ::Math.sqrt(5)) / 2.0
9
9
 
10
10
  vertices = [
11
11
  - 1, t, 0, 1, t, 0, - 1, - t, 0, 1, - t, 0,
@@ -30,4 +30,4 @@ module Mittsu
30
30
  }
31
31
  end
32
32
  end
33
- end
33
+ end
@@ -3,7 +3,7 @@ require 'mittsu/math'
3
3
 
4
4
  module Mittsu
5
5
  class LatheGeometry < Geometry
6
- def initialize(points, segments = 12, phi_start = 0.0, phi_length = (Math::PI * 2.0))
6
+ def initialize(points, segments = 12, phi_start = 0.0, phi_length = (::Math::PI * 2.0))
7
7
  super()
8
8
 
9
9
  @type = 'LatheGeometry'
@@ -21,8 +21,8 @@ module Mittsu
21
21
  for i in 0..segments do
22
22
  phi = phi_start + i.to_f * inverse_segments * phi_length
23
23
 
24
- c = Math.cos(phi)
25
- s = Math.sin(phi)
24
+ c = ::Math.cos(phi)
25
+ s = ::Math.sin(phi)
26
26
 
27
27
  for j in 0...points.length do
28
28
  pt = points[j]
@@ -19,23 +19,23 @@ module Mittsu
19
19
 
20
20
  def self.klein
21
21
  -> (v, u, target = Vector3.new) {
22
- u *= Math::PI
23
- v *= 2.0 * Math::PI
22
+ u *= ::Math::PI
23
+ v *= 2.0 * ::Math::PI
24
24
 
25
25
  u = u * 2.0
26
26
  x = nil
27
27
  y = nil
28
28
  z = nil
29
29
 
30
- if u < Math::PI
31
- x = 3.0 * Math.cos(u) * (1.0 + Math.sin(u)) + (2.0 * (1.0 - Math.cos(u) / 2.0)) * Math.cos(u) * Math.cos(v)
32
- z = -8.0 * Math.sin(u) - 2.0 * (1.0 - Math.cos(u) / 2.0) * Math.sin(u) * Math.cos(v)
30
+ if u < ::Math::PI
31
+ x = 3.0 * ::Math.cos(u) * (1.0 + ::Math.sin(u)) + (2.0 * (1.0 - ::Math.cos(u) / 2.0)) * ::Math.cos(u) * ::Math.cos(v)
32
+ z = -8.0 * ::Math.sin(u) - 2.0 * (1.0 - ::Math.cos(u) / 2.0) * ::Math.sin(u) * ::Math.cos(v)
33
33
  else
34
- x = 3.0 * Math.cos(u) * (1.0 + Math.sin(u)) + (2.0 * (1.0 - Math.cos(u) / 2.0)) * Math.cos(v + Math::PI)
35
- z = -8.0 * Math.sin(u)
34
+ x = 3.0 * ::Math.cos(u) * (1.0 + ::Math.sin(u)) + (2.0 * (1.0 - ::Math.cos(u) / 2.0)) * ::Math.cos(v + ::Math::PI)
35
+ z = -8.0 * ::Math.sin(u)
36
36
  end
37
37
 
38
- y = -2.0 * (1.0 - Math.cos(u) / 2.0) * Math.sin(v)
38
+ y = -2.0 * (1.0 - ::Math.cos(u) / 2.0) * ::Math.sin(v)
39
39
 
40
40
  target.set(x, y, z)
41
41
  }
@@ -56,13 +56,13 @@ module Mittsu
56
56
  # flat mobius strip
57
57
  # http://www.wolframalpha.com/input/?i=M%C3%B6bius+strip+parametric+equations&lk=1&a=ClashPrefs_*Surface.MoebiusStrip.SurfaceProperty.ParametricEquations-
58
58
  u = u - 0.5
59
- v = 2.0 * Math::PI * t
59
+ v = 2.0 * ::Math::PI * t
60
60
 
61
61
  a = 2.0
62
62
 
63
- x = Math.cos(v) * (a + u * Math.cos(v / 2.0))
64
- y = Math.sin(v) * (a + u * Math.cos(v / 2.0))
65
- z = u * Math.sin(v / 2)
63
+ x = ::Math.cos(v) * (a + u * ::Math.cos(v / 2.0))
64
+ y = ::Math.sin(v) * (a + u * ::Math.cos(v / 2.0))
65
+ z = u * ::Math.sin(v / 2)
66
66
 
67
67
  target.set(x, y, z)
68
68
  }
@@ -72,8 +72,8 @@ module Mittsu
72
72
  -> (u, t, target = Vector3.new) {
73
73
  # volumetric mobius strip
74
74
 
75
- u *= Math::PI
76
- t *= 2.0 * Math::PI
75
+ u *= ::Math::PI
76
+ t *= 2.0 * ::Math::PI
77
77
 
78
78
  u = u * 2.0
79
79
  phi = u / 2.0
@@ -81,13 +81,13 @@ module Mittsu
81
81
  a = 0.125
82
82
  b = 0.65
83
83
 
84
- x = a * Math.cos(t) * Math.cos(phi) - b * Math.sin(t) * Math.sin(phi)
85
- z = a * Math.cos(t) * Math.sin(phi) + b * Math.sin(t) * Math.cos(phi)
86
- y = (major + x) * Math.sin(u)
87
- x = (major + x) * Math.cos(u)
84
+ x = a * ::Math.cos(t) * ::Math.cos(phi) - b * ::Math.sin(t) * ::Math.sin(phi)
85
+ z = a * ::Math.cos(t) * ::Math.sin(phi) + b * ::Math.sin(t) * ::Math.cos(phi)
86
+ y = (major + x) * ::Math.sin(u)
87
+ x = (major + x) * ::Math.cos(u)
88
88
 
89
89
  target.set(x, y, z)
90
90
  }
91
91
  end
92
92
  end
93
- end
93
+ end
@@ -78,8 +78,8 @@ module Mittsu
78
78
  vertex.index = @vertices.push(vertex).length - 1
79
79
 
80
80
  # Texture coords are equivalent to map coords, calculate angle and convert to fraction of a circle.
81
- u = azimuth(vector) / 2.0 / Math::PI + 0.5
82
- v = inclination(vector) / Math::PI + 0.5
81
+ u = azimuth(vector) / 2.0 / ::Math::PI + 0.5
82
+ v = inclination(vector) / ::Math::PI + 0.5
83
83
  vertex.uv = Vector2.new(u, 1.0 - v)
84
84
 
85
85
  vertex
@@ -150,19 +150,19 @@ module Mittsu
150
150
 
151
151
  # Angle around the Y axis, counter-clockwise when looking from above.
152
152
  def azimuth(vector)
153
- Math.atan2(vector.z, -vector.x)
153
+ ::Math.atan2(vector.z, -vector.x)
154
154
  end
155
155
 
156
156
  # Angle above the XZ plane.
157
157
  def inclination(vector)
158
- Math.atan2(-vector.y, Math.sqrt(vector.x * vector.x + vector.z * vector.z))
158
+ ::Math.atan2(-vector.y, ::Math.sqrt(vector.x * vector.x + vector.z * vector.z))
159
159
  end
160
160
 
161
161
  # Texture fixing helper. Spheres have some odd behaviours.
162
162
  def correct_uv(uv, vector, azimuth)
163
163
  return Vector2.new(uv.x - 1.0, uv.y) if azimuth < 0
164
- return Vector2.new(azimuth / 2.0 / Math::PI + 0.5, uv.y) if vector.x.zero? && vector.z.zero?
164
+ return Vector2.new(azimuth / 2.0 / ::Math::PI + 0.5, uv.y) if vector.x.zero? && vector.z.zero?
165
165
  uv.clone
166
166
  end
167
167
  end
168
- end
168
+ end
@@ -3,7 +3,7 @@ require 'mittsu/math'
3
3
 
4
4
  module Mittsu
5
5
  class RingGeometry < Geometry
6
- def initialize(inner_radius = 0.0, outer_radius = 50.0, theta_segments = 8, phi_segments = 8, theta_start = 0.0, theta_length = (Math::PI * 2.0))
6
+ def initialize(inner_radius = 0.0, outer_radius = 50.0, theta_segments = 8, phi_segments = 8, theta_start = 0.0, theta_length = (::Math::PI * 2.0))
7
7
  super()
8
8
 
9
9
  @type = 'RingGeometry'
@@ -28,8 +28,8 @@ module Mittsu
28
28
  for o in 0..theta_segments do # number of segments per circle
29
29
  vertex = Vector3.new
30
30
  segment = theta_start + o.to_f / theta_segments.to_f * theta_length
31
- vertex.x = radius * Math.cos(segment)
32
- vertex.y = radius * Math.sin(segment)
31
+ vertex.x = radius * ::Math.cos(segment)
32
+ vertex.y = radius * ::Math.sin(segment)
33
33
 
34
34
  @vertices << vertex
35
35
  uvs << Vector2.new((vertex.x / outer_radius + 1.0) / 2.0, (vertex.y / outer_radius + 1.0) / 2.0)
@@ -77,4 +77,4 @@ module Mittsu
77
77
  )
78
78
  end
79
79
  end
80
- end
80
+ end
@@ -3,7 +3,7 @@ require 'mittsu/math'
3
3
 
4
4
  module Mittsu
5
5
  class SphereGeometry < Geometry
6
- def initialize(radius = 50.0, width_segments = 8, height_segments = 6, phi_start = 0.0, phi_length = (Math::PI * 2.0), theta_start = 0.0, theta_length = Math::PI)
6
+ def initialize(radius = 50.0, width_segments = 8, height_segments = 6, phi_start = 0.0, phi_length = (::Math::PI * 2.0), theta_start = 0.0, theta_length = ::Math::PI)
7
7
  super()
8
8
 
9
9
  @type = 'SphereGeometry'
@@ -33,9 +33,9 @@ module Mittsu
33
33
  v = y / height_segments.to_f
34
34
 
35
35
  vertex = Vector3.new
36
- vertex.x = -radius * Math.cos(phi_start + u * phi_length) * Math.sin(theta_start + v * theta_length)
37
- vertex.y = radius * Math.cos(theta_start + v * theta_length)
38
- vertex.z = radius * Math.sin(phi_start + u * phi_length) * Math.sin(theta_start + v * theta_length)
36
+ vertex.x = -radius * ::Math.cos(phi_start + u * phi_length) * ::Math.sin(theta_start + v * theta_length)
37
+ vertex.y = radius * ::Math.cos(theta_start + v * theta_length)
38
+ vertex.z = radius * ::Math.sin(phi_start + u * phi_length) * ::Math.sin(theta_start + v * theta_length)
39
39
 
40
40
  @vertices << vertex
41
41
 
@@ -3,7 +3,7 @@ require 'mittsu/math'
3
3
 
4
4
  module Mittsu
5
5
  class TorusGeometry < Geometry
6
- def initialize(radius = 100.0, tube = 40.0, radial_segments = 8, tubular_segments = 6, arc = (Math::PI * 2.0))
6
+ def initialize(radius = 100.0, tube = 40.0, radial_segments = 8, tubular_segments = 6, arc = (::Math::PI * 2.0))
7
7
  super()
8
8
 
9
9
  @type = 'TorusGeometry'
@@ -23,15 +23,15 @@ module Mittsu
23
23
  for j in 0..radial_segments do
24
24
  for i in 0..tubular_segments do
25
25
  u = i.to_f / tubular_segments * arc
26
- v = j.to_f / radial_segments * Math::PI * 2.0
26
+ v = j.to_f / radial_segments * ::Math::PI * 2.0
27
27
 
28
- center.x = radius * Math.cos(u)
29
- center.y = radius * Math.sin(u)
28
+ center.x = radius * ::Math.cos(u)
29
+ center.y = radius * ::Math.sin(u)
30
30
 
31
31
  vertex = Vector3.new
32
- vertex.x = (radius + tube * Math.cos(v)) * Math.cos(u)
33
- vertex.y = (radius + tube * Math.cos(v)) * Math.sin(u)
34
- vertex.z = tube * Math.sin(v)
32
+ vertex.x = (radius + tube * ::Math.cos(v)) * ::Math.cos(u)
33
+ vertex.y = (radius + tube * ::Math.cos(v)) * ::Math.sin(u)
34
+ vertex.z = tube * ::Math.sin(v)
35
35
 
36
36
  @vertices << vertex
37
37
 
@@ -37,7 +37,7 @@ module Mittsu
37
37
 
38
38
  for i in 0..tubular_segments do
39
39
  # the radian "u" is used to calculate the position on the torus curve of the current tubular segement
40
- u = i.to_f / tubular_segments.to_f * p_val.to_f * Math::PI * 2.0
40
+ u = i.to_f / tubular_segments.to_f * p_val.to_f * ::Math::PI * 2.0
41
41
 
42
42
  # now we calculate two points. P1 is our current position on the curve, P2 is a little farther ahead.
43
43
  # these points are used to create a special "coordinate space", which is necessary to calculate the correct vertex positions
@@ -57,9 +57,9 @@ module Mittsu
57
57
  for j in 0..radial_segments do
58
58
  # now calculate the vertices. they are nothing more than an extrusion of the torus curve.
59
59
  # because we extrude a shape in the xy-plane, there is no need to calculate a z-value.
60
- v = j.to_f / radial_segments.to_f * Math::PI * 2.0
61
- cx = -tube * Math.cos(v)
62
- cy = tube * Math.sin(v)
60
+ v = j.to_f / radial_segments.to_f * ::Math::PI * 2.0
61
+ cx = -tube * ::Math.cos(v)
62
+ cy = tube * ::Math.sin(v)
63
63
 
64
64
  # now calculate the final vertex position.
65
65
  # first we orient the extrusion with our basis vectos, then we add it to the current position on the curve
@@ -107,14 +107,14 @@ module Mittsu
107
107
  private
108
108
 
109
109
  def calculate_position_on_curve(u, p_val, q_val, radius, position)
110
- cu = Math.cos(u)
111
- su = Math.sin(u)
110
+ cu = ::Math.cos(u)
111
+ su = ::Math.sin(u)
112
112
  qu_over_p = q_val.to_f / p_val.to_f * u
113
- cs = Math.cos(qu_over_p)
113
+ cs = ::Math.cos(qu_over_p)
114
114
 
115
115
  position.x = radius * (2.0 + cs) * 0.5 * cu
116
116
  position.y = radius * (2.0 + cs) * su * 0.5
117
- position.z = radius * Math.sin(qu_over_p) * 0.5
117
+ position.z = radius * ::Math.sin(qu_over_p) * 0.5
118
118
  end
119
119
  end
120
- end
120
+ end
@@ -76,7 +76,7 @@ module Mittsu
76
76
  end
77
77
 
78
78
  def normalize(a)
79
- l = Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])
79
+ l = ::Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])
80
80
  [a[0] / l, a[1] / l, a[2] / l]
81
81
  end
82
82
  end
@@ -20,7 +20,7 @@ module Mittsu
20
20
  :shadow_camera,
21
21
  :shadow_matrix
22
22
 
23
- def initialize(color = nil, intensity = 1.0, distance = 0.0, angle = (Math::PI / 3.0), exponent = 10.0, decay = 1.0)
23
+ def initialize(color = nil, intensity = 1.0, distance = 0.0, angle = (::Math::PI / 3.0), exponent = 10.0, decay = 1.0)
24
24
  super(color)
25
25
 
26
26
  @type = 'SpotLight'
@@ -151,8 +151,8 @@ module Mittsu
151
151
  private
152
152
 
153
153
  def nearest_pow2(n)
154
- l = Math.log(n) / Math::LN2
155
- Math.pow(2, Math.round(l))
154
+ l = ::Math.log(n) / Math::LN2
155
+ ::Math.pow(2, ::Math.round(l))
156
156
  end
157
157
 
158
158
  def create_texture(where, name, source_file, repeat, offset, wrap, anisotropy)
data/lib/mittsu/math.rb CHANGED
@@ -17,13 +17,8 @@ require 'mittsu/math/vector2'
17
17
  require 'mittsu/math/vector3'
18
18
  require 'mittsu/math/vector4'
19
19
 
20
- BuiltInMath = Math
21
-
22
20
  module Mittsu
23
21
  module Math
24
- extend BuiltInMath
25
- include BuiltInMath
26
- BuiltInMath.methods.each { |m| public_class_method m }
27
22
 
28
23
  def self.sign(x)
29
24
  return Float::NAN unless x.is_a? Numeric
@@ -120,9 +120,9 @@ module Mittsu
120
120
  end
121
121
 
122
122
  def convert_linear_to_gamma
123
- self.r = Math.sqrt(self.r)
124
- self.g = Math.sqrt(self.g)
125
- self.b = Math.sqrt(self.b)
123
+ self.r = ::Math.sqrt(self.r)
124
+ self.g = ::Math.sqrt(self.g)
125
+ self.b = ::Math.sqrt(self.b)
126
126
  self
127
127
  end
128
128
 
@@ -56,57 +56,57 @@ module Mittsu
56
56
  m31 = te[2]; m32 = te[6]; m33 = te[10]
57
57
  order = order || @order
58
58
  if order == 'XYZ'
59
- @y = Math.asin(Math.clamp(m13, -1.0, 1.0))
59
+ @y = ::Math.asin(Math.clamp(m13, -1.0, 1.0))
60
60
  if m13.abs < 0.99999
61
- @x = Math.atan2(- m23, m33)
62
- @z = Math.atan2(- m12, m11)
61
+ @x = ::Math.atan2(- m23, m33)
62
+ @z = ::Math.atan2(- m12, m11)
63
63
  else
64
- @x = Math.atan2(m32, m22)
64
+ @x = ::Math.atan2(m32, m22)
65
65
  @z = 0.0
66
66
  end
67
67
  elsif order == 'YXZ'
68
- @x = Math.asin(- Math.clamp(m23, -1.0, 1.0))
68
+ @x = ::Math.asin(- Math.clamp(m23, -1.0, 1.0))
69
69
  if m23.abs < 0.99999
70
- @y = Math.atan2(m13, m33)
71
- @z = Math.atan2(m21, m22)
70
+ @y = ::Math.atan2(m13, m33)
71
+ @z = ::Math.atan2(m21, m22)
72
72
  else
73
- @y = Math.atan2(- m31, m11)
73
+ @y = ::Math.atan2(- m31, m11)
74
74
  @z = 0.0
75
75
  end
76
76
  elsif order == 'ZXY'
77
- @x = Math.asin(Math.clamp(m32, -1.0, 1.0))
77
+ @x = ::Math.asin(Math.clamp(m32, -1.0, 1.0))
78
78
  if m32.abs < 0.99999
79
- @y = Math.atan2(- m31, m33)
80
- @z = Math.atan2(- m12, m22)
79
+ @y = ::Math.atan2(- m31, m33)
80
+ @z = ::Math.atan2(- m12, m22)
81
81
  else
82
82
  @y = 0.0
83
- @z = Math.atan2(m21, m11)
83
+ @z = ::Math.atan2(m21, m11)
84
84
  end
85
85
  elsif order == 'ZYX'
86
- @y = Math.asin(- Math.clamp(m31, -1.0, 1.0))
86
+ @y = ::Math.asin(- Math.clamp(m31, -1.0, 1.0))
87
87
  if m31.abs < 0.99999
88
- @x = Math.atan2(m32, m33)
89
- @z = Math.atan2(m21, m11)
88
+ @x = ::Math.atan2(m32, m33)
89
+ @z = ::Math.atan2(m21, m11)
90
90
  else
91
91
  @x = 0.0
92
- @z = Math.atan2(- m12, m22)
92
+ @z = ::Math.atan2(- m12, m22)
93
93
  end
94
94
  elsif order == 'YZX'
95
- @z = Math.asin(Math.clamp(m21, -1.0, 1.0))
95
+ @z = ::Math.asin(Math.clamp(m21, -1.0, 1.0))
96
96
  if m21.abs < 0.99999
97
- @x = Math.atan2(- m23, m22)
98
- @y = Math.atan2(- m31, m11)
97
+ @x = ::Math.atan2(- m23, m22)
98
+ @y = ::Math.atan2(- m31, m11)
99
99
  else
100
100
  @x = 0.0
101
- @y = Math.atan2(m13, m33)
101
+ @y = ::Math.atan2(m13, m33)
102
102
  end
103
103
  elsif order == 'XZY'
104
- @z = Math.asin(- Math.clamp(m12, -1.0, 1.0))
104
+ @z = ::Math.asin(- Math.clamp(m12, -1.0, 1.0))
105
105
  if m12.abs < 0.99999
106
- @x = Math.atan2(m32, m22)
107
- @y = Math.atan2(m13, m11)
106
+ @x = ::Math.atan2(m32, m22)
107
+ @y = ::Math.atan2(m13, m11)
108
108
  else
109
- @x = Math.atan2(- m23, m33)
109
+ @x = ::Math.atan2(- m23, m33)
110
110
  @y = 0.0
111
111
  end
112
112
  else
@@ -86,9 +86,9 @@ module Mittsu
86
86
  def make_rotation_from_euler(euler)
87
87
  te = self.elements
88
88
  x, y, z = euler.x, euler.y, euler.z
89
- a, b = Math.cos(x), Math.sin(x)
90
- c, d = Math.cos(y), Math.sin(y)
91
- e, f = Math.cos(z), Math.sin(z)
89
+ a, b = ::Math.cos(x), ::Math.sin(x)
90
+ c, d = ::Math.cos(y), ::Math.sin(y)
91
+ e, f = ::Math.cos(z), ::Math.sin(z)
92
92
  if euler.order == 'XYZ'
93
93
  ae = a * e; af = a * f; be = b * e; bf = b * f
94
94
  te[0] = c * e
@@ -399,7 +399,7 @@ module Mittsu
399
399
  scale_x_sq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2]
400
400
  scale_y_sq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6]
401
401
  scale_z_sq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10]
402
- Math.sqrt([scale_x_sq, scale_y_sq, scale_z_sq].max)
402
+ ::Math.sqrt([scale_x_sq, scale_y_sq, scale_z_sq].max)
403
403
  end
404
404
 
405
405
  def make_translation(x, y, z)
@@ -413,7 +413,7 @@ module Mittsu
413
413
  end
414
414
 
415
415
  def make_rotation_x(theta)
416
- c, s = Math.cos(theta), Math.sin(theta)
416
+ c, s = ::Math.cos(theta), ::Math.sin(theta)
417
417
  self.set(
418
418
  1.0, 0.0, 0.0, 0.0,
419
419
  0.0, c, -s, 0.0,
@@ -424,7 +424,7 @@ module Mittsu
424
424
  end
425
425
 
426
426
  def make_rotation_y(theta)
427
- c, s = Math.cos(theta), Math.sin(theta)
427
+ c, s = ::Math.cos(theta), ::Math.sin(theta)
428
428
  self.set(
429
429
  c, 0.0, s, 0.0,
430
430
  0.0, 1.0, 0.0, 0.0,
@@ -435,7 +435,7 @@ module Mittsu
435
435
  end
436
436
 
437
437
  def make_rotation_z(theta)
438
- c, s = Math.cos(theta), Math.sin(theta)
438
+ c, s = ::Math.cos(theta), ::Math.sin(theta)
439
439
  self.set(
440
440
  c, -s, 0.0, 0.0,
441
441
  s, c, 0.0, 0.0,
@@ -447,8 +447,8 @@ module Mittsu
447
447
 
448
448
  def make_rotation_axis(axis, angle)
449
449
  # Based on http:#www.gamedev.net/reference/articles/article1199.asp
450
- c = Math.cos(angle)
451
- s = Math.sin(angle)
450
+ c = ::Math.cos(angle)
451
+ s = ::Math.sin(angle)
452
452
  t = 1.0 - c
453
453
  x, y, z = axis.x, axis.y, axis.z
454
454
  tx, ty = t * x, t * y
@@ -534,7 +534,7 @@ module Mittsu
534
534
  def make_perspective(fov, aspect, near, far)
535
535
  fov, aspect, near, far =
536
536
  fov.to_f, aspect.to_f, near.to_f, far.to_f
537
- ymax = near * Math.tan(Math.deg_to_rad(fov * 0.5))
537
+ ymax = near * ::Math.tan(Math.deg_to_rad(fov * 0.5))
538
538
  ymin = -ymax
539
539
  xmin = ymin * aspect
540
540
  xmax = ymax * aspect
@@ -51,12 +51,12 @@ module Mittsu
51
51
  # http:#www.mathworks.com/matlabcentral/fileexchange/
52
52
  # 20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/
53
53
  # content/SpinCalc.m
54
- c1 = Math.cos(euler.x / 2.0)
55
- c2 = Math.cos(euler.y / 2.0)
56
- c3 = Math.cos(euler.z / 2.0)
57
- s1 = Math.sin(euler.x / 2.0)
58
- s2 = Math.sin(euler.y / 2.0)
59
- s3 = Math.sin(euler.z / 2.0)
54
+ c1 = ::Math.cos(euler.x / 2.0)
55
+ c2 = ::Math.cos(euler.y / 2.0)
56
+ c3 = ::Math.cos(euler.z / 2.0)
57
+ s1 = ::Math.sin(euler.x / 2.0)
58
+ s2 = ::Math.sin(euler.y / 2.0)
59
+ s3 = ::Math.sin(euler.z / 2.0)
60
60
  if euler.order == 'XYZ'
61
61
  @x = s1 * c2 * c3 + c1 * s2 * s3
62
62
  @y = c1 * s2 * c3 - s1 * c2 * s3
@@ -96,11 +96,11 @@ module Mittsu
96
96
  # http:#www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
97
97
  # assumes axis is normalized
98
98
  half_angle = angle / 2.0
99
- s = Math.sin(half_angle)
99
+ s = ::Math.sin(half_angle)
100
100
  @x = axis.x * s
101
101
  @y = axis.y * s
102
102
  @z = axis.z * s
103
- @w = Math.cos(half_angle)
103
+ @w = ::Math.cos(half_angle)
104
104
  self.on_change_callback
105
105
  self
106
106
  end
@@ -114,25 +114,25 @@ module Mittsu
114
114
  m31 = te[2]; m32 = te[6]; m33 = te[10]
115
115
  trace = m11 + m22 + m33
116
116
  if trace > 0
117
- s = 0.5 / Math.sqrt(trace + 1.0)
117
+ s = 0.5 / ::Math.sqrt(trace + 1.0)
118
118
  @w = 0.25 / s
119
119
  @x = (m32 - m23) * s
120
120
  @y = (m13 - m31) * s
121
121
  @z = (m21 - m12) * s
122
122
  elsif m11 > m22 && m11 > m33
123
- s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33)
123
+ s = 2.0 * ::Math.sqrt(1.0 + m11 - m22 - m33)
124
124
  @w = (m32 - m23) / s
125
125
  @x = 0.25 * s
126
126
  @y = (m12 + m21) / s
127
127
  @z = (m13 + m31) / s
128
128
  elsif m22 > m33
129
- s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33)
129
+ s = 2.0 * ::Math.sqrt(1.0 + m22 - m11 - m33)
130
130
  @w = (m13 - m31) / s
131
131
  @x = (m12 + m21) / s
132
132
  @y = 0.25 * s
133
133
  @z = (m23 + m32) / s
134
134
  else
135
- s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22)
135
+ s = 2.0 * ::Math.sqrt(1.0 + m33 - m11 - m22)
136
136
  @w = (m21 - m12) / s
137
137
  @x = (m13 + m31) / s
138
138
  @y = (m23 + m32) / s
@@ -187,7 +187,7 @@ module Mittsu
187
187
  end
188
188
 
189
189
  def length
190
- Math.sqrt(@x * @x + @y * @y + @z * @z + @w * @w)
190
+ ::Math.sqrt(@x * @x + @y * @y + @z * @z + @w * @w)
191
191
  end
192
192
 
193
193
  def normalize
@@ -246,8 +246,8 @@ module Mittsu
246
246
  @z = _z
247
247
  return self
248
248
  end
249
- half_theta = Math.acos(cos_half_theta)
250
- sin_half_theta = Math.sqrt(1.0 - cos_half_theta * cos_half_theta)
249
+ half_theta = ::Math.acos(cos_half_theta)
250
+ sin_half_theta = ::Math.sqrt(1.0 - cos_half_theta * cos_half_theta)
251
251
  if sin_half_theta.abs < 0.001
252
252
  @w = 0.5 * (_w + @w)
253
253
  @x = 0.5 * (_x + @x)
@@ -255,8 +255,8 @@ module Mittsu
255
255
  @z = 0.5 * (_z + @z)
256
256
  return self
257
257
  end
258
- ratio_a = Math.sin((1.0. - t) * half_theta) / sin_half_theta,
259
- ratio_b = Math.sin(t * half_theta) / sin_half_theta
258
+ ratio_a = ::Math.sin((1.0. - t) * half_theta) / sin_half_theta,
259
+ ratio_b = ::Math.sin(t * half_theta) / sin_half_theta
260
260
  @w = (_w * ratio_a + @w * ratio_b)
261
261
  @x = (_x * ratio_a + @x * ratio_b)
262
262
  @y = (_y * ratio_a + @y * ratio_b)
@@ -138,7 +138,7 @@ module Mittsu
138
138
  d2 = v1.dot(v1) - tca * tca
139
139
  radius2 = sphere.radius * sphere.radius
140
140
  return nil if d2 > radius2
141
- thc = Math.sqrt(radius2 - d2)
141
+ thc = ::Math.sqrt(radius2 - d2)
142
142
  # t0 = first intersect point - entrance on front of sphere
143
143
  t0 = tca - thc
144
144
  # t1 = second intersect point - exit point on back of sphere
@@ -24,7 +24,7 @@ module Mittsu
24
24
  points.each do |point|
25
25
  max_radius_sq = [max_radius_sq, c.distance_to_squared(point)].max
26
26
  end
27
- @radius = Math.sqrt(max_radius_sq)
27
+ @radius = ::Math.sqrt(max_radius_sq)
28
28
  self
29
29
  end
30
30
 
@@ -71,7 +71,7 @@ module Mittsu
71
71
 
72
72
  result_length_sq = target.length_sq
73
73
  if (result_length_sq > 0)
74
- target.multiply_scalar(1.0 / Math.sqrt(result_length_sq))
74
+ target.multiply_scalar(1.0 / ::Math.sqrt(result_length_sq))
75
75
  else
76
76
  target.set(0.0, 0.0, 0.0)
77
77
  end
@@ -160,7 +160,7 @@ module Mittsu
160
160
  end
161
161
 
162
162
  def length
163
- Math.sqrt(length_sq)
163
+ ::Math.sqrt(length_sq)
164
164
  end
165
165
 
166
166
  def normalize
@@ -211,11 +211,11 @@ module Mittsu
211
211
  theta = self.dot(v) / (self.length * v.length)
212
212
 
213
213
  # clamp, to handle numerical problems
214
- Math.acos(Math.clamp(theta, -1.0, 1.0))
214
+ ::Math.acos(Math.clamp(theta, -1.0, 1.0))
215
215
  end
216
216
 
217
217
  def distance_to(v)
218
- Math.sqrt(self.distance_to_squared(v))
218
+ ::Math.sqrt(self.distance_to_squared(v))
219
219
  end
220
220
 
221
221
  def ==(v)
@@ -49,8 +49,8 @@ module Mittsu
49
49
  def set_axis_angle_from_quaternion(q)
50
50
  # http:#www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
51
51
  # q is assumed to be normalized
52
- @elements[3] = 2.0 * Math.acos(q.w)
53
- s = Math.sqrt(1.0 - q.w * q.w)
52
+ @elements[3] = 2.0 * ::Math.acos(q.w)
53
+ s = ::Math.sqrt(1.0 - q.w * q.w)
54
54
  if s < 0.0001
55
55
  @elements[0] = 1.0
56
56
  @elements[1] = 0.0
@@ -88,7 +88,7 @@ module Mittsu
88
88
  return self # zero angle, arbitrary axis
89
89
  end
90
90
  # otherwise self singularity is angle = 180
91
- angle = Math::PI
91
+ angle = ::Math::PI
92
92
  xx = (m11 + 1.0) / 2.0
93
93
  yy = (m22 + 1.0) / 2.0
94
94
  zz = (m33 + 1.0) / 2.0
@@ -101,7 +101,7 @@ module Mittsu
101
101
  y1 = 0.707106781
102
102
  z1 = 0.707106781
103
103
  else
104
- x1 = Math.sqrt(xx)
104
+ x1 = ::Math.sqrt(xx)
105
105
  y1 = xy / x1
106
106
  z1 = xz / x1
107
107
  end
@@ -111,7 +111,7 @@ module Mittsu
111
111
  y1 = 0.0
112
112
  z1 = 0.707106781
113
113
  else
114
- y1 = Math.sqrt(yy)
114
+ y1 = ::Math.sqrt(yy)
115
115
  x1 = xy / y1
116
116
  z1 = yz / y1
117
117
  end
@@ -121,7 +121,7 @@ module Mittsu
121
121
  y1 = 0.707106781
122
122
  z1 = 0.0
123
123
  else
124
- z1 = Math.sqrt(zz)
124
+ z1 = ::Math.sqrt(zz)
125
125
  x1 = xz / z1
126
126
  y1 = yz / z1
127
127
  end
@@ -130,7 +130,7 @@ module Mittsu
130
130
  return self # return 180 deg rotation
131
131
  end
132
132
  # as we have reached here there are no singularities so we can handle normally
133
- s = Math.sqrt((m32 - m23) * (m32 - m23) +
133
+ s = ::Math.sqrt((m32 - m23) * (m32 - m23) +
134
134
  (m13 - m31) * (m13 - m31) +
135
135
  (m21 - m12) * (m21 - m12)) # used to normalize
136
136
  s = 1.0 if (s.abs < 0.001)
@@ -139,7 +139,7 @@ module Mittsu
139
139
  @elements[0] = (m32 - m23) / s
140
140
  @elements[1] = (m13 - m31) / s
141
141
  @elements[2] = (m21 - m12) / s
142
- @elements[3] = Math.acos((m11 + m22 + m33 - 1.0) / 2.0)
142
+ @elements[3] = ::Math.acos((m11 + m22 + m33 - 1.0) / 2.0)
143
143
  self
144
144
  end
145
145
 
@@ -35,7 +35,7 @@ module Mittsu
35
35
  directions[offset + 1] = @_direction.y
36
36
  directions[offset + 2] = @_direction.z
37
37
 
38
- @cache.angles_cos[index] = Math.cos(angle)
38
+ @cache.angles_cos[index] = ::Math.cos(angle)
39
39
  @cache.exponents[index] = exponent;
40
40
  @cache.decays[index] = distance.zero? ? 0.0 : decay
41
41
  end
@@ -1001,7 +1001,7 @@ module Mittsu
1001
1001
  glUniformMatrix4fv(uniforms['projectionMatrix'], 1, GL_FALSE, array_to_ptr_easy(camera.projection_matrix.elements))
1002
1002
 
1003
1003
  if @logarithmic_depth_buffer
1004
- glUniform1f(uniforms['logDepthBuffFC'], 2.0 / Math.log(camera.far + 1.0) / Math::LN2)
1004
+ glUniform1f(uniforms['logDepthBuffFC'], 2.0 / ::Math.log(camera.far + 1.0) / Math::LN2)
1005
1005
  end
1006
1006
 
1007
1007
  if material.needs_camera_position_uniform? && !uniforms['cameraPosition'].nil?
@@ -1,4 +1,4 @@
1
1
  module Mittsu
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  REVISION = "71"
4
4
  end
data/mittsu.gemspec CHANGED
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'minitest-reporters'
34
34
  spec.add_development_dependency 'pry'
35
35
  spec.add_development_dependency 'benchmark-ips'
36
- spec.add_development_dependency 'simplecov'
36
+ spec.add_development_dependency 'simplecov', '0.17.1'
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mittsu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Smith
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-10 00:00:00.000000000 Z
11
+ date: 2021-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opengl-bindings
@@ -140,16 +140,16 @@ dependencies:
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ">="
143
+ - - '='
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: 0.17.1
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ">="
150
+ - - '='
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: 0.17.1
153
153
  description: Mittsu makes 3D graphics easier by providing an abstraction over OpenGL,
154
154
  and is based heavily off of THREE.js. No more weird pointers and wondering about
155
155
  the difference between a VAO and a VBO (besides the letter). Simply think of something
@@ -411,7 +411,7 @@ licenses:
411
411
  - MIT
412
412
  metadata:
413
413
  bug_tracker: https://github.com/jellymann/mittsu/issues
414
- post_install_message:
414
+ post_install_message:
415
415
  rdoc_options: []
416
416
  require_paths:
417
417
  - lib
@@ -427,8 +427,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
427
427
  version: '0'
428
428
  requirements:
429
429
  - OpenGL 3.3+ capable hardware and drivers
430
- rubygems_version: 3.0.3
431
- signing_key:
430
+ rubygems_version: 3.2.3
431
+ signing_key:
432
432
  specification_version: 4
433
433
  summary: 3D Graphics Library for Ruby
434
434
  test_files: []