bevy 1.0.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.
Files changed (93) hide show
  1. checksums.yaml +7 -0
  2. data/Cargo.lock +4279 -0
  3. data/Cargo.toml +36 -0
  4. data/README.md +226 -0
  5. data/crates/bevy/Cargo.toml +52 -0
  6. data/crates/bevy/src/app.rs +43 -0
  7. data/crates/bevy/src/component.rs +111 -0
  8. data/crates/bevy/src/entity.rs +30 -0
  9. data/crates/bevy/src/error.rs +32 -0
  10. data/crates/bevy/src/event.rs +190 -0
  11. data/crates/bevy/src/input_bridge.rs +300 -0
  12. data/crates/bevy/src/lib.rs +42 -0
  13. data/crates/bevy/src/mesh_renderer.rs +328 -0
  14. data/crates/bevy/src/query.rs +53 -0
  15. data/crates/bevy/src/render_app.rs +689 -0
  16. data/crates/bevy/src/resource.rs +28 -0
  17. data/crates/bevy/src/schedule.rs +186 -0
  18. data/crates/bevy/src/sprite_renderer.rs +355 -0
  19. data/crates/bevy/src/system.rs +44 -0
  20. data/crates/bevy/src/text_renderer.rs +258 -0
  21. data/crates/bevy/src/types/color.rs +114 -0
  22. data/crates/bevy/src/types/dynamic.rs +131 -0
  23. data/crates/bevy/src/types/math.rs +260 -0
  24. data/crates/bevy/src/types/mod.rs +9 -0
  25. data/crates/bevy/src/types/transform.rs +166 -0
  26. data/crates/bevy/src/world.rs +163 -0
  27. data/crates/bevy_ruby_render/Cargo.toml +22 -0
  28. data/crates/bevy_ruby_render/src/asset.rs +360 -0
  29. data/crates/bevy_ruby_render/src/audio.rs +511 -0
  30. data/crates/bevy_ruby_render/src/camera.rs +365 -0
  31. data/crates/bevy_ruby_render/src/gamepad.rs +398 -0
  32. data/crates/bevy_ruby_render/src/lib.rs +26 -0
  33. data/crates/bevy_ruby_render/src/material.rs +310 -0
  34. data/crates/bevy_ruby_render/src/mesh.rs +491 -0
  35. data/crates/bevy_ruby_render/src/sprite.rs +289 -0
  36. data/ext/bevy/Cargo.toml +20 -0
  37. data/ext/bevy/extconf.rb +6 -0
  38. data/ext/bevy/src/conversions.rs +137 -0
  39. data/ext/bevy/src/lib.rs +29 -0
  40. data/ext/bevy/src/ruby_app.rs +65 -0
  41. data/ext/bevy/src/ruby_color.rs +149 -0
  42. data/ext/bevy/src/ruby_component.rs +189 -0
  43. data/ext/bevy/src/ruby_entity.rs +33 -0
  44. data/ext/bevy/src/ruby_math.rs +384 -0
  45. data/ext/bevy/src/ruby_query.rs +64 -0
  46. data/ext/bevy/src/ruby_render_app.rs +779 -0
  47. data/ext/bevy/src/ruby_system.rs +122 -0
  48. data/ext/bevy/src/ruby_world.rs +107 -0
  49. data/lib/bevy/animation.rb +597 -0
  50. data/lib/bevy/app.rb +675 -0
  51. data/lib/bevy/asset.rb +613 -0
  52. data/lib/bevy/audio.rb +545 -0
  53. data/lib/bevy/audio_effects.rb +224 -0
  54. data/lib/bevy/camera.rb +412 -0
  55. data/lib/bevy/component.rb +91 -0
  56. data/lib/bevy/diagnostics.rb +227 -0
  57. data/lib/bevy/ecs_advanced.rb +296 -0
  58. data/lib/bevy/event.rb +199 -0
  59. data/lib/bevy/gizmos.rb +158 -0
  60. data/lib/bevy/gltf.rb +227 -0
  61. data/lib/bevy/hierarchy.rb +444 -0
  62. data/lib/bevy/input.rb +514 -0
  63. data/lib/bevy/lighting.rb +369 -0
  64. data/lib/bevy/material.rb +248 -0
  65. data/lib/bevy/mesh.rb +257 -0
  66. data/lib/bevy/navigation.rb +344 -0
  67. data/lib/bevy/networking.rb +335 -0
  68. data/lib/bevy/particle.rb +337 -0
  69. data/lib/bevy/physics.rb +396 -0
  70. data/lib/bevy/plugins/default_plugins.rb +34 -0
  71. data/lib/bevy/plugins/input_plugin.rb +49 -0
  72. data/lib/bevy/reflect.rb +361 -0
  73. data/lib/bevy/render_graph.rb +210 -0
  74. data/lib/bevy/resource.rb +185 -0
  75. data/lib/bevy/scene.rb +254 -0
  76. data/lib/bevy/shader.rb +319 -0
  77. data/lib/bevy/shape.rb +195 -0
  78. data/lib/bevy/skeletal.rb +248 -0
  79. data/lib/bevy/sprite.rb +152 -0
  80. data/lib/bevy/sprite_sheet.rb +444 -0
  81. data/lib/bevy/state.rb +277 -0
  82. data/lib/bevy/system.rb +206 -0
  83. data/lib/bevy/text.rb +99 -0
  84. data/lib/bevy/text_advanced.rb +455 -0
  85. data/lib/bevy/timer.rb +147 -0
  86. data/lib/bevy/transform.rb +158 -0
  87. data/lib/bevy/ui.rb +454 -0
  88. data/lib/bevy/ui_advanced.rb +568 -0
  89. data/lib/bevy/version.rb +5 -0
  90. data/lib/bevy/visibility.rb +250 -0
  91. data/lib/bevy/window.rb +302 -0
  92. data/lib/bevy.rb +390 -0
  93. metadata +150 -0
