tiny_gltf 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +14 -0
  3. data/.travis.yml +7 -0
  4. data/.yardopts +2 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +31 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +63 -0
  9. data/Rakefile +24 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/ext/tiny_gltf/extconf.rb +5 -0
  13. data/ext/tiny_gltf/json.hpp +14722 -0
  14. data/ext/tiny_gltf/rb_tiny_gltf.cpp +55 -0
  15. data/ext/tiny_gltf/rb_tiny_gltf.h +118 -0
  16. data/ext/tiny_gltf/rb_tiny_gltf_accessor.cpp +42 -0
  17. data/ext/tiny_gltf/rb_tiny_gltf_animation.cpp +21 -0
  18. data/ext/tiny_gltf/rb_tiny_gltf_animation_channel.cpp +13 -0
  19. data/ext/tiny_gltf/rb_tiny_gltf_animation_sampler.cpp +16 -0
  20. data/ext/tiny_gltf/rb_tiny_gltf_asset.cpp +15 -0
  21. data/ext/tiny_gltf/rb_tiny_gltf_buffer.cpp +16 -0
  22. data/ext/tiny_gltf/rb_tiny_gltf_buffer_view.cpp +16 -0
  23. data/ext/tiny_gltf/rb_tiny_gltf_camera.cpp +29 -0
  24. data/ext/tiny_gltf/rb_tiny_gltf_extension_map.cpp +12 -0
  25. data/ext/tiny_gltf/rb_tiny_gltf_image.cpp +25 -0
  26. data/ext/tiny_gltf/rb_tiny_gltf_init.c +81 -0
  27. data/ext/tiny_gltf/rb_tiny_gltf_light.cpp +16 -0
  28. data/ext/tiny_gltf/rb_tiny_gltf_material.cpp +14 -0
  29. data/ext/tiny_gltf/rb_tiny_gltf_mesh.cpp +37 -0
  30. data/ext/tiny_gltf/rb_tiny_gltf_model.cpp +52 -0
  31. data/ext/tiny_gltf/rb_tiny_gltf_node.cpp +67 -0
  32. data/ext/tiny_gltf/rb_tiny_gltf_parameter_map.cpp +39 -0
  33. data/ext/tiny_gltf/rb_tiny_gltf_primitive.cpp +35 -0
  34. data/ext/tiny_gltf/rb_tiny_gltf_sampler.cpp +16 -0
  35. data/ext/tiny_gltf/rb_tiny_gltf_scene.cpp +17 -0
  36. data/ext/tiny_gltf/rb_tiny_gltf_skin.cpp +17 -0
  37. data/ext/tiny_gltf/rb_tiny_gltf_texture.cpp +14 -0
  38. data/ext/tiny_gltf/rb_tiny_gltf_types.cpp +229 -0
  39. data/ext/tiny_gltf/rb_tiny_gltf_value.cpp +32 -0
  40. data/ext/tiny_gltf/stb_image.h +6509 -0
  41. data/ext/tiny_gltf/stb_image_write.h +1831 -0
  42. data/ext/tiny_gltf/tiny_gltf.h +4830 -0
  43. data/lib/tiny_gltf.rb +260 -0
  44. data/lib/tiny_gltf/version.rb +3 -0
  45. data/tiny_gltf.gemspec +43 -0
  46. metadata +189 -0
