Class: Stagecraft::Animation::Mixer
- Inherits:
-
Object
- Object
- Stagecraft::Animation::Mixer
- Defined in:
- lib/stagecraft/animation/mixer.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root) ⇒ Mixer
constructor
A new instance of Mixer.
- #play(clip, loop: :repeat, fade_in: 0.0) ⇒ Object
- #stop_all ⇒ Object
- #update(dt) ⇒ Object
Constructor Details
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
6 7 8 |
# File 'lib/stagecraft/animation/mixer.rb', line 6 def actions @actions end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
6 7 8 |
# File 'lib/stagecraft/animation/mixer.rb', line 6 def root @root end |
Instance Method Details
#play(clip, loop: :repeat, fade_in: 0.0) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/stagecraft/animation/mixer.rb', line 14 def play(clip, loop: :repeat, fade_in: 0.0) action = Action.new(clip, loop:, fade_in:) actions << action clip.tracks.each { |track| resolve_target(track) } action end |
#stop_all ⇒ Object
21 22 23 24 25 |
# File 'lib/stagecraft/animation/mixer.rb', line 21 def stop_all actions.each(&:stop) actions.clear self end |
#update(dt) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/stagecraft/animation/mixer.rb', line 27 def update(dt) samples = Hash.new { |hash, key| hash[key] = [] } actions.each do |action| next unless action.enabled action.advance(dt) action.clip.tracks.each do |track| target = resolve_target(track) next unless target samples[[target, track.target_path]] << [track.sample(action.time), action.weight] end end samples.each { |(target, path), values| apply_blend(target, path, values) } self end |