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

Function main

scripts/simple-fbx-test.mjs:11–66  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9console.log(`Testing: ${filePath}`);
10
11async function main() {
12 // Dynamic import to handle the module
13 const { FBXLoader } = await import('../packages/asset-system/dist/index.js');
14
15 const binaryData = readFileSync(filePath);
16 const loader = new FBXLoader();
17
18 const context = {
19 metadata: {
20 path: filePath,
21 name: filePath.split(/[\\/]/).pop(),
22 type: 'model/fbx',
23 guid: '',
24 size: binaryData.length,
25 hash: '',
26 dependencies: [],
27 lastModified: Date.now(),
28 importerVersion: '1.0.0',
29 labels: [],
30 tags: [],
31 version: 1
32 },
33 loadDependency: async () => null
34 };
35
36 const content = {
37 type: 'binary',
38 binary: binaryData.buffer
39 };
40
41 try {
42 const asset = await loader.parse(content, context);
43
44 console.log(`\nMeshes: ${asset.meshes?.length || 0}`);
45 console.log(`Nodes: ${asset.nodes?.length || 0}`);
46 console.log(`Skeleton joints: ${asset.skeleton?.joints?.length || 0}`);
47
48 if (asset.skeleton && asset.skeleton.joints.length > 0) {
49 console.log(`\nFirst 3 joints:`);
50 for (let i = 0; i < 3 && i < asset.skeleton.joints.length; i++) {
51 const joint = asset.skeleton.joints[i];
52 const node = asset.nodes?.[joint.nodeIndex];
53 console.log(` [${i}] "${joint.name}" nodeIndex=${joint.nodeIndex}`);
54 if (node) {
55 console.log(` position: [${node.transform.position.map(v => v.toFixed(2)).join(', ')}]`);
56 console.log(` rotation: [${node.transform.rotation.map(v => v.toFixed(4)).join(', ')}]`);
57 }
58 }
59 }
60
61 console.log('\nDone!');
62 } catch (error) {
63 console.error('Error:', error.message);
64 console.error(error.stack);
65 }
66}
67
68main();

Callers 1

Calls 7

parseMethod · 0.95
popMethod · 0.80
nowMethod · 0.80
logMethod · 0.45
joinMethod · 0.45
mapMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected