mittsu 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bce7b85c4911927e9f33bb5212d9011122a33356cc8811b33482af05577b9977
4
- data.tar.gz: 23620dc7e242612382df2647df7b45f2a21364543deb0d64e389844d65a069c1
3
+ metadata.gz: e3a8c66b2c63737be22e4495e20bc62888391dc63907e604d31eb8cbbf5fa432
4
+ data.tar.gz: f88e54369ac3e9c2b0534135f485310469d5dd37889504cf049eb23223cf0f2a
5
5
  SHA512:
6
- metadata.gz: 192b53dca3a2f7ecc79c22cdeae9410d7ce5dcf4af30803d9f0242bdc9caa10cef93cc8a1948932da102cbfe049e6d67951ce983e27ed40f20809fa18b044897
7
- data.tar.gz: d08903f9f798c488b35f52f991e311bdbd2f95427094c10b55c5c6d67570d4956c8616d52ad025b9507945e57a5e3ecbff876c50472317493e778d6819286d8e
6
+ metadata.gz: ea2ee4ab085e40061f432ed835f8f40948557467f85f33b7b4238a2d18cc4756ac43bb052d6631e4d8707f62d1ebce382cf5790727c28b257b73f71a08446458
7
+ data.tar.gz: fb77a518a9002b201a52590be84e13b9b57c1716b2e13d5c38b0d81265c6c26d8e440fb700d92e3759f8bfbd5323435c28dd780497da133fba4a09023800b3fd
@@ -13,21 +13,13 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  matrix:
16
- ruby: ['2.5.x', '2.6.x', '2.7.x', '3.0.x']
16
+ ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
17
17
  steps:
18
18
  - uses: actions/checkout@v1
19
- - name: Cache gems
20
- uses: actions/cache@v1
21
- with:
22
- path: vendor/bundle
23
- key: gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}-
24
- restore-keys: |
25
- gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}-
26
- gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-
27
- gems-v1-${{ runner.os }}-
28
- - uses: actions/setup-ruby@v1
19
+ - uses: ruby/setup-ruby@v1
29
20
  with:
30
21
  ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true
31
23
  - run: sudo apt-get update; sudo apt-get install cmake xorg-dev libgl1-mesa-dev
32
24
  - run: bash install-glfw.sh
33
25
  - run: gem install bundler
@@ -48,21 +40,13 @@ jobs:
48
40
  runs-on: macos-latest
49
41
  strategy:
50
42
  matrix:
51
- ruby: ['2.5.x', '2.6.x', '2.7.x', '3.0.x']
43
+ ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
52
44
  steps:
53
45
  - uses: actions/checkout@v1
54
- - name: Cache gems
55
- uses: actions/cache@v1
56
- with:
57
- path: vendor/bundle
58
- key: gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}-
59
- restore-keys: |
60
- gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}-
61
- gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-
62
- gems-v1-${{ runner.os }}-
63
- - uses: actions/setup-ruby@v1
46
+ - uses: ruby/setup-ruby@v1
64
47
  with:
65
48
  ruby-version: ${{ matrix.ruby }}
49
+ bundler-cache: true
66
50
  - run: brew install glfw
67
51
  - run: bundle install --path vendor/bundle
68
52
  - run: bundle exec rake test
@@ -71,24 +55,16 @@ jobs:
71
55
  name: Windows
72
56
  runs-on: windows-latest
73
57
  env:
74
- MITTSU_LIBGLFW_FILE: c:\projects\mittsu\glfw-3.3.1.bin.WIN32\lib-mingw\glfw3.dll
58
+ MITTSU_LIBGLFW_PATH: c:\projects\mittsu\glfw-3.3.1.bin.WIN32\lib-mingw
75
59
  strategy:
76
60
  matrix:
77
- ruby: ['2.5.x', '2.6.x', '2.7.x', '3.0.x']
61
+ ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
78
62
  steps:
79
63
  - uses: actions/checkout@v1
