voxelamming_gem 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8ff1ac60303d84e62d69ad720a84ef3db7e180ee41c121d0e8c099dfa267aa2d
4
- data.tar.gz: 17e564b684612fcf5ae6e1fbb748e89f2eb429fed9eff5a6759d79a7f9017bbe
3
+ metadata.gz: f3a3fa9a3c78410940120fbf945818cce7ba33a60f4ca589929320420ad990fd
4
+ data.tar.gz: cb7d29c6d811dadbc7eb8ff91763e6a2239e83b319af986d73f1821d4f4e8d54
5
5
  SHA512:
6
- metadata.gz: fb4f8cf109ff0205257e3e24cd11b2b634390beada5a4eb61135f936e809af393afa6675074359c76c85e39efd78bae969c8b2d14ad5de96335c4b68431f9cc5
7
- data.tar.gz: a00a9cae5444283683504ae9476c875d6faf910bbbf7944d361cb043e22a0efdca3eb35fa802853c996571561a27729c23d0e3231663c31a95577b2113154b59
6
+ metadata.gz: 36a8daed67d4c48a57d5e5d1f297062f876b02d7aa23be48f913efed9d8940587135837f2984a1ab0d7d09caf8bf5bb1be2bad0f962129e6f2aa9e7d7b6f3b7b
7
+ data.tar.gz: d2efbaed4f7ad61cf6b30da9b57337698a1f40e3d29de41714395ecd1a3884b3b4645a22fd81c4b222e28f72b8df4c30a28a9d642b548bb0e465924d58496bd3
data/CHANGELOG.md ADDED
@@ -0,0 +1,14 @@
1
+ ## VoxelammingGem Change log
2
+
3
+ ### ver. 0.1.0
4
+
5
+ - first release
6
+
7
+ ### ver. 0.1.1
8
+
9
+ - Map and ply file paths changed to be specified as relative paths.
10
+ - a few bug fixes
11
+
12
+ ### ver. 0.1.3
13
+
14
+ - Changed so that the size of the map can be specified.
data/README.md CHANGED
@@ -1,24 +1,80 @@
1
1
  # VoxelammingGem
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ This Ruby package converts Python code into JSON format and sends it to the Voxelamming app using WebSockets, allowing users to create 3D voxel models by writing Ruby scripts.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/voxelamming_gem`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ ## What's Voxelamming?
6
6
 
7
- ## Installation
7
+ <p align="center"><img src="https://creativival.github.io/voxelamming/image/voxelamming_icon.png" alt="Voxelamming Logo" width="200"/></p>
8
+
9
+ Voxelamming is an AR programming learning app. Even programming beginners can learn programming visually and enjoyably. Voxelamming supports iPhones and iPads with iOS 16 or later, and Apple Vision Pro.
8
10
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
11
+ ## Resources
10
12
 
11
- Install the gem and add to the application's Gemfile by executing:
13
+ * **Homepage:** https://creativival.github.io/voxelamming/index.en
14
+ * **Samples:** https://github.com/creativival/voxelamming/tree/main/sample/ruby
12
15
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
14
16
 
15
- If bundler is not being used to manage dependencies, install the gem by executing:
17
+ ## Installation
16
18
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
19
+ ```bash
20
+ gem install voxelamming
21
+ ```
18
22
 
19
23
  ## Usage
20
24
 
21
- TODO: Write usage instructions here
25
+ ```ruby
26
+ require 'voxelamming_gem'
27
+
28
+ room_name = '1000'
29
+ build_box = VoxelammingGem::BuildBox.new(room_name)
30
+
31
+ build_box.set_box_size(0.5)
32
+ build_box.set_build_interval(0.01)
33
+
34
+ for i in 0...100
35
+ build_box.create_box(-1, i, 0, r: 0, g: 1, b: 1)
36
+ build_box.create_box(0, i, 0, r: 1, g: 0, b: 0)
37
+ build_box.create_box(1, i, 0, r: 1, g: 1, b: 0)
38
+ build_box.create_box(2, i, 0, r: 0, g: 1, b: 1)
39
+ end
40
+
41
+ for i in 0...50
42
+ build_box.remove_box(0, i * 2, 0)
43
+ build_box.remove_box(1, i * 2 + 1, 0)
44
+ end
45
+
46
+ build_box.send_data
47
+ ```
48
+
49
+ This code snippet demonstrates a simple example where a red voxel is created at a specific location. You can use various functions provided by the `BuildBox` class to build more complex models.
50
+
51
+ #### Method description
52
+
53
+ | Method name | Description | Arguments |
54
+ |---|---|---|
55
+ | `set_room_name(room_name)` | Sets the room name for communicating with the device. | `room_name`: Room name (string) |
56
+ | `set_box_size(size)` | Sets the size of the voxel (default: 1.0). | `size`: Size (float) |
57
+ | `set_build_interval(interval)` | Sets the placement interval of the voxels (default: 0.01 seconds). | `interval`: Interval (float) |
58
+ | `change_shape(shape)` | Changes the shape of the voxel. | `shape`: Shape ("box", "square", "plane") |
59
+ | `change_material(is_metallic, roughness)` | Changes the material of the voxel. | `is_metallic`: Whether to make it metallic (boolean), `roughness`: Roughness (float) |
60
+ | `create_box(x, y, z, r, g, b, alpha)` | Places a voxel. | `x`, `y`, `z`: Position (float), `r`, `g`, `b`, `alpha`: Color (float, 0-1) |
61
+ | `create_box(x, y, z, texture)` | Places a voxel with texture. | `x`, `y`, `z`: Position (float), `texture`: Texture name (string) |
62
+ | `remove_box(x, y, z)` | Removes a voxel. | `x`, `y`, `z`: Position (float) |
63
+ | `write_sentence(sentence, x, y, z, r, g, b, alpha)` | Draws a string with voxels. | `sentence`: String (string), `x`, `y`, `z`: Position (float), `r`, `g`, `b`, `alpha`: Color (float, 0-1) |
64
+ | `set_light(x, y, z, r, g, b, alpha, intensity, interval, light_type)` | Places a light. | `x`, `y`, `z`: Position (float), `r`, `g`, `b`, `alpha`: Color (float, 0-1), `intensity`: Intensity (float), `interval`: Blinking interval (float), `light_type`: Type of light ("point", "spot", "directional") |
65
+ | `set_command(command)` | Executes a command. | `command`: Command ("axis", "japaneseCastle", "float", "liteRender") |
66
+ | `draw_line(x1, y1, z1, x2, y2, z2, r, g, b, alpha)` | Draws a line between two points. | `x1`, `y1`, `z1`: Starting point (float), `x2`, `y2`, `z2`: Ending point (float), `r`, `g`, `b`, `alpha`: Color (float, 0-1) |
67
+ | `send_data(name)` | Sends voxel data to the device; if the name argument is set, the voxel data can be stored and reproduced as history. | |
68
+ | `clear_data()` | Initializes voxel data. | |
69
+ | `translate(x, y, z, pitch, yaw, roll)` | Moves and rotates the coordinate system of the voxel. | `x`, `y`, `z`: Translation amount (float), `pitch`, `yaw`, `roll`: Rotation amount (float) |
70
+ | `animate(x, y, z, pitch, yaw, roll, scale, interval)` | Animates a voxel. | `x`, `y`, `z`: Translation amount (float), `pitch`, `yaw`, `roll`: Rotation amount (float), `scale`: Scale (float), `interval`: Interval (float) |
71
+ | `animate_global(x, y, z, pitch, yaw, roll, scale, interval)` | Animates all voxels. | `x`, `y`, `z`: Translation amount (float), `pitch`, `yaw`, `roll`: Rotation amount (float), `scale`: Scale (float), `interval`: Interval (float) |
72
+ | `push_matrix()` | Saves the current coordinate system to the stack. | |
73
+ | `pop_matrix()` | Restores the coordinate system from the stack. | |
74
+ | `frame_in()` | Starts recording a frame. | |
75
+ | `frame_out()` | Ends recording a frame. | |
76
+ | `set_frame_fps(fps)` | Sets the frame rate (default: 2). | `fps`: Frame rate (int) |
77
+ | `set_frame_repeats(repeats)` | Sets the number of frame repetitions (default: 10). | `repeats`: Number of repetitions (int) |
22
78
 
23
79
  ## Development
24
80
 
data/index.html ADDED
@@ -0,0 +1,139 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>VoxelammingGem</title>
6
+ <style>
7
+ body {
8
+ font-family: sans-serif;
9
+ line-height: 1.6;
10
+ margin: 2rem auto;
11
+ max-width: 800px;
12
+ padding: 0 1rem;
13
+ }
14
+
15
+ h1, h2, h3 {
16
+ margin-top: 1.5rem;
17
+ }
18
+
19
+ a {
20
+ color: #0645ad;
21
+ text-decoration: none;
22
+ }
23
+
24
+ a:hover {
25
+ text-decoration: underline;
26
+ }
27
+
28
+ img {
29
+ max-width: 100%;
30
+ height: auto;
31
+ }
32
+
33
+ pre {
34
+ background-color: #f5f5f5;
35
+ border: 1px solid #ccc;
36
+ overflow-x: auto;
37
+ padding: 1rem;
38
+ }
39
+
40
+ code {
41
+ font-family: monospace;
42
+ }
43
+
44
+ table {
45
+ border-collapse: collapse;
46
+ width: 100%;
47
+ }
48
+
49
+ th, td {
50
+ border: 1px solid #ccc;
51
+ padding: 0.5rem;
52
+ }
53
+
54
+ th {
55
+ background-color: #f0f0f0;
56
+ font-weight: bold;
57
+ }
58
+ </style>
59
+ </head>
60
+ <body>
61
+ <h1><a href="#voxelamminggem" id="voxelamminggem"></a>VoxelammingGem</h1>
62
+ <p>This Ruby package converts Python code into JSON format and sends it to the Voxelamming app using WebSockets, allowing users to create 3D voxel models by writing Ruby scripts.</p>
63
+ <h2><a href="#whats-voxelamming" id="whats-voxelamming"></a>What's Voxelamming?</h2>
64
+ <p align="center"><img src="https://creativival.github.io/voxelamming/image/voxelamming_icon.png" alt="Voxelamming Logo" width="200"/></p>
65
+ <p>Voxelamming is an AR programming learning app. Even programming beginners can learn programming visually and enjoyably. Voxelamming supports iPhones and iPads with iOS 16 or later, and Apple Vision Pro.</p>
66
+ <h2><a href="#resources" id="resources"></a>Resources</h2>
67
+ <ul>
68
+ <li><strong>Homepage:</strong> <a href="https://creativival.github.io/voxelamming/index.en">https://creativival.github.io/voxelamming/index.en</a></li>
69
+ <li><strong>Samples:</strong> <a href="https://github.com/creativival/voxelamming/tree/main/sample/ruby">https://github.com/creativival/voxelamming/tree/main/sample/ruby</a></li>
70
+ </ul>
71
+ <h2><a href="#installation" id="installation"></a>Installation</h2>
72
+ <pre><code class="bash">gem install voxelamming
73
+ </code></pre>
74
+ <h2><a href="#usage" id="usage"></a>Usage</h2>
75
+ <pre><code class="ruby">require 'voxelamming_gem'
76
+
77
+ room_name = '1000'
78
+ build_box = VoxelammingGem::BuildBox.new(room_name)
79
+
80
+ build_box.set_box_size(0.5)
81
+ build_box.set_build_interval(0.01)
82
+
83
+ for i in 0...100
84
+ build_box.create_box(-1, i, 0, r: 0, g: 1, b: 1)
85
+ build_box.create_box(0, i, 0, r: 1, g: 0, b: 0)
86
+ build_box.create_box(1, i, 0, r: 1, g: 1, b: 0)
87
+ build_box.create_box(2, i, 0, r: 0, g: 1, b: 1)
88
+ end
89
+
90
+ for i in 0...50
91
+ build_box.remove_box(0, i * 2, 0)
92
+ build_box.remove_box(1, i * 2 + 1, 0)
93
+ end
94
+
95
+ build_box.send_data
96
+ </code></pre>
97
+ <p>This code snippet demonstrates a simple example where a red voxel is created at a specific location. You can use various functions provided by the <code>BuildBox</code> class to build more complex models.</p>
98
+ <h4><a href="#method-description" id="method-description"></a>Method description</h4>
99
+ <table>
100
+ <thead>
101
+ <tr><th> Method name </th><th> Description </th><th> Arguments </th></tr>
102
+ </thead>
103
+ <tbody>
104
+ <tr><td> <code>set_room_name(room_name)</code> </td><td> Sets the room name for communicating with the device. </td><td> <code>room_name</code>: Room name (string) </td></tr>
105
+ <tr><td> <code>set_box_size(size)</code> </td><td> Sets the size of the voxel (default: 1.0). </td><td> <code>size</code>: Size (float) </td></tr>
106
+ <tr><td> <code>set_build_interval(interval)</code> </td><td> Sets the placement interval of the voxels (default: 0.01 seconds). </td><td> <code>interval</code>: Interval (float) </td></tr>
107
+ <tr><td> <code>change_shape(shape)</code> </td><td> Changes the shape of the voxel. </td><td> <code>shape</code>: Shape ("box", "square", "plane") </td></tr>
108
+ <tr><td> <code>change_material(is_metallic, roughness)</code> </td><td> Changes the material of the voxel. </td><td> <code>is_metallic</code>: Whether to make it metallic (boolean), <code>roughness</code>: Roughness (float) </td></tr>
109
+ <tr><td> <code>create_box(x, y, z, r, g, b, alpha)</code> </td><td> Places a voxel. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Position (float), <code>r</code>, <code>g</code>, <code>b</code>, <code>alpha</code>: Color (float, 0-1) </td></tr>
110
+ <tr><td> <code>create_box(x, y, z, texture)</code> </td><td> Places a voxel with texture. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Position (float), <code>texture</code>: Texture name (string) </td></tr>
111
+ <tr><td> <code>remove_box(x, y, z)</code> </td><td> Removes a voxel. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Position (float) </td></tr>
112
+ <tr><td> <code>write_sentence(sentence, x, y, z, r, g, b, alpha)</code> </td><td> Draws a string with voxels. </td><td> <code>sentence</code>: String (string), <code>x</code>, <code>y</code>, <code>z</code>: Position (float), <code>r</code>, <code>g</code>, <code>b</code>, <code>alpha</code>: Color (float, 0-1) </td></tr>
113
+ <tr><td> <code>set_light(x, y, z, r, g, b, alpha, intensity, interval, light_type)</code> </td><td> Places a light. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Position (float), <code>r</code>, <code>g</code>, <code>b</code>, <code>alpha</code>: Color (float, 0-1), <code>intensity</code>: Intensity (float), <code>interval</code>: Blinking interval (float), <code>light_type</code>: Type of light ("point", "spot", "directional") </td></tr>
114
+ <tr><td> <code>set_command(command)</code> </td><td> Executes a command. </td><td> <code>command</code>: Command ("axis", "japaneseCastle", "float", "liteRender") </td></tr>
115
+ <tr><td> <code>draw_line(x1, y1, z1, x2, y2, z2, r, g, b, alpha)</code> </td><td> Draws a line between two points. </td><td> <code>x1</code>, <code>y1</code>, <code>z1</code>: Starting point (float), <code>x2</code>, <code>y2</code>, <code>z2</code>: Ending point (float), <code>r</code>, <code>g</code>, <code>b</code>, <code>alpha</code>: Color (float, 0-1) </td></tr>
116
+ <tr><td> <code>send_data(name)</code> </td><td> Sends voxel data to the device; if the name argument is set, the voxel data can be stored and reproduced as history. </td><td> </td></tr>
117
+ <tr><td> <code>clear_data()</code> </td><td> Initializes voxel data. </td><td> </td></tr>
118
+ <tr><td> <code>translate(x, y, z, pitch, yaw, roll)</code> </td><td> Moves and rotates the coordinate system of the voxel. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Translation amount (float), <code>pitch</code>, <code>yaw</code>, <code>roll</code>: Rotation amount (float) </td></tr>
119
+ <tr><td> <code>animate(x, y, z, pitch, yaw, roll, scale, interval)</code> </td><td> Animates a voxel. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Translation amount (float), <code>pitch</code>, <code>yaw</code>, <code>roll</code>: Rotation amount (float), <code>scale</code>: Scale (float), <code>interval</code>: Interval (float) </td></tr>
120
+ <tr><td> <code>animate_global(x, y, z, pitch, yaw, roll, scale, interval)</code> </td><td> Animates all voxels. </td><td> <code>x</code>, <code>y</code>, <code>z</code>: Translation amount (float), <code>pitch</code>, <code>yaw</code>, <code>roll</code>: Rotation amount (float), <code>scale</code>: Scale (float), <code>interval</code>: Interval (float) </td></tr>
121
+ <tr><td> <code>push_matrix()</code> </td><td> Saves the current coordinate system to the stack. </td><td> </td></tr>
122
+ <tr><td> <code>pop_matrix()</code> </td><td> Restores the coordinate system from the stack. </td><td> </td></tr>
123
+ <tr><td> <code>frame_in()</code> </td><td> Starts recording a frame. </td><td> </td></tr>
124
+ <tr><td> <code>frame_out()</code> </td><td> Ends recording a frame. </td><td> </td></tr>
125
+ <tr><td> <code>set_frame_fps(fps)</code> </td><td> Sets the frame rate (default: 2). </td><td> <code>fps</code>: Frame rate (int) </td></tr>
126
+ <tr><td> <code>set_frame_repeats(repeats)</code> </td><td> Sets the number of frame repetitions (default: 10). </td><td> <code>repeats</code>: Number of repetitions (int) </td></tr>
127
+ </tbody>
128
+ </table>
129
+ <h2><a href="#development" id="development"></a>Development</h2>
130
+ <p>After checking out the repo, run <code>bin/setup</code> to install dependencies. Then, run <code>rake test</code> to run the tests. You can also run <code>bin/console</code> for an interactive prompt that will allow you to experiment.</p>
131
+ <p>To install this gem onto your local machine, run <code>bundle exec rake install</code>. To release a new version, update the version number in <code>version.rb</code>, and then run <code>bundle exec rake release</code>, which will create a git tag for the version, push git commits and the created tag, and push the <code>.gem</code> file to <a href="https://rubygems.org">rubygems.org</a>.</p>
132
+ <h2><a href="#contributing" id="contributing"></a>Contributing</h2>
133
+ <p>Bug reports and pull requests are welcome on GitHub at <a href="https://github.com/[USERNAME]/voxelamming_gem">https://github.com/[USERNAME]/voxelamming_gem</a>. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the <a href="https://github.com/[USERNAME]/voxelamming_gem/blob/master/CODE_OF_CONDUCT.md">code of conduct</a>.</p>
134
+ <h2><a href="#license" id="license"></a>License</h2>
135
+ <p>The gem is available as open source under the terms of the <a href="https://opensource.org/licenses/MIT">MIT License</a>.</p>
136
+ <h2><a href="#code-of-conduct" id="code-of-conduct"></a>Code of Conduct</h2>
137
+ <p>Everyone interacting in the VoxelammingGem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the <a href="https://github.com/[USERNAME]/voxelamming_gem/blob/master/CODE_OF_CONDUCT.md">code of conduct</a>.</p>
138
+ </body>
139
+ </html>
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module VoxelammingGem
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -491,9 +491,7 @@ module VoxelammingGem
491
491
  end
492
492
 
493
493
  # Map
494
- $column_num, $row_num = 257, 257
495
-
496
- def self.get_map_data_from_csv(csv_file, height_scale)
494
+ def self.get_map_data_from_csv(csv_file, height_scale, column_num = 257, row_num = 257)
497
495
  # csvファイルから地図データを読み込み
498
496
  heights = []
499
497
 
@@ -507,7 +505,7 @@ module VoxelammingGem
507
505
  # puts "heights: #{heights}"
508
506
 
509
507
  max_height = heights.max.floor
510
- box_positions = (0...$row_num).map { |i| heights[i * $column_num, $column_num] }
508
+ box_positions = (0...row_num).map { |i| heights[i * column_num, column_num] }
511
509
  puts "max_height: #{max_height}"
512
510
  # puts "box_positions: #{box_positions}"
513
511
  { 'boxes' => box_positions, 'max_height' => max_height }
data/main_make_model.rb CHANGED
@@ -6,7 +6,7 @@ build_box = VoxelammingGem::BuildBox.new(room_name)
6
6
  build_box.set_box_size(0.5)
7
7
  build_box.set_build_interval(0.01)
8
8
 
9
- ply_file_name = 'piyo.ply'
9
+ ply_file_name = 'ply_file/piyo.ply'
10
10
 
11
11
  boxes = VoxelammingGem.get_boxes_from_ply(ply_file_name)
12
12
  # puts boxes
data/main_map.rb CHANGED
@@ -8,7 +8,7 @@ build_box.set_build_interval(0.001)
8
8
  build_box.set_command('liteRender')
9
9
 
10
10
  column_num, row_num = 257, 257
11
- csv_file = 'map_38_138_100km.csv'
11
+ csv_file = 'map_file/map_38_138_100km.csv'
12
12
  height_scale = 100
13
13
  high_color = [0.5, 0, 0]
14
14
  low_color = [0, 1, 0]
Binary file
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxelamming_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - creativival
@@ -34,10 +34,12 @@ extensions: []
34
34
  extra_rdoc_files: []
35
35
  files:
36
36
  - ".ruby-version"
37
+ - CHANGELOG.md
37
38
  - CODE_OF_CONDUCT.md
38
39
  - LICENSE.txt
39
40
  - README.md
40
41
  - Rakefile
42
+ - index.html
41
43
  - lib/matrix_util.rb
42
44
  - lib/voxelamming_gem.rb
43
45
  - lib/voxelamming_gem/version.rb
@@ -52,6 +54,8 @@ files:
52
54
  - ply_file/frog5.ply
53
55
  - ply_file/piyo.ply
54
56
  - sig/voxelamming_gem.rbs
57
+ - voxelamming_gem-0.1.0.gem
58
+ - voxelamming_gem-0.1.1.gem
55
59
  homepage: https://creativival.github.io/voxelamming
56
60
  licenses:
57
61
  - MIT