Class: Rgltf::Animation

Inherits:
Properties::Base show all
Defined in:
lib/rgltf/properties/animation.rb

Defined Under Namespace

Classes: AnimationSampler, Channel

Instance Attribute Summary collapse

Attributes inherited from Properties::Base

#extensions, #extras, #index, #name, #owner_type, #source_json

Instance Method Summary collapse

Methods inherited from Properties::Base

#extension, #parse_extensions!

Constructor Details

#initialize(json, document:, index:) ⇒ Animation

Returns a new instance of Animation.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rgltf/properties/animation.rb', line 7

def initialize(json, document:, index:)
  super(json, document:, index:, owner_type: :animation)
  @samplers = json.fetch('samplers').each_with_index.map do |sampler, sampler_index|
    AnimationSampler.new(sampler, document:, animation_index: index, index: sampler_index)
  end.freeze
  @channels = json.fetch('channels').each_with_index.map do |channel, channel_index|
    Channel.new(channel, document:, animation: self, animation_index: index, index: channel_index)
  end.freeze
rescue KeyError => e
  raise FormatError, "invalid animation #{index}: #{e.message}"
end

Instance Attribute Details

#channelsObject (readonly)

Returns the value of attribute channels.



5
6
7
# File 'lib/rgltf/properties/animation.rb', line 5

def channels
  @channels
end

#samplersObject (readonly)

Returns the value of attribute samplers.



5
6
7
# File 'lib/rgltf/properties/animation.rb', line 5

def samplers
  @samplers
end

Instance Method Details

#nested_propertiesObject



19
20
21
# File 'lib/rgltf/properties/animation.rb', line 19

def nested_properties
  [*channels, *samplers]
end