data/lib/tiny_gltf.rb ADDED
@@ -0,0 +1,260 @@
1
+ require "tiny_gltf/version"
2
+ require "tiny_gltf/tiny_gltf"
3
+
4
+ module TinyGLTF
5
+ class Error < StandardError; end
6
+
7
+ class Model
8
+ attr_reader :asset
9
+ attr_reader :accessors
10
+ attr_reader :animations
11
+ attr_reader :buffers
12
+ attr_reader :buffer_views
13
+ attr_reader :materials
14
+ attr_reader :meshes
15
+ attr_reader :nodes
16
+ attr_reader :textures
17
+ attr_reader :images
18
+ attr_reader :skins
19
+ attr_reader :samplers
20
+ attr_reader :cameras
21
+ attr_reader :scenes
22
+ attr_reader :lights
23
+ attr_reader :default_scene_index
24
+
25
+ def initialize
26
+ @default_scene_index = nil
27
+ @accessors = []
28
+ @animations = []
29
+ @buffers = []
30
+ @buffer_views = []
31
+ @materials = []
32
+ @meshes = []
33
+ @nodes = []
34
+ @textures = []
35
+ @images = []
36
+ @skins = []
37
+ @samplers = []
38
+ @cameras = []
39
+ @scenes = []
40
+ @lights = []
41
+ end
42
+ end
43
+
44
+ class Accessor
45
+ attr_reader :buffer_view_index
46
+ # One of `:byte`, `:ubyte`, `:short`, `:ushort`, `:int`, `:uint`,
47
+ # `:float`, `:double`, `:unknown`
48
+ attr_reader :component_type
49
+ attr_reader :count
50
+ attr_reader :name
51
+ attr_reader :byte_offset
52
+ # One of `:vec2`, `:vec3`, `:vec4`, `:mat2`, `:mat3`, `:mat4`, `:scalar`,
53
+ # `:vector`, `:matrix`, `:unknown`
54
+ attr_reader :type
55
+ attr_reader :extras
56
+ attr_reader :min
57
+ attr_reader :max
58
+
59
+ def normalized?
60
+ !!@normalized
61
+ end
62
+ end
63
+
64
+ class Animation
65
+ attr_reader :name
66
+ attr_reader :channels
67
+ attr_reader :samplers
68
+ attr_reader :extras
69
+ end
70
+
71
+ class AnimationChannel
72
+ attr_reader :sampler_index
73
+ # index of the node to target
74
+ attr_reader :target_node_index
75
+ # one of `:translation`, `:rotation`, `:scale`, `:weights`
76
+ attr_reader :target_path
77
+ attr_reader :extras
78
+ end
79
+
80
+ class AnimationSampler
81
+ attr_reader :input
82
+ attr_reader :output
83
+ # one of `:linear`, `:step`, `:catmullromspline`, `:cubicspline`, `:linear`
84
+ attr_reader :interpolation
85
+ attr_reader :extras
86
+ end
87
+
88
+ class Asset
89
+ attr_reader :version
90
+ attr_reader :generator
91
+ attr_reader :minVersion
92
+ attr_reader :copyright
93
+ attr_reader :extensions
94
+ attr_reader :extras
95
+ end
96
+
97
+ class Buffer
98
+ attr_reader :name
99
+ attr_reader :data
100
+ attr_reader :uri
101
+ attr_reader :extras
102
+ end
103
+
104
+ class BufferView
105
+ attr_reader :name
106
+ attr_reader :buffer_index
107
+ # minimum 0, default 0
108
+ attr_reader :byte_offset
109
+ # required, minimum 1
110
+ attr_reader :byte_length
111
+ # minimum 4, maximum 252 (multiple of 4), default 0 = understood to be
112
+ # tightly packed
113
+ attr_reader :byte_stride
114
+ # one of `:buffer`, `:element_array_buffer`
115
+ attr_reader :target
116
+ attr_reader :extras
117
+ end
118
+
119
+ class Camera
120
+ # One of `:perspective` or `:orthographic`
121
+ attr_reader :type
122
+ attr_reader :name
123
+ # Only useful if #type is `:perspective`
124
+ attr_reader :aspect_ratio
125
+ # Only useful if #type is `:perspective`
126
+ attr_reader :yfov
127
+ # Only useful if #type is `:orthographic`
128
+ attr_reader :xmag
129
+ # Only useful if #type is `:orthographic`
130
+ attr_reader :ymag
131
+ attr_reader :znear
132
+ # `+Infinity` if #type is `:perspective` and an infinite projection should
133
+ # be used.
134
+ attr_reader :zfar
135
+ attr_reader :extensions
136
+ attr_reader :extras
137
+ end
138
+
139
+ class Image
140
+ attr_reader :name
141
+ attr_reader :width
142
+ attr_reader :height
143
+ attr_reader :components
144
+ attr_reader :data
145
+ attr_reader :buffer_view_index
146
+ # One of `"image/jpeg"`, `"image/png"`, `"image/bmp"`, `"image/gif"`,
147
+ # or `nil`
148
+ attr_reader :mime_type
149
+ attr_reader :uri
150
+ attr_reader :extras
151
+ attr_reader :extensions
152
+ end
153
+
154
+ class Light
155
+ attr_reader :name
156
+ attr_reader :color
157
+ attr_reader :type
158
+ end
159
+
160
+ class Primitive
161
+ # A Hash whose values are integers, where each integer is the index of the
162
+ # accessor containing the corresponding attribute.
163
+ attr_reader :attributes
164
+ # The index of the material to apply to this primitive when rendering.
165
+ attr_reader :material_index
166
+ # The index of the accessor that contains the indices.
167
+ attr_reader :indices
168
+ # One of `:points`, `:line`, `:line_loop`, `:triangles`, `:triangle_strip`,
169
+ # `:triangle_fan`, `:unknown`
170
+ attr_reader :mode
171
+ # Array of morph targets, where each target is a Hash with attributes in
172
+ # `:position, :normal, :tangent` pointing to their corresponding
173
+ # accessors.
174
+ attr_reader :morph_targets
175
+ attr_reader :extras
176
+ end
177
+
178
+ class Mesh
179
+ attr_reader :name
180
+ attr_reader :primitives
181
+ # weights to be applied to the Morph Targets
182
+ attr_reader :weights
183
+ attr_reader :morph_targets
184
+ attr_reader :extensions
185
+ attr_reader :extras
186
+ end
187
+
188
+ class Material
189
+ attr_reader :name
190
+ # hash containing PBR metal/roughness workflow values
191
+ attr_reader :values
192
+ # hash containing normal/occlusion/emissive values
193
+ attr_reader :additional_values
194
+ attr_reader :extensions
195
+ attr_reader :extras
196
+ end
197
+
198
+ class Node
199
+ attr_reader :name
200
+ # the index of the camera referenced by this node
201
+ attr_reader :camera_index
202
+ attr_reader :skin_index
203
+ attr_reader :mesh_index
204
+ attr_reader :children_indices
205
+ # If present, all of #rotation, #scale and #translation will be present,
206
+ # and #matrix will be nil.
207
+ attr_reader :rotation
208
+ # If present, all of #rotation, #scale and #translation will be present,
209
+ # and #matrix will be nil.
210
+ attr_reader :scale
211
+ # If present, all of #rotation, #scale and #translation will be present,
212
+ # and #matrix will be nil.
213
+ attr_reader :translation
214
+ # If present, #rotation, #scale and #translation will be nil.
215
+ attr_reader :matrix
216
+ # The weights of the instantiated Morph Target
217
+ attr_reader :weights
218
+ attr_reader :extensions
219
+ attr_reader :extras
220
+ end
221
+
222
+ class Sampler
223
+ attr_reader :name
224
+ # One of `:nearest`, `:linear`, `:nearest_mipmap_linear`,
225
+ # `:linear_mipmap_nearest`, `:nearest_mipmap_linear`,
226
+ # `:linear_mipmap_linear`
227
+ attr_reader :min_filter
228
+ # One of `:nearest`, `:linear`
229
+ attr_reader :mag_filter
230
+ # One of `:clamp_to_edge`, `:mirrored_repeat`, `:repeat`
231
+ attr_reader :wrap_s
232
+ # One of `:clamp_to_edge`, `:mirrored_repeat`, `:repeat`
233
+ attr_reader :wrap_t
234
+ # One of `:clamp_to_edge`, `:mirrored_repeat`, `:repeat`
235
+ attr_reader :wrap_r
236
+ attr_reader :extras
237
+ end
238
+
239
+ class Scene
240
+ attr_reader :name
241
+ attr_reader :nodes
242
+ attr_reader :extensions
243
+ attr_reader :extras
244
+ end
245
+
246
+ class Skin
247
+ attr_reader :name
248
+ attr_reader :inverse_bind_matrices
249
+ attr_reader :skeleton_root_node_index
250
+ attr_reader :joint_node_indices
251
+ end
252
+
253
+ class Texture
254
+ attr_reader :name
255
+ attr_reader :sampler_index
256
+ attr_reader :source_index
257
+ attr_reader :extensions
258
+ attr_reader :extras
259
+ end
260
+ end
@@ -0,0 +1,3 @@
1
+ module TinyGLTF
2
+ VERSION = "0.1.0"
3
+ end
data/tiny_gltf.gemspec ADDED
@@ -0,0 +1,43 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "tiny_gltf/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tiny_gltf"
8
+ spec.version = TinyGLTF::VERSION
9
+ spec.authors = ["Colin MacKenzie IV"]
10
+ spec.email = ["sinisterchipmunk@gmail.com"]
11
+
12
+ spec.summary = %q{Provides a Ruby extension for TinyGLTF, a C++ glTF 2.0 library.}
13
+ spec.homepage = "https://github.com/sinisterchipmunk/tiny_gltf-ruby"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+
26
+ # Specify which files should be added to the gem when it is released.
27
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
28
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
29
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
30
+ end
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+ spec.extensions = ["ext/tiny_gltf/extconf.rb"]
35
+
36
+ spec.add_development_dependency "bundler", "~> 2.0.a"
37
+ spec.add_development_dependency "rake", "~> 10.0"
38
+ spec.add_development_dependency "rake-compiler"
39
+ spec.add_development_dependency "minitest", "~> 5.0"
40
+ spec.add_development_dependency "yard", "~> 0.9"
41
+ spec.add_development_dependency 'redcarpet'
42
+ spec.add_development_dependency 'github-markup'
43
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiny_gltf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Colin MacKenzie IV
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 2.0.a
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.0.a
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake-compiler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: yard
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.9'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.9'
83
+ - !ruby/object:Gem::Dependency
84
+ name: redcarpet
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: github-markup
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - sinisterchipmunk@gmail.com
114
+ executables: []
115
+ extensions:
116
+ - ext/tiny_gltf/extconf.rb
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".travis.yml"
121
+ - ".yardopts"
122
+ - Gemfile
123
+ - Gemfile.lock
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - ext/tiny_gltf/extconf.rb
130
+ - ext/tiny_gltf/json.hpp
131
+ - ext/tiny_gltf/rb_tiny_gltf.cpp
132
+ - ext/tiny_gltf/rb_tiny_gltf.h
133
+ - ext/tiny_gltf/rb_tiny_gltf_accessor.cpp
134
+ - ext/tiny_gltf/rb_tiny_gltf_animation.cpp
135
+ - ext/tiny_gltf/rb_tiny_gltf_animation_channel.cpp
136
+ - ext/tiny_gltf/rb_tiny_gltf_animation_sampler.cpp
137
+ - ext/tiny_gltf/rb_tiny_gltf_asset.cpp
138
+ - ext/tiny_gltf/rb_tiny_gltf_buffer.cpp
139
+ - ext/tiny_gltf/rb_tiny_gltf_buffer_view.cpp
140
+ - ext/tiny_gltf/rb_tiny_gltf_camera.cpp
141
+ - ext/tiny_gltf/rb_tiny_gltf_extension_map.cpp
142
+ - ext/tiny_gltf/rb_tiny_gltf_image.cpp
143
+ - ext/tiny_gltf/rb_tiny_gltf_init.c
144
+ - ext/tiny_gltf/rb_tiny_gltf_light.cpp
145
+ - ext/tiny_gltf/rb_tiny_gltf_material.cpp
146
+ - ext/tiny_gltf/rb_tiny_gltf_mesh.cpp
147
+ - ext/tiny_gltf/rb_tiny_gltf_model.cpp
148
+ - ext/tiny_gltf/rb_tiny_gltf_node.cpp
149
+ - ext/tiny_gltf/rb_tiny_gltf_parameter_map.cpp
150
+ - ext/tiny_gltf/rb_tiny_gltf_primitive.cpp
151
+ - ext/tiny_gltf/rb_tiny_gltf_sampler.cpp
152
+ - ext/tiny_gltf/rb_tiny_gltf_scene.cpp
153
+ - ext/tiny_gltf/rb_tiny_gltf_skin.cpp
154
+ - ext/tiny_gltf/rb_tiny_gltf_texture.cpp
155
+ - ext/tiny_gltf/rb_tiny_gltf_types.cpp
156
+ - ext/tiny_gltf/rb_tiny_gltf_value.cpp
157
+ - ext/tiny_gltf/stb_image.h
158
+ - ext/tiny_gltf/stb_image_write.h
159
+ - ext/tiny_gltf/tiny_gltf.h
160
+ - lib/tiny_gltf.rb
161
+ - lib/tiny_gltf/version.rb
162
+ - tiny_gltf.gemspec
163
+ homepage: https://github.com/sinisterchipmunk/tiny_gltf-ruby
164
+ licenses:
165
+ - MIT
166
+ metadata:
167
+ allowed_push_host: https://rubygems.org
168
+ homepage_uri: https://github.com/sinisterchipmunk/tiny_gltf-ruby
169
+ post_install_message:
170
+ rdoc_options: []
171
+ require_paths:
172
+ - lib
173
+ required_ruby_version: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
+ requirements:
180
+ - - ">="
181
+ - !ruby/object:Gem::Version
182
+ version: '0'
183
+ requirements: []
184
+ rubyforge_project:
185
+ rubygems_version: 2.7.8
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Provides a Ruby extension for TinyGLTF, a C++ glTF 2.0 library.
189
+ test_files: []