Class: Rgltf::Animation::AnimationSampler

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

Constant Summary collapse

INTERPOLATIONS =
{ 'LINEAR' => :linear, 'STEP' => :step, 'CUBICSPLINE' => :cubicspline }.freeze

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, #nested_properties, #parse_extensions!

Constructor Details

#initialize(json, document:, animation_index:, index:) ⇒ AnimationSampler

Returns a new instance of AnimationSampler.



80
81
82
83
84
85
86
87
88
89
# File 'lib/rgltf/properties/animation.rb', line 80

def initialize(json, document:, animation_index:, index:)
  super(json, document:, index:, owner_type: :animation_sampler)
  @input = document.fetch_reference(:accessors, json.fetch('input'),
                                    "animations/#{animation_index}/samplers/#{index}/input")
  @output = document.fetch_reference(:accessors, json.fetch('output'),
                                     "animations/#{animation_index}/samplers/#{index}/output")
  @interpolation = INTERPOLATIONS.fetch(json.fetch('interpolation', 'LINEAR'))
rescue KeyError => e
  raise FormatError, "invalid animation sampler: #{e.message}"
end

Instance Attribute Details

#inputObject (readonly)

Returns the value of attribute input.



78
79
80
# File 'lib/rgltf/properties/animation.rb', line 78

def input
  @input
end

#interpolationObject (readonly)

Returns the value of attribute interpolation.



78
79
80
# File 'lib/rgltf/properties/animation.rb', line 78

def interpolation
  @interpolation
end

#outputObject (readonly)

Returns the value of attribute output.



78
79
80
# File 'lib/rgltf/properties/animation.rb', line 78

def output
  @output
end

Instance Method Details

#durationObject



91
92
93
# File 'lib/rgltf/properties/animation.rb', line 91

def duration
  input.max&.first || 0.0
end