mittsu 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build-workflow.yml +71 -0
  3. data/.gitignore +1 -0
  4. data/Gemfile +0 -3
  5. data/LICENSE.txt +1 -1
  6. data/README.md +6 -8
  7. data/Rakefile +1 -0
  8. data/install-glfw.ps1 +13 -0
  9. data/lib/mittsu/cameras/camera.rb +0 -2
  10. data/lib/mittsu/cameras/cube_camera.rb +0 -2
  11. data/lib/mittsu/cameras/orthographic_camera.rb +2 -4
  12. data/lib/mittsu/cameras/perspective_camera.rb +4 -5
  13. data/lib/mittsu/core/buffer_attribute.rb +12 -0
  14. data/lib/mittsu/core/buffer_geometry.rb +3 -3
  15. data/lib/mittsu/core/geometry.rb +2 -4
  16. data/lib/mittsu/core/object_3d.rb +9 -7
  17. data/lib/mittsu/core/raycaster.rb +0 -2
  18. data/lib/mittsu/extras/geometries/circle_geometry.rb +3 -3
  19. data/lib/mittsu/extras/geometries/cylinder_geometry.rb +5 -5
  20. data/lib/mittsu/extras/geometries/dodecahedron_geometry.rb +2 -2
  21. data/lib/mittsu/extras/geometries/icosahedron_geometry.rb +2 -2
  22. data/lib/mittsu/extras/geometries/lathe_geometry.rb +3 -3
  23. data/lib/mittsu/extras/geometries/parametric_geometry.rb +19 -19
  24. data/lib/mittsu/extras/geometries/polyhedron_geometry.rb +6 -7
  25. data/lib/mittsu/extras/geometries/ring_geometry.rb +4 -4
  26. data/lib/mittsu/extras/geometries/sphere_geometry.rb +4 -4
  27. data/lib/mittsu/extras/geometries/torus_geometry.rb +7 -7
  28. data/lib/mittsu/extras/geometries/torus_knot_buffer_geometry.rb +9 -9
  29. data/lib/mittsu/extras/helpers/camera_helper.rb +38 -38
  30. data/lib/mittsu/extras/image_utils.rb +1 -1
  31. data/lib/mittsu/lights/directional_light.rb +9 -5
  32. data/lib/mittsu/lights/spot_light.rb +1 -1
  33. data/lib/mittsu/loaders/loader.rb +2 -2
  34. data/lib/mittsu/loaders/obj_loader.rb +4 -0
  35. data/lib/mittsu/materials/material.rb +6 -3
  36. data/lib/mittsu/math/box2.rb +0 -2
  37. data/lib/mittsu/math/box3.rb +0 -2
  38. data/lib/mittsu/math/color.rb +3 -4
  39. data/lib/mittsu/math/euler.rb +25 -26
  40. data/lib/mittsu/math/frustum.rb +0 -2
  41. data/lib/mittsu/math/line3.rb +0 -2
  42. data/lib/mittsu/math/matrix3.rb +0 -2
  43. data/lib/mittsu/math/matrix4.rb +10 -12
  44. data/lib/mittsu/math/plane.rb +0 -2
  45. data/lib/mittsu/math/quaternion.rb +18 -20
  46. data/lib/mittsu/math/ray.rb +1 -3
  47. data/lib/mittsu/math/sphere.rb +1 -3
  48. data/lib/mittsu/math/spline.rb +0 -2
  49. data/lib/mittsu/math/triangle.rb +1 -3
  50. data/lib/mittsu/math/vector.rb +3 -3
  51. data/lib/mittsu/math/vector2.rb +0 -1
  52. data/lib/mittsu/math/vector3.rb +108 -1
  53. data/lib/mittsu/math/vector4.rb +8 -9
  54. data/lib/mittsu/math.rb +0 -5
  55. data/lib/mittsu/objects/line.rb +0 -1
  56. data/lib/mittsu/renderers/glfw_lib.rb +24 -3
  57. data/lib/mittsu/renderers/glfw_window.rb +6 -2
  58. data/lib/mittsu/renderers/opengl/core/object_3d.rb +1 -1
  59. data/lib/mittsu/renderers/opengl/lights/spot_light.rb +1 -1
  60. data/lib/mittsu/renderers/opengl/opengl_geometry_group.rb +1 -0
  61. data/lib/mittsu/renderers/opengl/opengl_program.rb +1 -2
  62. data/lib/mittsu/renderers/opengl/textures/texture.rb +2 -2
  63. data/lib/mittsu/renderers/opengl_renderer.rb +9 -14
  64. data/lib/mittsu/scenes/scene.rb +0 -2
  65. data/lib/mittsu/textures/texture.rb +4 -2
  66. data/lib/mittsu/utils.rb +15 -0
  67. data/lib/mittsu/version.rb +1 -2
  68. data/lib/mittsu.rb +1 -16
  69. data/mittsu.gemspec +14 -13
  70. metadata +60 -47
  71. data/.circleci/config.yml +0 -87
  72. data/.circleci/images/primary/Dockerfile +0 -10
  73. data/appveyor.yml +0 -23
  74. data/install_glfw.ps1 +0 -11
