Class: Rgltf::Builder::AnimationBuilder
- Inherits:
-
Object
- Object
- Rgltf::Builder::AnimationBuilder
- Defined in:
- lib/rgltf/builder/component_builders.rb
Instance Attribute Summary collapse
-
#channels ⇒ Object
readonly
Returns the value of attribute channels.
-
#samplers ⇒ Object
readonly
Returns the value of attribute samplers.
Instance Method Summary collapse
- #channel(sampler:, node:, path:, extensions: nil, extras: nil, target_extensions: nil, target_extras: nil) ⇒ Object
-
#initialize(builder) ⇒ AnimationBuilder
constructor
A new instance of AnimationBuilder.
- #sampler(input:, output:, interpolation: :linear, extensions: nil, extras: nil) ⇒ Object
Constructor Details
#initialize(builder) ⇒ AnimationBuilder
Returns a new instance of AnimationBuilder.
46 47 48 49 50 |
# File 'lib/rgltf/builder/component_builders.rb', line 46 def initialize(builder) @builder = builder @samplers = [] @channels = [] end |
Instance Attribute Details
#channels ⇒ Object (readonly)
Returns the value of attribute channels.
44 45 46 |
# File 'lib/rgltf/builder/component_builders.rb', line 44 def channels @channels end |
#samplers ⇒ Object (readonly)
Returns the value of attribute samplers.
44 45 46 |
# File 'lib/rgltf/builder/component_builders.rb', line 44 def samplers @samplers end |
Instance Method Details
#channel(sampler:, node:, path:, extensions: nil, extras: nil, target_extensions: nil, target_extras: nil) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rgltf/builder/component_builders.rb', line 68 def channel(sampler:, node:, path:, extensions: nil, extras: nil, target_extensions: nil, target_extras: nil) target_path = path.to_s unless Animation::Channel::TARGET_PATHS.include?(target_path) raise ArgumentError, "unsupported animation target path #{path.inspect}" end target = { 'node' => @builder.reference(node, :node), 'path' => target_path } target['extensions'] = target_extensions if target_extensions target['extras'] = target_extras unless target_extras.nil? value = { 'sampler' => sampler, 'target' => target } value['extensions'] = extensions if extensions value['extras'] = extras unless extras.nil? @channels << value self end |
#sampler(input:, output:, interpolation: :linear, extensions: nil, extras: nil) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rgltf/builder/component_builders.rb', line 52 def sampler(input:, output:, interpolation: :linear, extensions: nil, extras: nil) mode = interpolation.to_s.upcase raise ArgumentError, "unsupported interpolation #{interpolation.inspect}" unless %w[LINEAR STEP CUBICSPLINE].include?(mode) value = { 'input' => @builder.reference(input, :accessor), 'output' => @builder.reference(output, :accessor) } value['interpolation'] = mode unless mode == 'LINEAR' value['extensions'] = extensions if extensions value['extras'] = extras unless extras.nil? @samplers << value @samplers.length - 1 end |