mittsu 0.4.0 → 0.4.1

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: e3a8c66b2c63737be22e4495e20bc62888391dc63907e604d31eb8cbbf5fa432
4
- data.tar.gz: f88e54369ac3e9c2b0534135f485310469d5dd37889504cf049eb23223cf0f2a
3
+ metadata.gz: 806e8ad78d34edc7dfa72cbe35414c0fe765628b5dd074d691d5bf0f45dd52cb
4
+ data.tar.gz: b477a885ca405bd5ad8b71464b06ce794567c00abceb56738f3ace06885fe4d3
5
5
  SHA512:
6
- metadata.gz: ea2ee4ab085e40061f432ed835f8f40948557467f85f33b7b4238a2d18cc4756ac43bb052d6631e4d8707f62d1ebce382cf5790727c28b257b73f71a08446458
7
- data.tar.gz: fb77a518a9002b201a52590be84e13b9b57c1716b2e13d5c38b0d81265c6c26d8e440fb700d92e3759f8bfbd5323435c28dd780497da133fba4a09023800b3fd
6
+ metadata.gz: d65b207aaaf6136a1e6d7fd39237bd5710192748338eb388fd974d4128069cbc41b6df4132bc2597793f507ed7349abdb0f3d28e9df1584ff9d4e1f9a39c8bc2
7
+ data.tar.gz: b4eb049497dc7f46d4285d8d8d677f3221f08d904dcc21b1efa3e7044edea42a1d49e8979d74bd26c3bc9470598fd9755c460865cc324ce71b6c87fec036d07e
@@ -13,17 +13,16 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
  strategy:
15
15
  matrix:
16
- ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
16
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
17
17
  steps:
18
- - uses: actions/checkout@v1
18
+ - uses: actions/checkout@v4
19
+ - uses: awalsh128/cache-apt-pkgs-action@v1
20
+ with:
21
+ packages: libglfw3
19
22
  - uses: ruby/setup-ruby@v1
20
23
  with:
21
24
  ruby-version: ${{ matrix.ruby }}
22
25
  bundler-cache: true
23
- - run: sudo apt-get update; sudo apt-get install cmake xorg-dev libgl1-mesa-dev
24
- - run: bash install-glfw.sh
25
- - run: gem install bundler
26
- - run: bundle install --path vendor/bundle
27
26
  - name: Test & publish code coverage
28
27
  uses: paambaati/codeclimate-action@v2.2.1
29
28
  if: github.event_name == 'push'
@@ -40,15 +39,14 @@ jobs:
40
39
  runs-on: macos-latest
41
40
  strategy:
42
41
  matrix:
43
- ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
42
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
44
43
  steps:
45
- - uses: actions/checkout@v1
44
+ - uses: actions/checkout@v4
45
+ - run: brew install glfw
46
46
  - uses: ruby/setup-ruby@v1
47
47
  with:
48
48
  ruby-version: ${{ matrix.ruby }}
49
49
  bundler-cache: true
50
- - run: brew install glfw
51
- - run: bundle install --path vendor/bundle
52
50
  - run: bundle exec rake test
53
51
 
54
52
  windows:
@@ -58,14 +56,12 @@ jobs:
58
56
  MITTSU_LIBGLFW_PATH: c:\projects\mittsu\glfw-3.3.1.bin.WIN32\lib-mingw
59
57
  strategy:
60
58
  matrix:
61
- ruby: ['2.6', '2.7', '3.0', '3.1', 'head']
59
+ ruby: ['2.6', '2.7', '3.0', '3.1', '3.2', '3.3', 'head']
62
60
  steps:
63
- - uses: actions/checkout@v1
61
+ - uses: actions/checkout@v4
62
+ - run: .\install-glfw.ps1
64
63
  - uses: ruby/setup-ruby@v1
65
64
  with:
66
65
  ruby-version: ${{ matrix.ruby }}
67
66
  bundler-cache: true
68
- - run: .\install-glfw.ps1
69
- - run: gem install bundler
70
- - run: bundle install --path vendor/bundle
71
67
  - run: bundle exec rake test
@@ -397,7 +397,7 @@ module Mittsu
397
397
  end
398
398
 
399
399
  def merge_mesh(mesh)
400
- if mesh instanceof Mittsu::Mesh == false
400
+ if mesh.is_a?(Mittsu::Mesh) == false
401
401
  puts('ERROR: Mittsu::Geometry#merge_mesh: mesh not an instance of Mittsu::Mesh.', mesh.inspect)
