MCPcopy Create free account
hub / github.com/esengine/esengine / sampleAnimation

Function sampleAnimation

scripts/test-animation-times.mjs:118–138  ·  view source on GitHub ↗
(clip, time, nodes)

Source from the content-addressed store, hash-verified

116}
117
118function sampleAnimation(clip, time, nodes) {
119 const nodeTransforms = new Map();
120 for (const channel of clip.channels) {
121 const sampler = clip.samplers[channel.samplerIndex];
122 if (!sampler) continue;
123
124 const nodeIndex = channel.target.nodeIndex;
125 const path = channel.target.path;
126 const value = sampleSampler(sampler, time, path);
127 if (!value) continue;
128
129 if (!nodeTransforms.has(nodeIndex)) {
130 nodeTransforms.set(nodeIndex, {});
131 }
132 const t = nodeTransforms.get(nodeIndex);
133 if (path === 'translation') t.position = value;
134 else if (path === 'rotation') t.rotation = value;
135 else if (path === 'scale') t.scale = value;
136 }
137 return nodeTransforms;
138}
139
140function calculateBoneMatrices(skeleton, nodes, animTransforms) {
141 const { joints } = skeleton;

Callers 1

mainFunction · 0.70

Calls 4

sampleSamplerFunction · 0.70
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected