Skip to content

Commit 0540eb3

Browse files
mockersfcart
authored andcommitted
Gltf animations (bevyengine#3751)
# Objective - Load informations for animations from GLTF - Make experimenting on animations easier # Non Objective - Implement a solutions for all animations in Bevy. This would need a discussion / RFC. The goal here is only to have the information available to try different APIs ## Solution - Load animations with a representation close to the GLTF spec - Add an example to display animations. There is an animation driver in the example, not in Bevy code, to show how it can be used. The example is cycling between examples from the official gltf sample ([AnimatedTriangle](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedTriangle), [BoxAnimated](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxAnimated)), and one from me with some cases not present in the official examples. https://user-images.githubusercontent.com/8672791/150696656-073403f0-d921-43b6-beaf-099c7aee16ed.mp4 Co-authored-by: Carter Anderson <[email protected]>
1 parent 82b73f2 commit 0540eb3

File tree

9 files changed

+1422
-6
lines changed

9 files changed

+1422
-6
lines changed

CREDITS.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@
2121
* Ground tile from [Kenney's Tower Defense Kit](https://www.kenney.nl/assets/tower-defense-kit) (CC0 1.0 Universal)
2222
* Game icons from [Kenney's Game Icons](https://www.kenney.nl/assets/game-icons) (CC0 1.0 Universal)
2323
* Space ships from [Kenny's Simple Space Kit](https://www.kenney.nl/assets/simple-space) (CC0 1.0 Universal)
24+
* glTF animated triangle from [glTF Sample Models](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/AnimatedTriangle) (CC0 1.0 Universal)
25+
* glTF box animated from [glTF Sample Models](https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/BoxAnimated) ([CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) - by [Cesium](https://cesium.com))

Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,10 @@ path = "examples/3d/lighting.rs"
183183
name = "load_gltf"
184184
path = "examples/3d/load_gltf.rs"
185185

186+
[[example]]
187+
name = "manual_gltf_animation_player"
188+
path = "examples/3d/manual_gltf_animation_player.rs"
189+
186190
[[example]]
187191
name = "many_cubes"
188192
path = "examples/3d/many_cubes.rs"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
{
2+
"scene" : 0,
3+
"scenes" : [
4+
{
5+
"nodes" : [ 0 ]
6+
}
7+
],
8+
9+
"nodes" : [
10+
{
11+
"mesh" : 0,
12+
"rotation" : [ 0.0, 0.0, 0.0, 1.0 ]
13+
}
14+
],
15+
16+
"meshes" : [
17+
{
18+
"primitives" : [ {
19+
"attributes" : {
20+
"POSITION" : 1
21+
},
22+
"indices" : 0
23+
} ]
24+
}
25+
],
26+
27+
"animations": [
28+
{
29+
"samplers" : [
30+
{
31+
"input" : 2,
32+
"interpolation" : "LINEAR",
33+
"output" : 3
34+
}
35+
],
36+
"channels" : [ {
37+
"sampler" : 0,
38+
"target" : {
39+
"node" : 0,
40+
"path" : "rotation"
41+
}
42+
} ]
43+
}
44+
],
45+
46+
"buffers" : [
47+
{
48+
"uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=",
49+
"byteLength" : 44
50+
},
51+
{
52+
"uri" : "data:application/octet-stream;base64,AAAAAAAAgD4AAAA/AABAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAPT9ND/0/TS/AAAAAAAAAAAAAAAAAACAPw==",
53+
"byteLength" : 100
54+
}
55+
],
56+
"bufferViews" : [
57+
{
58+
"buffer" : 0,
59+
"byteOffset" : 0,
60+
"byteLength" : 6,
61+
"target" : 34963
62+
},
63+
{
64+
"buffer" : 0,
65+
"byteOffset" : 8,
66+
"byteLength" : 36,
67+
"target" : 34962
68+
},
69+
{
70+
"buffer" : 1,
71+
"byteOffset" : 0,
72+
"byteLength" : 100
73+
}
74+
],
75+
"accessors" : [
76+
{
77+
"bufferView" : 0,
78+
"byteOffset" : 0,
79+
"componentType" : 5123,
80+
"count" : 3,
81+
"type" : "SCALAR",
82+
"max" : [ 2 ],
83+
"min" : [ 0 ]
84+
},
85+
{
86+
"bufferView" : 1,
87+
"byteOffset" : 0,
88+
"componentType" : 5126,
89+
"count" : 3,
90+
"type" : "VEC3",
91+
"max" : [ 1.0, 1.0, 0.0 ],
92+
"min" : [ 0.0, 0.0, 0.0 ]
93+
},
94+
{
95+
"bufferView" : 2,
96+
"byteOffset" : 0,
97+
"componentType" : 5126,
98+
"count" : 5,
99+
"type" : "SCALAR",
100+
"max" : [ 1.0 ],
101+
"min" : [ 0.0 ]
102+
},
103+
{
104+
"bufferView" : 2,
105+
"byteOffset" : 20,
106+
"componentType" : 5126,
107+
"count" : 5,
108+
"type" : "VEC4",
109+
"max" : [ 0.0, 0.0, 1.0, 1.0 ],
110+
"min" : [ 0.0, 0.0, 0.0, -0.707 ]
111+
}
112+
],
113+
114+
"asset" : {
115+
"version" : "2.0"
116+
}
117+
118+
}

0 commit comments

Comments
 (0)