@@ -1,5 +1,3 @@
1
- require 'mittsu/math'
2
-
3
1
  module Mittsu
4
2
  class Triangle
5
3
  attr_accessor :a, :b, :c
@@ -73,7 +71,7 @@ module Mittsu
73
71
 
74
72
  result_length_sq = target.length_sq
75
73
  if (result_length_sq > 0)
76
- target.multiply_scalar(1.0 / Math.sqrt(result_length_sq))
74
+ target.multiply_scalar(1.0 / ::Math.sqrt(result_length_sq))
77
75
  else
78
76
  target.set(0.0, 0.0, 0.0)
79
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)
@@ -1,4 +1,3 @@
1
- require 'mittsu/math'
2
1
  require 'mittsu/math/vector'
3
2
 
4
3
  module Mittsu
@@ -1,4 +1,3 @@
1
- require 'mittsu/math'
2
1
  require 'mittsu/math/vector'
3
2
 
4
3
  module Mittsu
@@ -188,6 +187,114 @@ module Mittsu
188
187
  self
189
188
  end
190
189
 
190
+ def set_scalar(scalar)
191
+ set(scalar, scalar, scalar)
192
+
193
+ self
194
+ end
195
+
196
+ def set_component(index, value)
197
+ _x, _y, _z = *@elements
198
+
199
+ case index
200
+ when 0
201
+ set(value, _y, _z)
202
+ when 1
203
+ set(_x, value, _z)
204
+ when 2
205
+ set(_x, _y, value)
206
+ else
207
+ raise ArgumentError, "index is out of range: #{index}"
208
+ end
209
+
210
+ self
211
+ end
212
+
213
+ def get_component(index)
214
+ _x, _y, _z = *@elements
215
+
216
+ case index
217
+ when 0
218
+ return _x
219
+ when 1
220
+ return _y
221
+ when 2
222
+ return _z
223
+ else
224
+ raise ArgumentError, "index is out of range: #{index}"
225
+ end
226
+ end
227
+
228
+ def add_scaled_vector(vector, scalar)
229
+ set(vector.x * scalar, vector.y * scalar, vector.z * scalar)
230
+
231
+ self
232
+ end
233
+
234
+ def set_from_spherical(sphere)
235
+ set_from_spherical_coords(sphere.radius, sphere.phi, sphere.theta)
236
+ end
237
+
238
+ def set_from_spherical_coords(radius, phi, theta)
239
+ sin_phi_radius = ::Math.sin(phi) * radius
240
+ set(sin_phi_radius * ::Math.sin(theta), ::Math.cos(phi) * radius, sin_phi_radius * ::Math.cos(theta))
241
+
242
+ self
243
+ end
244
+
245
+ def set_from_cylindrical(cylinder)
246
+ set_from_cylindrical_coords(cylinder.radius, cylinder.theta, cylinder.y)
247
+ end
248
+
249
+ def set_from_cylindrical_coords(radius, theta, y)
250
+ set(radius * ::Math.sin(theta), y, radius * ::Math.sin(theta))
251
+
252
+ self
253
+ end
254
+
255
+ def set_from_matrix3_column(matrix, index)
256
+ from_array(matrix.elements, index * 3)
257
+ end
258
+
259
+ def equals(vector)
260
+ _x, _y, _z = *@elements
261
+
262
+ ((vector.x == _x) && (vector.y == _y) && (vector.z == _z ))
263
+ end
264
+
265
+ def from_buffer_attribute(attribute, index)
266
+ set(attribute.get_x(index), attribute.get_y(index), attribute.get_z(index))
267
+
268
+ self
269
+ end
270
+
271
+ def clamp_length(min, max)
272
+ divide_scalar(length || 1).multiply_scalar([min, [max, length].min].max)
273
+ end
274
+
275
+ def manhattan_distance_to(vector)
276
+ _x, _y, _z = *@elements
277
+
278
+ (_x - vector.x).abs + (_y - vector.y).abs + (_z - vector.z).abs
279
+ end
280
+
281
+ # TODO: maybe add range 3 values as arguments (range_x, range_y, range_z) to this method
282
+ def random()
283
+ set(Random.new.rand, Random.new.rand, Random.new.rand)
284
+
285
+ self
286
+ end
287
+
288
+ def random_direction()
289
+ u = (Random.new.rand - 0.5) *2
290
+ t = Random.new.rand * ::Math::PI * 2
291
+ f = ::Math.sqrt(1 - u ** 2)
292
+
293
+ set(f * ::Math.cos(t), f * ::Math.sin(t), u)
294
+
295
+ self
296
+ end
297
+
191
298
  def from_attribute(attribute, index, offset = 0)