402
402
  return
403
403
  end
@@ -469,7 +469,7 @@ module Mittsu
469
469
  end
470
470
  vertices = []
471
471
  @vertices.each do |vert|
472
- vertices << vertex.x << vertex.y << vertex.z
472
+ vertices << vert.x << vert.y << vert.z
473
473
  end
474
474
  faces = []
475
475
  normals = []
@@ -507,7 +507,7 @@ module Mittsu
507
507
  faces << get_uv_index(face_vertex_uvs[2], uvs_hash, uvs)
508
508
  end
509
509
  if has_face_normal
510
- faces << get_normal_index(face.normal)
510
+ faces << get_normal_index(face.normal, normals_hash, normals)
511
511
  end
512
512
  if has_face_vertex_normal
513
513
  vertex_normals = face.vertex_normals
@@ -305,17 +305,13 @@ module Mittsu
305
305
  end
306
306
 
307
307
  def to_json
308
- @_output = {
308
+ {
309
309
  metadata: {
310
310
  version: 4.3,
311
311
  type: 'Object',
312
312
  generator: 'ObjectExporter'
313
- }
314
- }
315
- @_geometries = {}
316
- @_materials = {}
317
- @_output[:object] = self.jsonify
318
- @_output
313
+ },
314
+ }.merge(jsonify)
319
315
  end
320
316
 
321
317
  def clone(object = nil, recursive = true)
@@ -346,46 +342,32 @@ module Mittsu
346
342
  protected
347
343
 
348
344
  def jsonify
349
- data = {
350
- uuid: @uuid,
351
- type: @type,
352
- matrix: @matrix.to_a
353
- }
354
- data[:name] = @name unless @name.nil? || @name.empty?
355
- data[:user_data] = @user_data unless @user_data.nil? || @user_data.empty?
356
- data[:visible] = @visible unless @visible
357
-
358
- if !self.children.empty?
359
- data[:children] = @children.map do |child|
360
- child.jsonify
361
- end
362
- end
363
-
364
- # TODO: implement jsonify for PointCloud
365
-
366
- data
367
- end
368
-
369
- def jsonify_geometry(geometry)
370
- @_output[:geometries] ||= []
371
- if @_geometries[geometry.uuid].nil?
372
- json = geometry.to_json
373
- json.delete :metadata
374
- @_geometries[geometry.uuid] = json
375
- @_output[:geometries] << json
376
- end
377
- geometry.uuid
378
- end
379
-
380
- def jsonify_material(material)
381
- @_output[:materials] ||= []
382
- if @_materials[material.uuid].nil?
383
- json = material.to_json
384
- json.delete :metadata
385
- @_materials[material.uuid] = json
386
- @_output[:materials] << json
387
- end
388
- material.uuid
345
+ children = @children.map(&:to_json)
346
+ {
347
+ object: {
348
+ uuid: @uuid,
349
+ type: @type,
350
+ matrix: @matrix.to_a,
351
+ geometry: @geometry&.uuid,
352
+ material: @material&.uuid,
353
+ name: @name&.empty? ? nil : @name,
354
+ user_data: @user_data&.empty? ? nil : @user_data,
355
+ visible: @visible ? nil : @visible,
356
+ children: children.map { |x| x[:object] }.flatten
357
+ }.reject { |k,v| v.nil? || v == [] },
358
+ geometries: ([jsonify_geometry] + children.map { |x| x[:geometries] }).flatten.compact,
359
+ materials: ([jsonify_material] + children.map { |x| x[:materials] }).flatten.compact
360
+ }.reject { |k,v| v.nil? || v == [] }
361
+ end
362
+
363
+ def jsonify_geometry
364
+ return nil if @geometry.nil?
365
+ @geometry.to_json.delete_if {|k, v| k == :metadata }
366
+ end
367
+
368
+ def jsonify_material
369
+ return nil if @material.nil?
370
+ @material.to_json.delete_if {|k, v| k == :metadata }
389
371
  end
390
372
  end
391
373
  end
@@ -53,7 +53,7 @@ module Mittsu
53
53
 
54
54
  when FACE_PATTERN then parse_face(line)
55
55
 
56
- when OBJECT_PATTERN then new_object($1) and reset_vertices
56
+ when OBJECT_PATTERN then handle_object($1)
57
57
  when GROUP_PATTERN # ignore
58
58
  when SMOOTH_GROUP_PATTERN # ignore
59
59
 
