[x3d-public] glTF animations
Joe D Williams
joedwil at earthlink.net
Mon Nov 14 14:06:27 PST 2016
How about a quick pass on glTF animations?
This following example defines a simple rotation and translation
animation for a ball.
My understanding may not be totally complete, but here is a cut at it.
glTF Definitions:
channel - data and processing for a specific parameter
sampler - a keyframe interpolator
parameter - data for the interpolator
glTF Animation Data Structure
Declares keyframe graphs - key times and keyValues
Structure
animation
animation.name (name of animation)
animation.channel (name of channel)
channel.sampler (name of sampler)
channel.target (target of sampler)
target.id (target node)
target.path (target field)
animation.parameters
TIME : channelname (key times)
type : channelname (data type and channel names)
(same number of types as number of channels)
(all parameters have same number of values)
animation.sampler (name of sampler)
sampler.input (name of parameter keyframe key times)
sampler.interpolation (type of interpolator)
sampler.output (data type of ouput)
(same number of samplers as number of channels)
glTF Declares:
* one or a set of interpolators and targets (channels)
* one or more sets of parameterized inputs (parameters) keyValues
* a set of times for interpolators (samplers) keyframe key times
[time[0] >= 0.0, and monotonically increasing values, i.e., time[n +
1] >= time[n]]
*same number of key times and keyValues
X3D Animation Example
A ball moves according to the translation and rotation interpolators.
<!-- Ball Animation interpolators -->
<Group DEF="BallAnimations">
<PositionInterpolator DEF='ballTransInterp'
key='0,0.2,0.4,0.6,0.8,1'
keyValue='-1 0.4 -1,0 0.7 0,0.5 0.6 0.5,2 4 10,0.5 0.6 0.5,-1
0.4 -1'>
</PositionInterpolator>
<OrientationInterpolator DEF='ballRotInterp'
key='0,0.2,0.4,0.6,0.8,1'
keyValue='1 0 1 0.5,-1 0 -1 1.5,-1 1 -1 3.5,-1 0.2 -1 3,-1 0.2 -1
3,1 0 1 0.5'>
</OrientationInterpolator>
</Group>
same number of key times and keyValues in all grouped animations
<!-- Ball Animation Routes -->
<ROUTE fromNode='BallTimer' fromField='fraction_changed'
toNode='ballTransInterp' toField='set_fraction'></ROUTE>
<ROUTE fromNode='ballTransInterp' fromField='value_changed'
toNode='SBall' toField='set_translation'></ROUTE>
<ROUTE fromNode='BallTimer' fromField='fraction_changed'
toNode='ballRotInterp' toField='set_fraction'></ROUTE>
<ROUTE fromNode='ballRotInterp' fromField='value_changed'
toNode='SBall' toField='set_rotation'></ROUTE>
</Group>
glTF Animation Example
animAccessor_0 = "0,0.2,0.4,0.6,0.8,1"
(list of key times)
animAccessor_2 = "-1 0.4 -1,0 0.7 0,0.5 0.6 0.5,2 4 10,0.5 0.6 0.5,-1
0.4 -1"
(list of translation keyValues)
animAccessor_3 = "1 0 1 0.5,-1 0 -1 1.5,-1 1 -1 3.5,-1 0.2 -1 3,-1
0.2 -1 3,1 0 1 0.5"
(list of rotation keyValues)
"Ball Animation": {
"channels": [
{
"sampler": "ballTransInterp",
"target": {
"id": "SBall",
"path": "translation"
}
},
{
"sampler": "ballRotInterp",
"target": {
"id": "SBall",
"path": "rotation"
}
}
],
"parameters": {
"TIME": "animAccessor_0",
"translation": "animAccessor_2",
"rotation": "animAccessor_3"
},
"samplers": {
"ballTransInterp": {
"input": "TIME",
"interpolation": "LINEAR",
"output": "translation"
}
"ballRotInterp": {
"input": "TIME",
"interpolation": "LINEAR",
"output": "rotation"
},
}
},
glTF shows how to build it in style ... certainly a sort of compressed
style with lots of dictionary.
The only problem here may be that glTF is not gonna like the rotation
axis-angle - since it likes unit quats.
Thanks and Best,
Joe
More information about the x3d-public
mailing list