80
- - name: Cache gems
81
- uses: actions/cache@v1
82
- with:
83
- path: vendor/bundle
84
- key: gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}-
85
- restore-keys: |
86
- gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-${{ hashFiles('**/*.gemspec') }}-
87
- gems-v1-${{ runner.os }}-${{ hashFiles('**/Gemfile') }}-
88
- gems-v1-${{ runner.os }}-
89
- - uses: actions/setup-ruby@v1
64
+ - uses: ruby/setup-ruby@v1
90
65
  with:
91
66
  ruby-version: ${{ matrix.ruby }}
67
+ bundler-cache: true
92
68
  - run: .\install-glfw.ps1
93
69
  - run: gem install bundler
94
70
  - run: bundle install --path vendor/bundle
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015-2016 Daniel Smith
3
+ Copyright (c) 2015-2022 Danielle Smith
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # Mittsu
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/mittsu.svg)](https://badge.fury.io/rb/mittsu)
4
- [![Test Coverage](https://api.codeclimate.com/v1/badges/22be300984d81fa10af8/test_coverage)](https://codeclimate.com/github/jellymann/mittsu/test_coverage)
5
- [![Maintainability](https://api.codeclimate.com/v1/badges/22be300984d81fa10af8/maintainability)](https://codeclimate.com/github/jellymann/mittsu/maintainability)
6
- [![Build Status](https://github.com/jellymann/mittsu/workflows/Build/badge.svg)](https://github.com/jellymann/mittsu/actions?query=workflow%3A%22Build%22)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/22be300984d81fa10af8/test_coverage)](https://codeclimate.com/github/danini-the-panini/mittsu/test_coverage)
5
+ [![Maintainability](https://api.codeclimate.com/v1/badges/22be300984d81fa10af8/maintainability)](https://codeclimate.com/github/danini-the-panini/mittsu/maintainability)
6
+ [![Build Status](https://github.com/danini-the-panini/mittsu/workflows/Build/badge.svg)](https://github.com/danini-the-panini/mittsu/actions?query=workflow%3A%22Build%22)
7
7
 
8
8
  3D Graphics Library for Ruby
9
9
 
@@ -15,7 +15,7 @@ Mittsu makes 3D graphics easier by providing an abstraction over OpenGL, and is
15
15
  ![Point Light](https://cloud.githubusercontent.com/assets/1171825/18411861/4531bb4c-7781-11e6-92b4-b6ebda60e2c9.gif)
16
16
  ![Tank Demo](https://cloud.githubusercontent.com/assets/1171825/18411862/4531fe9a-7781-11e6-9665-b172df1a3645.gif)
17
17
 
18
- (You can find the source for the Tank Demo [here](https://github.com/jellymann/mittsu-tank-demo))
18
+ (You can find the source for the Tank Demo [here](https://github.com/danini-the-panini/mittsu-tank-demo))
19
19
 
20
20
  ## Installation
21
21
 
@@ -34,6 +34,7 @@ $ sudo apt-get install libglfw3
34
34
  **NOTE:** On Windows, you will have to manually specify the glfw3.dll path in an environment variable
35
35
  (you can download it [here](http://www.glfw.org/download.html))
36
36
  ```bash
37
+ # ex) set MITTSU_LIBGLFW_PATH=C:\Users\username\lib-mingw-w64
37
38
  > set MITTSU_LIBGLFW_PATH=C:\path\to\glfw3.dll
38
39
  > ruby your_awesome_mittsu_app.rb
39
40
  ```
@@ -212,7 +213,7 @@ If you just want to see what Mittsu can do and how to do it, take a peek inside
212
213
 
213
214
  ## Contributing
214
215
 
215
- 1. Fork it ( https://github.com/jellymann/mittsu/fork )
216
+ 1. Fork it ( https://github.com/danini-the-panini/mittsu/fork )
216
217
  2. Create your feature branch (`git checkout -b my-new-feature`)
217
218
  3. Commit your changes (`git commit -am 'Add some feature'`)
218
219
  4. Push to the branch (`git push origin my-new-feature`)
@@ -50,6 +50,18 @@ module Mittsu
50
50
  self
51
51
  end
52
52
 
53
+ def get_x(index)
54
+ @array[index * @item_size]
55
+ end
56
+
57
+ def get_y(index)
58
+ @array[index * @item_size + 1]
59
+ end
60
+
61
+ def get_z(index)
62
+ @array[index * @item_size + 2]
63
+ end
64
+
53
65
  def set_xy(index, x, y)
54
66
  index *= @item_size
55
67
 
@@ -27,7 +27,6 @@ module Mittsu
27
27
  v1 = @vertices[indices[i]]
28
28
  v2 = @vertices[indices[i + 1]]
29
29
  v3 = @vertices[indices[i + 2]]
30
- binding.irb if v1.nil? || v2.nil? || v3.nil?
31
30
 
32
31
  faces[j] = Face3.new(v1.index, v2.index, v3.index, [v1.clone, v2.clone, v3.clone])
33
32
 
@@ -187,6 +187,114 @@ module Mittsu
187
187
  self
188
188
  end
189
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
+
190
298
  def from_attribute(attribute, index, offset = 0)
191
299
  index = index * attribute.itemSize + offset
192
300
 
@@ -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
@@ -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?
@@ -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 ???
@@ -35,7 +35,7 @@ module Mittsu
35
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
 
@@ -935,14 +935,14 @@ module Mittsu
935
935
  @_alpha = parameters.fetch(:alpha, false)
936
936
  @_depth = parameters.fetch(:depth, true)
937
937
  @_stencil = parameters.fetch(:stencil, true)
938
- @_antialias = parameters.fetch(:antialias, false)
939
938
  @_premultiplied_alpha = parameters.fetch(:premultiplied_alpha, true)
940
939
  @_preserve_drawing_buffer = parameters.fetch(:preserve_drawing_buffer, false)
941
940
  @logarithmic_depth_buffer = parameters.fetch(:logarithmic_depth_buffer, false)
942
941
 
943
942
  @width = parameters.fetch(:width, 800)
944
943
  @height = parameters.fetch(:height, 600)
945
- @title = parameters.fetch(:title, "Mittsu #{REVISION}")
944
+ @title = parameters.fetch(:title, "Mittsu #{VERSION}")
945
+ @antialias = parameters.fetch(:antialias, 0)
946
946
  end
947
947
 
948
948
  def get_gpu_capabilities
@@ -974,7 +974,7 @@ module Mittsu
974
974
  # preserve_drawing_buffer: _preserve_drawing_buffer
975
975
  # }
976
976
 
977
- @window = GLFW::Window.new(@width, @height, @title)
977
+ @window = GLFW::Window.new(@width, @height, @title, antialias: @antialias)
978
978
 
979
979
  default_target.set_viewport_size(*(@window.framebuffer_size))
980
980
 
@@ -1,4 +1,3 @@
1
1
  module Mittsu
2
- VERSION = "0.3.3"
3
- REVISION = "71"
2
+ VERSION = "0.4.0"
4
3
  end
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$)}) }
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.3
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
- - Daniel Smith
8
- autorequire:
7
+ - Danielle Smith
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-05 00:00:00.000000000 Z
11
+ date: 2022-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opengl-bindings
@@ -155,7 +155,7 @@ description: Mittsu makes 3D graphics easier by providing an abstraction over Op
155
155
  the difference between a VAO and a VBO (besides the letter). Simply think of something
156
156
  awesome and make it!
157
157
  email:
158
- - jellymann@gmail.com
158
+ - danini@hey.com
159
159
  executables: []
160
160
  extensions: []
161
161
  extra_rdoc_files: []
@@ -406,12 +406,12 @@ files:
406
406
  - lib/mittsu/utils.rb
407
407
  - lib/mittsu/version.rb
408
408
  - mittsu.gemspec
409
- homepage: https://github.com/jellymann/mittsu
409
+ homepage: https://github.com/danini-the-panini/mittsu
410
410
  licenses:
411
411
  - MIT
412
412
  metadata:
413
- bug_tracker: https://github.com/jellymann/mittsu/issues
414
- post_install_message:
413
+ bug_tracker: https://github.com/danini-the-panini/mittsu/issues
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.2.3
431
- signing_key:
430
+ rubygems_version: 3.3.7
431
+ signing_key:
432
432
  specification_version: 4
433
433
  summary: 3D Graphics Library for Ruby
434
434
  test_files: []