bestguigui_lab 0.14.1 → 0.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/bestguigui_lab/gltf_animator.rb +12 -25
- data/lib/bestguigui_lab/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccc420dcc4710f176292b2cec9b80a01ceed0cc297073dfddf847c2ca12ac65f
|
|
4
|
+
data.tar.gz: 940b1c9e78ecdb11bb51ed75371ba38f72c4960730decf85eb231b5c2db62002
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d21defb2e306380d7fbb4d6a26dd7679dabdd97e89405c34217f4021a1c5f06148a8d8fe39f3618f180e846eca0398f66ed14c76872439504adddb3292e06460
|
|
7
|
+
data.tar.gz: bdfee9d22037dd9c3b37e857e67665cb8b7b4f9e617d25a491c181a029de19ef7fc99b06c32f01da79a34f3543b390f3878e4b3ddc8f4051eec41233234247b2
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Bestguigui
|
|
4
|
-
# Lit le temps d'une
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
4
|
+
# Lit le temps d'une GLTFAnimation et renvoie sa pose locale — fondu
|
|
5
|
+
# enchaine (en temps reel, quel que soit speed) depuis la pose FIGEE de
|
|
6
|
+
# l'animation precedente au moment du #play, jamais depuis une pose
|
|
7
|
+
# qu'on continuerait a faire avancer/boucler pendant le fondu (ca
|
|
8
|
+
# blend deux cibles mouvantes, incoherent des que speed est eleve).
|
|
8
9
|
class GLTFAnimator
|
|
9
10
|
attr_accessor :speed
|
|
10
11
|
|
|
@@ -12,22 +13,15 @@ module Bestguigui
|
|
|
12
13
|
@current = nil
|
|
13
14
|
@time = 0.0
|
|
14
15
|
@loop = true
|
|
15
|
-
@
|
|
16
|
-
@previous_time = 0.0
|
|
17
|
-
@previous_loop = true
|
|
16
|
+
@previous_pose = nil
|
|
18
17
|
@transition_duration = 0.0
|
|
19
18
|
@transition_elapsed = 0.0
|
|
20
19
|
@speed = speed
|
|
21
20
|
end
|
|
22
21
|
|
|
23
|
-
#
|
|
24
|
-
# (secondes) du fondu enchaine depuis l'animation en cours ; 0 = coupe
|
|
25
|
-
# net (par defaut pour la toute premiere animation, rien avant elle).
|
|
22
|
+
# transition: duree reelle (secondes) du fondu, independante de speed.
|
|
26
23
|
def play(animation, loop: true, transition: 0.0)
|
|
27
|
-
|
|
28
|
-
@previous = transitioning ? @current : nil
|
|
29
|
-
@previous_time = @time
|
|
30
|
-
@previous_loop = @loop
|
|
24
|
+
@previous_pose = transition.positive? && @current ? pose : nil
|
|
31
25
|
@current = animation
|
|
32
26
|
@loop = loop
|
|
33
27
|
@time = 0.0
|
|
@@ -39,24 +33,20 @@ module Bestguigui
|
|
|
39
33
|
return unless @current
|
|
40
34
|
|
|
41
35
|
@time = advance_time(@time, dt * @speed, @current, @loop)
|
|
42
|
-
return unless @
|
|
36
|
+
return unless @previous_pose
|
|
43
37
|
|
|
44
|
-
@previous_time = advance_time(@previous_time, dt * @speed, @previous, @previous_loop)
|
|
45
38
|
@transition_elapsed += dt
|
|
46
|
-
@
|
|
39
|
+
@previous_pose = nil if @transition_elapsed >= @transition_duration
|
|
47
40
|
end
|
|
48
41
|
|
|
49
|
-
# Pose locale courante, fondue enchainee si une transition est en
|
|
50
|
-
# cours — Hash node => {translation:/rotation:/scale: => [...]},
|
|
51
|
-
# partiel (seuls les noeuds/proprietes reellement animes ici).
|
|
52
42
|
def pose
|
|
53
43
|
return {} unless @current
|
|
54
44
|
|
|
55
45
|
current_pose = @current.local_pose_at(@time)
|
|
56
|
-
return current_pose unless @
|
|
46
|
+
return current_pose unless @previous_pose
|
|
57
47
|
|
|
58
48
|
blend_t = @transition_duration.zero? ? 1.0 : (@transition_elapsed / @transition_duration).clamp(0.0, 1.0)
|
|
59
|
-
blend_poses(@
|
|
49
|
+
blend_poses(@previous_pose, current_pose, blend_t)
|
|
60
50
|
end
|
|
61
51
|
|
|
62
52
|
private
|
|
@@ -79,9 +69,6 @@ module Bestguigui
|
|
|
79
69
|
(from.keys | dest.keys).to_h { |path| [path, blend_property(path, from[path], dest[path], progress)] }
|
|
80
70
|
end
|
|
81
71
|
|
|
82
|
-
# Si une seule des deux animations definit cette propriete pour ce
|
|
83
|
-
# noeud, pas de vraie valeur "avant" a interpoler — on la garde telle
|
|
84
|
-
# quelle plutot que d'inventer une pose de depart arbitraire.
|
|
85
72
|
def blend_property(path, from, dest, progress)
|
|
86
73
|
return dest unless from
|
|
87
74
|
return from unless dest
|