@@ -105,9 +105,15 @@ module Mittsu
105
105
  raw_lines.split("\n").map(&:strip).reject(&:empty?).reject{|l| l.start_with? '#'}
106
106
  end
107
107
 
108
- def new_object(object_name = '')
109
- end_object
110
- @object = Object3D.new
108
+ def handle_object(object_name = '')
109
+ # Reset if we're already working on a named object
110
+ # otherwise, just name the one we have in progress
111
+ unless @object&.name.nil?
112
+ end_object
113
+ reset_vertices
114
+ @object = nil
115
+ end
116
+ @object ||= Object3D.new
111
117
  @object.name = object_name
112
118
  end
113
119
 
@@ -120,7 +126,7 @@ module Mittsu
120
126
 
121
127
  def new_mesh
122
128
  end_mesh
123
- new_object if @object.nil?
129
+ handle_object if @object.nil?
124
130
  @geometry = Geometry.new
125
131
  @mesh = Mesh.new(@geometry, @material || MeshLambertMaterial.new)
126
132
  @mesh.name = @object.name
@@ -38,18 +38,18 @@ module Mittsu
38
38
  object.traverse do |node|
39
39
  geometry = node.geometry
40
40
  if geometry != nil
41
- if geometry instanceof Mittsu::Geometry
41
+ if geometry.is_a?(Mittsu::Geometry)
42
42
  vertices = geometry.vertices
43
43
  vertices.each do |vertex|
44
44
  v1.copy(vertex)
45
- v1.apply_matrix4(node.matrixWorld)
45
+ v1.apply_matrix4(node.matrix_world)
46
46
  scope.expand_by_point(v1)
47
47
  end
48
- elsif geometry instanceof Mittsu::BufferGeometry && geometry.attributes['position'] != nil
48
+ elsif geometry.is_a?(Mittsu::BufferGeometry) && geometry.attributes['position'] != nil
49
49
  positions = geometry.attributes['position'].array
50
50
  positions.each_slice(3) do |postition|
51
51
  v1.set(position[0], position[1], position[2])
52
- v1.apply_matrix4(node.matrixWorld)
52
+ v1.apply_matrix4(node.matrix_world)
53
53
  scope.expand_by_point(v1)
54
54
  end
55
55
  end
@@ -143,9 +143,7 @@ module Mittsu
143
143
 
144
144
  def jsonify
145
145
  data = super
146
- data[:geometry] = jsonify_geometry(self.geometry)
147
- data[:material] = jsonify_material(self.material)
148
- data[:mode] = self.mode
146
+ data[:object][:mode] = self.mode
149
147
  data
150
148
  end
151
149
  end
@@ -98,7 +98,7 @@ module Mittsu
98
98
  @_ray.copy(raycaster.ray).apply_matrix4(@_inverse_matrix)
99
99
 
100
100
  if !geometry.bounding_box.nil?
101
- return unless ray.intersection_box?(geometry.bounding_box)
101
+ return unless @_ray.intersection_box?(geometry.bounding_box)
102
102
  end
103
103
 
104
104
 
@@ -132,16 +132,16 @@ module Mittsu
132
132
  v_c.from_array(positions, c * 3)
133
133
 
134
134
  if material.side == BackSide
135
- intersection_point = ray.intersect_triangle(v_c, v_b, v_a, true)
135
+ intersection_point = @_ray.intersect_triangle(v_c, v_b, v_a, true)
136
136
  else
137
- intersection_point = ray.intersect_triangle(v_a, v_b, v_c, material.side != DoubleSide)
137
+ intersection_point = @_ray.intersect_triangle(v_a, v_b, v_c, material.side != DoubleSide)
138
138
  end
139
139
 
140
140
  next if intersection_point.nil?
141
141
 
142
142
  intersection_point.apply_matrix4(@matrix_world)
143
143
 
144
- distance = racaster.ray.origin.distance_to(intersection_point)
144
+ distance = raycaster.ray.origin.distance_to(intersection_point)
145
145
 
146
146
  next if distance < precision || distance < raycaster.near || distance > raycaster.far
147
147
 
@@ -170,17 +170,17 @@ module Mittsu
170
170
  v_b.from_array(positions, j + 3)
171
171
  v_c.from_array(positions, j + 6)
172
172
 
173
- if material.side = BackSide
174
- intersection_point = ray.intersect_triangle(v_c, v_b, v_a, true)
173
+ if material.side == BackSide
174
+ intersection_point = @_ray.intersect_triangle(v_c, v_b, v_a, true)
175
175
  else