192
299
  index = index * attribute.itemSize + offset
193
300
 
@@ -1,4 +1,3 @@
1
- require 'mittsu/math'
2
1
  require 'mittsu/math/vector'
3
2
 
4
3
  module Mittsu
@@ -50,8 +49,8 @@ module Mittsu
50
49
  def set_axis_angle_from_quaternion(q)
51
50
  # http:#www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
52
51
  # q is assumed to be normalized
53
- @elements[3] = 2.0 * Math.acos(q.w)
54
- 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)
55
54
  if s < 0.0001
56
55
  @elements[0] = 1.0
57
56
  @elements[1] = 0.0
@@ -89,7 +88,7 @@ module Mittsu
89
88
  return self # zero angle, arbitrary axis
90
89
  end
91
90
  # otherwise self singularity is angle = 180
92
- angle = Math::PI
91
+ angle = ::Math::PI
93
92
  xx = (m11 + 1.0) / 2.0
94
93
  yy = (m22 + 1.0) / 2.0
95
94
  zz = (m33 + 1.0) / 2.0
@@ -102,7 +101,7 @@ module Mittsu
102
101
  y1 = 0.707106781
103
102
  z1 = 0.707106781
104
103
  else
105
- x1 = Math.sqrt(xx)
104
+ x1 = ::Math.sqrt(xx)
106
105
  y1 = xy / x1
107
106
  z1 = xz / x1
108
107
  end
@@ -112,7 +111,7 @@ module Mittsu
112
111
  y1 = 0.0
113
112
  z1 = 0.707106781
114
113
  else
115
- y1 = Math.sqrt(yy)
114
+ y1 = ::Math.sqrt(yy)
116
115
  x1 = xy / y1
117
116
  z1 = yz / y1
118
117
  end
@@ -122,7 +121,7 @@ module Mittsu
122
121
  y1 = 0.707106781
123
122
  z1 = 0.0
124
123
  else
125
- z1 = Math.sqrt(zz)
124
+ z1 = ::Math.sqrt(zz)
126
125
  x1 = xz / z1
127
126
  y1 = yz / z1
128
127
  end
@@ -131,7 +130,7 @@ module Mittsu
131
130
  return self # return 180 deg rotation
132
131
  end
133
132
  # as we have reached here there are no singularities so we can handle normally