@@ -0,0 +1,158 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bevy
4
+ class Gizmos
5
+ attr_accessor :enabled, :line_width
6
+
7
+ def initialize
8
+ @enabled = true
9
+ @line_width = 1.0
10
+ @commands = []
11
+ end
12
+
13
+ def line(start_point, end_point, color: nil)
14
+ @commands << { type: :line, start: start_point, end: end_point, color: color || Color.white }
15
+ self
16
+ end
17
+
18
+ def ray(origin, direction, length: 1.0, color: nil)
19
+ end_point = Vec3.new(
20
+ origin.x + direction.x * length,
21
+ origin.y + direction.y * length,
22
+ origin.z + direction.z * length
23
+ )
24
+ line(origin, end_point, color: color)
25
+ end
26
+
27
+ def circle(center, radius, color: nil, segments: 32)
28
+ @commands << { type: :circle, center: center, radius: radius, color: color || Color.white, segments: segments }
29
+ self
30
+ end
31
+
32
+ def sphere(center, radius, color: nil)
33
+ @commands << { type: :sphere, center: center, radius: radius, color: color || Color.white }
34
+ self
35
+ end
36
+
37
+ def rect(center, size, color: nil)
38
+ @commands << { type: :rect, center: center, size: size, color: color || Color.white }
39
+ self
40
+ end
41
+
42
+ def box3d(center, size, color: nil)
43
+ @commands << { type: :box, center: center, size: size, color: color || Color.white }
44
+ self
45
+ end
46
+
47
+ def arrow(start_point, end_point, color: nil)
48
+ @commands << { type: :arrow, start: start_point, end: end_point, color: color || Color.white }
49
+ self
50
+ end
51
+
52
+ def arc(center, radius, start_angle, end_angle, color: nil)
53
+ @commands << { type: :arc, center: center, radius: radius, start_angle: start_angle, end_angle: end_angle, color: color || Color.white }
54
+ self
55
+ end
56
+
57
+ def grid(center, cell_size, count, color: nil)
58
+ @commands << { type: :grid, center: center, cell_size: cell_size, count: count, color: color || Color.rgba(0.5, 0.5, 0.5, 1.0) }
59
+ self
60
+ end
61
+
62
+ def cross(center, size, color: nil)
63
+ half = size / 2.0
64
+ line(Vec3.new(center.x - half, center.y, center.z), Vec3.new(center.x + half, center.y, center.z), color: color)
65
+ line(Vec3.new(center.x, center.y - half, center.z), Vec3.new(center.x, center.y + half, center.z), color: color)
66
+ end
67
+
68
+ def commands
69
+ @commands
70
+ end
71
+
72
+ def clear
73
+ @commands = []
74
+ end
75
+
76
+ def command_count
77
+ @commands.size
78
+ end
79
+
80
+ def type_name
81
+ 'Gizmos'
82
+ end
83
+ end
84
+
85
+ class GizmoConfig
86
+ attr_accessor :enabled, :line_width, :depth_test, :render_layer
87
+
88
+ def initialize(
89
+ enabled: true,
90
+ line_width: 1.0,
91
+ depth_test: true,
92
+ render_layer: 0
93
+ )
94
+ @enabled = enabled
95
+ @line_width = line_width.to_f
96
+ @depth_test = depth_test
97
+ @render_layer = render_layer
98
+ end
99
+
100
+ def type_name
101
+ 'GizmoConfig'
102
+ end
103
+ end
104
+
105
+ class AabbGizmo
106
+ attr_accessor :color
107
+
108
+ def initialize(color: nil)
109
+ @color = color || Color.rgba(0.0, 1.0, 0.0, 1.0)
110
+ end
111
+
112
+ def type_name
113
+ 'AabbGizmo'
114
+ end
115
+ end
116
+
117
+ class LightGizmo
118
+ attr_accessor :draw_range, :draw_direction
119
+
120
+ def initialize(draw_range: true, draw_direction: true)
121
+ @draw_range = draw_range
122
+ @draw_direction = draw_direction
123
+ end
124
+
125
+ def type_name
126
+ 'LightGizmo'
127
+ end
128
+ end
129
+
130
+ class TransformGizmo
131
+ attr_accessor :enabled, :mode
132
+
133
+ TRANSLATE = :translate
134
+ ROTATE = :rotate
135
+ SCALE = :scale
136
+
137
+ def initialize(enabled: true, mode: TRANSLATE)
138
+ @enabled = enabled
139
+ @mode = mode
140
+ end
141
+
142
+ def translate_mode
143
+ @mode = TRANSLATE
144
+ end
145
+
146
+ def rotate_mode
147
+ @mode = ROTATE
148
+ end
149
+
150
+ def scale_mode
151
+ @mode = SCALE
152
+ end
153
+
154
+ def type_name
155
+ 'TransformGizmo'
156
+ end
157
+ end
158
+ end
data/lib/bevy/gltf.rb ADDED
@@ -0,0 +1,227 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bevy
4
+ class Gltf
5
+ attr_reader :path, :scenes, :meshes, :materials, :animations, :nodes
6
+
7
+ def initialize(path)
8
+ @path = path
9
+ @scenes = []
10
+ @meshes = []
11
+ @materials = []
12
+ @animations = []
13
+ @nodes = []
14
+ @loaded = false
15
+ end
16
+
17
+ def loaded?
18
+ @loaded
19
+ end
20
+
21
+ def mark_loaded(data = {})
22
+ @scenes = data[:scenes] || []
23
+ @meshes = data[:meshes] || []
24
+ @materials = data[:materials] || []
25
+ @animations = data[:animations] || []
26
+ @nodes = data[:nodes] || []
27
+ @loaded = true
28
+ end
29
+
30
+ def default_scene
31
+ @scenes.first
32
+ end
33
+
34
+ def type_name
35
+ 'Gltf'
36
+ end
37
+ end
38
+
39
+ class GltfMesh
40
+ attr_reader :name, :primitives
41
+
42
+ def initialize(name, primitives = [])
43
+ @name = name
44
+ @primitives = primitives
45
+ end
46
+
47
+ def type_name
48
+ 'GltfMesh'
49
+ end
50
+ end
51
+
52
+ class GltfPrimitive
53
+ attr_reader :mesh, :material
54
+
55
+ def initialize(mesh:, material: nil)
56
+ @mesh = mesh
57
+ @material = material
58
+ end
59
+
60
+ def type_name
61
+ 'GltfPrimitive'
62
+ end
63
+ end
64
+
65
+ class GltfNode
66
+ attr_reader :name, :transform, :mesh, :children
67
+
68
+ def initialize(name:, transform: nil, mesh: nil, children: [])
69
+ @name = name
70
+ @transform = transform || Transform.identity
71
+ @mesh = mesh
72
+ @children = children
73
+ end
74
+
75
+ def type_name
76
+ 'GltfNode'
77
+ end
78
+ end
79
+
80
+ class GltfScene
81
+ attr_reader :name, :nodes
82
+
83
+ def initialize(name, nodes = [])
84
+ @name = name
85
+ @nodes = nodes
86
+ end
87
+
88
+ def type_name
89
+ 'GltfScene'
90
+ end
91
+ end
92
+
93
+ class GltfAnimation
94
+ attr_reader :name, :duration
95
+
96
+ def initialize(name, duration = 0.0)
97
+ @name = name
98
+ @duration = duration.to_f
99
+ end
100
+
101
+ def type_name
102
+ 'GltfAnimation'
103
+ end
104
+ end
105
+
106
+ class SceneBundle3d
107
+ attr_reader :scene, :transform
108
+
109
+ def initialize(scene:, transform: nil)
110
+ @scene = scene
111
+ @transform = transform || Transform.identity
112
+ end
113
+
114
+ def type_name
115
+ 'SceneBundle3d'
116
+ end
117
+ end
118
+
119
+ class GltfAssetLoader
120
+ def initialize
121
+ @cache = {}
122
+ end
123
+
124
+ def load(path)
125
+ return @cache[path] if @cache[path]
126
+
127
+ gltf = Gltf.new(path)
128
+ @cache[path] = gltf
129
+ gltf
130
+ end
131
+
132
+ def is_loaded?(path)
133
+ @cache[path]&.loaded?
134
+ end
135
+
136
+ def get(path)
137
+ @cache[path]
138
+ end
139
+
140
+ def unload(path)
141
+ @cache.delete(path)
142
+ end
143
+
144
+ def clear
145
+ @cache.clear
146
+ end
147
+
148
+ def type_name
149
+ 'GltfAssetLoader'
150
+ end
151
+ end
152
+
153
+ class Mesh3d
154
+ attr_reader :handle
155
+
156
+ def initialize(handle)
157
+ @handle = handle
158
+ end
159
+
160
+ def type_name
161
+ 'Mesh3d'
162
+ end
163
+ end
164
+
165
+ class MeshMaterial3d
166
+ attr_reader :material
167
+
168
+ def initialize(material)
169
+ @material = material
170
+ end
171
+
172
+ def type_name
173
+ 'MeshMaterial3d'
174
+ end
175
+ end
176
+
177
+ class Pbr
178
+ attr_reader :base_color, :metallic, :roughness, :emissive
179
+
180
+ def initialize(base_color: nil, metallic: 0.0, roughness: 0.5, emissive: nil)
181
+ @base_color = base_color || Color.white
182
+ @metallic = metallic.to_f
183
+ @roughness = roughness.to_f
184
+ @emissive = emissive || Color.black
185
+ end
186
+
187
+ def with_base_color(color)
188
+ self.class.new(
189
+ base_color: color,
190
+ metallic: @metallic,
191
+ roughness: @roughness,
192
+ emissive: @emissive
193
+ )
194
+ end
195
+
196
+ def with_metallic(metallic)
197
+ self.class.new(
198
+ base_color: @base_color,
199
+ metallic: metallic,
200
+ roughness: @roughness,
201
+ emissive: @emissive
202
+ )
203
+ end
204
+
205
+ def with_roughness(roughness)
206
+ self.class.new(
207
+ base_color: @base_color,
208
+ metallic: @metallic,
209
+ roughness: roughness,
210
+ emissive: @emissive
211
+ )
212
+ end
213
+
214
+ def type_name
215
+ 'Pbr'
216
+ end
217
+
218
+ def to_h
219
+ {
220
+ base_color: @base_color.to_a,
221
+ metallic: @metallic,
222
+ roughness: @roughness,
223
+ emissive: @emissive.to_a
224
+ }
225
+ end
226
+ end
227
+ end