176
- intersection_point = ray.intersect_triangle(v_a, v_b, v_c, material.side != DoubleSide)
176
+ intersection_point = @_ray.intersect_triangle(v_a, v_b, v_c, material.side != DoubleSide)
177
177
  end
178
178
 
179
179
  next if intersection_point.nil?
180
180
 
181
181
  intersection_point.apply_matrix4(@matrix_world)
182
182
 
183
- distance = racaster.ray.origin.distance_to(intersection_point)
183
+ distance = raycaster.ray.origin.distance_to(intersection_point)
184
184
 
185
185
  next if distance < precision || distance < raycaster.near || distance > raycaster.far
186
186
 
@@ -269,10 +269,7 @@ module Mittsu
269
269
  protected
270
270
 
271
271
  def jsonify
272
- data = super
273
- data[:geometry] = jsonify_geometry(@geometry)
274
- data[:material] = jsonify_material(@material)
275
- data
272
+ super
276
273
  end
277
274
  end
278
275
  end
@@ -16,11 +16,11 @@ module Mittsu
16
16
 
17
17
  def raycast(raycaster, intersects)
18
18
  threshold = raycaster.params[:point_cloud][:threshold]
19
- @_inverse_matrix.inverse(self.materix_world)
19
+ @_inverse_matrix.inverse(self.matrix_world)
20
20
  @_ray.copy(raycaster.ray).apply_matrix4(@_inverse_matrix)
21
21
 
22
22
  if !geometry.bounding_box.nil?
23
- return if ray.intersection_box?(geometry.bounding_box) == false
23
+ return if @_ray.intersection_box?(geometry.bounding_box) == false
24
24
  end
25
25
 
26
26
  local_threshold = threshold / ((self.scale.x + self.scale.y + self.scale.z) / 3.0)
@@ -82,7 +82,7 @@ module Mittsu
82
82
  def test_point(point, index, local_threshold, raycaster, intersects)
83
83
  ray_point_distance = @_ray.distance_to_point(point)
84
84
  if ray_point_distance < local_threshold
85
- intersect_point = @_ray.closes_point_to_point(point)
85
+ intersect_point = @_ray.closest_point_to_point(point)
86
86
  intersect_point.apply_matrix4(self.matrix_world)
87
87
 
88
88
  distance = raycaster.ray.origin.distance_to(intersect_point)
@@ -1,3 +1,5 @@
1
+ require 'open3'
2
+
1
3
  module Mittsu
2
4
  module GenericLib
3
5
  def discover
@@ -32,7 +34,8 @@ module Mittsu
32
34
 
33
35
  class << self
34
36
  def kernel_module_in_use
35
- lspci_line = `lspci -nnk | grep -i vga -A3 | grep 'in use'`
37
+ lspci_line, stderr, _status = Open3.capture3("lspci -nnk | grep -i vga -A3 | grep 'in use'")
38
+ puts stderr if DEBUG
36
39
  /in use:\s*(\S+)/ =~ lspci_line && $1
37
40
  rescue
38
41
  ''
@@ -17,7 +17,9 @@ module Mittsu
17
17
  end
18
18
 
19
19
  def ldconfig
20
- `ldconfig -p | grep 'libglfw3\\?\\.so'`.lines
20
+ out, stderr, _status = Open3.capture3("ldconfig -p | grep 'libglfw3\\?\\.so'")
21
+ puts stderr if DEBUG
22
+ out.lines
21
23
  rescue
22
24
  []
23
25
  end
@@ -36,11 +38,11 @@ module Mittsu
36
38
  '/opt/homebrew/**']
37
39
 
38
40
  def path
39
- File.dirname(match)
41
+ File.dirname(match.to_s)
40
42
  end
41
43
 
42
44
  def file
43
- File.basename(match)
45
+ File.basename(match.to_s)
44
46
  end
45
47
 
46
48
  private
@@ -1,3 +1,3 @@
1
1
  module Mittsu
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Danielle Smith
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-13 00:00:00.000000000 Z
11
+ date: 2024-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opengl-bindings
@@ -411,7 +411,7 @@ licenses:
411
411
  - MIT
412
412
  metadata:
413
413
  bug_tracker: https://github.com/danini-the-panini/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.3.7
431
- signing_key:
430
+ rubygems_version: 3.5.23
431
+ signing_key:
432
432
  specification_version: 4
433
433
  summary: 3D Graphics Library for Ruby
434
434
  test_files: []