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

Function main

scripts/test-animation-t0.mjs:13–141  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

11console.log(`Testing animation at t=0: ${filePath}\n`);
12
13async function main() {
14 const { FBXLoader } = await import('../packages/asset-system/dist/index.js');
15
16 const binaryData = readFileSync(filePath);
17 const loader = new FBXLoader();
18
19 const context = {
20 metadata: {
21 path: filePath,
22 name: filePath.split(/[\\/]/).pop(),
23 type: 'model/fbx',
24 guid: '',
25 size: binaryData.length,
26 hash: '',
27 dependencies: [],
28 lastModified: Date.now(),
29 importerVersion: '1.0.0',
30 labels: [],
31 tags: [],
32 version: 1
33 },
34 loadDependency: async () => null
35 };
36
37 const content = {
38 type: 'binary',
39 binary: binaryData.buffer
40 };
41
42 const asset = await loader.parse(content, context);
43
44 if (!asset.animations || asset.animations.length === 0) {
45 console.log('No animation data!');
46 return;
47 }
48
49 const clip = asset.animations[0];
50 const nodes = asset.nodes;
51 const skeleton = asset.skeleton;
52
53 console.log(`Animation: "${clip.name}", duration: ${clip.duration}s`);
54 console.log(`Channels: ${clip.channels.length}, Samplers: ${clip.samplers.length}`);
55
56 // Sample animation at t=0
57 function sampleAtT0(sampler, componentCount) {
58 if (!sampler.output || sampler.output.length === 0) return null;
59 const result = [];
60 for (let i = 0; i < componentCount; i++) {
61 result.push(sampler.output[i]);
62 }
63 return result;
64 }
65
66 // Get animated transforms at t=0
67 const animTransforms = new Map();
68 for (const channel of clip.channels) {
69 const sampler = clip.samplers[channel.samplerIndex];
70 if (!sampler) continue;

Callers 1

Calls 12

parseMethod · 0.95
sampleAtT0Function · 0.85
popMethod · 0.80
nowMethod · 0.80
hasMethod · 0.65
setMethod · 0.65
getMethod · 0.65
pushMethod · 0.65
logMethod · 0.45
everyMethod · 0.45
joinMethod · 0.45
mapMethod · 0.45

Tested by

no test coverage detected