134
- s = Math.sqrt((m32 - m23) * (m32 - m23) +
133
+ s = ::Math.sqrt((m32 - m23) * (m32 - m23) +
135
134
  (m13 - m31) * (m13 - m31) +
136
135
  (m21 - m12) * (m21 - m12)) # used to normalize
137
136
  s = 1.0 if (s.abs < 0.001)
@@ -140,7 +139,7 @@ module Mittsu
140
139
  @elements[0] = (m32 - m23) / s
141
140
  @elements[1] = (m13 - m31) / s
142
141
  @elements[2] = (m21 - m12) / s
143
- @elements[3] = Math.acos((m11 + m22 + m33 - 1.0) / 2.0)
142
+ @elements[3] = ::Math.acos((m11 + m22 + m33 - 1.0) / 2.0)
144
143
  self
145
144
  end
146
145
 
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
@@ -54,7 +54,6 @@ module Mittsu
54
54
  offsets.each_with_index do |offset, oi|
55
55
  start = offset[:start]
56
56
  count = offset[:count]
57
- index = offset[:index]
58
57
 
59
58
  (start...(count-1)).step(step).each do |i|
60
59
  v_start.from_array(positions, a * 3)
@@ -25,17 +25,38 @@ module Mittsu
25
25
  end
26
26
 
27
27
  class Windows < GenericLib::Base
28
+ def file
29
+ 'glfw3.dll'
30
+ end
28
31
  end
29
32
 
30
33
  class MacOS < GenericLib::Base
34
+ SEARCH_GLOBS = ['/usr/local/lib/**',
35
+ '/usr/lib/**',
36
+ '/opt/homebrew/**']
37
+
31
38
  def path
32
- '/usr/local/lib'
39
+ File.dirname(match)
33
40
  end
34
41
 
35
42
  def file
36
- matches = Dir.glob('/usr/local/lib/libglfw*.dylib').map { |path| File.basename(path) }
37
- return matches.find { |m| m == 'libglfw3.dylib' || m == 'libglfw.3.dylib' } || matches.first
43
+ File.basename(match)
38
44
  end
45
+
46
+ private
47
+
48
+ def match
49
+ @match ||= find_match
50
+ end
51
+
52
+ def find_match
53
+ SEARCH_GLOBS.each do |glob|
54
+ matches = Dir.glob("#{glob}/libglfw*.dylib")
55
+ next if matches.empty?
56
+
57
+ return matches.find { |m| m.end_with?('libglfw3.dylib') || m.end_with?('libglfw.3.dylib') } || matches.first
58
+ end
59
+ end
39
60
  end
40
61
  end
41
62
  end
@@ -1,7 +1,7 @@
1
1
  require 'opengl'
2
2
  require 'glfw'
3
3
 
4
- require 'mittsu'
4
+ require 'mittsu/utils'
5
5
  require 'mittsu/renderers/glfw_lib'
6
6
  glfw_lib = Mittsu::GLFWLib.discover
7
7
  GLFW.load_lib(ENV["MITTSU_LIBGLFW_FILE"] || glfw_lib.file, ENV["MITTSU_LIBGLFW_PATH"] || glfw_lib.path) unless Mittsu.test?
@@ -13,7 +13,7 @@ module Mittsu
13
13
  class Window
14
14
  attr_accessor :key_press_handler, :key_release_handler, :key_repeat_handler, :char_input_handler, :cursor_pos_handler, :mouse_button_press_handler, :mouse_button_release_handler, :scroll_handler, :framebuffer_size_handler
15
15
 
16
- def initialize(width, height, title)
16
+ def initialize(width, height, title, antialias: 0)
17
17
  glfwInit
18
18
 
19
19
  glfwWindowHint GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE
@@ -22,6 +22,10 @@ module Mittsu
22
22
  glfwWindowHint GLFW_CONTEXT_VERSION_MINOR, 3
23
23
  glfwWindowHint GLFW_CONTEXT_REVISION, 0
24
24
 
25
+ if antialias > 0
26
+ glfwWindowHint GLFW_SAMPLES, antialias
27
+ end
28
+
25
29
  @width, @height, @title = width, height, title
26
30
  @handle = glfwCreateWindow(@width, @height, @title, nil, nil)
27
31
  if @handle.null?
@@ -1,6 +1,6 @@
1
1
  module Mittsu
2
2
  class Object3D
3
- attr_accessor :morph_target_influences, :renderer
3
+ attr_accessor :morph_target_influences, :renderer, :initted
4
4
  attr_reader :model_view_matrix
5
5
  attr_writer :active
6
6
 
@@ -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
@@ -20,6 +20,7 @@ module Mittsu
20
20
  @num_morph_normals = num_morph_normals
21
21
 
22
22
  @renderer = renderer
23
+ @custom_attributes_list = []
23
24
  end
24
25
 
25
26
  def create_mesh_buffers
@@ -1,10 +1,9 @@
1
1
  require 'erb'
2
-
3
2
  require 'mittsu/renderers/opengl/opengl_shader'
4
3
 
5
4
  module Mittsu
6
5
  class OpenGLProgram
7
- attr_reader :id, :program, :uniforms, :attributes
6
+ attr_reader :id, :program, :uniforms
8
7
  attr_accessor :code, :used_times, :attributes, :vertex_shader, :fragment_shader
9
8
 
10
9
  def initialize(renderer, code, material, parameters)
@@ -61,14 +61,14 @@ module Mittsu
61
61
  glTexParameteri(texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
62
62
 
63
63
  if wrap_s != ClampToEdgeWrapping || wrap_t != ClampToEdgeWrapping
64
- puts "WARNING: Mittsu::Texture: Texture is not power of two. Texture.wrap_s and Texture.wrap_t should be set to Mittsu::ClampToEdgeWrapping. (#{texture.source_file})"
64
+ puts "WARNING: Mittsu::Texture: Texture is not power of two. Texture.wrap_s and Texture.wrap_t should be set to Mittsu::ClampToEdgeWrapping. (#{source_file})"
65
65
  end
66
66
 
67
67
  glTexParameteri(texture_type, GL_TEXTURE_MAG_FILTER, filter_fallback(mag_filter))
68
68
  glTexParameteri(texture_type, GL_TEXTURE_MIN_FILTER, filter_fallback(min_filter))
69
69
 
70
70
  if min_filter != NearestFilter && min_filter != LinearFilter
71
- puts "WARNING: Mittsu::Texture: Texture is not a power of two. Texture.min_filter should be set to Mittsu::NearestFilter or Mittsu::LinearFilter. (#{texture.source_file})"
71
+ puts "WARNING: Mittsu::Texture: Texture is not a power of two. Texture.min_filter should be set to Mittsu::NearestFilter or Mittsu::LinearFilter. (#{source_file})"
72
72
  end
73
73
 
74
74
  # TODO: anisotropic extension ???
@@ -2,12 +2,10 @@ require 'opengl'
2
2
  require 'glfw'
3
3
  require 'fiddle'
4
4
 
5
-
6
5
  require 'mittsu/renderers/opengl/opengl_lib'
7
6
  opengl_lib = Mittsu::OpenGLLib.discover
8
7
  OpenGL.load_lib(ENV["MITTSU_LIBGL_FILE"] || opengl_lib.file, ENV["MITTSU_LIBGL_PATH"] || opengl_lib.path)
9
8
 
10
- require 'mittsu'
11
9
  require 'mittsu/renderers/glfw_window'
12
10
  require 'mittsu/renderers/opengl/opengl_implementations'
13
11
  require 'mittsu/renderers/opengl/opengl_debug'
@@ -30,12 +28,14 @@ require 'mittsu/renderers/opengl/opengl_mittsu_params'
30
28
 
31
29
  module Mittsu
32
30
  class OpenGLRenderer
33
- attr_accessor :auto_clear, :auto_clear_color, :auto_clear_depth, :auto_clear_stencil, :sort_objects, :gamma_factor, :gamma_input, :gamma_output, :shadow_map_enabled, :shadow_map_type, :shadow_map_cull_face, :shadow_map_debug, :shadow_map_cascade, :max_morph_targets, :max_morph_normals, :info, :pixel_ratio, :window, :width, :height, :state
31
+ attr_accessor :auto_clear, :auto_clear_color, :auto_clear_depth, :auto_clear_stencil, :sort_objects, :gamma_factor, :gamma_input,
32
+ :gamma_output, :shadow_map_enabled, :shadow_map_type, :shadow_map_cull_face, :shadow_map_debug, :shadow_map_cascade,
33
+ :max_morph_targets, :max_morph_normals, :info, :pixel_ratio, :window, :width, :height, :state
34
34
 
35
- attr_reader :logarithmic_depth_buffer, :max_morph_targets, :max_morph_normals, :shadow_map_type, :shadow_map_debug, :shadow_map_cascade, :programs, :light_renderer, :proj_screen_matrix
35
+ attr_reader :logarithmic_depth_buffer, :programs, :light_renderer, :proj_screen_matrix
36
36
 
37
37
  def initialize(parameters = {})
38
- puts "OpenGLRenderer (Revision #{REVISION})"
38
+ puts "Mittsu OpenGL Renderer #{VERSION}"
39
39
 
40
40
  fetch_parameters(parameters)
41
41
 
@@ -81,11 +81,6 @@ module Mittsu
81
81
 
82
82
  # TODO: get_context ???
83
83
  # TODO: force_context_loss ???
84
-
85
- def supports_vertex_textures?
86
- @_supports_vertex_textures
87
- end
88
-
89
84
  # TODO: supports_float_textures? ???
90
85
  # TODO: supports[half|standard|compressed|blend min max] ... ???
91
86
 
@@ -940,14 +935,14 @@ module Mittsu
940
935
  @_alpha = parameters.fetch(:alpha, false)
941
936
  @_depth = parameters.fetch(:depth, true)
942
937
  @_stencil = parameters.fetch(:stencil, true)
943
- @_antialias = parameters.fetch(:antialias, false)
944
938
  @_premultiplied_alpha = parameters.fetch(:premultiplied_alpha, true)
945
939
  @_preserve_drawing_buffer = parameters.fetch(:preserve_drawing_buffer, false)
946
940
  @logarithmic_depth_buffer = parameters.fetch(:logarithmic_depth_buffer, false)
947
941
 
948
942
  @width = parameters.fetch(:width, 800)
949
943
  @height = parameters.fetch(:height, 600)
950
- @title = parameters.fetch(:title, "Mittsu #{REVISION}")
944
+ @title = parameters.fetch(:title, "Mittsu #{VERSION}")
945
+ @antialias = parameters.fetch(:antialias, 0)
951
946
  end
952
947
 
953
948
  def get_gpu_capabilities
@@ -979,7 +974,7 @@ module Mittsu
979
974
  # preserve_drawing_buffer: _preserve_drawing_buffer
980
975
  # }
981
976
 
982
- @window = GLFW::Window.new(@width, @height, @title)
977
+ @window = GLFW::Window.new(@width, @height, @title, antialias: @antialias)
983
978
 
984
979
  default_target.set_viewport_size(*(@window.framebuffer_size))
985
980
 
@@ -1006,7 +1001,7 @@ module Mittsu
1006
1001
  glUniformMatrix4fv(uniforms['projectionMatrix'], 1, GL_FALSE, array_to_ptr_easy(camera.projection_matrix.elements))
1007
1002
 
1008
1003
  if @logarithmic_depth_buffer
1009
- 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)
1010
1005
  end
1011
1006
 
1012
1007
  if material.needs_camera_position_uniform? && !uniforms['cameraPosition'].nil?
@@ -1,5 +1,3 @@
1
- require 'mittsu'
2
-
3
1
  module Mittsu
4
2
  class Scene < Object3D
5
3
 
@@ -10,9 +10,10 @@ module Mittsu
10
10
  DEFAULT_IMAGE = nil
11
11
  DEFAULT_MAPPING = UVMapping
12
12
 
13
- attr_reader :id, :uuid, :type
13
+ attr_reader :id, :uuid
14
14
 
15
- attr_accessor :image, :name, :source_file, :mipmaps, :offset, :repeat, :generate_mipmaps, :premultiply_alpha, :filp_y, :unpack_alignment, :on_update, :mipmaps, :mapping, :wrap_s, :wrap_t, :mag_filter, :min_filter, :anisotropy, :format, :type
15
+ attr_accessor :image, :name, :source_file, :mipmaps, :offset, :repeat, :generate_mipmaps, :premultiply_alpha, :filp_y,
16
+ :unpack_alignment, :on_update, :mapping, :wrap_s, :wrap_t, :mag_filter, :min_filter, :anisotropy, :format, :type
16
17
 
17
18
  def initialize(image = DEFAULT_IMAGE, mapping = DEFAULT_MAPPING, wrap_s = ClampToEdgeWrapping, wrap_t = ClampToEdgeWrapping, mag_filter = LinearFilter, min_filter = LinearMipMapLinearFilter, format = RGBAFormat, type = UnsignedByteType, anisotropy = 1)
18
19
  super()
@@ -42,6 +43,7 @@ module Mittsu
42
43
 
43
44
  @_needs_update = false
44
45
  @on_update = nil
46
+ @_listeners = {}
45
47
  end
46
48
 
47
49
  def needs_update?
@@ -0,0 +1,15 @@
1
+ module Mittsu
2
+ DEBUG = ENV["DEBUG"] == "true"
3
+
4
+ def self.debug?
5
+ DEBUG
6
+ end
7
+
8
+ def self.env
9
+ ENV["MITTSU_ENV"]
10
+ end
11
+
12
+ def self.test?
13
+ env == 'test'
14
+ end
15
+ end
@@ -1,4 +1,3 @@
1
1
  module Mittsu
2
- VERSION = "0.3.1"
3
- REVISION = "71"
2
+ VERSION = "0.4.0"
4
3
  end
data/lib/mittsu.rb CHANGED
@@ -1,19 +1,4 @@
1
- module Mittsu
2
- DEBUG = ENV["DEBUG"] == "true"
3
-
4
- def self.debug?
5
- DEBUG
6
- end
7
-
8
- def self.env
9
- ENV["MITTSU_ENV"]
10
- end
11
-
12
- def self.test?
13
- env == 'test'
14
- end
15
- end
16
-
1
+ require "mittsu/utils"
17
2
  require "mittsu/version"
18
3
  require "mittsu/math"
19
4
  require "mittsu/core"
data/mittsu.gemspec CHANGED
@@ -6,15 +6,15 @@ require 'mittsu/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "mittsu"
8
8
  spec.version = Mittsu::VERSION
9
- spec.authors = ["Daniel Smith"]
10
- spec.email = ["jellymann@gmail.com"]
9
+ spec.authors = ["Danielle Smith"]
10
+ spec.email = ["danini@hey.com"]
11
11
 
12
12
  spec.summary = %q{3D Graphics Library for Ruby}
13
13
  spec.description = %q{Mittsu makes 3D graphics easier by providing an abstraction over OpenGL, and is based heavily off of THREE.js. No more weird pointers and wondering about the difference between a VAO and a VBO (besides the letter). Simply think of something awesome and make it!}
14
- spec.homepage = "https://github.com/jellymann/mittsu"
14
+ spec.homepage = "https://github.com/danini-the-panini/mittsu"
15
15
  spec.license = "MIT"
16
16
  spec.metadata = {
17
- "bug_tracker" => "https://github.com/jellymann/mittsu/issues"
17
+ "bug_tracker" => "https://github.com/danini-the-panini/mittsu/issues"
18
18
  }
19
19
 
20
20
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{(^(test|examples)/|\.sh$)}) }
@@ -23,14 +23,15 @@ Gem::Specification.new do |spec|
23
23
  spec.required_ruby_version = '>= 2.0.0'
24
24
  spec.requirements << 'OpenGL 3.3+ capable hardware and drivers'
25
25
 
26
- spec.add_runtime_dependency 'opengl-bindings', "~> 1.5"
27
- spec.add_runtime_dependency 'ffi', "~> 1.9"
28
- spec.add_runtime_dependency 'chunky_png', "~> 1.3"
26
+ spec.add_runtime_dependency 'opengl-bindings'
27
+ spec.add_runtime_dependency 'ffi'
28
+ spec.add_runtime_dependency 'chunky_png'
29
29
 
30
- spec.add_development_dependency "bundler", "~> 1.9"
31
- spec.add_development_dependency "rake", "~> 10.0"
32
- spec.add_development_dependency 'minitest', '~> 5.7'
33
- spec.add_development_dependency 'minitest-reporters', '~> 1.1'
34
- spec.add_development_dependency 'pry', '~> 0.10'
35
- spec.add_development_dependency 'benchmark-ips', '~> 2.3'
30
+ spec.add_development_dependency "bundler"
31
+ spec.add_development_dependency "rake"
32
+ spec.add_development_dependency 'minitest'
33
+ spec.add_development_dependency 'minitest-reporters'
34
+ spec.add_development_dependency 'pry'
35
+ spec.add_development_dependency 'benchmark-ips'
36
+ spec.add_development_dependency 'simplecov', '0.17.1'
36
37
  end